/* Self-hosted Inter (variable font, all weights in one file). Works offline. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: block;
  src: url('../fonts/InterVariable.woff2') format('woff2-variations'),
    url('../fonts/InterVariable.woff2') format('woff2');
}

/* Pixel display font for the in-game timer (Variant A HUD). */
@font-face {
  font-family: 'LoRes22';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url('../fonts/lo-res-22-narrow.ttf') format('truetype');
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --orange: #F07048;
  --black: #111111;
  --white: #FFFFFF;
  --dark-bg: #191B25;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', sans-serif;
  background: var(--dark-bg);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

img,
canvas,
button,
div {
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-select: none;
}

#app {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--dark-bg);
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--dark-bg);
}

/* ===== SCREENS ===== */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.screen.active {
  display: flex;
}

/* ===== SPLASH ===== */
#splash-screen {
  background: #000;
  cursor: pointer;
  justify-content: flex-start;
  padding: 0;
}

.splash-title-art {
  display: block;
  /* Mobile design spec: 41px from top, 32px side padding (in rem). */
  width: calc(100% - 4rem);
  /* 100% minus 2rem on each side = 32px+32px */
  height: auto;
  margin: 2.5625rem 2rem 0;
  /* 41px top, 32px sides, 0 bottom */
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  transform-origin: center;
  /* Gentle "breathing" loop. Different timing than the sun so they feel
     independent rather than in sync. GPU-composited transform. */
  animation: titlePulse 2.6s ease-in-out infinite;
}

@keyframes titlePulse {

  0%,
  100% {
    transform: scale(1) translateY(0);
  }

  50% {
    transform: scale(1.03) translateY(-3px);
  }
}

/* Tablet & kiosk: title sits at 75% width, centered, with proportional top space. */
@media (min-width: 768px) {
  .splash-title-art {
    width: 75%;
    margin: clamp(40px, 6vh, 110px) auto 0;
  }
}

.splash-art {
  display: block;
  width: 100%;
  height: auto;
  margin-top: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  transform-origin: center bottom;
  animation: splashBreath 3.2s ease-in-out infinite;
}

@keyframes splashBreath {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.02);
  }
}

.splash-tap-hint {
  font-family: 'Inter', sans-serif;
  font-size: clamp(11px, 2.6vw, 16px);
  color: rgba(255, 255, 255, 0.65);
  letter-spacing: 1px;
  margin: clamp(10px, 2.5vw, 20px) 0 clamp(20px, 4vw, 40px);
  text-align: center;
  animation: blink 1.4s ease-in-out infinite;
}

@keyframes blink {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: 0.25
  }
}

/* HUD-variant toggle on the name screen (top-right gear, 50% opacity). */
.hud-toggle {
  position: absolute;
  top: clamp(14px, 3vh, 28px);
  right: clamp(14px, 3vw, 28px);
  width: clamp(36px, 5.5vh, 52px);
  height: clamp(36px, 5.5vh, 52px);
  border: none;
  background: transparent;
  color: var(--white);
  cursor: pointer;
  opacity: 0.5;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: opacity 0.15s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}

.hud-toggle:hover {
  opacity: 0.85;
}

.hud-toggle:active {
  transform: scale(0.92);
}

.hud-toggle svg {
  width: 60%;
  height: 60%;
}

/* HUD-style picker panel */
.hud-panel {
  position: absolute;
  top: clamp(60px, 9vh, 92px);
  right: clamp(14px, 3vw, 28px);
  z-index: 6;
  background: #111;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(86vw, 280px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  animation: hudPanelIn 0.18s ease-out both;
}

.hud-panel[hidden] {
  display: none;
}

@keyframes hudPanelIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.hud-panel-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
  padding: 4px 0 2px;
}

.hud-option {
  background: #1c1c1c;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 10px;
  color: #fff;
  cursor: pointer;
  text-align: left;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.hud-option:hover {
  background: #242424;
}

.hud-option.is-active {
  border-color: #EAFF27;
}

.hud-option-preview {
  position: relative;
  height: 64px;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}

.hud-option-preview--a .hp-score {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
}

.hud-option-preview--a .hp-timer {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-family: 'LoRes22', monospace;
  font-size: 32px;
  color: rgba(180, 180, 180, 0.6);
}

.hud-option-preview--b .hp-corner {
  position: absolute;
  top: 6px;
  font-size: 8px;
  line-height: 1.2;
}

.hud-option-preview--b .hp-corner b {
  display: block;
  font-size: 11px;
}

.hud-option-preview--b .hp-corner--l {
  left: 8px;
  text-align: left;
}

.hud-option-preview--b .hp-corner--r {
  right: 8px;
  text-align: right;
}

.hud-option-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: rgba(255, 255, 255, 0.85);
}

/* ===== NAME SCREEN ===== */
#name-screen {
  background: #000;
  justify-content: center;
  /* vertical centering of input + keyboard */
  padding: 0;
  /* Note: position:absolute is inherited from .screen — it doubles as the
     containing block for the absolutely-positioned tap-hint. */
}

.name-input {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin-bottom: clamp(28px, 5vh, 72px);
  /* space between input and keyboard */
}

.name-display {
  font-family: 'Inter', sans-serif;
  font-size: clamp(28px, 7.2vw, 64px);
  font-weight: 600;
  color: var(--white);
  letter-spacing: 4px;
  min-height: 1.2em;
  text-align: center;
  padding: 0 6%;
  /* Wrap long names gracefully on narrow screens. */
  word-break: break-word;
}

.name-display.is-placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.name-input.shake {
  animation: nameShake 0.36s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes nameShake {

  10%,
  90% {
    transform: translateX(-3px);
  }

  20%,
  80% {
    transform: translateX(5px);
  }

  30%,
  50%,
  70% {
    transform: translateX(-9px);
  }

  40%,
  60% {
    transform: translateX(9px);
  }
}

.name-underline {
  width: clamp(220px, 60vw, 500px);
  height: 4px;
  background: #EAFF27;
  /* signature yellow-green accent */
  margin-top: clamp(6px, 1.4vw, 14px);
  border-radius: 0;
}

/* Keyboard wrapper — modern iOS-style white keys on black. */
.keyboard-wrap {
  background: transparent;
  padding: 0 clamp(8px, 2vw, 22px);
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.kb-row {
  display: flex;
  justify-content: center;
  gap: clamp(4px, 1vw, 9px);
  margin-bottom: clamp(4px, 1vw, 9px);
}

.kb-key {
  background: #FFFFFF;
  color: #1A1A1A;
  border: none;
  border-radius: clamp(6px, 1.4vw, 12px);
  font-family: 'Inter', sans-serif;
  font-size: clamp(13px, 3vw, 22px);
  font-weight: 500;
  flex: 1;
  min-width: 0;
  height: clamp(38px, 7.5vw, 64px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.07s, background 0.07s;
  flex-shrink: 1;
  padding: 0 2px;
  white-space: nowrap;
  overflow: hidden;
}

.kb-key:active,
.kb-key.pressed {
  transform: scale(0.92);
  background: #EAFF27;
}

/* Specials (shift / delete / period / hyphen / return) on the spacebar row keep
   sane proportions instead of stretching like letters. */
.kb-key.shift,
.kb-key.delete {
  flex: 1.4;
  font-size: clamp(13px, 3.2vw, 22px);
}

.kb-key.space {
  flex: 5;
  font-size: clamp(11px, 2.4vw, 18px);
  color: #555;
}

.kb-key.return-key {
  flex: 1.6;
  font-size: clamp(11px, 2.4vw, 18px);
  color: #1A1A1A;
}

.name-tap-hint {
  font-family: 'Inter', sans-serif;
  font-size: clamp(13px, 3vw, 20px);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 1px;
  text-align: center;
  animation: blink 1.6s ease-in-out infinite;
  /* Pin to bottom so the input+keyboard pair can stay centered above. */
  position: absolute;
  left: 0;
  right: 0;
  bottom: clamp(28px, 5vh, 70px);
}

/* ---- Name screen intro animations ---- */
/* Keys ripple in diagonally: each key's delay = row*0.05s + col*0.022s + 0.18s.
   Pure transform/opacity → GPU-composited, no main-thread cost, no game impact. */
@keyframes kbKeyIn {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.86);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes nameInputIn {
  0% {
    opacity: 0;
    transform: translateY(-12px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes nameUnderlineGrow {
  0% {
    transform: scaleX(0);
  }

  100% {
    transform: scaleX(1);
  }
}

@keyframes hintFadeIn {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

#name-screen.active .name-display {
  animation: nameInputIn 0.45s cubic-bezier(0.2, 0.85, 0.3, 1) both;
  animation-delay: 0.05s;
}

#name-screen.active .name-underline {
  transform-origin: center;
  animation: nameUnderlineGrow 0.5s cubic-bezier(0.2, 0.85, 0.3, 1) both;
  animation-delay: 0.18s;
}

#name-screen.active .kb-key {
  animation: kbKeyIn 0.42s cubic-bezier(0.2, 0.85, 0.3, 1) both;
  animation-delay: calc(var(--row, 0) * 0.05s + var(--col, 0) * 0.022s + 0.18s);
}

#name-screen.active .name-tap-hint {
  animation: hintFadeIn 0.5s ease both, blink 1.6s ease-in-out 1.2s infinite;
  animation-delay: 0.95s, 1.2s;
}

/* ===== GAME SCREEN ===== */
#game-screen {
  background: #000;
}

/* descifer brand mark — pinned near the bottom of the gameplay area, below
   the ground line. Sized small so it doesn't compete with the camel. */
.descifer-brand {
  position: absolute;
  left: 50%;
  bottom: clamp(72px, 14vh, 160px);
  transform: translateX(-50%);
  width: clamp(96px, 22vw, 180px);
  height: auto;
  pointer-events: none;
  user-select: none;
  z-index: 3;
  opacity: 0.95;
}

@media (orientation: landscape) and (min-width: 900px) {
  .descifer-brand {
    width: clamp(72px, 8vh, 120px);
    bottom: clamp(48px, 10vh, 110px);
  }
}

@media (orientation: portrait) and (min-width: 1000px) and (min-height: 1700px) {
  .descifer-brand {
    width: clamp(180px, 18vw, 260px);
    bottom: 221px;
    top: auto;
  }
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ===== COUNTDOWN OVERLAY ===== */
#countdown-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
  background: rgba(0, 0, 0, 0.28);
}

#countdown-overlay.active {
  display: flex;
}

#countdown-number {
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  font-size: clamp(72px, 20vw, 160px);
  color: var(--white);
  text-shadow: 0 0 28px rgba(255, 255, 255, 0.4);
  animation: countPulse 0.88s ease-out forwards;
}

@media (orientation: portrait) and (min-width: 1000px) and (min-height: 1700px) {
  #countdown-number {
    font-size: 360px;
    text-shadow: 0 0 60px rgba(255, 255, 255, 0.45);
  }
}

@keyframes countPulse {
  0% {
    transform: scale(1.6);
    opacity: 0;
  }

  28% {
    transform: scale(1.0);
    opacity: 1;
  }

  78% {
    transform: scale(0.92);
    opacity: 1;
  }

  100% {
    transform: scale(0.86);
    opacity: 0;
  }
}

#intro-overlay {
  position: absolute;

  inset: 0;
  display: none;
  overflow: hidden;
  pointer-events: none;
  z-index: 9;
}

#intro-overlay.active {
  display: block;
}

/* Cinematic letterbox bars — slam in, hold briefly, slam out. */
.intro-bar {
  position: absolute;
  left: 0;
  right: 0;
  background: #000;
  height: 0;
  z-index: 2;
}

.intro-bar-top {
  top: 0;
  animation: introBarTop 0.95s cubic-bezier(0.5, 0, 0.2, 1) forwards;
}

.intro-bar-bot {
  bottom: 0;
  animation: introBarBot 0.95s cubic-bezier(0.5, 0, 0.2, 1) forwards;
}

@keyframes introBarTop {
  0% {
    height: 0;
  }

  18% {
    height: 13%;
  }

  72% {
    height: 13%;
  }

  100% {
    height: 0;
  }
}

@keyframes introBarBot {
  0% {
    height: 0;
  }

  18% {
    height: 13%;
  }

  72% {
    height: 13%;
  }

  100% {
    height: 0;
  }
}

.intro-streak {
  position: absolute;
  left: -35%;
  width: 170%;
  height: 16%;
  background: linear-gradient(90deg,
      rgba(255, 255, 255, 0) 0%,
      rgba(240, 112, 72, 0.12) 18%,
      rgba(240, 112, 72, 0.82) 48%,
      rgba(255, 255, 255, 0.98) 52%,
      rgba(240, 112, 72, 0.82) 56%,
      rgba(255, 255, 255, 0) 88%);
  transform: skewX(-30deg) translateX(-100%);
  filter: blur(1px);
  opacity: 0;
  animation: introSweep 0.9s cubic-bezier(0.2, 0.85, 0.25, 1) forwards;
}

.intro-streak-a {
  top: 24%;
  animation-delay: 0.02s;
}

.intro-streak-b {
  top: 44%;
  animation-delay: 0.1s;
}

.intro-streak-c {
  top: 64%;
  animation-delay: 0.18s;
}

.intro-burst {
  position: absolute;
  inset: -18%;
  background: radial-gradient(circle at center, rgba(240, 112, 72, 0.56) 0%, rgba(240, 112, 72, 0.18) 18%, rgba(25, 27, 37, 0) 52%);
  opacity: 0;
  animation: introBurst 0.82s ease-out forwards;
}

.intro-word {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.78);
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  font-size: clamp(56px, 17vw, 168px);
  color: var(--white);
  text-shadow: 0 0 24px rgba(240, 112, 72, 0.85), 6px 6px 0 rgba(0, 0, 0, 0.55);
  letter-spacing: 10px;
  opacity: 0;
  animation: introWord 0.95s cubic-bezier(0.16, 0.84, 0.3, 1) forwards;
}

@keyframes introSweep {
  0% {
    transform: skewX(-30deg) translateX(-100%);
    opacity: 0;
  }

  18% {
    opacity: 1;
  }

  100% {
    transform: skewX(-30deg) translateX(100%);
    opacity: 0;
  }
}

@keyframes introBurst {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }

  25% {
    opacity: 1;
  }

  100% {
    transform: scale(1.18);
    opacity: 0;
  }
}

@keyframes introWord {
  0% {
    transform: translate(-50%, -50%) scale(0.72);
    opacity: 0;
  }

  28% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }

  72% {
    transform: translate(-50%, -50%) scale(0.98);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -50%) scale(1.08);
    opacity: 0;
  }
}

/* ===== RESULT SCREENS (Game Over + Well Played) =====
   Card-centric layout matching the v2 mockups:
   - black background, centered card, "Tap anywhere to restart" pinned below.
   - Game Over card is white; Well Played card is signature yellow.
   - Leaderboard rows render as outlined pill-shaped rectangles.
   - The current player's row gets inverted (black fill, white text). */
#gameover-screen,
#wellplayed-screen {
  background: #000;
  cursor: pointer;
  justify-content: center;
  padding: clamp(20px, 5vw, 48px);
  gap: clamp(28px, 5vh, 60px);
}

.result-card {
  background: var(--white);
  color: #000;
  width: min(88%, 520px);
  border-radius: 0;
  padding: clamp(20px, 5vw, 44px) clamp(18px, 4.5vw, 40px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.result-card--win {
  background: #EAFF27;
}

.result-title {
  font-family: 'Inter', sans-serif;
  font-weight: 900;
  font-size: clamp(34px, 9vw, 72px);
  line-height: 1.05;
  text-align: center;
  letter-spacing: -0.02em;
  color: #000;
}

.result-sub {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: clamp(13px, 3vw, 22px);
  text-align: center;
  margin-top: clamp(6px, 1.5vw, 12px);
  margin-bottom: clamp(18px, 4vw, 32px);
  color: #000;
}

.result-board {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.6vw, 14px);
}

.lb-row {
  display: flex;
  align-items: center;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: clamp(13px, 3.2vw, 22px);
  padding: clamp(10px, 2.2vw, 18px) clamp(14px, 3vw, 22px);
  border: 2px solid #000;
  border-radius: 0;
  color: #000;
  background: transparent;
}

.lb-rank {
  width: clamp(28px, 6vw, 48px);
  font-weight: 600;
  flex-shrink: 0;
}

.lb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 8px;
}

.lb-score {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* Current player row inverts on either screen. */
.lb-row.highlight {
  background: #000;
  color: var(--white);
  border-color: #000;
}

.result-tap-hint {
  font-family: 'Inter', sans-serif;
  font-size: clamp(13px, 3vw, 20px);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.45);
  text-align: center;
  letter-spacing: 0.3px;
  /* Hidden for the first ~3s of the result screen — the screen itself adds
     `.is-armed` after 3s to fade this in and enable the tap-to-restart. */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease;
}

#gameover-screen.is-armed .result-tap-hint,
#wellplayed-screen.is-armed .result-tap-hint {
  visibility: visible;
  opacity: 1;
  animation: blink 1.6s ease-in-out 0.5s infinite;
}

/* ===== ADMIN GEAR + PANEL ===== */
.admin-gear {
  position: absolute;
  top: clamp(14px, 2.5vh, 28px);
  right: clamp(14px, 2.5vw, 28px);
  width: clamp(36px, 5vw, 52px);
  height: clamp(36px, 5vw, 52px);
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: color 0.15s ease, transform 0.15s ease;
}

.admin-gear:hover,
.admin-gear:active {
  color: rgba(255, 255, 255, 0.85);
  transform: rotate(20deg);
}

.admin-gear svg {
  width: 60%;
  height: 60%;
}

#admin-panel {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

#admin-panel.active {
  display: flex;
}

.admin-card {
  background: #14161E;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: clamp(16px, 3vw, 28px);
  width: 100%;
  max-width: 460px;
  max-height: 92vh;
  overflow-y: auto;
  font-family: 'Inter', sans-serif;
  color: #fff;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.admin-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #EAFF27;
}

.admin-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  padding: 0 8px;
}

.admin-section {
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  padding: 16px 0;
}

.admin-section:first-of-type {
  border-top: none;
  padding-top: 0;
}

.admin-section-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 14px;
}

.admin-pending {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: rgba(234, 255, 39, 0.55);
  font-size: 11px;
}

.admin-row {
  margin-bottom: 14px;
}

.admin-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.88);
}

.admin-value {
  font-weight: 600;
  color: #EAFF27;
  font-variant-numeric: tabular-nums;
}

/* Range slider — track + thumb styled to match the kiosk theme. */
.admin-row input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 28px;
  cursor: pointer;
}

.admin-row input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.18);
}

.admin-row input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.18);
}

.admin-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #EAFF27;
  border: none;
  margin-top: -8px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.admin-row input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #EAFF27;
  border: none;
  cursor: pointer;
}

/* Toggle (checkbox styled as switch). */
.admin-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-toggle-row .admin-label {
  margin-bottom: 0;
}

.admin-toggle {
  -webkit-appearance: none;
  appearance: none;
  width: 50px;
  height: 28px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.15);
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.admin-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}

.admin-toggle:checked {
  background: #EAFF27;
}

.admin-toggle:checked::after {
  transform: translateX(22px);
  background: #14161E;
}

.admin-stat {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: 14px;
}

.admin-btn {
  width: 100%;
  padding: 11px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: background 0.15s ease;
}

.admin-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.admin-btn:active {
  transform: scale(0.98);
}

.admin-btn-danger {
  color: #FF7070;
  border-color: rgba(255, 80, 80, 0.3);
}

.admin-btn-danger:hover {
  background: rgba(255, 80, 80, 0.12);
}

/* ===== CINEMATIC OUTRO ===== */
#outro-overlay {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
  z-index: 12;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55) 0%, rgba(15, 10, 8, 0.92) 100%);
  opacity: 1;
  transition: opacity 0.55s ease;
}

#outro-overlay.active {
  display: block;
}

#outro-overlay.fading-out {
  opacity: 0;
}

.outro-bar {
  position: absolute;
  left: 0;
  right: 0;
  background: #000;
}

.outro-bar-top {
  top: 0;
  height: 14%;
  animation: outroBarIn 0.32s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.outro-bar-bot {
  bottom: 0;
  height: 14%;
  animation: outroBarIn 0.32s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes outroBarIn {
  0% {
    transform: translateY(-100%);
  }

  100% {
    transform: translateY(0);
  }
}

.outro-bar-bot {
  animation-name: outroBarInBot;
}

@keyframes outroBarInBot {
  0% {
    transform: translateY(100%);
  }

  100% {
    transform: translateY(0);
  }
}

.outro-stamp {
  position: absolute;
  top: 22%;
  left: 50%;
  font-family: 'Inter', sans-serif;
  font-size: clamp(56px, 16vw, 144px);
  color: #FFAB40;
  letter-spacing: 8px;
  text-shadow: 0 0 32px rgba(255, 171, 64, 0.85), 6px 6px 0 #000;
  opacity: 0;
  transform: translate(-50%, -50%) scale(3.2);
  animation: outroStamp 0.55s cubic-bezier(0.2, 1, 0.35, 1) 0.18s forwards;
}

@keyframes outroStamp {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(3.2);
    filter: blur(6px);
  }

  60% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.9);
    filter: blur(0);
  }

  82% {
    transform: translate(-50%, -50%) scale(1.06);
  }

  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.outro-label {
  position: absolute;
  top: 48%;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Inter', sans-serif;
  font-size: clamp(13px, 3vw, 22px);
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 6px;
  opacity: 0;
  animation: outroFadeIn 0.45s ease 0.85s forwards;
}

.outro-score {
  position: absolute;
  top: 58%;
  left: 50%;
  transform: translate(-50%, 0);
  font-family: 'Inter', sans-serif;
  font-size: clamp(60px, 19vw, 156px);
  color: #FFFFFF;
  text-shadow: 0 0 36px rgba(255, 255, 255, 0.55), 0 6px 0 rgba(0, 0, 0, 0.6);
  letter-spacing: 4px;
  opacity: 0;
  animation: outroFadeIn 0.4s ease 1.05s forwards;
}

@keyframes outroFadeIn {
  to {
    opacity: 1;
  }
}

.outro-flash {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  opacity: 0;
  animation: outroFlash 0.45s ease-out forwards;
}

@keyframes outroFlash {
  0% {
    opacity: 0;
  }

  20% {
    opacity: 0.85;
  }

  100% {
    opacity: 0;
  }
}

/* Cinematic crossfade — when the result screen appears after the outro,
   its children fade up in a staggered cascade so it never feels like a hard cut. */
#gameover-screen.active>*,
#wellplayed-screen.active>* {
  animation: resultIn 0.55s cubic-bezier(0.2, 0.85, 0.3, 1) both;
}

#gameover-screen.active>*:nth-child(1),
#wellplayed-screen.active>*:nth-child(1) {
  animation-delay: 0.00s;
}

#gameover-screen.active>*:nth-child(2),
#wellplayed-screen.active>*:nth-child(2) {
  animation-delay: 0.10s;
}

#gameover-screen.active>*:nth-child(3),
#wellplayed-screen.active>*:nth-child(3) {
  animation-delay: 0.22s;
}

#gameover-screen.active>*:nth-child(4),
#wellplayed-screen.active>*:nth-child(4) {
  animation-delay: 0.34s;
}

@keyframes resultIn {
  0% {
    opacity: 0;
    transform: translateY(22px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== DESKTOP FRAME =====
   On desktop landscape (>=900px wide), render the game inside a centered
   portrait phone-frame and let users type their name with a real keyboard.
   Tablet (portrait), kiosk (large portrait), and mobile are unaffected. */

@media (orientation: landscape) and (min-width: 900px) {
  body {
    background: radial-gradient(ellipse at center, #1a1a1a 0%, #000 70%);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #app {
    width: min(56vh, 100vw);
    height: min(100vh, 178vh);
    aspect-ratio: 9 / 16;
    max-height: 100vh;
    margin: 0 auto;
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6),
      0 0 0 1px rgba(255, 255, 255, 0.06);
  }

  #game-container {
    border-radius: 28px;
  }

  /* Hide on-screen keyboard and the bottom TAP TO START hint on desktop.
     Desktop users type with a physical keyboard and tap anywhere / press
     Enter to start. */
  #name-screen .keyboard-wrap,
  #name-screen .name-tap-hint,
  #splash-screen .splash-tap-hint {
    display: none !important;
  }

  /* Desktop frame is much smaller than mobile/kiosk — shrink the ENTER NAME
     display so it fits the phone-sized frame. */
  #name-screen .name-display {
    font-size: clamp(18px, 3.2vh, 28px);
    letter-spacing: 2px;
  }

  #name-screen .name-underline {
    width: clamp(140px, 28vh, 240px);
    height: 2px;
  }

  /* Result screens — compact typography for the desktop frame. */
  #gameover-screen .result-card,
  #wellplayed-screen .result-card {
    width: min(82%, 360px);
    padding: clamp(16px, 2.4vh, 26px) clamp(14px, 2.2vh, 22px);
  }

  #gameover-screen .result-title,
  #wellplayed-screen .result-title {
    font-size: clamp(28px, 5.4vh, 44px);
  }

  #gameover-screen .result-sub,
  #wellplayed-screen .result-sub {
    font-size: clamp(11px, 1.7vh, 14px);
    margin-bottom: clamp(12px, 2vh, 18px);
  }

  #gameover-screen .lb-row,
  #wellplayed-screen .lb-row {
    font-size: clamp(11px, 1.7vh, 14px);
    padding: clamp(7px, 1.3vh, 11px) clamp(10px, 1.6vh, 14px);
    border-width: 1.5px;
  }

  #gameover-screen .result-tap-hint,
  #wellplayed-screen .result-tap-hint {
    font-size: clamp(11px, 1.6vh, 14px);
  }
}