/* Numrix - Game Styles
 * Uses original PNG assets (ns0.png-ns9.png, headbox.png, bback-*.jpg, etc.)
 */

:root {
  --board-bg: #000000;
  --board-border: #eaea00;
  --combo-border: #eaea00;
  --perfect-border: #00c000;
  --combo-bg: rgba(40, 40, 0, 0.5);
  --wall-color: #c80000;
  --lock-color: #eaea00;

  --cell-size: min(17.5vw, 76px);
  --cell-gap: 0px;
  --board-padding: 3px;

  --header-bg: transparent;
  --header-text: #eaea00;

  --btn-done-fill: #006000;
  --btn-done-stroke: #40c040;
  --btn-undo-fill: #000060;
  --btn-undo-stroke: #4040c0;
  --btn-menu-fill: #600000;
  --btn-menu-stroke: #c04040;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: #000;
  color: #fff;
  font-family: "Marker Felt", "MarkerFelt-Thin", -apple-system, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: none; /* prevent scrolling while dragging cells */
}

.numrix {
  position: relative;
  width: 100%;
  max-width: 390px;
  height: 100dvh;
  max-height: 725px;
  display: flex;
  flex-direction: column;
  padding: 6px 8px;
  gap: 8px;
  overflow: hidden;
}

/* ── Headbox ───────────────────────────────────────────────── */

.headbox {
  background: transparent;
  padding: 4px 4px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 52px;
  flex-shrink: 0;
}

.headbox-title {
  color: var(--header-text);
  font-size: 32px;
  font-weight: bold;
  letter-spacing: 1px;
}

.headbox-counter {
  color: #fff;
  font-size: 26px;
  font-weight: bold;
}

.footer-version {
  color: rgba(200, 200, 200, 0.5);
  font-size: 11px;
  font-family: monospace;
  text-align: center;
  padding: 0 0 4px;
  margin-top: -2px;
  flex-shrink: 0;
}

/* ── Info area (scores + seed badge) ───────────────────────── */

.info {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0 4px;
  flex-shrink: 0;
}

.info-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #fff;
}

.info-line, .info-line-compact {
  font-size: 21px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1.35;
}

.info-line-compact {
  gap: 8px;
}

.info-label {
  color: #fff;
}

.info-value {
  color: #fff;
  font-weight: normal;
}


.info-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 4px;
  align-self: stretch;
}

.seed-badge {
  background: #3d3d00;
  border: 2px solid #a0a000;
  border-radius: 6px;
  padding: 4px 10px;
  color: #fff;
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 15px;
}

.seed-label {
  color: #e8e800;
  font-weight: bold;
}

.seed-value {
  color: #fff;
  font-weight: bold;
}

/* ── Secondary-actions toolbar ────────────────────────────── */

.toolbar {
  display: flex;
  gap: 6px;
  padding: 0 4px;
  margin: 4px 0 4px 0;
  flex-shrink: 0;
}

.toolbar-btn {
  flex: 1;
  padding: 10px 10px;
  background: rgba(40, 40, 60, 0.8);
  border: 1px solid rgba(160, 160, 200, 0.4);
  border-radius: 6px;
  color: rgba(220, 220, 220, 0.9);
  font-family: "Marker Felt", "MarkerFelt-Thin", sans-serif;
  font-size: 17px;
  cursor: pointer;
  transition: background 0.1s;
}

.toolbar-btn:hover {
  background: rgba(60, 60, 90, 0.95);
  color: #fff;
}

.toolbar-btn:active {
  transform: scale(0.96);
}

/* ── Board ─────────────────────────────────────────────────── */

.board-wrapper {
  position: relative;
  margin: 0 auto;
  max-width: 100%;
  width: calc(var(--cell-size) * 5);
  aspect-ratio: 1;
  flex-shrink: 0;
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 0;
  width: 100%;
  height: 100%;
  /* Board background image (one of bback-1/2/3/6/9.jpg). */
  background:
    url("/static/images/bback-9.jpg") center/cover no-repeat,
    var(--board-bg);
}

/* Grid lines — drawn as a separate absolutely-positioned layer so they
 * sit on top of the background image. Each cell is 1/5 of the board.
 * The linear-gradients draw the left+top edge of every cell (5 vertical
 * and 5 horizontal lines). The box-shadow adds the missing right+bottom
 * edge of the last column/row so the grid is closed on all sides. */
.board::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right,
      rgba(160, 160, 160, 0.35) 1px, transparent 1px),
    linear-gradient(to bottom,
      rgba(160, 160, 160, 0.35) 1px, transparent 1px);
  background-size: calc(100% / 5) calc(100% / 5);
  box-shadow:
    inset -1px 0 0 0 rgba(160, 160, 160, 0.35),
    inset 0 -1px 0 0 rgba(160, 160, 160, 0.35);
  z-index: 1;
}

.board-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
  z-index: 4;
  overflow: visible;
}

.combo-border-line {
  stroke-width: 5px;
}

.wall-line {
  stroke-width: 5px;
}

/* ── Cell ──────────────────────────────────────────────────── */

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  cursor: pointer;
  overflow: visible; /* allow combo frame to overlap */
  touch-action: none;
}

.cell-empty {
  background: transparent;
}

/* Combo cells just provide the background color. The frame is drawn
 * separately as a single SVG overlay on top of the board — so that
 * adjacent combos share borders correctly without doubling. */
.cell-combo {
  background: var(--combo-bg);
  z-index: 2;
  position: relative;
}

.cell-combo.cell-used {
  background: rgba(0, 80, 0, 0.4);
}

/* Active cell indicator: subtle scale bump on the background digit.
 * Keeps the same downward nudge as the base style so the glyph stays
 * visually centred under the scale transform. */
.cell-active .cell-bg-digit {
  transform: translateY(6%) scale(1.05);
}

/* ── Player line + name display ────────────────────────────── */

.player-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}
.player-line .player-name {
  white-space: nowrap;
}

.player-label {
  color: rgba(220, 220, 220, 0.8);
  font-size: 20px;
  font-weight: bold;
  padding-right: 4px;
}

/* "Anleitung" button top right next to the Numrix! logo */
.help-btn {
  background: #2a3a6a;
  border: 2px solid #6a8ae0;
  border-radius: 8px;
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
  padding: 8px 16px;
  align-self: center;
}
.help-btn:active {
  background: #3a4a7a;
}

/* EN / DE language toggle: segmented pair inside a wrapper so the
   rounding rules don't collide with other buttons in the headbox. */
.lang-toggle {
  display: flex;
  align-self: center;
  margin-left: 8px;
}
.lang-btn {
  background: #2a2a2a;
  border: 2px solid #555;
  color: #bbb;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
  padding: 8px 12px;
  min-width: 40px;
  border-radius: 0;
}
.lang-btn + .lang-btn {
  margin-left: -2px;
}
.lang-toggle .lang-btn:first-child {
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
}
.lang-toggle .lang-btn:last-child {
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
}
.lang-btn:active {
  background: #3a3a3a;
}
.lang-btn-active {
  background: #4a4a4a;
  border-color: #fff;
  color: #fff;
  position: relative;
  z-index: 1;
}

.player-name {
  color: #fff;
  font-weight: bold;
  font-size: 20px;
}

.player-id {
  color: rgba(180, 180, 180, 0.5);
  font-size: 15px;
}

.info-value.world-best {
  color: #ffd000;
  font-weight: bold;
}

/* ── Score table (3 columns: label | Schritt | Gesamt) ────── */

.score-table {
  display: grid;
  grid-template-columns: 1fr 2fr 2fr;
  gap: 1px 0;
  margin: 2px 0;
  width: 100%;
}

.score-hdr {
  color: rgba(220, 220, 220, 0.8);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
  padding-bottom: 2px;
}

.score-lbl,
.score-num {
  line-height: 1.1;
}

.score-lbl {
  color: rgba(220, 220, 220, 0.8);
  font-size: 20px;
  font-weight: bold;
  text-align: right;
  padding-right: 8px;
}

.score-num {
  color: #fff;
  font-size: 24px;
  font-weight: bold;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.score-num.score-best {
  color: #ffd000;
}

.step-indicator {
  text-align: center;
  color: rgba(200, 200, 200, 0.7);
  font-size: 14px;
  margin-top: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.step-indicator:active {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

/* ── Highscore overlay ─────────────────────────────────────── */

.highscore-panel {
  background: rgb(28, 28, 40);
  border: 2px solid rgb(200, 200, 200);
  border-radius: 12px;
  padding: 16px;
  max-width: 400px;
  width: 94%;
  max-height: min(640px, calc(100dvh - 40px));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.highscore-title {
  color: var(--header-text);
  text-align: center;
  font-family: "Marker Felt", "MarkerFelt-Thin", sans-serif;
  margin: 0;
}

/* Tab switcher (Top 10 / Eigener) */
.hs-tabs {
  display: flex;
  gap: 4px;
  padding: 0;
}

.hs-tab {
  flex: 1;
  padding: 10px 8px;
  background: rgba(40, 40, 60, 0.6);
  border: 1px solid rgba(160, 160, 200, 0.3);
  border-radius: 6px;
  color: rgba(220, 220, 220, 0.75);
  font-family: "Marker Felt", "MarkerFelt-Thin", sans-serif;
  font-size: 17px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.hs-tab:hover {
  background: rgba(60, 60, 90, 0.85);
  color: #fff;
}

.hs-tab-active {
  background: rgba(234, 234, 0, 0.15);
  border-color: rgba(234, 234, 0, 0.7);
  color: #eaea00;
  font-weight: bold;
}

.highscore-empty {
  text-align: center;
  color: rgba(200, 200, 200, 0.6);
  padding: 20px 0;
  font-style: italic;
}

.highscore-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 50dvh;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  padding: 6px;
}

.highscore-row {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  gap: 8px;
  align-items: baseline;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 15px;
  color: #fff;
}

.highscore-row:nth-child(odd) {
  background: rgba(255, 255, 255, 0.04);
}

.highscore-row-me {
  background: rgba(255, 210, 0, 0.2) !important;
  border: 1px solid rgba(255, 210, 0, 0.5);
}

.highscore-rank {
  color: rgba(180, 180, 180, 0.7);
  text-align: right;
  font-weight: bold;
}

.highscore-name {
  color: #fff;
  font-weight: bold;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.highscore-id {
  color: rgba(180, 180, 180, 0.45);
  font-size: 12px;
  padding-left: 6px;
}

.highscore-score {
  color: #ffd000;
  font-weight: bold;
  font-size: 17px;
  min-width: 40px;
  text-align: right;
}

.highscore-row-me .highscore-rank {
  color: #ffd000;
}

.highscore-close {
  background: rgb(96, 0, 0);
  border-color: rgb(192, 64, 64);
  width: 100%;
  padding: 12px;
  border: 2px solid;
  border-radius: 6px;
  color: #fff;
  font-family: inherit;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
}

/* ── Name-entry overlay ────────────────────────────────────── */

.name-entry {
  background: rgb(28, 28, 40);
  border: 2px solid rgb(200, 200, 200);
  border-radius: 12px;
  padding: 16px;
  max-width: 370px;
  width: 94%;
  max-height: min(640px, calc(100dvh - 40px));
  overflow-y: auto;
  text-align: center;
}

.name-entry-title {
  color: var(--header-text);
  margin-bottom: 10px;
  font-family: "Marker Felt", "MarkerFelt-Thin", sans-serif;
}

.name-entry-preview {
  background: #000;
  border: 2px solid rgba(200, 200, 200, 0.4);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 8px 0 4px;
  color: #fff;
  font-family: "Marker Felt", "MarkerFelt-Thin", sans-serif;
  font-size: 28px;
  min-height: 42px;
  letter-spacing: 1px;
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
}

.name-entry-hint {
  color: rgba(180, 180, 180, 0.6);
  font-size: 12px;
  margin-bottom: 12px;
}

.letter-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 4px;
  margin: 0 0 12px 0;
}

.letter-cell {
  aspect-ratio: 1;
  background: rgba(40, 40, 40, 0.85);
  border: 1px solid rgba(200, 200, 200, 0.25);
  border-radius: 4px;
  color: #fff;
  font-family: "Marker Felt", "MarkerFelt-Thin", sans-serif;
  font-size: 22px;
  cursor: pointer;
  transition: background 0.1s;
}

.letter-cell:hover {
  background: rgba(80, 80, 80, 0.95);
}

.letter-cell:active {
  transform: scale(0.95);
}

.letter-cell-back {
  background: rgba(120, 0, 0, 0.7);
  border-color: rgba(200, 60, 60, 0.7);
  font-size: 22px;
}

.letter-cell-back:hover {
  background: rgba(160, 0, 0, 0.85);
}

.name-entry-ok {
  width: 100%;
  padding: 12px;
  background: rgb(0, 120, 0);
  border: 2px solid rgb(0, 200, 0);
  border-radius: 6px;
  color: #fff;
  font-family: inherit;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
}

.name-entry-ok.disabled {
  background: rgb(40, 40, 40);
  border-color: rgb(80, 80, 80);
  color: rgb(140, 140, 140);
  cursor: not-allowed;
}

/* ── Score-breakdown animation ────────────────────────────── */

/* Two levels of highlight during the animation:
 *
 *   .cell-anim        → steady YELLOW glow on every cell of the scoring
 *                       region (the whole group being explained).
 *   .cell-anim-focus  → stronger ORANGE overlay on top, marking the
 *                       single combo currently being counted.
 *
 * A cell with both classes gets the orange overlay (more specific
 * selector wins), so the focused combo stands out within its yellow
 * region without the region highlight ever flickering off. */
.cell-anim {
  z-index: 3;
}

.cell-anim::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 3;
}

/* Perfect flash: bright overlay instead of dark */
.cell-anim.cell-anim-perfect::after {
  background: rgba(255, 255, 200, 0.5);
}

/* Default focus colour (fallback) */
.cell-anim.cell-anim-focus::after {
  background: rgba(255, 80, 0, 0.7);
}
/* Per-digit focus colours matching the digit PNG colours */
.cell-anim.anim-d0::after { background: rgba(200, 200, 200, 0.5); }
.cell-anim.anim-d1::after { background: rgba(0, 220, 0, 0.5); }
.cell-anim.anim-d2::after { background: rgba(160, 80, 220, 0.5); }
.cell-anim.anim-d3::after { background: rgba(255, 160, 0, 0.5); }
.cell-anim.anim-d4::after { background: rgba(0, 200, 220, 0.5); }
.cell-anim.anim-d5::after { background: rgba(40, 120, 255, 0.5); }
.cell-anim.anim-d6::after { background: rgba(240, 220, 0, 0.5); }
.cell-anim.anim-d7::after { background: rgba(240, 200, 0, 0.5); }
.cell-anim.anim-d8::after { background: rgba(220, 0, 180, 0.5); }
.cell-anim.anim-d9::after { background: rgba(220, 30, 30, 0.5); }

/* Make the board-score line look clickable + subtle hover */
.info-value.clickable {
  text-decoration: underline dotted rgba(255, 255, 255, 0.3);
  text-underline-offset: 2px;
}

.info-value.animating {
  color: #ffff00;
  transition: color 0.3s;
}

/* The SVG border overlay sits absolutely on top of the board grid. */
.board-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

/* Walls: thick red border, drawn on TOP of everything */
.wall-top::before {
  content: "";
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 3px;
  background: var(--wall-color);
  z-index: 5;
}
.wall-bottom::before {
  content: "";
  position: absolute;
  bottom: 0; left: 10%; right: 10%;
  height: 3px;
  background: var(--wall-color);
  z-index: 5;
}
.wall-left::before {
  content: "";
  position: absolute;
  left: 0; top: 10%; bottom: 10%;
  width: 3px;
  background: var(--wall-color);
  z-index: 5;
}
.wall-right::before {
  content: "";
  position: absolute;
  right: 0; top: 10%; bottom: 10%;
  width: 3px;
  background: var(--wall-color);
  z-index: 5;
}

/* Lock: circle border */
.lock-ring {
  position: absolute;
  inset: 4px;
  border: 3px solid var(--lock-color);
  border-radius: 50%;
  pointer-events: none;
}

/* ── Standalone digit (not in combo) ───────────────────────── */

.cell-digit {
  width: 55%;
  height: 55%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* ── Combo cell: large background digit + small result icons ─ */

.cell-bg-digit {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Marker Felt", "MarkerFelt-Thin", sans-serif;
  font-size: calc(var(--cell-size) * 0.75);
  font-weight: normal;
  /* col_ronum = {220, 220, 220} — light grey when NOT in the evaluation */
  color: rgba(220, 220, 220, 0.35);
  pointer-events: none;
  line-height: 1;
  z-index: 1;
  /* Marker Felt has a top-heavy metric — nudge the glyph down a touch so
   * it sits visually centred inside the cell. */
  transform: translateY(6%);
}

/* col_oknum = {0, 200, 0} — green when this cell contributes, dimmed as
 * a background watermark behind the small result icons */
.cell-combo.cell-used .cell-bg-digit {
  color: rgba(0, 140, 0, 0.45);
}

/* Result icons: small ns*.png images positioned in the cell */

.result-icon {
  position: absolute;
  width: 40%;
  height: 40%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  z-index: 2;
}

.result-center {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.result-tl {
  top: 6%;
  left: 6%;
}

.result-tr {
  top: 6%;
  right: 6%;
}

.result-bl {
  bottom: 6%;
  left: 6%;
}

.result-br {
  bottom: 6%;
  right: 6%;
}

/* ── Bomb indicator ────────────────────────────────────────── */

.bomb {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: bold;
  background: rgba(255, 0, 0, 0.85);
  color: #fff;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 3;
}

.bomb-1 { background: rgba(160, 80, 0, 0.9); }
.bomb-2 { background: rgba(220, 60, 0, 0.95); }
.bomb-3 {
  background: rgba(255, 0, 0, 1);
  animation: pulse 0.5s infinite;
}

/* ── Controls ──────────────────────────────────────────────── */

.controls {
  display: flex;
  gap: 8px;
  padding: 8px 0 4px 0;
  flex-shrink: 0;
  /* Sit directly beneath the board — no more push-to-bottom */
}

.btn {
  padding: 10px 14px;
  border: 2px solid;
  border-radius: 6px;
  font-family: "Marker Felt", "MarkerFelt-Thin", sans-serif;
  font-size: 30px;
  font-weight: bold;
  color: #fff;
  cursor: pointer;
  transition: background 0.1s;
}

.btn:active {
  transform: scale(0.96);
}

.btn-done {
  flex: 1;
  background: var(--btn-done-fill);
  border-color: var(--btn-done-stroke);
}

.btn-undo {
  flex: 1;
  background: var(--btn-undo-fill);
  border-color: var(--btn-undo-stroke);
}

.btn-leer {
  flex: 1;
  background: var(--btn-menu-fill);
  border-color: var(--btn-menu-stroke);
}

/* ── Overlay (Menu / Game Over / Highscores / Name Entry) ──── */

/* Overlays cover the whole screen and center their panel. The panels
 * themselves are capped via `max-height` so on a tall desktop window
 * they do not grow to fill the viewport. */
.overlay,
.highscore-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  z-index: 100;
  overflow-y: auto;
}

.menu, .game-over {
  background: rgb(28, 28, 40);
  border: 2px solid rgb(200, 200, 200);
  border-radius: 10px;
  padding: 16px;
  max-width: 340px;
  width: 92%;
  max-height: min(640px, calc(100dvh - 40px));
  overflow-y: auto;
}

.menu-title, .game-over-title {
  text-align: center;
  color: var(--header-text);
  margin-bottom: 14px;
  font-family: "Marker Felt", "MarkerFelt-Thin", sans-serif;
}

.menu-item {
  display: block;
  width: 100%;
  padding: 12px;
  margin-bottom: 8px;
  background: #000060;
  border: 2px solid #4040c0;
  border-radius: 6px;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
}

.menu-close {
  background: #600000;
  border-color: #c04040;
  margin-top: 8px;
}

.menu-danger {
  background: #603000;
  border-color: #c07030;
}

/* ── Onboarding / ID entry ────────────────────────────────── */

.onboard-current {
  text-align: center;
  margin-bottom: 12px;
}

.onboard-desc {
  color: rgba(220, 220, 220, 0.8);
  font-size: 15px;
  margin: 0 0 14px;
  text-align: center;
  line-height: 1.4;
}

.id-display {
  text-align: center;
  font-family: monospace;
  font-size: 32px;
  font-weight: bold;
  color: #ffd000;
  letter-spacing: 8px;
  padding: 12px 0 4px;
}

.id-status {
  text-align: center;
  color: rgba(240, 120, 120, 0.9);
  font-size: 14px;
  min-height: 18px;
  margin-bottom: 8px;
}

.id-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}

.id-keypad-row {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.id-key {
  padding: 14px 0;
  background: #000060;
  border: 2px solid #4040c0;
  border-radius: 6px;
  color: #fff;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
}

.id-backspace {
  min-width: 80px;
  background: #400030;
  border-color: #a04080;
}

.id-buttons {
  display: flex;
  gap: 8px;
}

.id-buttons .menu-item {
  flex: 1;
  margin-bottom: 0;
}

.menu-section {
  margin: 12px 0;
}

.menu-section h3 {
  color: rgb(200, 200, 200);
  font-size: 14px;
  margin-bottom: 8px;
  text-align: center;
}

.seed-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.seed-btn {
  padding: 6px 4px;
  border-radius: 6px;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1;
  border: 2px solid rgb(80, 80, 80);
  background: rgb(50, 50, 50);
  transition: border-color 0.15s, background 0.15s;
}

.seed-btn-name {
  font-size: 13px;
}

.seed-btn-score {
  font-size: 11px;
  color: rgb(0, 220, 0);
  font-weight: bold;
  font-family: inherit;
  line-height: 1;
}

.seed-btn-top {
  font-size: 11px;
  color: #ffd000;
  font-weight: bold;
  font-family: inherit;
  line-height: 1;
}

.seed-btn-tied {
  font-size: 17px;
  color: rgb(0, 220, 0);
  font-weight: bold;
  font-family: inherit;
  line-height: 1;
  margin-top: 4px;
}

.seed-btn.seed-played {
  border-color: rgb(180, 180, 0);
  background: rgba(180, 180, 0, 0.08);
}

.seed-btn.seed-tied {
  border-color: rgb(0, 192, 0);
  background: rgba(0, 192, 0, 0.1);
}

.seed-btn.seed-unplayed {
  border-color: rgb(60, 60, 60);
  background: rgba(60, 60, 60, 0.15);
}
.seed-btn.seed-unplayed .seed-btn-score {
  color: rgba(200, 200, 200, 0.4);
}

/* ── Game Over ─────────────────────────────────────────────── */

.final-stats {
  margin: 16px 0;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(100, 100, 100, 0.3);
  font-size: 18px;
}

.stat-value {
  color: rgb(0, 200, 0);
  font-weight: bold;
}

.btn-new-game {
  display: block;
  width: 100%;
  padding: 14px;
  background: rgb(0, 96, 0);
  border: 2px solid rgb(64, 192, 64);
  border-radius: 8px;
  color: #fff;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  margin-top: 8px;
  font-family: inherit;
}

/* ── Step Picker ──────────────────────────────────────────── */

.step-picker {
  background: rgb(28, 28, 40);
  border: 2px solid rgb(200, 200, 200);
  border-radius: 12px;
  padding: 12px;
  max-width: 380px;
  width: 94%;
  max-height: min(640px, calc(100dvh - 40px));
  overflow-y: auto;
}

/* ── Tutorial (bottom-anchored bubble, game stays visible) ─── */

.tutorial-blocker {
  position: absolute;
  inset: 0;
  z-index: 150;
  background: transparent;
  touch-action: none;
}

.tutorial-bubble {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: calc(var(--cell-size) * 5 + 28px);
  max-width: calc(100% - 8px);
  background: rgb(28, 28, 40);
  border: 2px solid rgb(180, 180, 255);
  border-radius: 10px;
  padding: 10px 12px 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
  z-index: 200;
  height: 225px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.tutorial-body {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  color: #ddd;
}

.tutorial-bubble-top {
  top: 8px;
}

.tutorial-bubble-bottom {
  bottom: 8px;
}

.tutorial-close-x {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #600000;
  border: 2px solid #c04040;
  color: #fff;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tutorial-close-x:active {
  background: #800000;
}

.tutorial-title {
  text-align: center;
  color: var(--header-text);
  margin: 0 32px 6px;
  font-family: "Marker Felt", "MarkerFelt-Thin", sans-serif;
  font-size: 23px;
}


.tutorial-para {
  color: rgba(240, 240, 240, 1);
  font-size: 18px;
  line-height: 1.35;
  margin: 0 0 8px;
}

.tutorial-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 6px;
}

.tutorial-nav .menu-item {
  margin-bottom: 0;
  min-width: 85px;
  padding: 8px 12px;
  font-size: 16px;
}

.tutorial-spacer {
  min-width: 90px;
}

.tutorial-progress {
  color: rgba(200, 200, 200, 0.85);
  font-size: 14px;
  font-family: monospace;
  white-space: nowrap;
  padding: 0 4px;
}

.tutorial-done {
  background: rgb(0, 96, 0);
  border-color: rgb(64, 192, 64);
}

.step-picker-title {
  text-align: center;
  color: var(--header-text);
  margin-bottom: 8px;
  font-family: "Marker Felt", "MarkerFelt-Thin", sans-serif;
}

.step-picker-total {
  text-align: center;
  color: rgb(0, 200, 0);
  font-weight: bold;
  font-size: 18px;
  margin-bottom: 12px;
}

.step-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-bottom: 12px;
}

.step-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: rgb(50, 50, 50);
  border: 2px solid rgb(80, 80, 80);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  padding: 2px 0;
}

.step-cell:active {
  background: rgb(70, 70, 70);
}

.step-number {
  color: rgba(200, 200, 200, 0.6);
  font-size: 11px;
  font-weight: bold;
}

.step-score {
  color: #fff;
  font-size: 14px;
  font-weight: bold;
}

.step-best {
  color: #ffd000;
  font-size: 11px;
  font-weight: bold;
}

.step-score.step-score-tied {
  font-size: 22px;
  color: #00d060;
}

.step-current {
  border-color: rgb(255, 200, 0);
  background: rgba(255, 200, 0, 0.12);
}

.step-played {
  border-color: rgb(180, 180, 0);
  background: rgba(180, 180, 0, 0.08);
}
.step-played .step-score {
  color: rgb(220, 220, 0);
}

.step-perfect {
  border-color: rgb(0, 192, 0);
  background: rgba(0, 192, 0, 0.1);
}
.step-perfect .step-score {
  color: rgb(0, 220, 0);
}

.step-unplayed {
  border-color: rgb(60, 60, 60);
  background: rgba(60, 60, 60, 0.15);
}
.step-unplayed .step-score {
  color: rgba(200, 200, 200, 0.4);
}

.step-locked {
  cursor: default;
}

.step-picker-close {
  display: block;
  width: 100%;
  padding: 12px;
  background: #600000;
  border: 2px solid #c04040;
  border-radius: 6px;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
}

/* ── Step Complete (transition screen) ────────────────────── */

.step-complete {
  background: rgb(28, 28, 40);
  border: 2px solid rgb(200, 200, 200);
  border-radius: 12px;
  padding: 20px;
  max-width: 360px;
  width: 92%;
  text-align: center;
}

.step-complete-title {
  color: var(--header-text);
  margin-bottom: 16px;
  font-family: "Marker Felt", "MarkerFelt-Thin", sans-serif;
  font-size: 22px;
}

.step-complete-stats {
  margin-bottom: 20px;
}

.step-complete-stats .stat-row {
  font-size: 18px;
}

.step-complete-stats .stat-total {
  border-top: 2px solid rgba(100, 100, 100, 0.5);
  margin-top: 4px;
  padding-top: 12px;
}
.step-complete-stats .stat-total .stat-value {
  color: rgb(0, 200, 0);
  font-size: 22px;
}

.step-complete-player {
  text-align: center;
  margin-bottom: 12px;
}
.step-complete-player .player-name {
  color: #fff;
  font-weight: bold;
  font-size: 18px;
}
.step-complete-player .player-id {
  color: rgba(180, 180, 180, 0.5);
  font-size: 14px;
}

/* Mini highscore list (step-complete screen) */
.mini-highscore {
  margin: 8px 0 12px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
}

.mini-hs-title {
  color: rgba(200, 200, 200, 0.7);
  font-size: 12px;
  text-align: center;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mini-hs-empty {
  text-align: center;
  color: rgba(150, 150, 150, 0.5);
  font-size: 14px;
  padding: 4px 0;
}

.mini-hs-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 4px;
  border-radius: 3px;
  font-size: 14px;
}

.mini-hs-me {
  background: rgba(255, 200, 0, 0.1);
}

.mini-hs-rank {
  color: rgba(180, 180, 180, 0.6);
  width: 20px;
  text-align: right;
  flex-shrink: 0;
}

.mini-hs-name {
  color: #fff;
  font-weight: bold;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-hs-id {
  color: rgba(150, 150, 150, 0.4);
  font-size: 11px;
  flex-shrink: 0;
}

.mini-hs-score {
  color: rgb(0, 200, 0);
  font-weight: bold;
  flex-shrink: 0;
  min-width: 30px;
  text-align: right;
}

.mini-hs-me .mini-hs-name {
  color: rgb(255, 200, 0);
}

.step-complete-buttons {
  display: flex;
  gap: 8px;
}

.btn-step-back,
.btn-step-next,
.btn-step-done {
  flex: 1;
  padding: 14px 8px;
  border-radius: 8px;
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
  border: 2px solid;
}

.btn-step-back {
  background: #000060;
  border-color: #4040c0;
}

.btn-step-next {
  background: rgb(0, 96, 0);
  border-color: rgb(64, 192, 64);
}

.btn-step-done {
  background: rgb(0, 96, 0);
  border-color: rgb(64, 192, 64);
}

/* ── Animations ────────────────────────────────────────────── */

@keyframes pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.2); }
}
