:root {
  --bg: #0b0f24;
  --bg2: #121735;
  --panel: #161c40;
  --panel2: #1d2452;
  --line: #2a3270;
  --text: #e9ecff;
  --muted: #8f97c9;
  --accent: #00e1a0;
  --accent2: #00b884;
  --gold: #ffc400;
  --pink: #ff2d78;
  --danger: #ff4d6d;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 70% -10%, #2a1d6b55, transparent 60%),
    radial-gradient(900px 500px at 0% 110%, #003d4f55, transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
html { touch-action: manipulation; }
input { font-size: 16px !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tab-lock { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: #05081ce6; backdrop-filter: blur(6px); padding: 20px; }
.tab-lock[hidden] { display: none; }
.tab-lock-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 26px; max-width: 360px; text-align: center; display: grid; gap: 10px; justify-items: center; }
.tab-lock-card h2 { margin: 6px 0 0; font-size: 20px; }
.tab-lock-card p { margin: 0 0 8px; color: var(--muted); }
.logo-dot.big { width: 46px; height: 46px; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }

#app { display: flex; flex-direction: column; height: 100dvh; min-height: 100vh; }
@supports (height: 100dvh) { #app { min-height: 0; } }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: #0e1330cc; border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px); position: relative; z-index: 5;
}
.logo { font-weight: 900; letter-spacing: .14em; font-size: 20px; display: flex; align-items: center; gap: 8px;
  background: linear-gradient(90deg, #fff, #9fffe0 40%, var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo-dot { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff8c8, var(--gold) 55%, #b37400); box-shadow: 0 0 12px #ffc40099; }
.wallet { display: flex; align-items: center; gap: 8px; margin-left: auto; min-width: 0; }
#balance { white-space: nowrap; }
.balance { min-width: 0; display: flex; align-items: center; gap: 8px; background: var(--bg2); border: 1px solid var(--line); padding: 7px 14px; border-radius: 999px; font-weight: 800; font-size: 17px; transition: box-shadow .25s, border-color .25s; }
.balance.up { border-color: var(--accent); box-shadow: 0 0 18px #00e1a055; }
.balance.down { border-color: #ff4d6d88; }
.coin { width: 18px; height: 18px; border-radius: 50%; flex: none; background: radial-gradient(circle at 35% 30%, #fff6c2, var(--gold) 50%, #c98a00); box-shadow: inset 0 0 0 2px #ffdf6a, 0 0 6px #ffc40066; }
.coin.sm { width: 15px; height: 15px; }
.refill { background: linear-gradient(180deg, #ffd84d, #ffb300); color: #2b1d00; font-weight: 800; padding: 7px 12px; border-radius: 999px; font-size: 13px; box-shadow: 0 0 16px #ffc40066; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 26px #ffc400cc, 0 0 0 3px #ffc40055; } }
.top-actions { display: flex; gap: 4px; margin-left: 4px; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--panel2); color: var(--text); }
.icon-btn svg { width: 21px; height: 21px; fill: currentColor; }
#soundBtn .ico-off { display: none; }
#soundBtn[aria-pressed="false"] .ico-on { display: none; }
#soundBtn[aria-pressed="false"] .ico-off { display: block; }

/* Layout */
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 330px 1fr; gap: 14px; padding: 14px; padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.stage { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 10px; background: linear-gradient(180deg, #121a46, #0d1233); border: 1px solid var(--line); border-radius: 16px; padding: 10px; position: relative; overflow: hidden; }
.board-wrap { position: relative; flex: 1; min-height: 0; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: manipulation; }

/* Controls */
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg2); border-radius: 999px; padding: 4px; }
.tab { padding: 8px; border-radius: 999px; font-weight: 700; color: var(--muted); transition: background .2s, color .2s; }
.tab.active { background: #2b3482; color: #fff; box-shadow: 0 2px 8px #0006; }
.tab:disabled { opacity: .6; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field label:not(.switch), .lbl { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 8px; }
.field.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field.two > div { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hint { text-transform: none; letter-spacing: 0; font-weight: 500; opacity: .8; }
.pill { background: var(--panel2); color: var(--text); border-radius: 6px; padding: 1px 8px; font-size: 13px; }
.bet-row { display: flex; gap: 6px; }
.input-wrap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; transition: border-color .15s; }
.input-wrap:focus-within { border-color: var(--accent); }
.input-wrap.bad { border-color: var(--danger); animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.input-wrap input, .txt { width: 100%; min-width: 0; background: transparent; border: 0; color: var(--text); font: inherit; font-weight: 700; padding: 10px 0; outline: none; font-variant-numeric: tabular-nums; }
.txt { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.txt:focus { border-color: var(--accent); }
.txt:disabled { opacity: .45; }
.chip-btn { background: var(--panel2); border-radius: 10px; padding: 0 11px; font-weight: 800; min-width: 40px; transition: background .15s; }
.chip-btn:hover:not(:disabled), .preset:hover:not(:disabled) { background: #283068; }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.preset { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 0; font-size: 13px; font-weight: 700; color: var(--muted); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg2); border-radius: 10px; padding: 4px; gap: 4px; }
.seg button { padding: 8px 4px; border-radius: 7px; font-weight: 700; color: var(--muted); transition: background .15s, color .15s; }
.seg button:hover:not(:disabled):not(.active) { color: var(--text); }
.seg button.active { background: #2b3482; color: #fff; box-shadow: 0 2px 8px #0006, inset 0 1px 0 #ffffff14; }
.seg button:disabled { opacity: .5; }
.seg button.active:disabled { opacity: .75; }
#riskSeg button[data-risk="low"].active { box-shadow: inset 0 -3px 0 #3dffa0, 0 2px 8px #0006; }
#riskSeg button[data-risk="medium"].active { box-shadow: inset 0 -3px 0 var(--gold), 0 2px 8px #0006; }
#riskSeg button[data-risk="high"].active { box-shadow: inset 0 -3px 0 #ff4d7d, 0 2px 8px #0006; }
.seg.sm button { padding: 7px 4px; font-size: 13px; }
.adj-row { display: grid; grid-template-columns: 1fr 96px; gap: 8px; }
.pct-wrap { position: relative; }
.pct-wrap span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; }
.pct-wrap .txt { padding-right: 26px; }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 26px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: linear-gradient(90deg, var(--accent) var(--p, 100%), #2f3878 var(--p, 100%)); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 6px; background: #2f3878; }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px #00e1a055, 0 2px 6px #0008; }
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: #fff; }
input[type=range]:disabled { opacity: .45; }
.lock-note { font-size: 12px; color: var(--gold); opacity: .85; }

.drop-btn { width: 100%; padding: 15px; border-radius: 12px; font-weight: 900; font-size: 17px; letter-spacing: .04em; color: #002b1e;
  background: linear-gradient(180deg, #2bffbf, var(--accent) 50%, var(--accent2)); box-shadow: 0 6px 22px #00e1a044, inset 0 -3px 0 #0006; transition: transform .08s, filter .15s, box-shadow .15s; }
.drop-btn:hover:not(:disabled) { filter: brightness(1.08); box-shadow: 0 8px 30px #00e1a066, inset 0 -3px 0 #0006; }
.drop-btn:active:not(:disabled) { transform: translateY(2px) scale(.99); }
.drop-btn:disabled { filter: grayscale(.7) brightness(.7); }
.drop-btn.stop { background: linear-gradient(180deg, #ff7a96, var(--danger)); color: #2b0010; box-shadow: 0 6px 22px #ff4d6d44, inset 0 -3px 0 #0006; }
.drop-btn.mobile-first { display: block; }
.auto-status { text-align: center; font-size: 13px; color: var(--muted); font-weight: 600; }
.fineprint { margin: auto 0 0; font-size: 11.5px; color: #6c74a8; text-align: center; }

/* History */
.history { display: flex; gap: 6px; height: 30px; overflow: hidden; padding: 0 2px; mask-image: linear-gradient(90deg, #000 85%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); }
.hchip { flex: none; min-width: 48px; height: 30px; padding: 0 8px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #1a0c00; animation: chipIn .3s cubic-bezier(.2,1.4,.4,1); font-variant-numeric: tabular-nums; }
@keyframes chipIn { from { transform: translateX(-24px) scale(.6); opacity: 0; } }

.stage-top { display: flex; align-items: center; gap: 10px; flex: none; }
.stage-top .history { flex: 1; min-width: 0; }
.session { flex: none; display: flex; align-items: center; gap: 8px; background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; height: 30px; }
.session b { font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.session b.pos { color: var(--accent); }
.session b.neg { color: var(--danger); }

.tooltip { position: absolute; transform: translate(-50%, -100%); background: #0b0f24f2; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; pointer-events: none; white-space: nowrap; box-shadow: 0 8px 24px #000a; z-index: 3; }
.tooltip b { font-size: 15px; }
.tooltip .row { display: flex; justify-content: space-between; gap: 14px; color: var(--muted); }
.tooltip .row span:last-child { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }

/* FX + banner + toasts */
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20; }
.banner { position: fixed; left: 50%; top: 38%; padding: 18px 40px; border-radius: 50%; background: radial-gradient(closest-side, #05081cd0, #05081c80 60%, transparent); transform: translate(-50%, -50%) scale(.6); opacity: 0; pointer-events: none; z-index: 21; text-align: center; transition: opacity .25s, transform .35s cubic-bezier(.2,1.6,.4,1); }
.banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.banner .t { line-height: 1.05; font-size: clamp(28px, 7vw, 64px); font-weight: 900; letter-spacing: .06em; background: linear-gradient(180deg, #fff, var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 4px 18px #ffc40088); }
.banner.mega .t { background: linear-gradient(180deg, #fff, #ff7ab0 50%, var(--pink)); -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 4px 24px #ff2d78aa); }
.banner .s { font-size: clamp(18px, 4vw, 30px); font-weight: 800; color: #fff; text-shadow: 0 2px 12px #000; font-variant-numeric: tabular-nums; }
.toasts { position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%); width: max-content; max-width: calc(100vw - 24px); text-align: center; display: flex; flex-direction: column; gap: 8px; z-index: 30; pointer-events: none; align-items: center; }
.toast { background: #1d2452f2; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; font-weight: 600; box-shadow: 0 8px 24px #000a; animation: toastIn .25s ease-out; }
.toast.out { opacity: 0; transform: translateY(-8px); transition: .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }
body.shake .layout { animation: bigshake .5s; }
@keyframes bigshake { 10%,50%,90% { transform: translate(-5px, 2px); } 30%,70% { transform: translate(5px, -2px); } }

/* Dialogs */
.dlg { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 18px; width: min(460px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 30px 80px #000c; }
.dlg.wide { width: min(620px, calc(100vw - 24px)); }
.dlg.small { width: min(360px, calc(100vw - 24px)); }
.dlg::backdrop { background: #04061399; backdrop-filter: blur(3px); }
.dlg[open] { animation: dlgIn .22s ease-out; }
@keyframes dlgIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dlg-head h2 { margin: 0; font-size: 20px; }
.x { width: 34px; height: 34px; border-radius: 8px; color: var(--muted); font-size: 16px; }
.x:hover { background: var(--panel2); color: var(--text); }
.dlg .field { margin-bottom: 14px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.ghost, .primary { padding: 9px 14px; border-radius: 10px; font-weight: 700; }
.ghost { background: var(--panel2); }
.ghost:hover { background: #283068; }
.ghost.danger { color: #ff8aa0; }
.primary { background: var(--accent); color: #002b1e; }
.primary.danger { background: var(--danger); color: #2b0010; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { background: var(--bg2); border-radius: 10px; padding: 10px 12px; }
.stat span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.stat b { font-size: 17px; font-variant-numeric: tabular-nums; }
.stat b.pos { color: var(--accent); } .stat b.neg { color: var(--danger); }
.chart-box { margin-top: 10px; background: var(--bg2); border-radius: 10px; padding: 8px; }
#chart { width: 100%; height: 160px; display: block; }
.chart-label { font-size: 12px; color: var(--muted); text-align: center; margin-top: 4px; }
.balls { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.ballopt { aspect-ratio: 1; border-radius: 12px; background: var(--bg2); display: grid; place-items: center; border: 2px solid transparent; }
.ballopt.active { border-color: var(--accent); }
.ballopt i { width: 26px; height: 26px; border-radius: 50%; display: block; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sw { width: 44px; height: 26px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); position: relative; transition: background .2s; flex: none; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + .sw { background: var(--accent2); }
.switch input:checked + .sw::after { transform: translateX(18px); }
.switch input:focus-visible + .sw { outline: 2px solid var(--accent); outline-offset: 2px; }
.keys { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
kbd { background: var(--bg2); border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 6px; padding: 1px 7px; font: 700 12px system-ui; color: var(--text); margin-right: 4px; }
.howto { padding-left: 20px; margin: 0 0 10px; display: grid; gap: 6px; }
.fair { color: var(--muted); font-size: 13.5px; background: var(--bg2); padding: 10px 12px; border-radius: 10px; }
.dlg h3 { font-size: 15px; margin: 14px 0 8px; }
.odds { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.odd { background: var(--bg2); border-radius: 8px; padding: 6px 8px; font-size: 12px; color: var(--muted); border-left: 4px solid; font-variant-numeric: tabular-nums; }
.odd b { display: block; color: var(--text); font-size: 14px; }
#confirmText { margin: 4px 0 6px; font-size: 15.5px; }

/* Responsive */
@media (max-width: 820px) {
  #app { height: auto; min-height: 100dvh; }
  .layout { display: flex; flex-direction: column-reverse; padding: 8px; gap: 8px; }
  .stage { height: min(66dvh, calc(100vw * 1.02 + 60px)); min-height: 280px; flex: none; padding: 8px; }
  .panel { overflow: visible; }
  .tabs { order: 0; }
  .drop-btn.desk { display: none; }
  .topbar { padding: 8px 10px; gap: 8px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .logo { font-size: 17px; }
  .balance { font-size: 15px; padding: 6px 11px; }
  .icon-btn { width: 36px; height: 36px; }
  .fineprint { margin-top: 4px; }
  .session { padding: 4px 10px; }
}
@media (max-width: 480px) {
  .layout { padding: 6px; gap: 6px; }
  .stage { padding: 6px; }
  .balance.long { font-size: 13px; padding: 6px 9px; }
  .balance.xlong { font-size: 11.5px; }
  .logo { font-size: 0; gap: 0; }
  .logo-dot { width: 20px; height: 20px; }
  .top-actions { gap: 0; margin-left: 0; }
  .icon-btn { width: 34px; }
  .refill { padding: 6px 9px; font-size: 12px; }
  .session span { display: none; }
  .wallet:has(.refill:not([hidden])) .balance { font-size: 13px; padding: 6px 9px; }
  .wallet:has(.refill:not([hidden])) .balance .coin { display: none; }
  .topbar:has(.refill:not([hidden])) .logo { display: none; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .layout { flex-direction: row; }
  .drop-btn.desk { display: none; }
  #app { height: 100dvh; }
  .layout { display: grid; grid-template-columns: 260px 1fr; padding: 6px; gap: 6px; flex: 1; padding-left: max(6px, env(safe-area-inset-left)); padding-right: max(6px, env(safe-area-inset-right)); }
  .stage { height: auto; min-height: 0; padding: 6px; gap: 6px; }
  .panel { overflow-y: auto; padding: 8px 10px; gap: 8px; }
  .drop-btn.mobile-first { padding: 9px; font-size: 15px; }
  .topbar { padding: 4px 10px; }
  .tab { padding: 5px; }
  .field { gap: 4px; }
  .input-wrap .coin { display: none; }
  .chip-btn { padding: 0 8px; min-width: 34px; }
  .input-wrap input, .txt { padding: 7px 0; }
  .txt { padding: 7px 10px; }
  .seg button { padding: 6px 4px; }
  .fineprint { display: none; }
  .history, .hchip, .session { height: 24px; }
  .session span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .banner { transition: opacity .2s !important; transform: translate(-50%, -50%) !important; }
}

/* ===================== v2 additions ===================== */
.cash { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: #0f6b3f; color: #8dffbf; font-weight: 900; font-size: 13px; flex: none; box-shadow: inset 0 0 0 2px #2fd17f; }
.cur { color: var(--accent); font-weight: 900; }
.hint2 { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Money bar */
.money-bar { display: flex; gap: 6px; flex: none; overflow-x: auto; scrollbar-width: none; }
.money-bar::-webkit-scrollbar { display: none; }
.mb-item { flex: 1 0 auto; min-width: 74px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 5px 10px; display: flex; flex-direction: column; justify-content: center; }
.mb-item span { font-size: 10.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.mb-item span i { font-style: normal; color: var(--text); }
.mb-item b { font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mb-item b.pos { color: var(--accent); } .mb-item b.neg { color: var(--danger); }
.mb-main { min-width: 120px; border-color: #2fd17f66; background: linear-gradient(180deg, #0f2a26, var(--bg2)); }
.mb-main b { font-size: 17px; color: #8dffbf; }
.mb-lvl { min-width: 96px; }
.xp { height: 6px; border-radius: 6px; background: #2f3878; margin-top: 5px; overflow: hidden; }
.xp-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width .3s; }
.legend { flex: none; display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 800; color: var(--muted); background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 0 10px; height: 30px; white-space: nowrap; }
.lg { width: 11px; height: 11px; border-radius: 50%; display: inline-block; margin-left: 4px; }
.lg.bouncy, .sb.bouncy { background: #ff3b3b; }
.lg.rainbow, .sb.rainbow { background: conic-gradient(#ff2d6a, #ffc400, #9dff2e, #00f0ff, #9d7bff, #ff2d6a); }
.lg.golden, .sb.golden { background: radial-gradient(circle at 35% 30%, #fff8c8, #ffd000 55%, #a86b00); box-shadow: 0 0 6px #ffd000; }
.sb { padding: 0 6px; border-radius: 6px; color: #120a00; font-weight: 800; }
.sb.rainbow { color: #fff; text-shadow: 0 1px 2px #000; }
.hchip.k-bouncy { box-shadow: 0 0 0 2px #ff3b3b; }
.hchip.k-rainbow { box-shadow: 0 0 0 2px #9d7bff, 0 0 10px #00f0ff; }
.hchip.k-golden { box-shadow: 0 0 0 2px #fff3a0, 0 0 12px #ffd000; }

/* Chip rack (Scratch-style chips, round casino look) */
.chips { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.chip { position: relative; aspect-ratio: 1; border-radius: 50%; font-weight: 900; font-size: 11.5px; color: #111; display: grid; place-items: center;
  background: radial-gradient(circle, var(--c1) 0 52%, transparent 53%), repeating-conic-gradient(var(--c2) 0 15deg, #ffffffcc 15deg 30deg);
  box-shadow: inset 0 0 0 2px #0005, 0 2px 4px #0008; transition: transform .1s, box-shadow .15s; letter-spacing: -.02em; }
.chip span { position: relative; text-shadow: 0 1px 0 #fff6; }
.chip.dark span { color: #fff; text-shadow: 0 1px 2px #000; }
.chip:hover:not(:disabled) { transform: translateY(-2px); }
.chip.active { box-shadow: inset 0 0 0 2px #0005, 0 0 0 2px #fff, 0 0 12px var(--c2); }
.chip:disabled { opacity: .35; filter: grayscale(.6); }
.chip.cant { opacity: .45; }

.seg.multi { grid-auto-columns: 1fr; }
.seg.multi button { padding: 7px 0; font-variant-numeric: tabular-nums; }
.drop-cost { text-align: center; font-size: 12px; color: var(--muted); margin-top: -6px; min-height: 15px; font-variant-numeric: tabular-nums; }
.drop-cost.bad { color: var(--danger); }
.desk-drop { position: sticky; bottom: 0; z-index: 1; display: flex; flex-direction: column; gap: 8px; background: var(--panel); padding-top: 4px; }
.desk-drop .drop-btn.desk { position: static; }
.desk-drop .drop-cost.desk { margin-top: -2px; }

/* Work / shop / trophies */
.actions { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 6px; }
.act { position: relative; overflow: hidden; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 6px; font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.act:hover:not(:disabled) { background: #232a5e; }
.act .ico { position: relative; }
.act .txt2 { position: relative; white-space: nowrap; font-variant-numeric: tabular-nums; }
.act .fill { position: absolute; inset: 0; width: 0; background: linear-gradient(90deg, #0f6b3f, #2fd17f); opacity: .55; }
.act.working { border-color: #2fd17f; }
.act.dot::after { content: ""; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--pink); box-shadow: 0 0 6px var(--pink); }

.shop-money { color: var(--muted); margin-bottom: 10px; }
.shop-money b { color: #8dffbf; font-size: 16px; }
.shop { display: grid; gap: 8px; }
.item { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.item .big { font-size: 26px; text-align: center; }
.item h4 { margin: 0; font-size: 15px; }
.item p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.pips { display: flex; gap: 3px; margin-top: 5px; }
.pips i { width: 16px; height: 5px; border-radius: 3px; background: #2f3878; }
.pips i.on { background: var(--gold); }
.buy { background: var(--accent); color: #002b1e; font-weight: 900; padding: 9px 12px; border-radius: 10px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.buy:disabled { background: #2f3878; color: var(--muted); }
.buy.owned { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.ach { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; gap: 10px; align-items: center; opacity: .5; filter: grayscale(1); }
.ach.got { opacity: 1; filter: none; border-color: #ffc40088; background: linear-gradient(180deg, #2a2410, var(--bg2)); }
.ach .medal { font-size: 24px; }
.ach b { font-size: 13.5px; display: block; }
.ach small { color: var(--muted); font-size: 12px; }
.ballopt.locked { opacity: .45; }
.ballopt.locked::after { content: "🔒"; position: absolute; font-size: 12px; }
.ballopt { position: relative; }
.balls { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); }
.toast.ach-t { border-color: var(--gold); background: #2a2410f2; }

@media (max-width: 820px) {
  .money-bar { gap: 5px; }
  .mb-item { min-width: 64px; padding: 4px 8px; }
  .mb-main { min-width: 104px; }
  .mb-item b { font-size: 13px; }
  .mb-main b { font-size: 15px; }
  .stage { height: min(72dvh, calc(100vw * 1.02 + 110px)); }
  .legend { display: none; }
}
@media (max-width: 480px) {
  .mb-job, .mb-item:nth-child(3) { display: none; }
  .chips { grid-template-columns: repeat(6, 1fr); gap: 4px; }
  .chip { font-size: 9.5px; }
  .act { font-size: 12px; padding: 8px 4px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .money-bar .mb-item { padding: 2px 8px; }
  .mb-item span { font-size: 9.5px; }
  .mb-job, .mb-lvl, .mb-item:nth-child(3) { display: none; }
  .legend { display: none; }
  .chips { grid-template-columns: repeat(6, 1fr); gap: 4px; }
  .chip { font-size: 9px; }
  .drop-cost { margin-top: -4px; }
}

.toasts.in-dlg { position: sticky; top: 0; left: auto; transform: none; width: auto; max-width: none; margin-bottom: 8px; z-index: 2; }
.shop-h { margin: 14px 0 8px; font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.buy { min-width: 108px; display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.buy small { font-size: 10.5px; font-weight: 700; opacity: .85; }
.buy.cant { background: #252c63; color: #c3c9f5; }
.pips i { background: #3b4590; }
input[type=range]:disabled::-webkit-slider-runnable-track { background: #2f3878; }
input[type=range]:disabled::-webkit-slider-thumb { background: #8f97c9; box-shadow: none; }
.m-drop { display: none; }
.act .txt2 { overflow: hidden; text-overflow: ellipsis; }
.actions { grid-template-columns: 1.5fr 1fr 1fr; }
@media (max-width: 820px) {
  .m-drop { display: flex; flex-direction: column; gap: 6px; order: -1; position: sticky; top: 0; z-index: 3; background: var(--panel); padding-bottom: 4px; }
  .drop-cost.mobile-first { margin-top: 0; }
  .drop-cost.desk { display: none; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .m-drop { display: flex; flex-direction: column; gap: 4px; order: -1; position: sticky; top: 0; z-index: 3; background: var(--panel); padding-bottom: 2px; }
  .drop-cost.mobile-first { margin-top: 0; }
  .drop-cost.desk { display: none; }
  .actions .act { padding: 6px 4px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .stage-top { display: none; }
  .stage { height: auto; min-height: 0; }
  .money-bar { gap: 4px; }
  .money-bar .mb-item { flex-direction: row; align-items: center; gap: 6px; padding: 0 8px; height: 24px; min-width: 0; }
  .money-bar .mb-item b { font-size: 12.5px; }
  .money-bar .mb-main b { font-size: 13px; }
}

/* toasts: out of the way, never block taps */
.toasts { top: auto; bottom: max(16px, env(safe-area-inset-bottom)); left: auto; right: 16px; transform: none; align-items: flex-end; }
.toast { font-size: 13.5px; padding: 8px 12px; background: #1d2452e6; backdrop-filter: blur(4px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
.toast.out { transform: translateY(8px); }
@media (max-width: 820px) {
  .topbar { position: sticky; top: 0; }
  .toasts { left: 50%; right: auto; transform: translateX(-50%); align-items: center; bottom: max(10px, env(safe-area-inset-bottom)); }
}
.act { gap: 4px; padding: 9px 4px; }
.lg.golden { box-shadow: 0 0 0 1.5px #fff, 0 0 6px #ffd000; }

/* final toast placement: slim pill under the header, centred, never intercepts taps */
.toasts { top: calc(58px + env(safe-area-inset-top)); bottom: auto; left: 50%; right: auto; transform: translateX(-50%); align-items: center; pointer-events: none; }
.toast { font-size: 13px; padding: 6px 14px; border-radius: 999px; white-space: nowrap; max-width: calc(100vw - 24px); overflow: hidden; text-overflow: ellipsis; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }
.toast.out { transform: translateY(-6px); }
@media (max-width: 820px) { .toasts { top: calc(50px + env(safe-area-inset-top)); bottom: auto; } }
@media (orientation: landscape) and (max-height: 500px) {
  .toasts { top: calc(40px + env(safe-area-inset-top)); }
  .actions { grid-template-columns: 1.6fr 1fr 1fr; gap: 4px; }
  .actions .act { font-size: 11px; gap: 3px; }
  .money-bar .mb-main { min-width: 0; }
  .act.dot::after { top: 3px; right: 3px; width: 6px; height: 6px; }
}
.act.dot::after { top: 4px; right: 4px; }

/* landscape phones: toasts go to the bottom-right corner of the board (over the empty side of the buckets row is avoided) */
@media (orientation: landscape) and (max-height: 500px) {
  .toasts { top: auto; bottom: max(6px, env(safe-area-inset-bottom)); left: auto; right: max(8px, env(safe-area-inset-right)); transform: none; align-items: flex-end; }
  .toast { font-size: 11.5px; padding: 4px 10px; max-width: 46vw; }
  .money-bar .mb-main { display: none; }
  .panel { padding-bottom: 14px; }
}
/* keep the floating toast clear of the board stats on desktop: sit inside the header band */
@media (min-width: 821px) { .toasts { top: calc(10px + env(safe-area-inset-top)); } }

@media (orientation: landscape) and (max-height: 500px) {
  /* landscape phones: toast floats over the top of the board (balls spawn in the middle), never over buckets */
  .toasts { top: calc(48px + env(safe-area-inset-top)); bottom: auto; left: auto; right: max(10px, env(safe-area-inset-right)); align-items: flex-end; }
  .panel { scrollbar-width: none; }
  .panel::-webkit-scrollbar { display: none; }
}

@media (max-width: 820px), (orientation: landscape) and (max-height: 500px) {
  .desk-drop { display: none; }
}
@media (max-width: 820px) {
  /* phones: toast sits just under the money bar, over the empty spawn area of the board */
  .toasts { top: calc(132px + env(safe-area-inset-top)); }
}
@media (orientation: landscape) and (max-height: 500px) {
  .toasts { top: auto; bottom: calc(46px + env(safe-area-inset-bottom)); left: auto; right: max(10px, env(safe-area-inset-right)); transform: none; }
}

.buy { min-width: 132px; }
.buy.cant { opacity: .75; cursor: not-allowed; }
.toasts.in-dlg { position: sticky; top: -18px; margin: -18px -18px 10px; padding-top: 10px; background: linear-gradient(var(--panel) 70%, transparent); align-items: center; }
.toasts.in-dlg:empty { display: none; }

.toasts.in-dlg { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); margin: 0; padding: 0; background: none; width: max-content; max-width: calc(100% - 190px); }
.toasts.in-dlg .toast { font-size: 12.5px; padding: 5px 12px; }
.buy { min-width: 150px; }
@media (max-width: 480px) { .buy { min-width: 112px; padding: 8px; } .item { grid-template-columns: 34px 1fr auto; gap: 8px; } .toasts.in-dlg { max-width: calc(100% - 120px); } }

/* in-dialog toasts: a slim banner pinned to the bottom edge of the dialog, above the content */
.dlg { position: relative; }
.toasts.in-dlg { position: sticky; top: auto; bottom: -18px; left: auto; transform: none; width: auto; max-width: none; margin: 8px -18px -18px; padding: 8px 12px 12px; background: linear-gradient(transparent, var(--panel) 35%); align-items: center; z-index: 2; }

/* hold-to-rapid-fire */
.drop-btn { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.drop-btn.holding { transform: translateY(2px) scale(.985); filter: brightness(1.12) saturate(1.2); box-shadow: 0 0 0 3px #ffffff55, 0 0 28px #00e1a0aa, inset 0 -3px 0 #0006; animation: rapid .18s linear infinite alternate; }
@keyframes rapid { to { box-shadow: 0 0 0 3px #ffc40088, 0 0 36px #ffc400aa, inset 0 -3px 0 #0006; } }
@media (prefers-reduced-motion: reduce) { .drop-btn.holding { animation: none; } }
