@font-face {
  font-family: Barlow Condensed;
  src: url('/assets/barlow-condensed-900.woff2') format('woff2');
  font-weight: 900;
  font-display: swap;
}

@font-face {
  font-family: DM Sans;
  src: url('/assets/dm-sans.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
}

@font-face {
  font-family: IBM Plex Mono;
  src: url('/assets/ibm-plex-mono-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --black: #100f0d;
  --panel: #1b1a17;
  --yellow: #ffcb05;
  --white: #faf8f1;
  --muted: #b9b4a9;
  --line: #3a362e;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'DM Sans', Arial, sans-serif;
  --mono: 'IBM Plex Mono', monospace;
  font: 400 1rem/1.45 var(--body);
  background: var(--black);
  color: var(--white);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; }
button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 4px; }
.yellow { color: var(--yellow); }
.display { font-family: var(--display); font-weight: 900; letter-spacing: -.015em; line-height: .86; text-transform: uppercase; }
.site-width { width: min(1180px, calc(100% - 72px)); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.site-header { z-index: 1; background: #100f0df2; border-bottom: 1px solid #ffffff16; }
.header-content { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: inline-flex; align-items: center; gap: 13px; }
.brand-mark { display: grid; place-items: center; background: var(--yellow); width: 68px; height: 43px; border-radius: 8px; }
.brand-mark img { width: 51px; height: auto; }
.brand-name { font-weight: 800; letter-spacing: -.04em; font-size: 1.25rem; white-space: nowrap; }

.stage-link, .small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #ffffff07;
  color: var(--white);
  padding: 0 13px;
  font-size: .875rem;
  font-weight: 700;
  white-space: nowrap;
}

.stage-link:hover, .small-button:hover { border-color: #947832; background: #ffcb0510; }
.icon { position: relative; display: inline-block; flex: 0 0 auto; width: 16px; height: 16px; color: var(--yellow); }
.icon-rank::before {
  content: ''; position: absolute; bottom: 2px; left: 6px; width: 3px; height: 12px; border-radius: 1px;
  background: currentColor; box-shadow: -5px 4px 0 currentColor, 5px 2px 0 currentColor;
}
.icon-rank { overflow: hidden; height: 14px; }
.icon-preview::before {
  content: ''; position: absolute; inset: 3px 0; border: 1.5px solid currentColor; border-radius: 65% 65%;
}
.icon-preview::after { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: currentColor; }
.icon-tiles::before {
  content: ''; position: absolute; top: 1px; left: 1px; width: 6px; height: 6px; border-radius: 1px;
  background: currentColor; box-shadow: 8px 0 currentColor, 0 8px currentColor, 8px 8px currentColor;
}
.icon-fullscreen {
  background:
    linear-gradient(currentColor 0 0) left top / 5px 1.5px,
    linear-gradient(currentColor 0 0) left top / 1.5px 5px,
    linear-gradient(currentColor 0 0) right top / 5px 1.5px,
    linear-gradient(currentColor 0 0) right top / 1.5px 5px,
    linear-gradient(currentColor 0 0) left bottom / 5px 1.5px,
    linear-gradient(currentColor 0 0) left bottom / 1.5px 5px,
    linear-gradient(currentColor 0 0) right bottom / 5px 1.5px,
    linear-gradient(currentColor 0 0) right bottom / 1.5px 5px;
  background-repeat: no-repeat;
  width: 14px;
  height: 14px;
}

.game-page { position: relative; isolation: isolate; background: radial-gradient(ellipse at 8% 75%, #211806, transparent 57%), var(--black); }
.game-page::before {
  content: '';
  pointer-events: none;
  z-index: -1;
  position: absolute;
  inset: auto auto 68px 0;
  width: min(100%, 870px);
  height: 260px;
  background: url('/assets/event-wave.webp') left bottom / auto 100% no-repeat;
  mix-blend-mode: screen;
  opacity: .64;
  mask-image: linear-gradient(to right, #000 55%, transparent 97%), linear-gradient(to bottom, transparent, #000 28% 75%, transparent);
  mask-composite: intersect;
}
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 520px);
  gap: clamp(32px, 6vw, 108px);
  align-content: start;
  align-items: start;
  padding-block: clamp(36px, 5.7vh, 64px) 36px;
  flex: 1;
}
.game-intro { padding-top: 34px; }
.eyebrow {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--yellow);
  font: 500 .83rem/1.2 var(--mono);
  text-transform: uppercase;
  letter-spacing: .105em;
}
.signal {
  display: inline-block;
  flex: 0 0 22px;
  height: 16px;
  color: inherit;
  background:
    linear-gradient(currentColor 0 0) 0 center / 2px 4px,
    linear-gradient(currentColor 0 0) 5px center / 2px 9px,
    linear-gradient(currentColor 0 0) 10px center / 2px 16px,
    linear-gradient(currentColor 0 0) 15px center / 2px 11px,
    linear-gradient(currentColor 0 0) 20px center / 2px 5px;
  background-repeat: no-repeat;
}
.round-tag { color: var(--muted); font: 500 .76rem/1.3 var(--mono); margin-top: 12px; text-transform: uppercase; }
.game-title { margin-top: 25px; font-size: clamp(5rem, 9.45vw, 9rem); }
.game-title span { display: block; }
.intro-copy { color: var(--muted); max-width: 365px; margin-top: 27px; font-size: clamp(1.0625rem, 1.45vw, 1.21rem); line-height: 1.55; }
.game-guide {
  display: flex;
  align-items: start;
  gap: 13px;
  max-width: 372px;
  margin-top: 28px;
  padding: 16px;
  border: 1px solid #5d4a24;
  border-radius: 12px;
  background: #19160fe8;
}
.guide-icon { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 7px; background: #ffcb051a; }
.game-guide strong { display: block; font-size: .91rem; }
.game-guide p { color: var(--muted); margin-top: 3px; font-size: .9rem; line-height: 1.45; }

.puzzle-card {
  padding: clamp(15px, 2.1vw, 24px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 20px 65px #0005;
}
.puzzle-header, .puzzle-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.puzzle-header { margin-bottom: 15px; }
.puzzle-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.puzzle-heading h2 { font-size: 1.23rem; font-weight: 800; letter-spacing: -.035em; }
.puzzle-heading span, .moves { color: var(--muted); font: 500 .82rem/1.15 var(--mono); white-space: nowrap; }
.puzzle-mat { position: relative; border-radius: 12px; background: #100f0d; border: 1px solid #473b25; overflow: hidden; }
.puzzle-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 3px; aspect-ratio: 1000 / 1062; }
.tile {
  position: relative;
  display: block;
  min-width: 0;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 3px;
  background-color: #26231d;
  background-repeat: no-repeat;
  background-size: 300% 300%;
  image-rendering: auto;
  -webkit-tap-highlight-color: transparent;
}
.tile[data-tile] { background-image: url('/assets/audio-ads-poster.webp'); }
.tile[data-tile='0'] { background-position: 0 0; }
.tile[data-tile='1'] { background-position: 50% 0; }
.tile[data-tile='2'] { background-position: 100% 0; }
.tile[data-tile='3'] { background-position: 0 50%; }
.tile[data-tile='4'] { background-position: 50% 50%; }
.tile[data-tile='5'] { background-position: 100% 50%; }
.tile[data-tile='6'] { background-position: 0 100%; }
.tile[data-tile='7'] { background-position: 50% 100%; }
.tile[data-tile='8'] { background-position: 100% 100%; }
.tile:focus-visible, .tile[aria-pressed='true'] { outline: 3px solid var(--yellow); outline-offset: -4px; z-index: 1; }
.tile[aria-pressed='true']::after {
  content: '✓'; pointer-events: none; position: absolute; top: 8px; right: 8px; width: 25px; height: 25px; display: grid;
  place-items: center; font-size: .92rem; font-weight: 800; color: #181406; background: var(--yellow); border-radius: 50%;
}
@media (hover: hover) {
  .tile:not(:disabled):hover { box-shadow: inset 0 0 0 2px #ffcb05bb; }
}
.puzzle-board.solved { gap: 0; }
.puzzle-board.solved .tile { border-radius: 0; }
.board-message { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 15px; background: #100f0dbd; text-align: center; }
.puzzle-footer { margin-top: 15px; padding-bottom: 1px; }
.progress p { color: var(--muted); font-size: .875rem; }
.progress strong { margin-right: 3px; color: var(--yellow); font: 500 .8rem/1.2 var(--mono); }
.progress-track { display: flex; gap: 4px; margin-top: 7px; }
.progress-track span { width: clamp(9px, 2vw, 16px); height: 3px; background: #575044; border-radius: 2px; }
.progress-track .filled { background: var(--yellow); }
.finish-bar { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 15px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.finish-bar p { color: var(--yellow); font-size: .875rem; font-weight: 700; }

.site-footer { display: flex; min-height: 54px; align-items: center; padding-block: 11px; border-top: 1px solid #ffffff18; font: 500 .76rem/1.4 var(--mono); color: var(--muted); }
.footer-divider { padding-inline: 5px; color: var(--yellow); }

.dialog {
  width: min(480px, calc(100% - 28px)); max-height: calc(100% - 28px); overflow: auto;
  padding: 0; color: var(--white); border: 1px solid #5d4a24; border-radius: 18px;
  background: #201e19; box-shadow: 0 26px 90px #000a;
}
.dialog::backdrop { background: #080703d9; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 1.1rem; }
.close-button { min-height: 40px; min-width: 40px; padding: 0; font-size: 1.55rem; font-weight: 400; }
.reference-dialog { width: min(550px, calc(100% - 28px)); }
.reference-dialog img { object-fit: contain; margin-inline: auto; width: 100%; height: auto; max-height: calc(100dvh - 98px); }
.dialog-body { padding: 23px; }
.dialog-body h2 { font-size: clamp(3.1rem, 10vw, 4.35rem); }
.dialog-body p { margin-block: 14px 19px; color: var(--muted); }
.dialog-body label { display: block; margin-bottom: 6px; font-weight: 700; font-size: .9rem; }
.dialog-body input {
  width: 100%; min-height: 49px; padding: 9px 12px; color: var(--white); background: #100f0d;
  border: 1px solid #666053; border-radius: 8px;
}
.primary-button {
  display: inline-flex; justify-content: center; align-items: center; min-height: 50px; width: 100%;
  margin-top: 13px; padding: 9px 14px; background: var(--yellow); color: #161308;
  border: 1px solid transparent; border-radius: 8px; font-weight: 800; text-align: center;
}
.primary-button:disabled { opacity: .6; }
.primary-button:hover { background: #ffdc56; }
.dialog-body .form-error { margin-block: 5px 0; color: #ffbca2; font-size: .88rem; }

.stage-page { background: radial-gradient(ellipse at 92% 0%, #211b0f 0%, transparent 51%), var(--black); }
.stage-page .site-width { width: min(1512px, calc(100% - 84px)); }
.stage-layout {
  display: grid; grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr); gap: clamp(16px, 2.3vw, 34px);
  flex: 1; align-content: center; align-items: stretch; padding-block: clamp(21px, 4vh, 48px);
}
.join-panel {
  position: relative; isolation: isolate; overflow: hidden; color: #181407; background: var(--yellow);
  padding: clamp(23px, 3.2vw, 49px); border-radius: 22px; display: flex; align-items: flex-start; flex-direction: column;
}
.join-panel::after {
  content: ''; position: absolute; z-index: -1; pointer-events: none; inset: 0;
  background: repeating-radial-gradient(ellipse at 115% 75%, transparent 0 14px, #2b230920 15px 16px, transparent 17px 24px);
  mask-image: linear-gradient(135deg, transparent 60%, #000);
}
.join-panel .eyebrow { color: #332600; }
.join-panel h1 { margin-top: 17px; font-size: clamp(3.5rem, 6.3vw, 7.55rem); }
.join-copy { font-size: clamp(1rem, 1.3vw, 1.2rem); font-weight: 650; margin-top: 12px; }
.qr-frame {
  display: grid; align-items: center; justify-items: center; aspect-ratio: 1;
  width: min(100%, clamp(190px, 33vh, 420px)); overflow: hidden; margin-top: clamp(17px, 2.5vh, 30px);
  border: 1px solid #20170518; border-radius: 14px; background: #fff;
  box-shadow: 0 8px 24px #5c420828;
}
.qr-frame img { width: 100%; height: 100%; }
.qr-frame p { padding: 15px; text-align: center; }
.join-link {
  display: inline-block; overflow-wrap: anywhere; margin-top: 12px;
  font: 500 .9rem/1.35 var(--mono); text-decoration: underline; text-underline-offset: 3px;
}
.join-panel :focus-visible { outline-color: #191307; }
.qr-download { display: inline-flex; min-height: 32px; align-items: center; margin-top: 5px; font-weight: 750; font-size: .85rem; }
.qr-download:hover { text-decoration: underline; text-underline-offset: 3px; }

.stage-board {
  display: flex; flex-direction: column; min-width: 0; justify-content: space-between;
  padding: clamp(20px, 3vw, 45px); border: 1px solid var(--line); border-radius: 22px; background: #191713;
}
.stage-board-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.stage-board-head h2 { font-size: clamp(3.05rem, 5vw, 6.25rem); }
.live-badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 9px;
  border-radius: 6px; border: 1px solid #4d4629; color: var(--muted); white-space: nowrap;
  font: 500 .74rem/1.1 var(--mono); text-transform: uppercase; letter-spacing: .08em;
}
.live-badge > span:first-child { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.live-badge[data-state='online'] { color: var(--yellow); border-color: #5e4d14; background: #ffcb0510; }
.stage-results { margin-top: clamp(20px, 3.35vh, 41px); }
.winner-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: clamp(10px, 1.4vw, 24px);
  min-height: clamp(92px, 13vh, 166px); padding: 12px clamp(11px, 1.75vw, 28px);
  border-radius: 13px; border: 1px solid #6d581a; background: linear-gradient(115deg, #3b2c0c, #241e11 70%);
}
.winner-card[data-filled='true'] { background: var(--yellow); border-color: var(--yellow); color: #171306; }
.winner-rank { color: var(--yellow); font: 900 clamp(3.05rem, 4.8vw, 6.2rem)/.86 var(--display); }
.winner-detail p { color: var(--yellow); text-transform: uppercase; letter-spacing: .08em; font: 500 clamp(.7rem, 1vw, 1rem)/1.2 var(--mono); }
.winner-detail h3 { font-size: clamp(1.05rem, 2.2vw, 2.6rem); font-weight: 800; line-height: 1.03; margin-top: 5px; overflow-wrap: anywhere; }
.winner-time { color: var(--yellow); font: 500 clamp(.8rem, 1.3vw, 1.3rem)/1.2 var(--mono); }
.winner-card[data-filled='true'] :is(.winner-rank, .winner-detail p, .winner-time) { color: #171306; }
.rank-head, .rank-row { display: grid; align-items: center; }
.rank-head {
  display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); margin-top: clamp(15px, 2.35vh, 28px);
  padding: 0 1px 7px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
  font: 500 clamp(.69rem, 1vw, .87rem)/1.2 var(--mono);
}
.rank-list { margin: 0; padding: 0; list-style: none; }
.rank-row {
  min-height: clamp(42px, 7vh, 76px); grid-template-columns: clamp(27px, 3.5vw, 51px) minmax(0, 1fr) auto;
  border-bottom: 1px solid var(--line); gap: 8px; padding-block: 5px;
}
.rank-number, .rank-time { font: 500 clamp(.82rem, 1.2vw, 1.25rem)/1 var(--mono); }
.rank-number { color: #d1b158; }
.rank-time { color: var(--muted); }
.rank-name { padding-right: 4px; font-size: clamp(1rem, 1.63vw, 1.7rem); font-weight: 700; overflow-wrap: anywhere; }
.rank-row[data-filled='false'] .rank-name { color: var(--muted); font-weight: 500; }
.stage-count {
  padding-top: clamp(12px, 2vh, 23px); color: var(--muted); font: 500 .8rem/1.25 var(--mono);
  text-transform: uppercase; letter-spacing: .06em;
}
.stage-footer { min-height: 48px; }

@media (max-width: 1150px) {
  .game-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 50%); gap: 32px; }
  .game-intro { padding-top: 25px; }
  .game-title { font-size: clamp(4.275rem, 9.4vw, 6.2rem); }
  .stage-page .site-width { width: calc(100% - 50px); }
}

@media (max-width: 710px) {
  .site-width, .stage-page .site-width { width: calc(100% - 32px); }
  .header-content { min-height: 61px; }
  .brand { gap: 9px; }
  .brand-mark { width: 55px; height: 36px; border-radius: 6px; }
  .brand-mark img { width: 41px; }
  .brand-name { font-size: 1.05rem; }
  .stage-link { min-height: 40px; gap: 7px; padding-inline: 9px; }
  .game-layout { max-width: 530px; grid-template-columns: minmax(0, 1fr); gap: 16px; padding-block: 24px 27px; }
  .game-intro { padding-top: 0; }
  .eyebrow { font-size: .73rem; letter-spacing: .08em; gap: 8px; }
  .game-title { font-size: clamp(2.65rem, 10.35vw, 4.1rem); margin-top: 12px; line-height: .95; }
  .game-title span { display: inline; }
  .intro-copy { margin-top: 10px; font-size: 1rem; line-height: 1.37; max-width: 360px; }
  .game-guide { align-items: center; margin-top: 12px; gap: 7px; padding: 0; background: none; border: 0; }
  .guide-icon { width: 24px; height: 24px; flex-basis: 24px; border-radius: 4px; }
  .guide-icon .icon { transform: scale(.8); }
  .game-guide strong { display: none; }
  .game-guide p { margin: 0; font-size: .82rem; }
  .puzzle-card { padding: 12px; border-radius: 15px; }
  .puzzle-header { margin-bottom: 10px; }
  .puzzle-heading h2 { font-size: 1.09rem; }
  .puzzle-header .small-button { min-height: 39px; }
  .puzzle-footer { margin-top: 11px; }
  .puzzle-mat { border-radius: 8px; }
  .game-page::before { inset-block-end: auto; top: 100px; height: 220px; opacity: .3; mask-image: linear-gradient(to bottom, transparent, #000 70%, transparent); }
  .site-footer { min-height: 48px; font-size: .69rem; }
  .stage-layout { grid-template-columns: minmax(0, 1fr); max-width: 530px; gap: 14px; padding-block: 18px 22px; }
  .join-panel, .stage-board { border-radius: 15px; }
  .join-panel { padding: 23px; }
  .join-panel h1 { margin-top: 12px; }
  .join-copy { margin-top: 8px; }
  .qr-frame { width: min(230px, 100%); }
  .stage-board-head { flex-wrap: wrap; }
}

@media (min-width: 711px) and (max-height: 770px) {
  .stage-page .header-content { min-height: 61px; }
  .stage-layout { padding-block: 19px; }
  .stage-page .stage-footer { min-height: 34px; }
  .stage-board { padding-block: 22px; }
  .join-panel { padding-block: 23px; }
  .stage-results { margin-top: 23px; }
  .rank-row { min-height: 43px; }
}

@media (max-width: 375px) {
  .puzzle-card { padding: 9px; }
  .game-title { font-size: clamp(2.225rem, 10.1vw, 2.55rem); }
  .stage-board-head h2 { font-size: 2.75rem; }
}
