:root {
  color-scheme: dark;
  background: #000;
  color: #fff;
  font-family: system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-width: 280px; min-height: 100%; }

body {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  background: #000;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.portal {
  width: min(100vw, calc(100vh * 1672 / 941));
  width: min(100vw, calc(100svh * 1672 / 941));
}

.artwork { position: relative; width: 100%; }
.artwork { container-type: inline-size; }

.desktop-artwork {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
}

.portal-links { position: absolute; inset: 0; }

.portal-link {
  position: absolute;
  top: 44.7396386823%;
  height: 40.8076514346%;
  display: block;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  clip-path: polygon(3.5% 0, 96.5% 0, 100% 3.5%, 100% 96.5%, 96.5% 100%, 3.5% 100%, 0 96.5%, 0 3.5%);
  transition: background-color 150ms ease, box-shadow 150ms ease;
}

.portal-link--rules { left: 3.3492822967%; width: 22.3684210526%; }
.portal-link--countdown { left: 27.0933014354%; width: 22.2488038278%; }
.portal-link--participant { left: 50.7775119617%; width: 22.2488038278%; }
.portal-link--winners { left: 74.4019138756%; width: 22.3684210526%; }

/* Real text replaces the four baked-in artwork headings at every crop size. */
.portal-card-title {
  position: absolute;
  left: 9%; right: 5%; top: 33%; height: 14%;
  display: flex; align-items: center;
  padding-left: 3%;
  color: #f5f5ef;
  isolation: isolate;
  font: 750 1.92cqw/1.2 'PingFang SC', 'Microsoft YaHei', sans-serif;
  letter-spacing: .04em;
  white-space: nowrap;
}
.portal-card-title::before { content: ''; position: absolute; inset: 2px -2px; z-index: -1; background: #050905; filter: blur(5px); }

[hidden] { display: none !important; }
.client-stage { position: fixed; inset: 0; background: #030703; z-index: 10; }
.client-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #030703; }
body.client-open { overflow: hidden; }
.display-controls {
  position: fixed; right: max(18px, env(safe-area-inset-right)); top: max(18px, env(safe-area-inset-top));
  z-index: 30; display: flex; align-items: center; gap: 10px;
  padding: 6px; border: 1px solid #a1f60350; border-radius: 8px;
  background: #060c06e8; backdrop-filter: blur(14px);
  transition: opacity .25s, transform .25s;
}
.display-controls button, .client-loading button {
  font: 600 13px/1.4 system-ui, sans-serif; padding: 9px 13px; border: 1px solid #a1f60355;
  border-radius: 4px; color: #e8efd9; background: #112006; cursor: pointer;
}
.display-controls button:hover, .client-loading button:hover { color: #a1f603; border-color: #a1f603; }
.display-controls :focus-visible, .client-loading :focus-visible { outline: 2px solid #a1f603; outline-offset: 3px; }
#client-label { font-size: 12px; color: #c1d49e; padding-inline: 4px; }
body.client-open .display-controls { top: auto; bottom: max(18px, env(safe-area-inset-bottom)); }
/* Ready clients provide their own controls; an outer toolbar would cover
   native controls such as the award detail's next-work button. */
body.client-ready .display-controls { display: none; }
body.controls-idle .display-controls:not(:focus-within):not(:hover) { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.client-loading { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: #030703; color: #e7efd9; }
.client-loading p { margin: 6px 20px; text-align: center; line-height: 1.7; }
.client-loading a { color: #a1f603; }
.loading-fallback { font-size: 13px; color: #abb899; }
.loading-orbit { width: 40px; height: 40px; border: 2px solid #a1f60325; border-top-color: #a1f603; border-radius: 50%; animation: orbit .8s linear infinite; }
.display-notice { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 40; max-width: min(90vw, 600px); padding: 12px 20px; color: #e7efd9; background: #15230af2; border: 1px solid #a1f60370; border-radius: 6px; line-height: 1.6; }
.portal { animation: page-arrive .42s ease-out both; }
.client-stage iframe.client-arriving { animation: page-arrive .4s ease-out both; }
@keyframes page-arrive { from { opacity: 0; transform: translateY(8px) scale(.995); } to { opacity: 1; transform: none; } }
@keyframes orbit { to { transform: rotate(360deg); } }

@media (hover: hover) {
  .portal-link:hover {
    background-color: rgb(181 255 43 / 4%);
    box-shadow: inset 0 0 0 2px rgb(181 255 43 / 65%), inset 0 0 32px rgb(181 255 43 / 8%);
  }
}

.portal-link:focus-visible {
  outline: 3px solid #e4ffa3;
  outline-offset: -6px;
  background-color: rgb(181 255 43 / 6%);
  box-shadow: inset 0 0 0 2px #b5ff2b;
}

.mobile-header, .mobile-footer { display: none; }

/* The smaller layout uses crops of the untouched designer artwork. */
@media (max-width: 900px) and (orientation: portrait), (max-width: 600px) {
  body { display: block; background: #030703; }
  .portal { width: 100%; padding: 0 16px 20px; }
  .desktop-artwork { display: none; }

  .mobile-header {
    display: block;
    width: calc(100% + 32px);
    margin-left: -16px;
    aspect-ratio: 880 / 410;
    background-image: url('/assets/hackathon-portal.png');
    background-repeat: no-repeat;
    background-size: 190% 229.512195122%;
    background-position: 50.5050505051% 0;
  }

  .portal-links {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
  }

  .portal-link {
    position: relative;
    left: auto;
    top: auto;
    width: 100%;
    height: auto;
    aspect-ratio: var(--crop-width) / 384;
    background-image: url('/assets/hackathon-portal.png');
    background-repeat: no-repeat;
    background-size: var(--background-width) 245.0520833333%;
    background-position: var(--background-x) 75.5834829443%;
    container-type: inline-size;
  }
  .portal-card-title { font-size: 8.6cqw; }
  .display-controls { right: 10px; top: auto; bottom: max(10px, env(safe-area-inset-bottom)); gap: 4px; }
  .display-controls button { font-size: 11px; padding: 8px; }
  #client-label { display: none; }

  .portal-link--rules {
    --crop-width: 374;
    --background-width: 447.0588235294%;
    --background-x: 4.3143297381%;
  }

  .portal-link--countdown {
    --crop-width: 372;
    --background-width: 449.4623655914%;
    --background-x: 34.8461538462%;
  }

  .portal-link--participant {
    --crop-width: 372;
    --background-width: 449.4623655914%;
    --background-x: 65.3076923077%;
  }

  .portal-link--winners {
    --crop-width: 374;
    --background-width: 447.0588235294%;
    --background-x: 95.8397534669%;
  }

  .mobile-footer {
    display: block;
    width: 100%;
    max-width: 440px;
    margin: 20px auto 0;
    aspect-ratio: 800 / 100;
    background-image: url('/assets/hackathon-portal.png');
    background-repeat: no-repeat;
    background-size: 209% 941%;
    background-position: 6.3073394495% 98.6920332937%;
  }
}

@media (max-width: 600px) {
  .portal-links { grid-template-columns: minmax(0, 1fr); gap: 18px; max-width: 440px; margin-inline: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
