@font-face {
  font-family: "Press Start 2P";
  src: url("/fonts/press-start-2p.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0020-007E, U+00B7, U+00D7, U+2013-2014, U+2018-2019, U+201C-201D, U+2026, U+2191, U+2193;
}

@font-face {
  font-family: 'Fredoka';
  src: url('/fonts/fredoka-bold.woff2') format('woff2');
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #05070a;
  --panel: #101721;
  --panel-2: #172232;
  --panel-3: #0a1017;
  --text: #edf7ff;
  --muted: #91a4b5;
  --line: #2a4053;
  /* Borders on interactive controls must reach 3:1 against the surfaces they
     sit on (WCAG 2.2 non-text contrast); --line stays for decorative rules. */
  --control-line: #5b7a96;
  --accent: #46f2a4;
  --accent-2: #ffcf5a;
  --danger: #ff5d73;
  --blue: #56c7ff;
  --mode-arena: #46f2a4;
  --mode-classic: #ffcf5a;
  --mode-rune: #a88cff;
  --focus-ring: #9adfff;
  --radius: 10px;
  --font-arcade: "Press Start 2P", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

/* Make the `hidden` attribute reliable even on elements that set display
   (e.g. .setup / .game-wrap use display:grid, which would otherwise win). */
[hidden] {
  display: none !important;
}

/* Touch-only settings (joystick/arrows, left-handed) are useless with a mouse —
   hide them on desktop/fine-pointer devices. */
@media (pointer: fine) and (hover: hover) {
  .touch-only {
    display: none !important;
  }
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    radial-gradient(circle at 20% 8%, rgba(70, 242, 164, 0.12), transparent 34%),
    radial-gradient(circle at 80% 0%, rgba(255, 93, 115, 0.11), transparent 30%),
    var(--bg);
  background-size: 28px 28px, 28px 28px, auto, auto, auto;
  color: var(--text);
  font-family: var(--font-arcade);
  font-size: 13px;
}

html,
body {
  width: 100%;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--control-line);
  border-radius: 6px;
  background: linear-gradient(180deg, #1c2a3b, #111a25);
  color: var(--text);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

button:hover {
  border-color: var(--accent);
  box-shadow: 0 0 18px rgba(70, 242, 164, 0.14);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  box-shadow: none;
}

button:disabled:hover {
  border-color: var(--line);
  transform: none;
  box-shadow: none;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--control-line);
  border-radius: 6px;
  background: #081018;
  color: var(--text);
  padding: 0 12px;
  text-transform: uppercase;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(86, 199, 255, 0.14);
  outline: 0;
}

.shell {
  width: min(760px, calc(100vw - 32px));
  min-height: 100svh;
  margin: 0 auto;
  padding: 22px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  justify-items: center;
}

.landing {
  width: 100%;
  max-width: 440px;
  justify-self: center;
}

.panel,
.game-wrap {
  border: 1px solid rgba(86, 199, 255, 0.22);
  border-radius: 8px;
  background: rgba(16, 23, 33, 0.92);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.setup {
  padding: 22px;
  display: grid;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.78rem;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 0.96;
}

.lede {
  color: var(--muted);
  line-height: 1.5;
  margin: 12px 0 0;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.auth-panel {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.auth-row,
.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.google-signin {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  max-width: 300px;
  margin: 0 auto;
  overflow: hidden;
}

/* Defensive: never let the Google button (or a fallback render) blow up to fill
   the panel. Caps any stray SVG/IMG and the GSI wrapper to a sane size. */
.google-signin > div,
.google-signin iframe {
  max-width: 100%;
}

.google-signin svg,
.google-signin img {
  max-height: 40px;
  width: auto;
}

/* Account widget pinned to the top-right corner of the screen. */
.auth-corner {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

body.is-playing .auth-corner {
  display: none;
}

.auth-corner .auth-message {
  margin: 0;
  font-size: 0.72rem;
  text-align: right;
  max-width: 220px;
}

.auth-corner .auth-signed-in {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 5px 6px 5px 12px;
  border: 1px solid rgba(86, 199, 255, 0.3);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(22, 32, 46, 0.92), rgba(8, 14, 22, 0.94));
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #e8f2ff;
  font-size: 0.82rem;
  max-width: 60vw;
}

.auth-corner .auth-signed-in span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 130px;
}

.auth-corner .auth-signed-in button {
  min-height: 30px;
  padding: 0 12px;
  font-size: 0.74rem;
  border-radius: 999px;
}

/* "Sign in with Google" button (official logo) — dark, themed, compact. Shown
   when the GSI button can't render (e.g. local dev) and matches the GSI look. */
.google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(86, 199, 255, 0.32);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(22, 32, 46, 0.92), rgba(8, 14, 22, 0.94));
  color: #e8f2ff;
  font-family: "Courier New", monospace;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.4px;
  cursor: pointer;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.google-btn:hover {
  border-color: rgba(86, 199, 255, 0.6);
  box-shadow: 0 0 22px rgba(86, 199, 255, 0.3);
  transform: translateY(-1px);
}

.google-btn:active {
  transform: translateY(0);
}

.google-btn .google-g {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.google-btn .g-text {
  white-space: nowrap;
}

/* On phones the corner sign-in becomes a clean icon-only circle. */
@media (max-width: 620px) {
  .google-btn {
    width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    gap: 0;
    border-radius: 50%;
  }
  .google-btn .g-text {
    display: none;
  }
}

/* Score summary line on the menu. */
.best-line {
  margin: 4px 0 0;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
}

.best-line strong {
  color: var(--accent-2);
}

.auth-hint {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.auth-panel input {
  min-height: 40px;
  text-transform: none;
}

.auth-actions button,
.auth-signed-in button {
  min-height: 40px;
}

.auth-signed-in {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
}

.auth-signed-in[hidden] {
  display: none;
}

.auth-signed-in span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-message {
  min-height: 18px;
  margin: 0;
  color: var(--accent);
  font-size: 0.78rem;
}

.auth-message.error {
  color: var(--danger);
}

.skin-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.skin {
  aspect-ratio: 1;
  min-height: 54px;
  padding: 5px;
}

.skin.active {
  border-color: var(--accent-2);
  background: #24200d;
  box-shadow: 0 0 18px rgba(255, 207, 90, 0.18);
}

.skin span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 3px;
  background: repeating-linear-gradient(90deg, var(--skin-a, #46f2a4) 0 8px, var(--skin-b, #56c7ff) 8px 16px);
}

.setup-settings {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 14px;
  display: grid;
  gap: 12px;
}

.setup-settings > summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  list-style: none;
}

.setup-settings[open] > summary {
  margin-bottom: 2px;
}

.setup-settings select {
  background: rgba(0, 0, 0, 0.35);
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 6px 8px;
}

.toggle {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
}

.toggle input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.status {
  min-height: 22px;
  margin: 0;
  color: var(--accent-2);
}

.game-wrap {
  min-width: 0;
  padding: 14px;
  display: grid;
  gap: 12px;
}

/* In-game rail: stats on the left, the pause control dead centre (the only
   position that is symmetric across the left/right-handed mirror), sound on
   the right. */
.game-rail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.rail-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.rail-stat {
  min-width: 0;
  border: 1px solid var(--control-line);
  border-radius: 6px;
  padding: 6px 8px;
  background: rgba(8, 16, 24, 0.9);
}

.rail-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.58rem;
  text-transform: uppercase;
}

.rail-stat strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
}

.rail-btn {
  width: 52px;
  min-height: 52px;
  padding: 0;
  border: 1px solid var(--control-line);
  border-radius: 8px;
  background: rgba(8, 16, 24, 0.9);
  font-size: 0.72rem;
}

.pause-btn {
  justify-self: center;
  color: var(--accent-2);
  border-color: rgba(255, 207, 90, 0.65);
  letter-spacing: 0;
}

.pause-btn:hover {
  border-color: var(--accent-2);
  box-shadow: 0 0 18px rgba(255, 207, 90, 0.22);
}

.icon-button {
  justify-self: end;
}

/* The board stage is the flex middle of the shell: the canvas is sized by JS
   from THIS box (viewport-driven), never from whatever the HUD left over. */
.board-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
}

/* The single overlay slot: pause / result, mutually exclusive. */
.overlay-slot {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(3, 6, 9, 0.72);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.overlay-slot[hidden] {
  display: none;
}

.overlay-card {
  width: min(420px, 100%);
  max-height: 100%;
  overflow-y: auto;
  display: grid;
  gap: 14px;
  justify-items: center;
  padding: clamp(16px, 4vw, 26px);
  border: 1px solid var(--control-line);
  border-radius: 14px;
  background: rgba(16, 23, 33, 0.96);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  text-align: center;
}

.overlay-card h2 {
  margin: 0;
  font-size: clamp(1.1rem, 5vw, 1.6rem);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.overlay-card .mode-tag {
  margin: 0;
  color: var(--muted);
  font-size: 0.62rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.overlay-card .mode-tag strong {
  color: var(--text);
}

.result-score {
  display: grid;
  gap: 4px;
}

.result-score span {
  color: var(--muted);
  font-size: 0.62rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.result-score strong {
  color: var(--accent);
  font-size: clamp(1.6rem, 8vw, 2.4rem);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-shadow: 0 0 18px rgba(70, 242, 164, 0.5);
}

.result-best {
  min-height: 1.2em;
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
}

.result-best.record {
  padding: 3px 11px;
  border: 1px solid rgba(255, 207, 90, 0.6);
  border-radius: 999px;
  background: rgba(255, 207, 90, 0.14);
  color: #ffe08a;
  text-transform: uppercase;
}

.overlay-actions {
  width: 100%;
  display: grid;
  gap: 10px;
}

.overlay-actions button {
  min-height: 48px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.overlay-actions .primary-action {
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  color: #03210f;
}

.danger-btn,
.overlay-actions .danger-btn {
  border-color: rgba(255, 93, 115, 0.65);
  color: #ff9fb0;
}

.danger-btn.confirming,
.overlay-actions .danger-btn.confirming {
  background: rgba(255, 93, 115, 0.22);
  border-color: var(--danger);
  color: #ffdce3;
}

.overlay-notice {
  min-height: 1.2em;
  margin: 0;
  color: var(--muted);
  font-size: 0.62rem;
}

canvas {
  width: min(100%, 768px);
  justify-self: center;
  max-height: min(72vh, 820px);
  aspect-ratio: 1;
  display: block;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #030609;
  image-rendering: pixelated;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

body.is-playing {
  overflow: hidden;
  touch-action: none;
}

body.is-playing .shell {
  width: 100vw;
  max-width: none;
  height: 100svh;
  min-height: 100svh;
  margin: 0;
  padding: clamp(8px, 1.2vmin, 16px);
  grid-template-columns: 1fr;
  align-items: stretch;
}

@supports (height: 100dvh) {
  body.is-playing .shell {
    height: 100dvh;
    min-height: 100dvh;
  }
}

body.is-playing .setup {
  display: none;
}

body.is-playing .game-wrap {
  min-height: 0;
  height: 100%;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: stretch;
}

body.is-playing #board {
  max-width: 100%;
  max-height: none;
  align-self: center;
}

canvas.level-flash {
  animation: canvasFlash 800ms ease;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto 150px;
  gap: 10px;
  align-items: center;
}

.scoreboard {
  min-height: 70px;
  display: grid;
  gap: 6px;
  align-content: start;
}

.score {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 3px 6px;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.score.changed {
  animation: scorePulse 520ms ease;
}

.score.dead strong {
  text-decoration: line-through;
}

.score strong {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swatch {
  width: 16px;
  height: 16px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 4px;
  background: linear-gradient(135deg, var(--skin-a, #46f2a4), var(--skin-b, #56c7ff));
}

.badge {
  border: 1px solid rgba(255, 93, 115, 0.55);
  border-radius: 999px;
  color: var(--danger);
  padding: 1px 6px;
  font-size: 0.72rem;
}

.pad {
  display: none;
}

#restartBtn {
  justify-self: end;
  width: min(150px, 100%);
}

@keyframes scorePulse {
  0% {
    background: rgba(255, 207, 90, 0);
    border-color: transparent;
  }
  30% {
    background: rgba(255, 207, 90, 0.25);
    border-color: rgba(255, 207, 90, 0.7);
  }
  100% {
    background: rgba(255, 207, 90, 0);
    border-color: transparent;
  }
}

@keyframes canvasFlash {
  0%, 100% {
    border-color: var(--line);
    box-shadow: none;
  }
  35% {
    border-color: var(--level-accent, var(--accent-2));
    box-shadow: 0 0 30px color-mix(in srgb, var(--level-accent, var(--accent-2)) 35%, transparent);
  }
}

@media (hover: none), (pointer: coarse) {
  .pad {
    justify-self: center;
    width: 204px;
    display: grid;
    grid-template-columns: repeat(3, 64px);
    grid-template-rows: repeat(3, 64px);
    gap: 6px;
  }

  .pad button {
    width: 64px;
    min-height: 64px;
    border-radius: 999px;
    font-size: 1.35rem;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
  }

  .pad [data-dir="up"] {
    grid-column: 2;
    grid-row: 1;
  }

  .pad [data-dir="left"] {
    grid-column: 1;
    grid-row: 2;
  }

  .pad [data-dir="down"] {
    grid-column: 2;
    grid-row: 3;
  }

  .pad [data-dir="right"] {
    grid-column: 3;
    grid-row: 2;
  }
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .pad,
  #restartBtn {
    justify-self: center;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100vw - 18px, 1240px);
    padding: 10px 0;
  }

  .setup,
  .game-wrap {
    padding: 10px;
  }

  /* Declutter the start screen on phones so the play button is front and centre. */
  .setup { gap: 10px; }
  .setup .lede { display: none; }
  .setup .eyebrow { display: none; }

  .game-rail {
    gap: 6px;
  }

  .rail-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  /* Level + Best stay visible; Mode/Status remain in the DOM (tests and
     screen readers) but leave the narrow rail to the two live numbers. */
  .rail-stat:first-child,
  .rail-stat:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }

  .rail-btn {
    width: 48px;
    min-height: 48px;
  }

  /* Squeeze the horizontal chrome in play so the 32-cell board gets the
     width: 360px phone -> 360 - 8 (shell) - 12 (wrap) - 2 (border) = 338px,
     ~10.5px per cell (UX-01). */
  body.is-playing .shell {
    padding: 4px;
  }

  body.is-playing .game-wrap {
    padding: 6px;
    gap: 6px;
  }

  body.is-playing .scoreboard {
    min-height: 0;
  }

  .skin-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Landscape phones: height is the scarce resource, so the controls move into a
   column beside the board instead of competing with it for vertical space.
   Everything stays on screen — no scrolling (body.is-playing hides overflow). */
@media (orientation: landscape) and (max-height: 560px) {
  body.is-playing .shell {
    padding: 6px;
  }

  body.is-playing .game-wrap {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 6px 10px;
    padding: 8px;
  }

  body.is-playing .game-rail {
    grid-column: 1 / -1;
  }

  body.is-playing .rail-stat {
    padding: 3px 7px;
  }

  body.is-playing .rail-btn {
    width: 44px;
    min-height: 44px;
  }

  body.is-playing .board-stage {
    grid-column: 1;
    grid-row: 2;
  }

  body.is-playing .controls {
    grid-column: 2;
    grid-row: 2;
    grid-template-columns: 1fr;
    gap: 6px;
    align-content: center;
    justify-items: center;
  }

  body.is-playing .scoreboard {
    min-height: 0;
  }

  body.is-playing .classic-actions {
    justify-items: center;
  }

  body.is-playing .classic-actions #restartBtn {
    min-height: 44px;
  }
}

@media (max-width: 760px) {
  body.is-playing canvas {
    max-height: none;
  }
}

/* ===================== Clean landing + Single Player setup ===================== */

.brand {
  text-align: center;
}

.brand h1 {
  font-size: clamp(1.6rem, 7vw, 2.6rem);
  line-height: 1.04;
  letter-spacing: 1px;
}

.brand .lede {
  margin: 10px 0 0;
}

/* Primary Single Player button. */
.mode-actions {
  display: grid;
  gap: 12px;
}

.mode-cta {
  width: 100%;
  min-height: 62px;
  padding: 16px;
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 1px;
  border: none;
  border-radius: 14px;
  color: #03210f;
  background: linear-gradient(135deg, #46f2a4, #56c7ff);
  box-shadow: 0 0 24px rgba(70, 242, 164, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.mode-cta:hover {
  transform: translateY(-1px);
  border-color: transparent;
  box-shadow: 0 0 32px rgba(86, 199, 255, 0.5);
}

.mode-cta.primary {
  margin-top: 4px;
}

/* Single Player setup step. */
.sp-setup {
  padding: 22px;
  display: grid;
  gap: 14px;
  position: relative;
  width: 100%;
  max-width: 440px;
  justify-self: center;
}

/* On desktop the setup is a roomy two-column card instead of a phone strip. */
@media (min-width: 760px) {
  .sp-setup {
    max-width: 720px;
    grid-template-columns: 1fr 1fr;
    column-gap: 28px;
    row-gap: 16px;
    align-items: start;
  }
  .sp-back,
  .sp-title,
  .sp-preview,
  .sp-setup #spPlayBtn,
  .sp-setup .status {
    grid-column: 1 / -1;
  }
  .sp-preview {
    padding: 16px;
  }
  .sp-setup #headPreview {
    width: 300px;
    height: 170px;
  }
}

.sp-setup[hidden] {
  display: none;
}

.sp-back {
  justify-self: start;
  min-height: 36px;
  padding: 6px 14px;
  font-size: 0.9rem;
  background: rgba(8, 16, 24, 0.7);
}

.sp-title {
  margin: 0;
  font-size: clamp(1.3rem, 5vw, 1.8rem);
  letter-spacing: 1px;
}

.sp-preview {
  display: flex;
  justify-content: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: radial-gradient(circle at 50% 38%, rgba(86, 199, 255, 0.1), rgba(3, 6, 9, 0.55));
}

#headPreview {
  width: 240px;
  height: 160px;
  max-width: 100%;
  image-rendering: auto;
  border: 0;
  background: transparent;
}

.field > span {
  font-size: 0.82rem;
  color: var(--muted);
}

/* Head picker shows a small canvas preview per shape. */
.arena-head-choice {
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 6px 4px 4px;
  min-height: auto;
}

.arena-head-choice canvas {
  display: block;
  width: 100%;
  height: 40px;
}

.arena-head-choice .head-label {
  font-size: 11px;
}

/* Hide the landing + setup panels while a game is running. */
body.is-playing .landing,
body.is-playing .sp-setup {
  display: none;
}

/* ===================== Approved three-mode landing ===================== */

body {
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

/* Two-tone focus ring: a dark core ring plus a light halo, so a visible 3:1
   boundary exists on BOTH light accent buttons and dark panels (the old single
   #9adfff ring measured ~1:1 on the accent-green Play button). */
:focus-visible {
  outline: 3px solid #04080c;
  outline-offset: 1px;
  box-shadow: 0 0 0 4px var(--focus-ring), 0 0 14px rgba(154, 223, 255, 0.55);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -52px;
  left: 12px;
  z-index: 200;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  text-decoration: none;
  transition: top 120ms ease;
}

.skip-link:focus-visible {
  top: 12px;
}

.page {
  width: min(1120px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 14px 0 40px;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 18px;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 700;
  letter-spacing: 1px;
  font-size: 1.05rem;
  text-transform: uppercase;
}

.site-brand svg {
  flex: 0 0 auto;
}

.topbar .auth-corner {
  position: static;
  z-index: auto;
  align-items: flex-end;
  flex: 0 0 auto;
}

.topbar .auth-message {
  max-width: 240px;
  min-height: 0;
}

.topbar .auth-message:empty {
  display: none;
}

.signin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(86, 199, 255, 0.32);
  background: linear-gradient(180deg, rgba(22, 32, 46, 0.92), rgba(8, 14, 22, 0.94));
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 700;
}

.signin:hover {
  border-color: rgba(86, 199, 255, 0.6);
  box-shadow: 0 0 22px rgba(86, 199, 255, 0.3);
}

.shell {
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 26px;
  align-items: start;
  justify-items: stretch;
}

.mode-select {
  min-width: 0;
}

.section-label {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.modes {
  display: grid;
  gap: 14px;
}

button.mode-card {
  --mode-c: var(--mode-arena);
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  text-align: left;
}

button.mode-card:hover,
button.mode-card:active {
  border: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
}

.mode-card .card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 112px;
  padding: 16px 18px;
  border: 1px solid var(--control-line);
  border-radius: var(--radius);
  background: rgba(16, 23, 33, 0.92);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, background 160ms ease;
}

.mode-card:hover .card {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--mode-c) 65%, transparent);
  box-shadow: 0 0 24px color-mix(in srgb, var(--mode-c) 18%, transparent);
}

.mode-card:focus-visible {
  outline: 0;
  box-shadow: none;
}

.mode-card:focus-visible .card {
  outline: 3px solid #04080c;
  outline-offset: 1px;
  box-shadow: 0 0 0 4px var(--focus-ring), 0 0 14px rgba(154, 223, 255, 0.55);
}

.mode-card.selected .card {
  border-color: var(--mode-c);
  background: linear-gradient(135deg, color-mix(in srgb, var(--mode-c) 12%, var(--panel)), var(--panel));
  box-shadow: 0 0 26px color-mix(in srgb, var(--mode-c) 26%, transparent),
              inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.mode-card .tile {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--mode-c) 45%, transparent);
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--mode-c) 20%, transparent), rgba(3, 6, 9, 0.6));
}

.mode-copy {
  display: block;
  min-width: 0;
}

.mode-name {
  display: block;
  color: var(--text);
  font-size: clamp(1.15rem, 2.4vw, 1.5rem);
  font-weight: 700;
  letter-spacing: 1px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.chips > span {
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.68rem;
  letter-spacing: 1px;
  line-height: 1.35;
  text-transform: uppercase;
}

.mode-score {
  display: block;
  min-height: 1.35em;
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.mode-score strong {
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
}

.mode-card .go {
  color: color-mix(in srgb, var(--mode-c) 80%, var(--text));
  font-size: 1.3rem;
  transition: transform 160ms ease;
}

.mode-card:hover .go,
.mode-card.selected .go {
  transform: translateX(3px);
}

.mode-arena {
  --mode-c: var(--mode-arena) !important;
}

.mode-classic {
  --mode-c: var(--mode-classic) !important;
}

.mode-rune {
  --mode-c: var(--mode-rune) !important;
}

.sp-setup.setup-panel {
  width: 100%;
  max-width: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  padding: 22px;
  border-radius: var(--radius);
}

.sp-setup.setup-panel > * {
  grid-column: 1;
}

.sp-setup.setup-panel .sp-title {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.sp-setup.setup-panel .sp-preview {
  min-height: 120px;
  padding: 0;
  border-radius: var(--radius);
  background: radial-gradient(circle at 50% 38%, rgba(86, 199, 255, 0.1), rgba(3, 6, 9, 0.55));
}

.sp-setup.setup-panel #headPreview {
  width: min(100%, 240px);
  height: 120px;
}

.choice-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field > span,
.choice-field legend {
  padding: 0;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.sp-setup .skin-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.sp-setup .skin {
  min-height: 48px;
  padding: 4px;
  border-radius: 8px;
}

.sp-setup .arena-head-picker {
  grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
  margin: 0;
}

.sp-setup .arena-head-choice {
  min-height: 58px;
  border-radius: 8px;
  background: rgba(3, 6, 9, 0.48);
}

.sp-setup .arena-head-choice.active {
  border-color: var(--accent);
  background: rgba(70, 242, 164, 0.12);
}

.sp-setup .setup-settings select {
  min-height: 44px;
}

.sp-setup .toggle {
  min-height: 44px;
  cursor: pointer;
}

.sp-setup .toggle input {
  width: 24px;
  min-height: 24px;
}

.sp-setup .mode-cta {
  min-height: 58px;
  margin-top: 0;
  border: 0;
  border-radius: 12px;
  color: #03210f;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  box-shadow: 0 0 24px rgba(70, 242, 164, 0.3);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.hint kbd {
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-3);
  color: var(--text);
  font: inherit;
}

.classic-actions {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.score-notice {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  text-align: right;
}

.classic-actions #restartBtn {
  width: min(150px, 100%);
}

body.is-playing .page {
  width: 100%;
  height: 100%;
  padding: 0;
}

body.is-playing .topbar,
body.is-playing .mode-select,
body.is-playing .setup-panel {
  display: none;
}

@media (min-width: 900px) {
  .shell {
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: 34px;
  }

  .mode-select {
    margin-top: 6px;
  }
}

@media (max-width: 620px) {
  .page {
    width: min(100vw - 18px, 1120px);
    padding-top: 8px;
  }

  .shell {
    width: 100%;
    padding: 0;
  }

  .sp-setup.setup-panel {
    padding: 16px;
  }
}

@media (max-width: 560px) {
  .signin {
    width: 44px;
    min-width: 44px;
    padding: 0;
    border-radius: 50%;
  }

  .signin .signin-text {
    display: none;
  }

  .site-brand {
    font-size: 0.92rem;
  }
}

@media (max-width: 380px) {
  .mode-card .card {
    grid-template-columns: 52px minmax(0, 1fr) auto;
    gap: 11px;
    min-height: 102px;
    padding: 13px 12px;
  }

  .mode-card .tile {
    width: 52px;
    height: 52px;
  }

  .chips {
    gap: 4px;
  }

  .chips > span {
    padding-inline: 6px;
    font-size: 0.61rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Compact Landscape Arena Menu (Single-Screen Mobile & Desktop)
   ========================================================================== */
.arena-menu-grid {
  display: grid;
  grid-template-columns: 200px 1fr 210px;
  gap: 16px;
  align-items: center;
  width: 100%;
}

.online-tag {
  display: inline-block;
  font-size: 0.6rem;
  letter-spacing: 1px;
  font-weight: 700;
  padding: 2px 7px;
  margin-left: 10px;
  background: rgba(70, 242, 164, 0.12);
  color: #46f2a4;
  border: 1px solid rgba(70, 242, 164, 0.35);
  border-radius: 4px;
}

.sp-setup.setup-panel {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 18px;
  background: rgba(6, 12, 20, 0.88);
  border: 1px solid rgba(86, 199, 255, 0.22);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.65);
}

.sp-setup.setup-panel .sp-preview {
  min-height: 80px;
  height: 85px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 50%, rgba(86, 199, 255, 0.12), rgba(3, 6, 9, 0.7));
  border-radius: 8px;
  margin-bottom: 8px;
}

.sp-setup.setup-panel #headPreview {
  width: 100%;
  height: 85px;
}

.player-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.compact-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.compact-field span,
.compact-choice legend {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

.compact-field input {
  font-size: 0.82rem;
  padding: 6px 10px;
  min-height: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(3, 6, 9, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #edf7ff;
}

.compact-field input:focus {
  border-color: #46f2a4;
  outline: none;
  box-shadow: 0 0 8px rgba(70, 242, 164, 0.3);
}

.sp-setup .skin-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin-top: 4px;
}

.sp-setup .skin {
  min-height: 30px;
  height: 30px;
  padding: 2px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.sp-setup .skin.active {
  border-color: #ffffff;
  transform: scale(1.08);
}

.sp-setup .arena-head-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  margin-top: 4px;
}

.sp-setup .arena-head-choice {
  min-height: 36px;
  height: 36px;
  padding: 2px;
  border-radius: 6px;
  background: rgba(3, 6, 9, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
}

.sp-setup .arena-head-choice.active {
  border-color: #46f2a4;
  background: rgba(70, 242, 164, 0.15);
}

.compact-settings {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  background: rgba(3, 6, 9, 0.45);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.compact-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--muted);
}

.compact-setting span {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.compact-setting select,
.compact-setting input[type="range"] {
  flex: 1;
  max-width: 120px;
  min-height: 28px;
  height: 28px;
  font-size: 0.74rem;
  border-radius: 5px;
  background: rgba(3, 6, 9, 0.7);
  color: #edf7ff;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.compact-toggles {
  display: flex;
  justify-content: space-around;
  gap: 8px;
}

.toggle-sm {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  color: var(--muted);
  cursor: pointer;
}

.toggle-sm input {
  width: 17px;
  height: 17px;
  accent-color: #46f2a4;
}

.play-btn-glow {
  width: 100%;
  min-height: 52px;
  height: 52px;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 1.2px;
  border-radius: 10px;
  background: linear-gradient(135deg, #46f2a4 0%, #38bdf8 100%);
  color: #03150d;
  box-shadow: 0 0 20px rgba(70, 242, 164, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.play-btn-glow:active {
  transform: scale(0.97);
  box-shadow: 0 0 10px rgba(70, 242, 164, 0.6);
}

/* Landscape Mobile specific fit */
@media (orientation: landscape), (max-height: 540px) {
  html, body {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
  }
  .page {
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    padding: 4px 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .topbar {
    padding: 2px 10px;
    min-height: 32px;
  }
  .site-brand svg {
    width: 20px;
    height: 20px;
  }
  .site-brand span {
    font-size: 0.85rem;
  }
  .shell {
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
    padding: 0;
  }
  .sp-setup.setup-panel {
    padding: 8px 14px;
    max-height: calc(100vh - 42px);
  }
  .arena-menu-grid {
    grid-template-columns: 180px 1fr 190px;
    gap: 12px;
  }
  .sp-setup.setup-panel .sp-preview,
  .sp-setup.setup-panel #headPreview {
    height: 72px;
    min-height: 72px;
  }
  .sp-setup .skin {
    min-height: 26px;
    height: 26px;
  }
  .sp-setup .arena-head-choice {
    min-height: 32px;
    height: 32px;
  }
  .play-btn-glow {
    min-height: 46px;
    height: 46px;
    font-size: 0.88rem;
  }
}

/* ==========================================================================
   CARTOON MOBILE UI KIT (Inspired by user design image)
   ========================================================================== */

/* The main capsule / tablet container */
.cartoon-frame {
  position: relative;
  background: linear-gradient(180deg, #60a8fa 0%, #3d86ea 30%, #2552ba 70%, #152467 100%) !important;
  border: 4px solid #0f162e !important;
  border-radius: 28px !important;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.65), inset 0 2px 2px rgba(255, 255, 255, 0.45) !important;
  overflow: visible;
}

/* Side grip handles on left and right */
.cartoon-frame::before,
.cartoon-frame::after {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 9px;
  height: 64px;
  background: #0f162e;
  border-radius: 5px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
  z-index: 10;
}
.cartoon-frame::before {
  left: -13px;
}
.cartoon-frame::after {
  right: -13px;
}

/* Bottom banner with dark navy background and bold title */
.cartoon-bottom-bar {
  background: #141b34;
  border-top: 3.5px solid #0f162e;
  border-radius: 0 0 24px 24px;
  margin: 8px -14px -14px -14px;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cartoon-bottom-title {
  color: #ffffff;
  font-family: var(--font-arcade, monospace);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1px;
  text-shadow: 0 2px 0 #080c1a;
}

/* Metallic silver plate buttons with 4 corner rivets */
.cartoon-btn,
.play-btn-glow {
  position: relative;
  background: linear-gradient(180deg, #ffffff 0%, #edf2f9 45%, #c8d3e4 100%) !important;
  border: 3.5px solid #0f162e !important;
  border-radius: 12px !important;
  color: #0f162e !important;
  font-family: system-ui, -apple-system, sans-serif !important;
  font-weight: 900 !important;
  font-size: 14px !important;
  letter-spacing: 0.5px !important;
  text-align: center;
  padding: 8px 14px;
  box-shadow: 0 5px 0 #0f162e, 0 8px 14px rgba(0, 0, 0, 0.35) !important;
  cursor: pointer;
  user-select: none;
  transition: transform 0.08s ease, box-shadow 0.08s ease !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

/* Corner rivets (dots) */
.cartoon-btn::before,
.play-btn-glow::before {
  content: "";
  position: absolute;
  inset: 2px;
  pointer-events: none;
  background-image:
    radial-gradient(circle 2px at 3px 3px, #586980 100%, transparent 100%),
    radial-gradient(circle 2px at calc(100% - 3px) 3px, #586980 100%, transparent 100%),
    radial-gradient(circle 2px at 3px calc(100% - 3px), #586980 100%, transparent 100%),
    radial-gradient(circle 2px at calc(100% - 3px) calc(100% - 3px), #586980 100%, transparent 100%);
}

.cartoon-btn:hover,
.play-btn-glow:hover {
  background: linear-gradient(180deg, #ffffff 0%, #f4f8fd 45%, #d4e0ee 100%) !important;
  transform: translateY(-1px);
  box-shadow: 0 6px 0 #0f162e, 0 10px 16px rgba(0, 0, 0, 0.4) !important;
}

.cartoon-btn:active,
.play-btn-glow:active {
  transform: translateY(4px) !important;
  box-shadow: 0 1px 0 #0f162e, 0 2px 4px rgba(0, 0, 0, 0.25) !important;
}

.cartoon-btn.danger {
  background: linear-gradient(180deg, #ff8c9b 0%, #ff5d73 45%, #c92f44 100%) !important;
  color: #ffffff !important;
}

.cartoon-btn.btn-sm {
  padding: 5px 10px;
  font-size: 11px !important;
  box-shadow: 0 3px 0 #0f162e !important;
}
.cartoon-btn.btn-sm:active {
  transform: translateY(2px) !important;
  box-shadow: 0 1px 0 #0f162e !important;
}

/* Square icon button with 4 rivets */
.cartoon-square-btn {
  position: relative;
  width: 32px;
  height: 32px;
  background: linear-gradient(180deg, #ffffff 0%, #edf2f9 45%, #c8d3e4 100%);
  border: 2.5px solid #0f162e;
  border-radius: 8px;
  color: #0f162e;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 0 #0f162e, 0 5px 8px rgba(0,0,0,0.3);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.cartoon-square-btn::before {
  content: "";
  position: absolute;
  inset: 2px;
  pointer-events: none;
  background-image:
    radial-gradient(circle 1.5px at 2px 2px, #586980 100%, transparent 100%),
    radial-gradient(circle 1.5px at calc(100% - 2px) 2px, #586980 100%, transparent 100%),
    radial-gradient(circle 1.5px at 2px calc(100% - 2px), #586980 100%, transparent 100%),
    radial-gradient(circle 1.5px at calc(100% - 2px) calc(100% - 2px), #586980 100%, transparent 100%);
}
.cartoon-square-btn:hover {
  background: linear-gradient(180deg, #ffffff 0%, #f4f8fd 45%, #d4e0ee 100%);
}
.cartoon-square-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #0f162e;
}

/* Resource Capsule / Pill */
.cartoon-pill {
  display: inline-flex;
  align-items: center;
  background: linear-gradient(180deg, #4f9bf5, #2352b8);
  border: 2.5px solid #0f162e;
  border-radius: 20px;
  padding: 2px 4px 2px 2px;
  box-shadow: 0 3px 0 #0f162e;
}

.cartoon-pill-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #0f162e;
  background: #141b34;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  color: #ffd700;
}

.cartoon-pill-slot {
  background: #0f162e;
  border-radius: 10px;
  padding: 1px 8px;
  margin: 0 4px;
  color: #ffd700;
  font-family: monospace;
  font-size: 12px;
  font-weight: bold;
}

.cartoon-pill-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid #0f162e;
  background: #ffd700;
  color: #0f162e;
  font-weight: 900;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.08s ease;
}
.cartoon-pill-btn:hover {
  transform: scale(1.1);
}
.cartoon-pill-btn:active {
  transform: scale(0.92);
}

/* Admin Modal */
.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(3, 6, 12, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.admin-card {
  width: 100%;
  max-width: 460px;
  padding: 16px !important;
  color: #ffffff;
}
.admin-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid rgba(255,255,255,0.18);
  padding-bottom: 8px;
  margin-bottom: 12px;
}
.admin-modal-title {
  font-family: var(--font-arcade, monospace);
  font-size: 13px;
  color: #ffffff;
  text-shadow: 0 2px 0 #0f162e;
}
.admin-close-btn {
  background: #0f162e;
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.admin-section {
  background: rgba(15, 22, 46, 0.88);
  border: 2px solid #0f162e;
  border-radius: 12px;
  padding: 10px 12px;
}
.admin-section h4 {
  margin: 0 0 6px 0;
  font-size: 12px;
  color: #ffd700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.admin-current-balance {
  font-size: 12px;
  margin-bottom: 8px;
}
.admin-quick-recharges {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.admin-custom-row {
  display: flex;
  gap: 6px;
}
.admin-custom-row input {
  flex: 1;
  background: #070a16;
  border: 2px solid #233458;
  border-radius: 8px;
  color: #ffd700;
  font-family: monospace;
  padding: 4px 8px;
  font-size: 13px;
}
.admin-royale-info {
  font-size: 11px;
  line-height: 1.5;
  color: #cbd5e1;
  margin-bottom: 8px;
}
.admin-royale-info strong {
  color: #ffffff;
}
.admin-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* ==========================================================================
   USER TEMPLATE STYLES (Fredoka One Cartoon UI)
   ========================================================================== */
:root {
  --blue-gradient-top: #74bdf7;
  --blue-gradient-bottom: #4e65d6;
  --dark-border: #1a1c2e;
  --dark-panel: #2a2d46;
  --white-btn-top: #ffffff;
  --white-btn-bottom: #dbe2ef;
  --gold-coin: #ffd700;
  --gold-coin-border: #ccaa00;
}

body {
  font-family: 'Fredoka One', cursive, system-ui, sans-serif !important;
  background: radial-gradient(circle at center, #3b3a56 0%, #171625 100%) !important;
  color: var(--dark-border);
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

body.is-playing {
  display: block !important;
  background: #05070a !important;
}

body.is-playing .game-container {
  display: none !important;
}

.game-container {
  width: 100%;
  height: 100%;
  max-width: 1200px;
  max-height: 675px;
  position: relative;
  padding: 20px 30px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  z-index: 10;
}

.blue-panel {
  background: linear-gradient(to bottom, var(--blue-gradient-top), var(--blue-gradient-bottom));
  border: 4px solid var(--dark-border);
  border-radius: 16px;
  box-shadow: 0 8px 0 var(--dark-border), 
              inset 0 -4px 0 rgba(0,0,0,0.2), 
              inset 0 4px 0 rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  padding: 10px 15px;
  gap: 15px;
}

.profile-avatar {
  width: 50px;
  height: 50px;
  background-color: #c4c4c4;
  border: 3px solid var(--dark-border);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.5rem;
  color: #888;
  overflow: hidden;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.2);
}

.profile-name-input {
  background-color: var(--dark-panel);
  border: 3px solid var(--dark-border);
  border-radius: 20px;
  color: white;
  font-family: 'Fredoka One', cursive, sans-serif;
  font-size: clamp(0.9rem, 2vw, 1.2rem);
  padding: 6px 12px;
  width: 140px;
  outline: none;
  box-shadow: inset 0 3px 0 rgba(0,0,0,0.4), 0 2px 0 rgba(255,255,255,0.2);
  text-align: center;
  text-transform: uppercase;
  transition: border-color 0.2s, transform 0.2s;
}

.profile-name-input:focus {
  border-color: var(--gold-coin);
  transform: scale(1.02);
}

.currency-icon {
  width: 45px;
  height: 45px;
  background: linear-gradient(to bottom, var(--gold-coin), var(--gold-coin-border));
  border: 3px solid var(--dark-border);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.5rem;
  color: white;
  text-shadow: 2px 2px 0 var(--dark-border);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.2);
}

.currency-amount {
  color: white;
  font-size: clamp(1.2rem, 2.5vw, 1.5rem);
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 var(--dark-border),
               -1px -1px 0 var(--dark-border), 
               1px -1px 0 var(--dark-border), 
               -1px 1px 0 var(--dark-border), 
               1px 1px 0 var(--dark-border);
}

.btn-white {
  background: linear-gradient(to bottom, var(--white-btn-top), var(--white-btn-bottom)) !important;
  border: 4px solid var(--dark-border) !important;
  border-radius: 14px !important;
  box-shadow: 0 8px 0 var(--dark-border) !important;
  position: relative;
  cursor: pointer;
  font-family: 'Fredoka One', cursive, sans-serif !important;
  color: var(--dark-border) !important;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.1s ease, box-shadow 0.1s ease !important;
  text-transform: uppercase;
}

.btn-white:hover {
  transform: scale(1.03);
}

.btn-white:active {
  transform: scale(1) translateY(8px) !important;
  box-shadow: 0 0 0 var(--dark-border) !important;
}

.rivet {
  position: absolute;
  width: 6px;
  height: 6px;
  background-color: var(--dark-border);
  border-radius: 50%;
  box-shadow: inset -1px -1px 0 rgba(255,255,255,0.5);
}
.rivet.top-left { top: 6px; left: 6px; }
.rivet.top-right { top: 6px; right: 6px; }
.rivet.bottom-left { bottom: 6px; left: 6px; }
.rivet.bottom-right { bottom: 6px; right: 6px; }

.btn-add {
  width: 40px;
  height: 40px;
  font-size: 1.5rem;
  padding: 0;
  border-radius: 10px !important;
  box-shadow: 0 5px 0 var(--dark-border) !important;
}
.btn-add:active {
  transform: scale(1) translateY(5px) !important;
}

.center-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-grow: 1;
  z-index: 5;
}

.stats-panel {
  background-color: var(--dark-panel);
  border: 4px solid var(--dark-border);
  border-radius: 16px;
  padding: 15px 30px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: inset 0 5px 0 rgba(0,0,0,0.4), 
              0 4px 0 rgba(0,0,0,0.2);
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 15px;
  color: #8da2cc;
  font-size: clamp(1rem, 2vw, 1.2rem);
  letter-spacing: 0.5px;
}

.stat-row i {
  color: white;
  font-size: 1.3em;
  width: 30px;
  text-align: center;
}

.stat-highlight {
  color: white;
  margin-left: auto;
  padding-left: 15px;
}

.btn-massive {
  padding: 20px 50px;
  font-size: clamp(1.4rem, 3.5vw, 2rem) !important;
  border-radius: 20px !important;
  letter-spacing: 2px;
  gap: 15px;
}

.top-right-group {
  display: flex;
  gap: 15px;
  align-items: center;
}

.btn-settings {
  width: 65px;
  height: 65px;
  font-size: 2rem;
  border-radius: 15px !important;
}

@media (max-width: 768px) {
  .game-container { padding: 15px; }
  .blue-panel { padding: 8px 12px; gap: 10px; }
  .profile-avatar { width: 40px; height: 40px; }
  .profile-name-input { width: 110px; font-size: 0.9rem; padding: 4px 8px; }
  .currency-icon { width: 35px; height: 35px; font-size: 1.2rem; }
  .btn-add { width: 35px; height: 35px; font-size: 1.2rem; }
  .stats-panel { padding: 12px 20px; }
  .top-right-group { gap: 10px; }
  .btn-settings { width: 50px; height: 50px; font-size: 1.5rem; }
}

