:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  background: #08113c;
  color: white;
  touch-action: manipulation;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #08113c; }
body { min-height: 100dvh; overflow: hidden; }
button { font: inherit; -webkit-tap-highlight-color: transparent; }

.controller-shell {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #111b4d 0%, #08113c 100%);
}

.controller-header,
.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.controller-header { min-height: 42px; }
.brand { font-weight: 800; letter-spacing: .02em; }
.status { font-weight: 800; font-size: 13px; letter-spacing: .08em; opacity: .9; }

.message-panel {
  margin: auto 0;
  text-align: center;
  padding: 24px;
}
.message-icon { font-size: 58px; color: #e31837; }
.message-panel h1 { margin: 8px 0; font-size: 28px; }
.message-panel p { margin: 0; opacity: .75; line-height: 1.4; }

#game-root {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.score-row {
  min-height: 44px;
  padding: 0 4px;
  font-weight: 800;
  letter-spacing: .08em;
}
#score { font-size: 32px; line-height: 1; color: #f9b612; }

.hint {
  margin: 0;
  padding: 0 4px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  opacity: .78;
  min-height: 18px;
}

/* ---------- Clap, Clap, DING! / shared lane controls ---------- */

.ding-controller,
.nonstop-controller {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lane-stack {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(4, minmax(56px, 1fr));
  gap: 8px;
}

.lane-button {
  width: 100%;
  min-height: 56px;
  border: 2px solid rgba(255,255,255,.24);
  border-radius: 18px;
  background: rgba(255,255,255,.06);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 70ms ease, background 100ms ease, border-color 100ms ease;
}

.lane-button span {
  width: min(17vw, 72px);
  height: min(17vw, 72px);
  min-width: 46px;
  min-height: 46px;
  border-radius: 999px;
  background: #304cb2;
  border: 7px solid #f9b612;
  box-shadow: inset 0 -8px 0 rgba(0,0,0,.25), 0 5px 0 rgba(0,0,0,.22);
}

.lane-button:active:not(:disabled) { transform: scale(.975); }
.lane-button:active:not(:disabled) span { transform: translateY(3px); box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.lane-button:disabled { opacity: .34; cursor: default; }
.lane-button.success { background: rgba(249,182,18,.22); border-color: #f9b612; }
.lane-button.success span { background: #e31837; }
.lane-button.selected { border-color: #f9b612; background: rgba(249,182,18,.14); }

/* ---------- Nonstop FIRE button ---------- */

.fire-button {
  min-height: 64px;
  border: 0;
  border-radius: 18px;
  background: #e31837;
  color: white;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: .12em;
  cursor: pointer;
  transition: transform 70ms ease, opacity 100ms ease;
}
.fire-button:active:not(:disabled) { transform: scale(.97); }
.fire-button:disabled { opacity: .32; cursor: default; }

/* ---------- Trivia ---------- */

.trivia-controller {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.question-text {
  margin: 0;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.06);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  min-height: 3.5em;
}

.choice-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(4, minmax(48px, 1fr));
  gap: 8px;
}

.choice-button {
  width: 100%;
  min-height: 48px;
  border: 2px solid rgba(255,255,255,.24);
  border-radius: 14px;
  background: rgba(255,255,255,.06);
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  cursor: pointer;
  text-align: left;
  transition: transform 70ms ease, background 100ms ease, border-color 100ms ease;
}
.choice-button:active:not(:disabled) { transform: scale(.98); }
.choice-button:disabled { opacity: .4; cursor: default; }
.choice-label {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #304cb2;
  border: 2px solid #f9b612;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
}
.choice-copy { flex: 1; font-size: 15px; font-weight: 600; }

/* ---------- Ops Tac Toe ---------- */

.opstactoe-controller {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.opstactoe-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(9, 1fr);
  gap: 3px;
}

.grid-cell {
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 6px;
  background: rgba(255,255,255,.05);
  cursor: pointer;
  padding: 0;
  transition: transform 70ms ease, background 100ms ease;
}
.grid-cell:active:not(:disabled) { transform: scale(.92); }
.grid-cell:disabled:not(.guessed) { opacity: .3; cursor: default; }
.grid-cell.pending { background: rgba(249,182,18,.28); }
.grid-cell.hit { background: #e31837; border-color: #e31837; }
.grid-cell.sunk { background: #7a0f21; border-color: #7a0f21; }
.grid-cell.miss { background: rgba(255,255,255,.08); }

/* ---------- Celebration ---------- */

.celebration {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.heart {
  position: absolute;
  bottom: -48px;
  font-size: 34px;
  animation: fly 1.4s ease-out forwards;
}
@keyframes fly {
  from { transform: translateY(0) rotate(0deg) scale(.7); opacity: 0; }
  15% { opacity: 1; }
  to { transform: translateY(-115dvh) rotate(420deg) scale(1.25); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
