/* =========================================================
   THEMES: every colour/font/shape lives here as a token.
   The rest of the file only uses var(--...).
   ========================================================= */

:root, :root[data-theme="arcade"] {
  --font: 'Press Start 2P', monospace;
  --title-font: 'Press Start 2P', monospace;
  --btn-font: 'Press Start 2P', monospace;
  --title-size: 17px; --h2-size: 14px; --stat-size: 11px; --card-size: 10px; --small-size: 9px;
  --btn-size: 16px; --buy-size: 9px; --banner-size: 10px; --body-line: 1.7;
  --bg: repeating-linear-gradient(0deg, rgba(0,0,0,.25) 0 2px, transparent 2px 4px), #0d0d1a;
  --bg-solid: #0d0d1a;
  --text: #e8ffe8;
  --title: #ffe600;
  --title-shadow: 3px 3px 0 #e4002b, 6px 6px 0 #000;
  --panel: #111; --panel-border: 3px solid #00e5ff; --panel-shadow: 4px 4px 0 #000; --radius: 0;
  --machine-bg: #e4002b; --machine-border: 4px solid #000;
  --machine-shadow: 8px 8px 0 #000, inset 0 0 0 4px #ffe600; --machine-radius: 0; --machine-pad: 18px 14px;
  --bulb: #ffe600; --bulb2: #00e5ff; --bulb-radius: 0;
  --reels-bg: #000; --reel-bg: #f4f0d8; --reel-radius: 0; --reel-border: 3px solid #000; --reel-fade: rgba(0,0,0,.35);
  --seven: #e4002b; --seven-shadow: 2px 2px 0 #000;
  --payline: #39ff14; --banner: #ffe600; --banner-hot: #39ff14;
  --btn-bg: #ffe600; --btn-text: #000; --btn-shadow: 0 6px 0 #a08f00, 6px 12px 0 #000; --btn-radius: 0;
  --btn-press-shadow: 0 2px 0 #a08f00, 2px 4px 0 #000;
  --icon-bg: #2b2b4a; --bar-bg: #333;
  --bar: repeating-linear-gradient(90deg, #39ff14 0 8px, #1a8f00 8px 10px);
  --locked-bg: #333; --locked-text: #888;
  --accent: #39ff14; --danger: #ff3355;
  --modal-bg: #111; --overlay: rgba(0,0,0,.82);
}

:root[data-theme="neon"] {
  --font: 'Poppins', sans-serif; --title-font: 'Monoton', cursive; --btn-font: 'Poppins', sans-serif;
  --title-size: 30px; --h2-size: 24px; --stat-size: 16px; --card-size: 15px; --small-size: 13px;
  --btn-size: 22px; --buy-size: 13px; --banner-size: 14px; --body-line: 1.45;
  --bg: radial-gradient(ellipse at top, #3b0f6b 0%, #1a0633 55%, #0b0218 100%); --bg-solid: #1a0633;
  --text: #f5e9ff; --title: #ffd54a;
  --title-shadow: 0 0 6px #ffb300, 0 0 18px #ff6ad5, 0 0 32px #b14dff;
  --panel: rgba(40,10,75,.85); --panel-border: 1px solid rgba(255,213,74,.35);
  --panel-shadow: 0 0 14px rgba(177,77,255,.35); --radius: 14px;
  --machine-bg: linear-gradient(160deg, #ffe58a, #c99a1e 35%, #7a5306 60%, #e6bc45);
  --machine-border: 2px solid #fff3c4;
  --machine-shadow: 0 0 30px rgba(255,200,60,.45), 0 0 70px rgba(177,77,255,.4);
  --machine-radius: 26px; --machine-pad: 16px 14px 18px;
  --bulb: #fff6c8; --bulb2: #ff5fd2; --bulb-radius: 50%;
  --reels-bg: #12031f; --reel-bg: linear-gradient(#fff, #f1e6ff 50%, #fff); --reel-radius: 10px;
  --reel-border: 2px solid #c99a1e; --reel-fade: rgba(30,5,60,.55);
  --seven: #e0007a; --seven-shadow: 0 0 6px #ff6ad5;
  --payline: #ff3db8; --banner: #3a1a00; --banner-hot: #fff;
  --btn-bg: linear-gradient(#ff4fb8, #c21b8a); --btn-text: #fff;
  --btn-shadow: 0 6px 0 #6d0b4c, 0 0 22px rgba(255,79,184,.7); --btn-radius: 999px;
  --btn-press-shadow: 0 2px 0 #6d0b4c, 0 0 22px rgba(255,79,184,.7);
  --icon-bg: linear-gradient(135deg, #ffd54a, #ff6ad5); --bar-bg: rgba(255,255,255,.12);
  --bar: linear-gradient(90deg, #ffd54a, #ff4fb8); --locked-bg: rgba(255,255,255,.1); --locked-text: #bba6d6;
  --accent: #ffd54a; --danger: #ff6b8b; --modal-bg: #24073f; --overlay: rgba(10,0,25,.85);
}

:root[data-theme="pastel"] {
  --font: 'Fredoka', sans-serif; --title-font: 'Pacifico', cursive; --btn-font: 'Fredoka', sans-serif;
  --title-size: 30px; --h2-size: 24px; --stat-size: 16px; --card-size: 16px; --small-size: 13px;
  --btn-size: 22px; --buy-size: 14px; --banner-size: 14px; --body-line: 1.45;
  --bg: radial-gradient(circle at 15% 10%, #ffd6e7 0 18%, transparent 19%),
        radial-gradient(circle at 90% 30%, #c9f2e3 0 14%, transparent 15%),
        radial-gradient(circle at 20% 85%, #fff0b8 0 12%, transparent 13%), #fff6ef;
  --bg-solid: #fff6ef; --text: #5a3d55; --title: #ff6f9f; --title-shadow: 2px 2px 0 #fff, 4px 4px 0 #ffc2d6;
  --panel: #fff; --panel-border: 2px solid #ffd1e0; --panel-shadow: 0 6px 16px rgba(255,111,159,.15); --radius: 20px;
  --machine-bg: linear-gradient(160deg, #ffb3cc, #ff8fb5 50%, #ffa9c6); --machine-border: 4px solid #fff;
  --machine-shadow: 0 14px 30px rgba(255,111,159,.35); --machine-radius: 34px; --machine-pad: 16px 14px 18px;
  --bulb: #fff; --bulb2: #b8f0dc; --bulb-radius: 50%;
  --reels-bg: #fff2f7; --reel-bg: #fff; --reel-radius: 16px; --reel-border: 2px solid #ffd1e0; --reel-fade: rgba(255,214,231,.5);
  --seven: #ff4f8b; --seven-shadow: 2px 2px 0 #ffd1e0;
  --payline: #7fd8be; --banner: #fff; --banner-hot: #fff;
  --btn-bg: linear-gradient(#8fe3c8, #5cc9a7); --btn-text: #fff;
  --btn-shadow: 0 6px 0 #3fa585, 0 10px 20px rgba(92,201,167,.4); --btn-radius: 24px;
  --btn-press-shadow: 0 2px 0 #3fa585;
  --icon-bg: linear-gradient(135deg, #ffe0ec, #d9f7ec); --bar-bg: #ffe6ef;
  --bar: linear-gradient(90deg, #ff8fb5, #ffd36e); --locked-bg: #f1e6ec; --locked-text: #b49aab;
  --accent: #5cc9a7; --danger: #ff4f8b; --modal-bg: #fff; --overlay: rgba(255,240,246,.9);
}

/* =========================================================
   LAYOUT (theme-agnostic)
   ========================================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh; min-height: 100dvh;
  font-family: var(--font); line-height: var(--body-line);
  background: var(--bg); background-color: var(--bg-solid); background-attachment: fixed;
  color: var(--text); padding: 16px 16px 40px; overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
.wrap { max-width: 430px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }

/* ---- Header ---- */
header { display: flex; flex-direction: column; align-items: center; gap: 12px; position: relative; }
h1 {
  font-family: var(--title-font); font-weight: 400; font-size: var(--title-size);
  text-align: center; line-height: 1.3; color: var(--title); text-shadow: var(--title-shadow);
  padding: 0 34px; user-select: none;
}
.mute {
  position: absolute; top: 0; right: 0; width: 34px; height: 34px; border-radius: var(--radius);
  background: var(--panel); border: var(--panel-border); color: var(--text); font-size: 16px;
  display: grid; place-items: center; font-family: sans-serif;
}
.stats { display: flex; gap: 10px; width: 100%; }
.pill {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 6px;
  border-radius: var(--radius); background: var(--panel); border: var(--panel-border);
  box-shadow: var(--panel-shadow); font-weight: 700; font-size: var(--stat-size); white-space: nowrap;
}
.pill small { opacity: .7; font-weight: 400; font-size: .75em; }
.pill.bump { animation: bump .35s ease-out; }
@keyframes bump { 40% { transform: scale(1.12); } }

/* ---- Machine ---- */
.machine {
  position: relative; padding: var(--machine-pad); border-radius: var(--machine-radius);
  background: var(--machine-bg); border: var(--machine-border); box-shadow: var(--machine-shadow);
}
.marquee { display: flex; justify-content: space-between; margin: -4px 4px 10px; }
.bulb { width: 10px; height: 10px; border-radius: var(--bulb-radius); background: var(--bulb); box-shadow: 0 0 8px var(--bulb); }
.bulb:nth-child(even) { background: var(--bulb2); box-shadow: 0 0 8px var(--bulb2); }
.machine.spinning .bulb { animation: blink .3s steps(1) infinite; }
.machine.spinning .bulb:nth-child(even) { animation-delay: .15s; }
.machine.hot .bulb { animation: blink .12s steps(1) infinite; }
.machine.hot .bulb:nth-child(even) { animation-delay: .06s; }
@keyframes blink { 50% { opacity: .15; box-shadow: none; } }

.reels {
  display: flex; gap: 8px; padding: 10px; position: relative;
  border-radius: max(0px, calc(var(--machine-radius) - 8px));
  background: var(--reels-bg); box-shadow: inset 0 4px 14px rgba(0,0,0,.45);
  --cell: clamp(52px, 17vw, 68px);
}
.reel {
  flex: 1; height: calc(var(--cell) * 3); overflow: hidden; position: relative;
  border-radius: var(--reel-radius); background: var(--reel-bg); border: var(--reel-border);
}
.reel::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(var(--reel-fade), transparent 30%, transparent 70%, var(--reel-fade));
}
.strip { position: absolute; left: 0; right: 0; top: 0; will-change: transform; }
.sym {
  height: var(--cell); display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cell) * .62); line-height: 1; user-select: none;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}
.sym.seven {
  font-family: 'Press Start 2P', 'Arial Black', sans-serif; font-weight: 900;
  font-size: calc(var(--cell) * .58); color: var(--seven); text-shadow: var(--seven-shadow);
}
.reel.win-glow { box-shadow: 0 0 0 3px var(--accent), 0 0 18px var(--accent); }
.payline {
  position: absolute; left: 4px; right: 4px; top: 50%; height: 3px; transform: translateY(-50%);
  background: var(--payline); box-shadow: 0 0 10px var(--payline); opacity: .8; pointer-events: none; z-index: 2;
}
.banner {
  text-align: center; margin-top: 12px; min-height: 1.6em; font-weight: 800; letter-spacing: .05em;
  font-size: var(--banner-size); color: var(--banner);
}
.machine.hot .banner { color: var(--banner-hot); animation: shake .25s linear infinite; }
.machine.hot .reels { animation: shake .25s linear infinite; }
@keyframes shake { 25% { transform: translateX(-2px) rotate(-.4deg); } 75% { transform: translateX(2px) rotate(.4deg); } }

.spin {
  display: block; width: 100%; margin-top: 12px; padding: 18px; border: none; border-radius: var(--btn-radius);
  font-family: var(--btn-font); font-size: var(--btn-size); font-weight: 800; letter-spacing: .08em;
  color: var(--btn-text); background: var(--btn-bg); box-shadow: var(--btn-shadow);
  transition: transform .08s, box-shadow .08s, filter .2s;
}
.spin:active:not(:disabled) { transform: translateY(4px); box-shadow: var(--btn-press-shadow); }
.spin:disabled { filter: grayscale(.6) brightness(.85); }
.spin.done { font-size: calc(var(--btn-size) * .7); line-height: 1.5; }

[hidden] { display: none !important; }

/* ---- Paytable ---- */
.paytable-box {
  border-radius: var(--radius); background: var(--panel); border: var(--panel-border);
  box-shadow: var(--panel-shadow); padding: 10px 14px;
}
.paytable-box summary {
  cursor: pointer; text-align: center; font-family: var(--title-font); font-size: var(--card-size);
  color: var(--title); list-style: none; user-select: none; padding: 4px 0;
}
.paytable-box summary::-webkit-details-marker { display: none; }
.paytable-box summary::after { content: " [+]"; }
.paytable-box[open] summary::after { content: " [-]"; }
.pt-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 5px 0; border-bottom: 1px dashed var(--bar-bg);
}
.pt-row:last-of-type { border-bottom: none; }
.pt-combo { display: flex; gap: 4px; }
.pt-sym {
  width: 30px; height: 30px; display: grid; place-items: center; font-size: 20px;
  background: var(--reel-bg); border-radius: var(--reel-radius); border: var(--reel-border);
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}
.pt-sym.seven { font-family: 'Press Start 2P', 'Arial Black', sans-serif; font-size: 16px; color: var(--seven); text-shadow: var(--seven-shadow); }
.pt-win { font-weight: 800; font-size: var(--card-size); color: var(--accent); text-align: right; }
.pt-win em { display: block; font-style: normal; font-size: var(--small-size); color: var(--title); }
.pt-top .pt-win { font-size: calc(var(--card-size) * 1.25); }
.pt-note { margin-top: 8px; font-size: var(--small-size); opacity: .75; text-align: center; }

/* ---- Shop ---- */
h2 {
  font-family: var(--title-font); font-weight: 400; font-size: var(--h2-size); color: var(--title);
  text-align: center; text-shadow: var(--title-shadow); margin-top: 6px;
}
.shop { display: flex; flex-direction: column; gap: 12px; }
.card {
  display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: var(--radius);
  background: var(--panel); border: var(--panel-border); box-shadow: var(--panel-shadow); position: relative;
}
.card .icon {
  width: 54px; height: 54px; flex: none; border-radius: var(--reel-radius); display: grid; place-items: center;
  font-size: 28px; background: var(--icon-bg); font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}
.card.locked .icon { filter: grayscale(1); opacity: .55; }
.card .icon img { max-width: 78%; max-height: 78%; object-fit: contain; display: block; }
.card .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.card .name { font-weight: 700; font-size: var(--card-size); }
.card .teaser { font-size: var(--small-size); opacity: .75; }
.bar { height: 8px; border-radius: 99px; background: var(--bar-bg); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--bar); transition: width .8s ease-out; }
.cost { font-size: var(--small-size); opacity: .85; }
.buy {
  flex: none; padding: 10px 12px; border: none; border-radius: var(--btn-radius); font-family: var(--btn-font);
  font-weight: 800; font-size: var(--buy-size); background: var(--btn-bg); color: var(--btn-text); box-shadow: var(--btn-shadow);
}
.buy:active:not(:disabled) { transform: translateY(3px); box-shadow: var(--btn-press-shadow); }
.buy:disabled { background: var(--locked-bg); color: var(--locked-text); box-shadow: none; }
.card.ready { animation: ready 1.2s ease-in-out infinite; }
.card.ready::before {
  content: "NEW!"; position: absolute; top: -10px; left: -6px; padding: 3px 6px; font-size: 9px;
  background: var(--danger); color: #fff; border-radius: var(--radius); font-family: var(--btn-font); transform: rotate(-8deg);
}
@keyframes ready { 50% { box-shadow: var(--panel-shadow), 0 0 0 3px var(--accent), 0 0 22px var(--accent); } }

/* ---- Modal & overlays ---- */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center;
  padding: 16px; background: var(--overlay);
}
.overlay.open { display: flex; animation: fade .25s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 420px; max-height: calc(100dvh - 32px); overflow-y: auto; padding: 18px;
  background: var(--modal-bg); border: var(--panel-border); border-radius: var(--radius); box-shadow: var(--panel-shadow);
  display: flex; flex-direction: column; gap: 14px; animation: pop .35s cubic-bezier(.2,1.4,.4,1);
}
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.modal h3 { font-family: var(--title-font); font-weight: 400; font-size: var(--h2-size); color: var(--title); text-align: center; line-height: 1.4; }
.modal img, .modal video { width: 100%; max-height: 60dvh; object-fit: contain; border-radius: var(--reel-radius); border: var(--reel-border); display: block; background: #000; }
.modal p { white-space: pre-wrap; font-size: var(--card-size); line-height: 1.8; }
.modal .spin { margin-top: 0; padding: 14px; font-size: calc(var(--btn-size) * .8); }

.jackpot { flex-direction: column; text-align: center; gap: 18px; }
.jackpot .big {
  font-family: var(--title-font); font-size: calc(var(--title-size) * 2); color: var(--title);
  text-shadow: var(--title-shadow); animation: zoom .8s ease-in-out infinite alternate; line-height: 1.3;
}
.jackpot .amount { font-family: var(--title-font); font-size: var(--title-size); color: var(--accent); }
.jackpot .spin { max-width: 320px; }
@keyframes zoom { to { transform: scale(1.12) rotate(-2deg); } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; padding: 12px 16px;
  background: var(--danger); color: #fff; border-radius: var(--radius); font-size: var(--small-size);
  display: none; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { display: block; animation: fade .2s; }

/* ---- Login ---- */
.login { min-height: calc(100dvh - 56px); justify-content: center; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login .machine { text-align: center; }
.login p { font-size: var(--small-size); text-align: center; color: var(--btn-text); }
:root[data-theme="arcade"] .login p { color: #fff; }
.login input {
  width: 100%; padding: 14px; font-family: var(--font); font-size: 16px; text-align: center;
  border: var(--reel-border); border-radius: var(--reel-radius); background: var(--reel-bg); color: #222;
}
.login .error { color: #fff; background: #000; padding: 8px; display: none; font-size: var(--small-size); }
.login .error.show { display: block; animation: shake .25s linear 2; }

/* ---- Dev panel ---- */
.dev-fab {
  position: fixed; right: 12px; bottom: 12px; z-index: 70; width: 46px; height: 46px; border-radius: 50%;
  border: 2px solid #fff; background: #222; color: #fff; font-size: 22px; font-family: sans-serif;
}
.dev-panel {
  position: fixed; inset: auto 8px 66px 8px; z-index: 70; max-width: 420px; margin: 0 auto; max-height: 70dvh; overflow-y: auto;
  background: #1b1b1b; color: #eee; border: 2px solid #ffe600; padding: 12px; font: 13px/1.4 system-ui, sans-serif;
  display: none; flex-direction: column; gap: 10px; border-radius: 8px;
}
.dev-panel.open { display: flex; }
.dev-panel h4 { font-size: 14px; color: #ffe600; }
.dev-panel .row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.dev-panel button, .dev-panel input, .dev-panel select {
  font: 13px system-ui, sans-serif; padding: 7px 9px; border-radius: 4px; border: 1px solid #555; background: #333; color: #fff;
}
.dev-panel input { width: 70px; }
.dev-panel button.warn { border-color: #ff3355; color: #ff8899; }
.dev-panel pre { background: #000; padding: 8px; font-size: 11px; overflow-x: auto; max-height: 160px; white-space: pre-wrap; word-break: break-all; }
.dev-badge {
  position: fixed; top: 6px; left: 6px; z-index: 70; background: #ffe600; color: #000; font: 700 10px system-ui, sans-serif;
  padding: 3px 6px; border-radius: 3px;
}

/* ---- Theme-specific extras ---- */
:root[data-theme="arcade"] .card { line-height: 1.6; }
:root[data-theme="pastel"] body::after {
  content: "🎈\A🎈"; white-space: pre; position: fixed; top: 70px; right: 6px; font-size: 30px; opacity: .8; pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .machine.hot .reels, .machine.hot .banner, .card.ready, .jackpot .big { animation: none; }
}
