@font-face { font-family: 'Cinzel'; font-weight: 600; src: url('assets/fonts/cinzel-600.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Cinzel'; font-weight: 700; src: url('assets/fonts/cinzel-700.woff2') format('woff2'); font-display: swap; }

:root {
  --bg: #0b0906; --panel: #15110c; --panel-2: #1c1610; --line: #3a2f1c; --line-2: #5a4a2a;
  --gold: #e6c36a; --gold-2: #b8934a; --text: #e6dcc6; --muted: #a89e88; --dim: #7f766a;
  --good: #8fd98f; --bad: #e08a8a; --blue: #8aa4ff; --rune: #ffb760; --unique: #c7a35a;
  --cell: 110px;
}
@media (max-width: 700px) { :root { --cell: 72px; } }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, Segoe UI, sans-serif; min-height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, rgba(230, 195, 106, 0.08), transparent 60%),
              linear-gradient(rgba(11, 9, 6, 0.86), rgba(11, 9, 6, 0.96)), url('ui/blood-moor.jpg') center top / cover fixed no-repeat;
  padding: 18px 16px 40px;
}
h1, h2, h3, .serif { font-family: 'Cinzel', Georgia, serif; letter-spacing: 0.02em; }
.num { font-variant-numeric: tabular-nums; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled, button.cant { opacity: 0.45; cursor: not-allowed; }
kbd { font: 11px/1 system-ui; background: #0b0906; border: 1px solid var(--line-2); border-radius: 3px; padding: 1px 4px; color: var(--muted); margin-left: 6px; }

.wrap { max-width: 1120px; margin: 0 auto; display: grid; grid-template-columns: 1fr 320px; gap: 16px; }
@media (max-width: 900px) { .wrap { grid-template-columns: 1fr; } }
.top { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.top h1 { margin: 0; font-size: 26px; color: var(--gold); text-shadow: 0 0 18px rgba(230, 195, 106, 0.25); }
.top .sub { color: var(--muted); font-size: 12px; }
.balance { font-family: 'Cinzel', serif; font-size: 20px; color: var(--gold); text-align: right; }
.balance small { font: 12px system-ui; color: var(--muted); margin-left: 6px; }
.jackpot { font: 12px system-ui; color: var(--muted); }
.jackpot b { font-family: 'Cinzel', serif; color: var(--gold); font-size: 14px; }

.panel { background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); }
.panel .head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.panel .head h2 { margin: 0; font-size: 16px; color: var(--gold); }
.panel .head .sub { color: var(--muted); font-size: 12px; }

/* ---------- reels ---------- */
.machine { padding: 14px; position: relative; }
.reels {
  position: relative; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 10px;
  background: linear-gradient(#0d0a06, #120e09); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.7);
}
.reels.banwave { box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.7), 0 0 0 1px #7a2a2a, 0 0 24px rgba(176, 74, 74, 0.35); }
@media (max-width: 700px) { .reels { gap: 5px; padding: 6px; } }
.reel { position: relative; height: calc(3 * var(--cell)); overflow: hidden; border-radius: 6px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); }
.reel.pickable { cursor: pointer; border-color: var(--gold-2); box-shadow: 0 0 14px rgba(230, 195, 106, 0.35); }
.reel.pickable:hover { box-shadow: 0 0 22px rgba(230, 195, 106, 0.7); }
.reel .strip { position: absolute; left: 0; right: 0; top: 0; will-change: transform; }
.reel .cell { height: var(--cell); display: flex; align-items: center; justify-content: center; }
.reel .cell img { max-height: calc(var(--cell) - 22px); max-width: 80%; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.7)); }
.reel .cell.win { background: radial-gradient(circle, rgba(230, 195, 106, 0.28), transparent 70%); }
.reel .cell.win img { animation: pulse 0.6s ease-in-out infinite alternate; }
.reel .cell.feat { background: radial-gradient(circle, rgba(138, 164, 255, 0.28), transparent 70%); }
.reel .cell.feat img { animation: pulse 0.6s ease-in-out infinite alternate; }
.reel .cell.upgraded { background: radial-gradient(circle, rgba(255, 183, 96, 0.3), transparent 70%); }
@keyframes pulse { from { transform: scale(1); filter: drop-shadow(0 0 4px rgba(230, 195, 106, 0.6)); } to { transform: scale(1.1); filter: drop-shadow(0 0 14px rgba(230, 195, 106, 1)); } }
.reel .cell.dim img { opacity: 0.35; }
.lines-overlay { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.lines-overlay polyline { fill: none; stroke: var(--gold); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; opacity: 0.9; filter: drop-shadow(0 0 6px rgba(230, 195, 106, 0.8)); }

.message { min-height: 48px; margin: 12px 4px 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-family: 'Cinzel', serif; font-size: 18px; color: var(--gold); }
.message.big { font-size: 26px; text-shadow: 0 0 20px rgba(230, 195, 106, 0.5); }
.message.lose { color: var(--dim); font-size: 14px; font-family: system-ui, sans-serif; }
.message .detail { display: block; font: 12px/1.5 system-ui, sans-serif; color: var(--muted); margin-top: 2px; max-width: 100%; }
.freebar { margin: 8px 4px 0; padding: 6px 10px; border: 1px solid var(--line-2); border-radius: 6px; background: rgba(230, 195, 106, 0.06); color: var(--gold); font-size: 13px; display: none; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.freebar.on { display: flex; }
.freebar .ban { color: var(--bad); }
.actionbar { margin: 10px 4px 0; display: none; gap: 8px; justify-content: center; flex-wrap: wrap; }
.actionbar.on { display: flex; }

/* ---------- bet form ---------- */
.betform { padding: 12px 14px 14px; display: grid; gap: 10px; }
.field { display: grid; gap: 4px; }
.f-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; display: flex; justify-content: space-between; }
.f-label .cap { color: var(--dim); text-transform: none; letter-spacing: 0; }
.f-row { display: flex; gap: 6px; align-items: stretch; }
.f-row input[type="number"], .f-row input[type="text"] { flex: 1; min-width: 0; background: #0b0906; color: var(--text); border: 1px solid var(--line-2); border-radius: 6px; padding: 8px 10px; font: 15px system-ui; }
.mini { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 0 10px; color: var(--text); font-size: 13px; }
.mini:hover { border-color: var(--gold-2); }
.btn { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; color: var(--text); }
.btn:hover:not(:disabled) { border-color: var(--gold-2); }
.btn.primary { background: linear-gradient(#2a2114, #1a140c); border-color: var(--gold-2); color: var(--gold); font-family: 'Cinzel', serif; font-size: 17px; font-weight: 700; padding: 14px; box-shadow: 0 0 0 1px rgba(230, 195, 106, 0.15) inset; }
.btn.primary:hover:not(:disabled) { box-shadow: 0 0 18px rgba(230, 195, 106, 0.25); }
.btn.red { border-color: #7a2a2a; color: #f0b0b0; }
.btn.blue { border-color: #2a3a7a; color: #b0c0ff; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toggle { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.toggle input { accent-color: var(--gold-2); }
.foot { color: var(--dim); font-size: 12px; margin: 0; }

/* ---------- paytable / features ---------- */
.paytable { padding: 8px 14px 12px; }
.paytable table { width: 100%; border-collapse: collapse; font-size: 13px; }
.paytable th, .paytable td { padding: 4px 6px; text-align: right; border-bottom: 1px solid var(--line); }
.paytable th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.paytable td:first-child, .paytable th:first-child { text-align: left; }
.paytable td:first-child img { height: 26px; vertical-align: middle; margin-right: 8px; }
.paytable .rune { color: var(--rune); }
.paytable .special { color: var(--gold); }
.paytable .note { color: var(--dim); font-size: 12px; margin: 8px 0 0; }
.features { padding: 8px 14px 12px; display: grid; gap: 8px; }
.feature { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: start; font-size: 13px; color: var(--muted); }
.feature img { width: 44px; height: 44px; object-fit: contain; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.7)); }
.feature b { display: block; color: var(--gold); font-family: 'Cinzel', serif; font-size: 13px; }

/* ---------- fairness / history ---------- */
.fair { padding: 10px 14px 14px; font-size: 12px; color: var(--muted); }
.fair code { display: block; background: #0b0906; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; color: var(--text); word-break: break-all; font: 11px/1.4 ui-monospace, Consolas, monospace; margin: 4px 0 8px; }
.fair .kv { margin: 6px 0; }
.fair .k { color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; font-size: 10px; }
.fair .ok { color: var(--good); }
.fair .revealed { border-top: 1px dashed var(--line-2); margin-top: 10px; padding-top: 8px; }
.history { padding: 6px 14px 12px; }
.history ol { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow: auto; }
.history li { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.history li .won { color: var(--good); }
.history li .lost { color: var(--dim); }
.history li .nonce { color: var(--dim); }

/* ---------- modal (d2bot-style backdrop + sheet) ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.72); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; animation: fade 0.18s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet { width: min(560px, 100%); background: var(--panel); border: 1px solid var(--gold-2); border-radius: 12px; box-shadow: 0 20px 80px rgba(0, 0, 0, 0.8), 0 0 40px rgba(230, 195, 106, 0.12); padding: 18px 20px 20px; animation: pop 0.2s ease-out; }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.sheet h2 { margin: 0 0 4px; color: var(--gold); font-size: 22px; }
.sheet .sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.sheet .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.sheet .actions .btn { min-width: 120px; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .choice { grid-template-columns: 1fr; } }
.choice button { text-align: left; padding: 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel-2); }
.choice button:hover { border-color: var(--gold); box-shadow: 0 0 16px rgba(230, 195, 106, 0.25); }
.choice b { display: block; color: var(--gold); font-family: 'Cinzel', serif; margin-bottom: 4px; }
.choice span { color: var(--muted); font-size: 12px; }

/* Diablo Clone fight */
.dclone { display: grid; grid-template-columns: 96px 1fr; gap: 16px; align-items: center; }
.dclone .boss { width: 96px; height: 120px; display: flex; align-items: center; justify-content: center; font-size: 64px; filter: drop-shadow(0 0 18px rgba(255, 60, 60, 0.6)); }
.dclone .boss.dead { filter: grayscale(1) opacity(0.5); }
.lifebar { height: 14px; background: #2a0d0d; border: 1px solid #7a2a2a; border-radius: 7px; overflow: hidden; }
.lifebar i { display: block; height: 100%; width: 100%; background: linear-gradient(#e04040, #8a1a1a); transition: width 0.35s ease-out; }
.hits { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; min-height: 26px; }
.hits span { border: 1px solid var(--line-2); border-radius: 5px; padding: 2px 8px; font-size: 12px; color: var(--text); background: var(--panel-2); animation: pop 0.2s ease-out; }
.drop { display: grid; grid-template-columns: 56px 1fr; gap: 14px; align-items: center; margin-top: 14px; padding: 12px; border: 1px solid var(--line-2); border-radius: 10px; background: rgba(230, 195, 106, 0.05); }
.drop img { width: 56px; height: 56px; object-fit: contain; filter: drop-shadow(0 0 12px rgba(138, 164, 255, 0.7)); }
.drop b { color: var(--gold); font-family: 'Cinzel', serif; }
.drop .line { display: block; color: var(--blue); font-size: 13px; }
.drop .line.max { color: var(--gold); }
.drop .pay { font-family: 'Cinzel', serif; font-size: 22px; color: var(--good); margin-top: 4px; }
.drop.dead img { filter: grayscale(1) opacity(0.5); }
.qbar { height: 6px; background: #1a140c; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.qbar i { display: block; height: 100%; background: var(--blue); width: 0; transition: width 0.6s ease-out; }

/* Gheed */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px 0; }
.card { height: 110px; border-radius: 10px; border: 1px solid var(--line-2); display: flex; align-items: center; justify-content: center; font-family: 'Cinzel', serif; font-size: 20px; background: var(--panel-2); }
.card.red { color: #f0b0b0; border-color: #7a2a2a; }
.card.blue { color: #b0c0ff; border-color: #2a3a7a; }
.card.revealed.red { background: radial-gradient(circle, #7a2a2a, #2a0d0d); }
.card.revealed.blue { background: radial-gradient(circle, #2a3a7a, #0d1230); }
.card.lost { opacity: 0.35; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #2a1010; color: #f0c0c0; border: 1px solid #7a2a2a; border-radius: 8px; padding: 10px 14px; font-size: 13px; opacity: 0; transition: opacity 0.2s; pointer-events: none; z-index: 60; }
.toast.show { opacity: 1; }

/* ---------- account / login / leaderboard / stats ---------- */
.who { text-align: right; }
.account { margin-top: 4px; font-size: 12px; color: var(--muted); display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.account b { color: var(--text); }
.login-sheet .field { margin-bottom: 10px; }
.login-sheet input[type="text"], .login-sheet input[type="password"] { width: 100%; background: #0b0906; color: var(--text); border: 1px solid var(--line-2); border-radius: 6px; padding: 9px 10px; font: 15px system-ui; }
.login-sheet .err { color: var(--bad); font-size: 13px; min-height: 1.2em; margin: 4px 0 0; }
.login-sheet .switch { color: var(--muted); font-size: 12px; margin-top: 10px; }
.login-sheet .switch button { background: none; border: none; color: var(--gold); text-decoration: underline; padding: 0; }
.board { padding: 6px 14px 12px; overflow-x: auto; }
.board table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.board th, .board td { padding: 5px 6px; text-align: right; border-bottom: 1px solid var(--line); }
.board th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.board td:nth-child(2), .board th:nth-child(2) { text-align: left; }
.board tr.me td { color: var(--gold); }
.board .rank { color: var(--dim); }
.board .on { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--good); margin-right: 6px; box-shadow: 0 0 6px var(--good); }
.stats { padding: 8px 14px 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 13px; }
.stats .stat { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); padding: 3px 0; color: var(--muted); }
.stats .stat b { color: var(--text); font-weight: 600; }
.stats .stat.gold b { color: var(--gold); }
.stats .wide { grid-column: 1 / -1; }

.machine, .reels, .message, .freebar, .actionbar { user-select: none; -webkit-user-select: none; }
.reelpicks { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
@media (max-width: 520px) { .reelpicks { grid-template-columns: repeat(3, 1fr); } }
.reelpicks button.reelpick { display: grid; gap: 6px; justify-items: center; padding: 8px 4px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel-2); }
.reelpicks button.reelpick:hover { border-color: var(--gold); box-shadow: 0 0 16px rgba(230, 195, 106, 0.25); }
.reelpicks button.reelpick b { color: var(--gold); font-family: 'Cinzel', serif; font-size: 12px; }
.reelpicks .col { display: grid; gap: 4px; }
.reelpicks .col img { width: 34px; height: 34px; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0,0,0,.7)); }

.betform .toggles { display: grid; gap: 6px; padding: 2px 2px 0; }
.betform .toggle { justify-content: flex-start; margin: 0; }
.betform .toggle input { width: 15px; height: 15px; margin: 0; flex: 0 0 auto; }
.betform #auto { width: 100%; }

/* ---------- multi-machine additions ---------- */
.reels.rows4 { grid-template-columns: repeat(5, 1fr); }
.reels.rows4 .reel { height: calc(4 * var(--cell)); }
.reel .cell { position: relative; }
.reel .cell .badge { position: absolute; right: 6px; bottom: 6px; background: rgba(11, 9, 6, 0.85); border: 1px solid var(--gold-2); color: var(--gold); border-radius: 6px; font: 700 12px/1 'Cinzel', serif; padding: 3px 6px; }
.reel .cell .badge.jp { background: #2a1010; border-color: #b04a4a; color: #ffd0d0; }
.reel .cell .badge.grand { background: #1a1230; border-color: #8aa4ff; color: #cfd8ff; }
.reel .cell.lock { background: radial-gradient(circle, rgba(230, 195, 106, 0.22), transparent 70%); }
.reel .cell.lock img { filter: drop-shadow(0 0 10px rgba(230, 195, 106, 0.9)); }
.reel .cell.empty img { opacity: 0.12; }
.reel .cell.flick img { animation: flick 0.35s linear infinite; }
@keyframes flick { 0% { opacity: 0.2; transform: translateY(-6px); } 50% { opacity: 0.6; } 100% { opacity: 0.2; transform: translateY(6px); } }
.meter { margin: 8px 4px 0; display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }
.meter .bar { height: 12px; background: #1a140c; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.meter .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #7a2a2a, #e04040); transition: width 0.5s ease-out; box-shadow: 0 0 10px rgba(224, 64, 64, 0.6); }
.meter b { color: var(--gold); font-family: 'Cinzel', serif; }
.holdbar { margin: 8px 4px 0; padding: 6px 10px; border: 1px solid #7a2a2a; border-radius: 6px; background: rgba(176, 74, 74, 0.08); color: #f0c0c0; font-size: 13px; display: none; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.holdbar.on { display: flex; }
.picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0; }
.pick { height: 120px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel-2); display: grid; place-items: center; font-family: 'Cinzel', serif; color: var(--gold); font-size: 20px; }
.pick img { width: 44px; height: 44px; object-fit: contain; }
.pick.revealed { border-color: var(--gold); box-shadow: 0 0 16px rgba(230, 195, 106, 0.3); }
.lobby { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.card-m { display: grid; grid-template-rows: 150px auto 1fr auto; text-decoration: none; color: inherit; overflow: hidden; transition: transform 0.15s, box-shadow 0.15s; }
.card-m:hover { transform: translateY(-2px); box-shadow: 0 14px 44px rgba(0, 0, 0, 0.6), 0 0 24px rgba(230, 195, 106, 0.15); }
.card-m .art { background: #0d0a06 center / cover; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px; border-bottom: 1px solid var(--line); }
.card-m .art img { height: 72px; max-width: 30%; object-fit: contain; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.8)); }
.card-m h2 { margin: 0; padding: 12px 14px 0; color: var(--gold); font-size: 18px; }
.card-m p { margin: 6px 14px 12px; color: var(--muted); font-size: 13px; }
.card-m .cta { margin: 0 14px 14px; }
.card-m .tags { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 14px; }
.card-m .tags span { font-size: 11px; color: var(--dim); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; }
.betform .f-label { align-items: baseline; }
.betform .f-row .mini { min-width: 44px; }

/* ================= machine themes ================= */
body.theme-runes { --accent: #e6c36a; --accent-2: #b8934a; --accent-glow: rgba(230, 195, 106, 0.45); --frame: #5a4a2a; --bg-url: url('ui/blood-moor.jpg'); --tile: #1a140c; }
body.theme-baal  { --accent: #ff6a5a; --accent-2: #b03a2e; --accent-glow: rgba(255, 106, 90, 0.45); --frame: #6a2a24; --bg-url: url('ui/bg-baal.jpg'); --tile: #1c0f0d; --gold: #ffb3a7; --gold-2: #c9584a; }
body.theme-dclone{ --accent: #7fe0a8; --accent-2: #2e8a5a; --accent-glow: rgba(127, 224, 168, 0.4); --frame: #244a34; --bg-url: url('ui/bg-kurast.jpg'); --tile: #0d1a12; --gold: #a8f0c4; --gold-2: #3f9d6b; }
body.theme-baal, body.theme-dclone, body.theme-runes {
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-glow), transparent 60%),
              linear-gradient(rgba(11, 9, 6, 0.80), rgba(11, 9, 6, 0.95)), var(--bg-url) center top / cover fixed no-repeat;
}
body.theme-baal .panel, body.theme-dclone .panel { border-color: var(--frame); }
body.theme-baal .top h1, body.theme-dclone .top h1 { color: var(--accent); text-shadow: 0 0 18px var(--accent-glow); }
body.theme-baal .panel .head h2, body.theme-dclone .panel .head h2 { color: var(--accent); }
body.theme-baal .btn.primary, body.theme-dclone .btn.primary { border-color: var(--accent-2); color: var(--accent); }
body.theme-baal .reels { border-color: var(--frame); box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.8), 0 0 0 3px #2a1210, 0 0 30px var(--accent-glow); background: linear-gradient(#150a09, #1e0d0b); }
body.theme-dclone .reels { border-color: var(--frame); box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.8), 0 0 0 3px #0b1a10, 0 0 30px var(--accent-glow); background: linear-gradient(#0a120d, #0f1a12); }
body.theme-baal .reel .cell.win, body.theme-dclone .reel .cell.win { background: radial-gradient(circle, var(--accent-glow), transparent 70%); }
.banner { height: 110px; background: var(--bg-url) center 30% / cover no-repeat; border-bottom: 1px solid var(--frame, var(--line-2)); position: relative; border-radius: 10px 10px 0 0; }
.banner::after { content: ''; position: absolute; inset: 0; background: linear-gradient(rgba(11, 9, 6, 0.15), rgba(21, 17, 12, 0.95)); border-radius: 10px 10px 0 0; }
.banner .title { position: absolute; left: 16px; bottom: 10px; z-index: 1; font-family: 'Cinzel', serif; font-size: 22px; color: var(--accent, var(--gold)); text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9); }
.banner .ticker { position: absolute; right: 12px; bottom: 10px; z-index: 1; display: flex; gap: 8px; }
.banner .ticker span { background: rgba(11, 9, 6, 0.75); border: 1px solid var(--accent-2, var(--gold-2)); border-radius: 6px; padding: 4px 8px; font-size: 11px; color: var(--muted); }
.banner .ticker span b { display: block; font-family: 'Cinzel', serif; font-size: 14px; color: var(--accent, var(--gold)); }
.banner .ticker span.grand b { color: #fff; text-shadow: 0 0 10px var(--accent-glow); }

/* symbol tiles: every symbol sits on a framed tile coloured by rarity */
.reel .cell { padding: 6px; }
.reel .cell .tile { position: absolute; inset: 5px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.06); background: linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.25)), var(--tile, #1a140c); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 2px 6px rgba(0, 0, 0, 0.5); }
.reel .cell img { position: relative; z-index: 1; }
.reel .cell[data-rarity="rune"] .tile { border-color: rgba(255, 183, 96, 0.35); box-shadow: inset 0 0 18px rgba(255, 183, 96, 0.08); }
.reel .cell[data-rarity="unique"] .tile { border-color: rgba(199, 163, 90, 0.45); box-shadow: inset 0 0 18px rgba(199, 163, 90, 0.12); }
.reel .cell[data-rarity="gem"] .tile { border-color: rgba(255, 255, 255, 0.08); }
.reel .cell[data-rarity="special"] .tile { border-color: rgba(138, 164, 255, 0.55); box-shadow: inset 0 0 22px rgba(138, 164, 255, 0.18); }
.reel .cell[data-rarity="wild"] .tile { border-color: var(--accent, var(--gold)); box-shadow: inset 0 0 22px var(--accent-glow); }
.reel .cell .badge { z-index: 2; }

/* motion */
.reel.spinning img { opacity: 0.85; }
.reel.landed .strip { /* settle handled by the scroll easing */ }
@keyframes land { 0% { transform: translateY(calc(-1 * var(--land-y)) ) translateY(-14px); } 100% { transform: translateY(calc(-1 * var(--land-y))); } }
.reel.antic { border-color: var(--accent, var(--gold)); box-shadow: 0 0 18px var(--accent-glow), inset 0 0 30px var(--accent-glow); animation: anticpulse 0.5s ease-in-out infinite alternate; }
@keyframes anticpulse { from { box-shadow: 0 0 10px var(--accent-glow); } to { box-shadow: 0 0 28px var(--accent-glow), inset 0 0 30px var(--accent-glow); } }
.reel .cell.win .tile { border-color: var(--accent, var(--gold)); box-shadow: 0 0 18px var(--accent-glow), inset 0 0 24px var(--accent-glow); }
.reel .cell.feat .tile { border-color: var(--blue); box-shadow: 0 0 18px rgba(138, 164, 255, 0.6); }

/* win counter + tiers */
.wincount { font-family: 'Cinzel', serif; font-variant-numeric: tabular-nums; }
.bigwin { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.bigwin .inner { text-align: center; animation: bwpop 0.5s cubic-bezier(.2,1.4,.3,1); }
@keyframes bwpop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.bigwin .tier { font-family: 'Cinzel', serif; font-weight: 700; font-size: clamp(36px, 8vw, 84px); letter-spacing: 0.06em; color: var(--accent, var(--gold)); text-shadow: 0 0 30px var(--accent-glow), 0 4px 0 rgba(0,0,0,.7), 0 0 80px var(--accent-glow); }
.bigwin .amt { font-family: 'Cinzel', serif; font-size: clamp(28px, 6vw, 60px); color: #fff; text-shadow: 0 0 24px var(--accent-glow), 0 3px 0 rgba(0,0,0,.7); margin-top: 6px; }
.bigwin .veil { position: absolute; inset: 0; background: radial-gradient(circle at 50% 50%, rgba(0,0,0,0.55), rgba(0,0,0,0.85)); animation: fade 0.3s ease-out; }
.bigwin.mega .tier { color: #ffd27a; } .bigwin.epic .tier { color: #ff9a6a; }
.coin { position: fixed; z-index: 71; width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2b0, var(--accent, #e6c36a) 55%, #7a5a1e); box-shadow: 0 0 8px var(--accent-glow); pointer-events: none; animation: coinfall 1.6s cubic-bezier(.3,.6,.6,1) forwards; }
@keyframes coinfall { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(var(--dx), 110vh) rotate(720deg); opacity: 0.2; } }
.sound-btn { background: transparent; border: 1px solid var(--line-2); border-radius: 6px; color: var(--muted); font-size: 12px; padding: 2px 8px; }
.sound-btn.on { color: var(--accent, var(--gold)); border-color: var(--accent-2, var(--gold-2)); }

/* ================= mobile ================= */
@media (max-width: 700px) {
  body { padding: 10px 10px calc(84px + env(safe-area-inset-bottom, 0px)); }
  .top { gap: 6px; }
  .top h1 { font-size: 22px; }
  .top .sub { display: none; }
  .who { text-align: left; }
  .account { justify-content: flex-start; flex-wrap: wrap; }
  .panel .head { padding: 8px 10px; }
  .machine { padding: 8px; }
  .banner { height: 76px; }
  .banner .title { font-size: 16px; left: 10px; bottom: 8px; }
  .banner .ticker { right: 6px; bottom: 6px; gap: 4px; }
  .banner .ticker span { padding: 2px 5px; font-size: 9px; } .banner .ticker span b { font-size: 11px; }
  .message { font-size: 15px; min-height: 40px; }
  .message.big { font-size: 20px; }
  .reel .cell { padding: 3px; } .reel .cell .tile { inset: 2px; border-radius: 5px; }
  .reel .cell .badge { right: 3px; bottom: 3px; font-size: 10px; padding: 2px 4px; }
  .betform { padding: 10px; }
  .f-row input[type="number"], .f-row input[type="text"] { font-size: 16px; padding: 10px; } /* 16px stops iOS zooming */
  .mini { min-height: 40px; }
  .btn { min-height: 44px; }
  .board table { font-size: 12px; }
  .stats { grid-template-columns: 1fr; }
  .sheet { padding: 14px; }
  .sheet h2 { font-size: 18px; }
  .choice { grid-template-columns: 1fr; }
  .dclone { grid-template-columns: 64px 1fr; } .dclone .boss { width: 64px; height: 80px; font-size: 44px; }
  /* sticky spin bar */
  .spinbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; gap: 8px; align-items: center; padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); background: rgba(11, 9, 6, 0.94); border-top: 1px solid var(--frame, var(--line-2)); backdrop-filter: blur(6px); }
  .spinbar .bal { flex: 1; font-family: 'Cinzel', serif; color: var(--accent, var(--gold)); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .spinbar .bal small { display: block; font: 11px system-ui; color: var(--muted); }
  .spinbar button { min-height: 46px; padding: 8px 14px; }
  .spinbar .btn.primary { font-size: 16px; padding: 10px 18px; }
}
@media (min-width: 701px) { .spinbar { display: none; } }

/* ================= mobile, second pass: fit the machine to the screen ================= */
@media (max-width: 700px) {
  html, body { max-width: 100vw; overflow-x: hidden; }
  body, body.theme-runes, body.theme-baal, body.theme-dclone { background-attachment: scroll; padding-left: 8px; padding-right: 8px; }
  :root { --cell: clamp(44px, calc((100vw - 16px - 2px - 12px - 16px - 4 * 4px) / 5), 96px); } /* body pad, panel border, machine pad, reels pad, 4 gaps */
  .wrap { gap: 10px; }
  .top { display: grid; grid-template-columns: 1fr auto; align-items: center; }
  .top h1 { font-size: 20px; }
  .balance { font-size: 16px; }
  .jackpot { font-size: 11px; }
  .account { font-size: 11px; gap: 6px; }
  .account .mini, .account .sound-btn { padding: 2px 6px; font-size: 11px; min-height: 0; }
  .panel { border-radius: 8px; }
  .machine { padding: 6px; }
  .reels { gap: 4px; padding: 6px; border-radius: 8px; }
  .reel { border-radius: 4px; }
  .reel .cell img { max-height: calc(var(--cell) - 12px); max-width: 84%; }
  .lines-overlay polyline { stroke-width: 2; }
  .banner { height: 64px; border-radius: 8px 8px 0 0; }
  .freebar, .holdbar, .meter { margin: 6px 2px 0; font-size: 12px; padding: 5px 8px; }
  .message { margin: 8px 2px 0; }
  .message .detail { font-size: 11px; }
  .f-label { font-size: 11px; }
  .f-row { gap: 4px; }
  .f-row .mini { min-width: 38px; padding: 0 6px; }
  .betform .btn.primary { padding: 12px; font-size: 16px; }
  .betform #auto { display: none; } /* the sticky bar has it */
  .paytable td:first-child img { height: 20px; margin-right: 5px; }
  .paytable th, .paytable td { padding: 3px 4px; font-size: 12px; }
  .features { gap: 6px; }
  .feature { grid-template-columns: 34px 1fr; font-size: 12px; }
  .feature img { width: 34px; height: 34px; }
  .fair code { font-size: 10px; }
  .history ol { max-height: 180px; }
  .board th:nth-child(n+6), .board td:nth-child(n+6) { display: none; } /* keep #, player, FG, won, best on phones */
  .lobby { grid-template-columns: 1fr; }
  .card-m { grid-template-rows: 110px auto 1fr auto; }
  .card-m .art img { height: 56px; }
  .bigwin .tier { font-size: clamp(30px, 11vw, 48px); }
  .bigwin .amt { font-size: clamp(22px, 8vw, 36px); }
  .reelpicks { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .reelpicks .col img { width: 26px; height: 26px; }
  .picks { gap: 6px; } .pick { height: 90px; font-size: 16px; }
}
@media (max-width: 380px) {
  :root { --cell: clamp(40px, calc((100vw - 62px) / 5), 96px); }
  .top h1 { font-size: 18px; }
}

.reel .strip { transform: translate3d(0, 0, 0); backface-visibility: hidden; }
.reel .cell img { will-change: transform; }

/* ================= Countess Runs + Gheed's Wheel ================= */
body.theme-countess { --accent: #c9a0ff; --accent-2: #6a3fb0; --accent-glow: rgba(201, 160, 255, 0.42); --frame: #3c2a5a; --bg-url: url('ui/blood-moor.jpg'); --tile: #140f1c; --gold: #d9c2ff; --gold-2: #7a52c2; }
body.theme-gheed { --accent: #ffd27a; --accent-2: #b8862e; --accent-glow: rgba(255, 210, 122, 0.45); --frame: #5a4416; --bg-url: url('ui/blood-moor.jpg'); --tile: #1a1408; --gold: #ffd27a; --gold-2: #b8862e; }
body.theme-countess, body.theme-gheed { background: radial-gradient(1200px 600px at 50% -10%, var(--accent-glow), transparent 60%), linear-gradient(rgba(11, 9, 6, 0.82), rgba(11, 9, 6, 0.96)), var(--bg-url) center top / cover fixed no-repeat; }
body.theme-countess .panel, body.theme-gheed .panel { border-color: var(--frame); }
body.theme-countess .top h1, body.theme-gheed .top h1, body.theme-countess .panel .head h2, body.theme-gheed .panel .head h2 { color: var(--accent); }
body.theme-countess .btn.primary, body.theme-gheed .btn.primary { border-color: var(--accent-2); color: var(--accent); }
body.theme-countess .reels { border-color: var(--frame); box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.8), 0 0 0 3px #1a1226, 0 0 30px var(--accent-glow); background: linear-gradient(#0d0a12, #120e1a); }
body.theme-gheed .reels { border-color: var(--frame); box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.8), 0 0 0 3px #2a1f08, 0 0 30px var(--accent-glow); background: linear-gradient(#120e06, #1a1408); }
body.theme-countess .reel .cell.win, body.theme-gheed .reel .cell.win { background: radial-gradient(circle, var(--accent-glow), transparent 70%); }

/* cascade ladder + shatter/drop */
.ladder { display: flex; gap: 6px; justify-content: center; margin: 0 0 8px; }
.ladder span { font-family: 'Cinzel', serif; font-size: 13px; color: var(--dim); border: 1px solid var(--line); border-radius: 6px; padding: 3px 10px; transition: all 0.2s; }
.ladder span.on { color: var(--accent); border-color: var(--accent); box-shadow: 0 0 14px var(--accent-glow); transform: scale(1.12); }
.ladder span.free { border-style: dashed; }
.reel .cell.shatter img { animation: shatter 0.45s ease-in forwards; }
.reel .cell.shatter .tile { animation: tilefade 0.45s ease-in forwards; }
@keyframes shatter { 0% { transform: scale(1); opacity: 1; filter: brightness(1.6); } 60% { transform: scale(1.25) rotate(8deg); opacity: 0.7; } 100% { transform: scale(0.2) rotate(-20deg); opacity: 0; } }
@keyframes tilefade { to { opacity: 0.2; } }
.reel .cell.drop { animation: dropin 0.45s cubic-bezier(.2,.9,.3,1.2); }
@keyframes dropin { from { transform: translateY(calc(-1.2 * var(--cell))); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* 3-reel machine + wheel */
.reels.reels3 { grid-template-columns: repeat(3, 1fr); max-width: calc(3 * var(--cell) + 60px); margin: 0 auto; }
.machine.gheed { position: relative; }
.wheelwrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 5; pointer-events: none; opacity: 0; transition: opacity 0.4s; }
.wheelwrap.on { opacity: 1; }
.wheelwrap::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 50% 50%, rgba(0,0,0,0.55), rgba(0,0,0,0.85)); }
.wheel { position: relative; width: min(340px, 78vw); aspect-ratio: 1; border-radius: 50%; border: 6px solid var(--accent-2, var(--gold-2)); box-shadow: 0 0 0 4px #0b0906, 0 0 40px var(--accent-glow), inset 0 0 30px rgba(0,0,0,0.7); transform: rotate(0deg); }
.wheel .lbl { position: absolute; left: 50%; top: 50%; width: 70px; margin-left: -35px; margin-top: -10px; text-align: center; font-family: 'Cinzel', serif; font-weight: 700; font-size: 14px; color: #f4ead0; text-shadow: 0 1px 3px #000; transform-origin: 50% 50%; }
.wheel .lbl.jp { color: #2a1a00; font-size: 11px; }
.wheelwrap .pointer { position: absolute; top: calc(50% - min(170px, 39vw) - 14px); left: 50%; width: 0; height: 0; margin-left: -12px; border-left: 12px solid transparent; border-right: 12px solid transparent; border-top: 26px solid var(--accent, var(--gold)); filter: drop-shadow(0 0 8px var(--accent-glow)); z-index: 6; }
.wheelwrap .hub { position: absolute; width: 46px; height: 46px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2c0, var(--accent, #e6c36a) 55%, #7a5a1e); box-shadow: 0 0 14px var(--accent-glow); z-index: 6; }
@media (max-width: 700px) { .wheel .lbl { width: 54px; margin-left: -27px; font-size: 11px; } .wheel .lbl.jp { font-size: 8px; } }
