:root {
  color-scheme: dark;
  --ink: #f6f1e7;
  --muted: rgba(246, 241, 231, 0.72);
  --gold: #f0c98a;
  --line: rgba(255, 255, 255, 0.16);
  --panel: rgba(255, 255, 255, 0.07);
  --sky: #14122e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--sky);
}

html.is-playing,
html.is-playing body {
  touch-action: none;
}

body {
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

[hidden] { display: none !important; }

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

.picker {
  position: fixed;
  inset: 0;
  z-index: 3;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding:
    calc(28px + env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    calc(28px + env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  background:
    linear-gradient(180deg, rgba(8, 10, 24, 0.18), rgba(8, 10, 24, 0.02) 28%, rgba(8, 10, 24, 0.28));
  opacity: 1;
  visibility: visible;
  transition: opacity 240ms ease, visibility 0s linear 0s;
}

.picker.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 240ms ease, visibility 0s linear 240ms;
}

.hero {
  width: min(640px, 100%);
  text-align: center;
  margin-top: 8px;
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
}

h1 {
  margin: 0;
  font-size: clamp(52px, 9vw, 88px);
  line-height: 0.9;
  letter-spacing: -0.045em;
  font-weight: 800;
  color: #f7f1e6;
}

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  h1 {
    background-image: linear-gradient(180deg, #ffffff 12%, #f3d7a4 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }
}

.lede {
  margin: 14px auto 0;
  max-width: 38rem;
  font-size: clamp(16px, 2.4vw, 19px);
  line-height: 1.45;
  color: var(--muted);
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
}

.grid {
  width: min(980px, 100%);
  margin-top: 28px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.pick {
  position: relative;
  flex: 0 0 auto;
  width: 156px;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  border-radius: 22px;
  min-height: 132px;
  padding: 12px 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.pick::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 50% 28%, var(--glow, transparent), transparent 68%);
  pointer-events: none;
}

.pick canvas {
  width: 84px;
  height: 84px;
  position: relative;
  z-index: 1;
}

.pick span {
  position: relative;
  z-index: 1;
  line-height: 1.15;
  text-align: center;
}

.pick:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
}

.pick:active { transform: scale(0.97); }

.pick:focus { outline: none; }

.pick:focus-visible,
.exit:focus-visible,
#sound:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.hint {
  margin: 22px 0 0;
  font-size: 13px;
  letter-spacing: 0.01em;
  color: rgba(246, 241, 231, 0.55);
  text-align: center;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

.hud {
  position: fixed;
  z-index: 4;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding:
    calc(12px + env(safe-area-inset-top))
    calc(12px + env(safe-area-inset-right))
    0
    calc(12px + env(safe-area-inset-left));
  pointer-events: none;
}

.counter {
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: clamp(12px, 3.4vw, 15px);
  letter-spacing: 0.01em;
  color: var(--ink);
  background: rgba(8, 10, 24, 0.48);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  min-height: 44px;
  display: flex;
  align-items: center;
  white-space: nowrap;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.hud-actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.exit, #sound {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(8, 10, 24, 0.5);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.exit {
  font-weight: 700;
  font-size: 16px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
}

#sound {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 0;
}

#sound svg { width: 22px; height: 22px; display: block; }

#sound[aria-pressed="false"] .icon-on,
#sound[aria-pressed="true"] .icon-off { display: none; }

.exit:hover, #sound:hover { background: rgba(255, 255, 255, 0.14); }
.exit:active, #sound:active { transform: scale(0.97); }

.selfcheck {
  position: fixed;
  z-index: 5;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: #6d2430;
  color: white;
  font-size: 14px;
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background: #14122e;
}

@media (max-width: 520px) {
  .pick { width: calc(50% - 6px); }
}

@media (max-height: 520px) {
  .hero { margin-top: 0; }
  h1 { font-size: clamp(36px, 8vw, 56px); }
  .lede { margin-top: 8px; font-size: 15px; }
  .grid { margin-top: 14px; }
  .pick { min-height: 112px; }
  .hint { margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .pick, .picker { transition: none; }
}
