/* ==========================================================================
   SweeperCreeper v2 — retro casino design system.
   Legibility rules: Press Start 2P only for short display strings ≥ 14px;
   Pixelify Sans ≥ 16px for everything readable; muted text stays ≥ 4.5:1.
   ========================================================================== */

:root {
  --font-display: 'Press Start 2P', monospace;
  --font-body: 'Pixelify Sans', system-ui, sans-serif;

  --bg: #101014;
  --felt-a: #1b432e; --felt-b: #153323; --felt-c: #11291b;
  --panel: #1e1e27;
  --panel-deep: #14141b;
  --ink: #f4efe6;
  --ink-dim: #b6ae9e;
  --line: #000;

  --gold: #ffb300;
  --gold-soft: #ffd54f;
  --red: #e5484d;
  --green: #2fbf71;
  --blue: #4da3ff;
  --purple: #b07cff;
  --cyan: #3fd6de;

  --cell-back-a: #33439a; --cell-back-b: #232f6e;
  --cell-back-line: #0d1230;
  --cell-face: #efe8d4;
  --cell-face-line: #a89d7f;
  --cell-mine: #2c2c34;

  --shadow-panel: 6px 6px 0 rgba(0, 0, 0, .55);
  --shadow-btn: 4px 4px 0 rgba(0, 0, 0, .8);
  --border-thick: 3px solid var(--line);

  --cell: 38px; /* set by JS per board */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html[data-theme="light"] {
  --bg: #e9f2e6;
  --felt-a: #c8e6c9; --felt-b: #aed8b0; --felt-c: #93c996;
  --panel: #fffdf6;
  --panel-deep: #efeadb;
  --ink: #1c1a15;
  --ink-dim: #5d574a;
  --line: #23211c;
  --cell-back-a: #4b64c9; --cell-back-b: #3a4fa5;
  --cell-face: #fffdf2;
  --cell-face-line: #b8ac8c;
  --cell-mine: #37373f;
  --shadow-panel: 6px 6px 0 rgba(35, 33, 28, .35);
  --shadow-btn: 4px 4px 0 rgba(35, 33, 28, .5);
}

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

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
  overscroll-behavior-y: none; /* no rubber-band voids or pull-to-refresh mid-game */
  -webkit-tap-highlight-color: transparent;
}

/* ---- Backdrop -------------------------------------------------------- */
.felt-bg {
  position: fixed; inset: -60%;
  background: repeating-radial-gradient(circle at 50% 50%,
    var(--felt-a) 0, var(--felt-a) 42px,
    var(--felt-b) 42px, var(--felt-b) 84px,
    var(--felt-c) 84px, var(--felt-c) 126px);
  animation: swirl 90s linear infinite;
  z-index: -2;
}
@keyframes swirl { to { transform: rotate(360deg); } }

.crt {
  position: fixed; inset: 0; pointer-events: none; z-index: 60;
  background: linear-gradient(rgba(0,0,0,0) 50%, rgba(0,0,0,.10) 50%);
  background-size: 100% 4px;
  opacity: .5;
}
html[data-theme="light"] .crt { opacity: .15; }

#fxCanvas { position: fixed; inset: 0; pointer-events: none; z-index: 55; }

#flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 54; opacity: 0;
}
#flash.on { animation: flashfade .35s ease-out; }
#flash[data-kind="danger"]  { background: radial-gradient(circle, rgba(229,72,77,.35), rgba(229,72,77,.12)); }
#flash[data-kind="gold"]    { background: radial-gradient(circle, rgba(255,179,0,.3), rgba(255,179,0,.1)); }
#flash[data-kind="success"] { background: radial-gradient(circle, rgba(47,191,113,.3), rgba(47,191,113,.1)); }
@keyframes flashfade { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ---- Layout ----------------------------------------------------------- */
#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(12px + var(--safe-top)) 12px calc(12px + var(--safe-bottom));
}

.screen {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: screenIn .25s ease-out;
}
.screen.hidden, .hidden { display: none !important; }
@keyframes screenIn { from { opacity: 0; transform: translateY(14px); } }

.panel {
  background: var(--panel);
  border: var(--border-thick);
  border-radius: 12px;
  box-shadow: var(--shadow-panel);
  padding: 16px;
  width: 100%;
}

/* ---- Type -------------------------------------------------------------- */
h2 { font-family: var(--font-display); font-size: 1.15rem; letter-spacing: 0; }
h3 { font-family: var(--font-display); font-size: 1rem; margin-bottom: 14px; line-height: 1.6; }
h4 { font-family: var(--font-body); font-size: 1.1rem; margin: 16px 0 8px; color: var(--gold); text-transform: uppercase; }
.dim { color: var(--ink-dim); font-weight: 500; }
.win { color: var(--gold); }
.lose { color: var(--red); }

/* ---- Buttons ----------------------------------------------------------- */
button {
  font-family: var(--font-body);
  color: inherit;
  touch-action: manipulation;
}
.btn {
  border: var(--border-thick);
  border-radius: 10px;
  padding: 12px 22px;
  font-size: 1.15rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: transform .08s, box-shadow .08s, filter .12s;
  background: var(--panel-deep);
  color: var(--ink);
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--line); }
.btn-gold  { background: var(--gold); color: #1a1408; }
.btn-red   { background: var(--red); color: #fff; }
.btn-plain { background: var(--panel-deep); color: var(--ink); }
.btn-big   { width: 100%; margin-top: 16px; font-size: 1.3rem; padding: 16px; }
.btn:disabled { filter: grayscale(1) brightness(.7); cursor: not-allowed; transform: none; box-shadow: var(--shadow-btn); }

.chip-btn {
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font-size: .98rem;
  font-weight: 700;
  padding: 8px 14px;
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(0,0,0,.6);
  transition: transform .08s, box-shadow .08s;
}
.chip-btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0; }

.icon-btn {
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel-deep);
  color: var(--ink);
  width: 40px; height: 40px;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  flex: none;
}

/* ---- Home -------------------------------------------------------------- */
.home-header { text-align: center; margin-top: clamp(4px, 4vh, 40px); }
.logo {
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 7.5vw, 2.6rem);
  line-height: 1.25;
  color: var(--gold);
  text-shadow: 4px 4px 0 rgba(0,0,0,.85);
  display: flex; flex-direction: column; align-items: center;
}
html[data-theme="light"] .logo { text-shadow: 4px 4px 0 rgba(35,33,28,.35); }
.logo-creeper { color: var(--green); animation: creep 3.2s ease-in-out infinite; }
@keyframes creep { 0%,100% { transform: translateX(0); } 50% { transform: translateX(6px); } }
.tagline {
  margin-top: 12px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--ink-dim);
  font-size: 1rem;
}

.home-cards { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 460px; }
.mode-card {
  display: flex; align-items: center; gap: 16px;
  text-align: left;
  background: var(--panel);
  border: var(--border-thick);
  border-radius: 14px;
  box-shadow: var(--shadow-panel);
  padding: 16px 18px;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
}
.mode-card:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 rgba(0,0,0,.55); }
.mode-card:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 rgba(0,0,0,.55); }
.mode-icon {
  font-size: 2rem; width: 58px; height: 58px; flex: none;
  display: grid; place-items: center;
  border: var(--border-thick); border-radius: 10px;
  background: var(--panel-deep);
}
.mode-run .mode-icon { color: var(--red); background: #2a1215; }
html[data-theme="light"] .mode-run .mode-icon { background: #ffd9db; }
.mode-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mode-name { font-family: var(--font-display); font-size: .95rem; color: var(--gold); }
.daily-num { color: var(--cyan); }
.mode-desc { font-size: .98rem; color: var(--ink-dim); font-weight: 500; }
.mode-extra { font-size: .95rem; font-weight: 700; color: var(--green); min-height: 0; }
.mode-extra:empty { display: none; }

.home-footer { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.home-tip {
  color: var(--ink-dim);
  font-size: .95rem;
  text-align: center;
  max-width: 420px;
  min-height: 2.6em;
}

/* ---- Classic setup ------------------------------------------------------ */
.setup-panel { max-width: 460px; }
.panel-title-row { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.preset-grid { display: flex; flex-direction: column; gap: 10px; }
.preset-card {
  display: flex; justify-content: space-between; align-items: center;
  border: var(--border-thick); border-radius: 10px;
  background: var(--panel-deep);
  box-shadow: var(--shadow-btn);
  padding: 14px 16px;
  cursor: pointer;
  font-size: 1.05rem;
  transition: transform .08s, box-shadow .08s;
}
.preset-card:active { transform: translate(3px,3px); box-shadow: 0 0 0; }
.preset-card b { font-size: 1.15rem; }
.preset-card .preset-meta { color: var(--ink-dim); font-weight: 500; }
.preset-card .preset-best { color: var(--gold); font-weight: 700; font-size: .95rem; }
.custom-setup { margin-top: 16px; }
.custom-setup summary { cursor: pointer; font-weight: 700; color: var(--ink-dim); font-size: 1rem; padding: 6px 0; }
.custom-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.custom-fields label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; color: var(--gold); text-transform: uppercase; font-size: .9rem; }
.custom-fields input {
  font-family: var(--font-body);
  font-size: 1.2rem; font-weight: 700;
  padding: 10px; text-align: center;
  background: var(--panel-deep); color: var(--ink);
  border: var(--border-thick); border-radius: 8px;
  width: 100%;
}
.custom-fields input:focus { outline: none; border-color: var(--blue); }

/* ---- HUD ---------------------------------------------------------------- */
#screen-game { gap: 10px; }
.hud { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.hud-top { display: flex; align-items: center; gap: 10px; }
.hud-title { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.hud-title b { font-family: var(--font-display); font-size: .85rem; white-space: nowrap; }
.boss-tag {
  font-size: .85rem; font-weight: 700;
  color: var(--red);
  border: 2px solid var(--red); border-radius: 6px;
  padding: 1px 7px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hud-timer { font-family: var(--font-display); font-size: .85rem; color: var(--ink-dim); }
.hud-timer.urgent { color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.quota-wrap { width: 100%; }
.quota-bar {
  position: relative; height: 26px;
  border: 2px solid var(--line); border-radius: 8px;
  background: var(--panel-deep);
  overflow: hidden;
}
.quota-fill {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: linear-gradient(90deg, var(--red), var(--gold));
  transition: width .35s ease-out;
}
.quota-fill.met { background: linear-gradient(90deg, var(--green), var(--gold)); }
.quota-label {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-weight: 700; font-size: .95rem;
  color: var(--ink);
  text-shadow: 0 1px 2px rgba(0,0,0,.7);
}
html[data-theme="light"] .quota-label { text-shadow: 0 1px 2px rgba(255,255,255,.7); color: #1c1a15; }

.hud-stats { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stat {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel-deep);
  border: 2px solid var(--line); border-radius: 8px;
  padding: 4px 10px;
  font-size: 1rem;
}
.stat b { font-size: 1.1rem; font-weight: 700; letter-spacing: .5px; }
.stat-combo { border-color: var(--gold); }
.stat-combo b { color: var(--gold); }
.stat-combo.blazing { animation: comboPulse .6s infinite; }
@keyframes comboPulse { 50% { transform: scale(1.07); } }
.stat-lives { letter-spacing: 2px; }
.stat-lives .lost { filter: grayscale(1) brightness(.5); }

.joker-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.joker-chip {
  font-size: 1.15rem;
  border: 2px solid var(--purple); border-radius: 8px;
  background: var(--panel-deep);
  padding: 2px 8px;
  cursor: pointer;
}

/* ---- Board -------------------------------------------------------------- */
.board-wrap {
  padding: 10px;
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: calc(100dvh - 300px);
  display: flex;
}
#screen-game { max-width: min(1100px, 100%); }
#screen-game .hud, #screen-game .action-bar { max-width: 720px; margin-inline: auto; }
.board {
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  gap: 3px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  margin: auto;
}

.cell {
  width: var(--cell); height: var(--cell);
  border-radius: calc(var(--cell) * 0.14);
  display: grid; place-items: center;
  cursor: pointer;
  position: relative;
  font-family: var(--font-display);
  font-size: calc(var(--cell) * 0.42);
  line-height: 1;
}
.cell.hidden-cell {
  background: linear-gradient(145deg, var(--cell-back-a), var(--cell-back-b));
  border: 2px solid var(--cell-back-line);
  border-bottom-width: 4px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.14);
}
.cell.hidden-cell::after {
  content: '';
  position: absolute; inset: 22%;
  border: 2px solid rgba(255,255,255,.13);
  border-radius: 20%;
  pointer-events: none;
}
@media (hover: hover) {
  .cell.hidden-cell:hover { filter: brightness(1.25); }
}
.cell.hidden-cell:active { transform: translateY(2px); border-bottom-width: 2px; }

.cell.revealed {
  background: var(--cell-face);
  border: 2px solid var(--cell-face-line);
  cursor: default;
  animation: flipIn .16s ease-out backwards;
  animation-delay: var(--d, 0s);
}
@keyframes flipIn { from { transform: scaleX(.1); filter: brightness(1.6); } }

.cell.flagged::before {
  content: '🚩';
  font-size: calc(var(--cell) * 0.52);
  animation: plantFlag .15s ease-out;
}
@keyframes plantFlag { from { transform: scale(1.6); } }

/* number colors — classic palette, high contrast on the cream face */
.cell.n1 { color: #1660d0; } .cell.n2 { color: #1e7d32; }
.cell.n3 { color: #d02f2f; } .cell.n4 { color: #6a1fb5; }
.cell.n5 { color: #a34700; } .cell.n6 { color: #0e7490; }
.cell.n7 { color: #ad1457; } .cell.n8 { color: #37474f; }

.cell.mine-boom {
  background: var(--red);
  border: 2px solid #7e1216;
  animation: boomShake .4s ease-out;
}
@keyframes boomShake {
  0%, 60% { transform: scale(1.15) rotate(-4deg); }
  30% { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1); }
}
.cell.mine-shown { background: var(--cell-mine); border: 2px solid #000; }
.cell.defused { background: var(--cell-face); border: 2px solid var(--cyan); }
.cell.wrong-flag { background: #6e3b00; }

.cell.holo {
  background: linear-gradient(120deg, #d84fd0, #4fa9d8, #d8c94f, #6ad84f, #d84fd0);
  background-size: 500% 500%;
  animation: holoShift 3.5s ease infinite;
  border: 2px solid #fff;
  border-bottom-width: 4px;
}
@keyframes holoShift { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

.cell.sparkle::after {
  content: '✨';
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: calc(var(--cell) * 0.4);
  border: none;
  animation: pulse 1.4s infinite;
}

.cell.armed { outline: 3px dashed var(--gold); outline-offset: -3px; }
.cell.armed-radar { outline-color: var(--cyan); }
.cell.armed-danger { outline-color: var(--red); }

/* ---- Hint + actions ------------------------------------------------------ */
.hint-bar {
  min-height: 1.4em;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  color: var(--ink-dim);
}
.hint-bar .hl { color: var(--gold); }

.action-bar {
  position: sticky;
  bottom: calc(6px + var(--safe-bottom));
  z-index: 40;
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 560px;
  background: var(--panel);
  border: var(--border-thick);
  border-radius: 14px;
  box-shadow: var(--shadow-panel);
  padding: 8px;
}
.action-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--panel-deep);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 7px 2px 5px;
  cursor: pointer;
  color: var(--ink);
  min-width: 0;
}
.action-btn .a-icon { font-size: 1.3rem; line-height: 1; position: relative; }
.action-btn .a-icon i {
  font-style: normal;
  font-size: .8rem; font-weight: 700;
  position: absolute; top: -4px; right: -12px;
  background: var(--gold); color: #1a1408;
  border-radius: 999px;
  min-width: 17px; height: 17px;
  display: grid; place-items: center;
  padding: 0 3px;
  border: 2px solid var(--line);
}
.action-btn .a-label { font-size: .8rem; font-weight: 700; color: var(--ink-dim); }
.action-btn.on { border-color: var(--gold); background: #3a2f10; }
html[data-theme="light"] .action-btn.on { background: #ffedbb; }
.action-btn.on .a-label { color: var(--gold); }
.action-btn:disabled { opacity: .38; cursor: not-allowed; }
.action-btn.passive { cursor: default; }
.action-btn.cashout { border-color: var(--green); }
.action-btn.cashout .a-label { color: var(--green); }
.action-btn.cashout.ready { background: var(--green); animation: cashReady 1.2s infinite; }
.action-btn.cashout.ready .a-label { color: #0b2a1a; }
@keyframes cashReady { 50% { filter: brightness(1.2); } }

/* ---- Shop ---------------------------------------------------------------- */
#screen-shop { max-width: 520px; }
.shop-heading { text-align: center; font-size: 1.2rem; }
.payout-list { list-style: none; margin-top: 12px; }
.payout-list li {
  display: flex; justify-content: space-between;
  font-size: 1.1rem; font-weight: 600;
  padding: 6px 4px;
  border-bottom: 2px dashed rgba(128,128,128,.25);
  animation: screenIn .3s ease-out backwards;
}
.payout-list li b { color: var(--gold); }
.payout-total {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px;
  font-size: 1.25rem; font-weight: 700; text-transform: uppercase;
}
.payout-total b { font-family: var(--font-display); font-size: 1.15rem; color: var(--green); }

.shop-row-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.shop-row-head h3 { margin: 0; font-size: .9rem; }
.shop-jokers { display: flex; gap: 12px; margin-top: 14px; }
.joker-card {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center;
  background: var(--panel-deep);
  border: var(--border-thick); border-radius: 12px;
  box-shadow: var(--shadow-btn);
  padding: 14px 10px;
  cursor: pointer;
  transition: transform .1s;
}
.joker-card:not(.sold):hover { transform: translateY(-3px); }
.joker-card.sold { opacity: .45; cursor: default; }
.joker-card .j-icon { font-size: 2.2rem; }
.joker-card .j-name { font-weight: 700; font-size: 1.05rem; color: var(--gold); }
.joker-card .j-desc { font-size: .92rem; color: var(--ink-dim); min-height: 3.6em; }
.joker-card .j-price { font-family: var(--font-display); font-size: .85rem; color: var(--green); }
.joker-card[data-rarity="uncommon"] { border-color: var(--blue); }
.joker-card[data-rarity="rare"] { border-color: var(--purple); }
.joker-card[data-rarity="legendary"] { border-color: var(--gold); }
.joker-owned { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.joker-owned:empty { display: none; }

.shop-items-head { margin-top: 18px; }
.shop-items { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.shop-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-deep);
  border: 2px solid var(--line); border-radius: 10px;
  box-shadow: 3px 3px 0 rgba(0,0,0,.5);
  padding: 10px;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
}
.shop-item:disabled { opacity: .4; cursor: not-allowed; }
.shop-item .si-icon { font-size: 1.6rem; }
.shop-item .si-name { font-weight: 700; font-size: .98rem; display: block; }
.shop-item .si-price { color: var(--green); font-weight: 700; font-size: .95rem; }

/* ---- Modals --------------------------------------------------------------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(6, 6, 10, .78);
  display: grid; place-items: center;
  /* keep boxes clear of the notch/Dynamic Island and home indicator */
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  opacity: 0; pointer-events: none;
  transition: opacity .15s;
  touch-action: none; /* backdrop swallows gestures — no scroll bleed-through */
}
.modal.active { opacity: 1; pointer-events: auto; }
.modal-box {
  max-width: 440px; width: 100%;
  text-align: center;
  transform: translateY(12px) scale(.97);
  transition: transform .15s ease-out;
  max-height: calc(100dvh - 32px - var(--safe-top) - var(--safe-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}
body.modal-open { overflow: hidden; }
.modal.active .modal-box { transform: none; }
.modal-actions { display: flex; gap: 12px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.modal-tall { max-width: 520px; }
.msg-body { font-size: 1.15rem; }
.msg-body .big { font-family: var(--font-display); font-size: 1.5rem; display: block; margin: 12px 0; }

/* gamble modal */
.odds-big { font-family: var(--font-display); font-size: 2.4rem; margin: 10px 0 2px; }
.odds-big.safe { color: var(--green); }
.odds-big.risky { color: var(--gold); }
.odds-big.danger { color: var(--red); }
.odds-sub { color: var(--ink-dim); font-size: .95rem; font-weight: 600; }
.odds-bar-track {
  height: 26px; margin-top: 14px;
  border: 2px solid var(--line); border-radius: 8px;
  background: var(--green);
  overflow: hidden;
}
.odds-bar-fill { height: 100%; width: 0%; background: var(--red); transition: width .5s steps(12); }
.odds-scale { display: flex; justify-content: space-between; font-size: .95rem; font-weight: 700; margin-top: 6px; }
.odds-detail { color: var(--ink-dim); font-size: .98rem; margin-top: 12px; min-height: 1.4em; }
.gamble-payout {
  margin-top: 12px;
  font-size: 1.15rem; font-weight: 700;
  color: var(--gold);
}

/* mystery roulette */
.roulette {
  position: relative;
  height: 84px;
  border: var(--border-thick); border-radius: 10px;
  background: var(--panel-deep);
  overflow: hidden;
}
.roulette-marker {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 3px; margin-left: -1.5px;
  background: var(--gold);
  z-index: 2;
  box-shadow: 0 0 8px var(--gold);
}
.roulette-strip {
  display: flex; align-items: center; height: 100%;
  position: absolute; left: 0;
  will-change: transform;
}
.roulette-item {
  width: 120px; flex: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 1.7rem;
  border-right: 2px dashed rgba(128,128,128,.3);
}
.roulette-item small { font-size: .78rem; font-weight: 700; color: var(--ink-dim); }
.mystery-result {
  min-height: 2.2em;
  margin-top: 14px;
  font-size: 1.2rem; font-weight: 700;
  color: var(--gold);
}

/* boss modal */
.boss-box { border-color: var(--red); }
.boss-icon { font-size: 3.4rem; animation: pulse 2s infinite; }
.boss-name { color: var(--red); margin: 12px 0 6px; }
.boss-desc { font-size: 1.15rem; font-weight: 600; }

/* settings */
.settings-list { display: flex; flex-direction: column; gap: 4px; text-align: left; }
.setting-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 1.1rem; font-weight: 600;
  padding: 10px 4px;
  border-bottom: 2px dashed rgba(128,128,128,.2);
  cursor: pointer;
}
.toggle { appearance: none; width: 52px; height: 28px; border: 2px solid var(--line); border-radius: 999px; background: var(--panel-deep); position: relative; cursor: pointer; flex: none; }
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--ink-dim);
  transition: transform .15s, background .15s;
}
.toggle:checked { background: var(--green); }
.toggle:checked::after { transform: translateX(24px); background: #fff; }
.version-line { margin-top: 14px; color: var(--ink-dim); font-size: .85rem; }

/* stats modal */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; }
.stats-grid .srow {
  background: var(--panel-deep);
  border: 2px solid var(--line); border-radius: 8px;
  padding: 8px 10px;
}
.stats-grid .srow small { display: block; color: var(--ink-dim); font-size: .82rem; font-weight: 700; text-transform: uppercase; }
.stats-grid .srow b { font-size: 1.25rem; }
.joker-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.joker-gallery .jg {
  aspect-ratio: 1;
  display: grid; place-items: center;
  font-size: 1.4rem;
  background: var(--panel-deep);
  border: 2px solid var(--line); border-radius: 8px;
}
.joker-gallery .jg.locked { opacity: .35; filter: grayscale(1); }
.best-times { display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: 1.05rem; }
.best-times div { display: flex; justify-content: space-between; border-bottom: 2px dashed rgba(128,128,128,.2); padding: 4px 2px; }

/* leaderboard */
.board-list { display: flex; flex-direction: column; gap: 4px; text-align: left; max-height: 46dvh; overflow-y: auto; }
.board-row {
  display: grid;
  grid-template-columns: 2.2em 1fr auto;
  align-items: baseline;
  gap: 10px;
  padding: 7px 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel-deep);
  font-size: 1.02rem;
}
.board-row .br-rank { font-family: var(--font-display); font-size: .8rem; color: var(--ink-dim); }
.board-row .br-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .br-score { font-weight: 700; color: var(--gold); }
.board-row .br-meta { color: var(--ink-dim); font-size: .85rem; font-weight: 600; margin-left: 6px; }
.board-row.me { border-color: var(--gold); background: #3a2f10; }
html[data-theme="light"] .board-row.me { background: #ffedbb; }
.board-row:nth-child(1) .br-rank { color: var(--gold); }
.board-row:nth-child(2) .br-rank { color: #cfcfcf; }
.board-row:nth-child(3) .br-rank { color: #c98a4b; }
.board-you { margin-top: 10px; font-weight: 700; color: var(--gold); min-height: 1.3em; }
.rank-line { color: var(--cyan); font-weight: 700; }

.name-input {
  font-family: var(--font-body);
  font-size: 1.25rem; font-weight: 700;
  padding: 10px 12px; text-align: center;
  background: var(--panel-deep); color: var(--ink);
  border: var(--border-thick); border-radius: 8px;
  width: min(260px, 90%);
  margin-top: 10px;
}
.name-input:focus { outline: none; border-color: var(--gold); }

/* keyboard cursor */
.cell.kb-cursor { outline: 3px solid var(--cyan); outline-offset: 1px; z-index: 2; }

/* how-to — long-form text gets extra reading ergonomics for the pixel font */
.how-body { text-align: left; display: flex; flex-direction: column; gap: 16px; }
.how-row { display: flex; gap: 12px; align-items: flex-start; }
.how-icon { font-size: 1.5rem; flex: none; width: 36px; text-align: center; }
.how-row p { font-size: 1.08rem; line-height: 1.6; color: var(--ink); }
.how-row b { color: var(--gold); }
.msg-body { line-height: 1.55; }

/* ---- Float text / toasts --------------------------------------------------- */
.float-text {
  position: fixed; z-index: 90;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--gold);
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000;
  pointer-events: none;
  animation: floatUp 1.4s ease-out forwards;
  white-space: nowrap;
}
.float-text.danger { color: var(--red); }
.float-text.success { color: var(--green); }
.float-text.holo { color: var(--cyan); }
.float-text.small { font-size: .8rem; }
@keyframes floatUp {
  0% { opacity: 0; transform: translateX(-50%) translateY(6px) scale(.7); }
  12% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.05); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-56px) scale(1); }
}

#toasts {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(10px + var(--safe-top));
  z-index: 120;
  display: flex; flex-direction: column; gap: 8px;
  width: min(94vw, 420px);
  pointer-events: none;
}
.toast {
  background: var(--panel);
  border: var(--border-thick); border-radius: 10px;
  box-shadow: var(--shadow-btn);
  padding: 10px 14px;
  font-weight: 700; font-size: 1rem;
  text-align: center;
  animation: toastIn .2s ease-out, toastOut .3s ease-in forwards;
  animation-delay: 0s, var(--ttl, 2.2s);
}
.toast.gold { border-color: var(--gold); color: var(--gold); }
.toast.danger { border-color: var(--red); color: var(--red); }
.toast.success { border-color: var(--green); color: var(--green); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* ---- Shake ------------------------------------------------------------------ */
@keyframes shakeAnim {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-7px, 4px); }
  40% { transform: translate(8px, -5px); }
  60% { transform: translate(-6px, -4px); }
  80% { transform: translate(5px, 5px); }
}
.shake { animation: shakeAnim .35s ease-out; }
.shake-hard { animation: shakeAnim .5s ease-out; animation-iteration-count: 2; }

/* ---- Responsive --------------------------------------------------------------- */
@media (max-width: 480px) {
  body { font-size: 16px; }
  #app { padding-left: 8px; padding-right: 8px; }
  .panel { padding: 12px; }
  .hud-title b { font-size: .75rem; }
  .hud-timer { font-size: .75rem; }
  .stat { padding: 3px 8px; font-size: .92rem; }
  .stat b { font-size: 1rem; }
  .shop-jokers { flex-direction: row; }
  .board-wrap { max-height: calc(100dvh - 292px); }
}

@media (min-width: 900px) {
  .home-cards { max-width: 520px; }
  .board-wrap { max-height: calc(100dvh - 260px); }
}

/* ---- Reduced motion ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .felt-bg { animation: none; }
  .logo-creeper { animation: none; }
  .cell.revealed { animation: none; }
  .cell.holo { animation-duration: 8s; }
  .shake, .shake-hard { animation: none; }
  .screen { animation: none; }
}

html[data-fx="off"] .felt-bg { animation: none; }
html[data-fx="off"] .cell.revealed { animation: none; }
