:root {
  --text: #f6ecd6; --muted: #bfae8c; --gold: #e9c46a; --gold-hi: #fff1c1;
  --goldgrad: linear-gradient(135deg, #7a5310 0%, #e9c46a 22%, #fff3c9 38%, #c99a32 55%, #f7df95 72%, #8a6114 100%);
  --onyx: linear-gradient(160deg, rgba(34, 28, 38, .94), rgba(9, 8, 12, .97));
  --serif: "Cinzel", "Cormorant Garamond", Georgia, "Noto Serif", serif;
  --sans: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: #07060a; color: var(--text); font-family: var(--sans); user-select: none; -webkit-user-select: none; }
body { position: fixed; inset: 0; background: radial-gradient(120% 80% at 50% 0%, #2a1f2e, #07060a 70%); }
button { font-family: inherit; cursor: pointer; color: var(--text); }
[hidden] { display: none !important; }

/* ---------- background + felt veil ---------- */
#bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
#bgv { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .9s; background: center / cover no-repeat; }
#bgv.on { opacity: 1; }
#bgShade { position: absolute; inset: 0; background: radial-gradient(90% 60% at 50% 45%, rgba(7,6,10,.25), rgba(7,6,10,.6)), linear-gradient(180deg, rgba(7,6,10,.6), rgba(7,6,10,.2) 30%, rgba(7,6,10,.35) 75%, rgba(7,6,10,.85)); }
/* at the table: deep green felt over the scenery so the cards stay readable */
body:not(.athome) #bgShade.felt { background: radial-gradient(120% 85% at 50% 40%, rgba(18,58,44,.74), rgba(8,26,20,.86) 60%, rgba(7,6,10,.93)); }

#app { position: relative; z-index: 1; height: 100%; max-width: 560px; margin: 0 auto; }
#game, #home { position: absolute; inset: 0; display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top) + 8px) 10px calc(env(safe-area-inset-bottom) + 8px); }
body.athome #game { visibility: hidden; }
body:not(.athome) #home { display: none; }

/* ---------- home ---------- */
#home { padding-left: 12px; padding-right: 12px; overflow-y: auto; overscroll-behavior: contain; animation: viewIn .45s ease-out; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } }
#home > * { flex: none; }
.titleArt { position: relative; width: 100%; aspect-ratio: 16 / 8.5; border-radius: 18px; background: #0b090e center / cover no-repeat; box-shadow: 0 14px 40px rgba(0,0,0,.6); overflow: hidden; }
.titleArt::before { content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.5px; background: var(--goldgrad); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }
.titleArt::after, .card::after, button.wide.go::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: linear-gradient(105deg, transparent 40%, rgba(255,245,215,.2) 50%, transparent 60%) no-repeat; background-size: 250% 100%; animation: sheen 7s ease-in-out infinite; }
@keyframes sheen { 0%, 60% { background-position: 150% 0; } 100% { background-position: -60% 0; } }
h1 { margin: 16px 0 0; text-align: center; font: 700 33px/1.05 var(--serif); letter-spacing: .08em; text-transform: uppercase; background: var(--goldgrad); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 2px 0 rgba(0,0,0,.6)) drop-shadow(0 0 18px rgba(233,196,106,.25)); }
@media (max-width: 380px) { h1 { font-size: 29px; letter-spacing: .06em; } }
.tagline { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); margin: 8px 0 16px; font-size: 11px; letter-spacing: .3em; text-transform: uppercase; }
.tagline::before, .tagline::after { content: ""; width: 34px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold)); }
.tagline::after { transform: scaleX(-1); }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card { position: relative; overflow: hidden; min-height: 64px; border-radius: 16px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; text-align: left; border: 1.5px solid transparent; background: var(--onyx) padding-box, var(--goldgrad) border-box; box-shadow: 0 10px 24px rgba(0,0,0,.5); transition: transform .12s; }
.card.big { grid-column: span 2; padding: 14px; background: linear-gradient(135deg, #4a0d1c, #1a0509 70%) padding-box, var(--goldgrad) border-box; }
.card.daily { grid-column: span 2; background: linear-gradient(135deg, #073a2c, #03140f 70%) padding-box, var(--goldgrad) border-box; }
.card:active { transform: scale(.97); }
.card img { flex: none; width: 48px; height: 48px; object-fit: contain; filter: drop-shadow(0 4px 8px rgba(0,0,0,.6)); animation: bob 3.4s ease-in-out infinite; }
.card.big img { width: 72px; height: 72px; }
.card:not(.big):not(.daily) { gap: 8px; padding: 10px; }
.card:not(.big):not(.daily) img { width: 40px; height: 40px; }
.card:not(.big):not(.daily) b { font-size: 15px; letter-spacing: .04em; }
@keyframes bob { 50% { transform: translateY(-3px); } }
.card > div { min-width: 0; }
.card b { display: block; font: 700 16px var(--serif); letter-spacing: .06em; background: var(--goldgrad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.card.big b { font-size: 22px; }
.card small { display: block; font-size: 11.5px; line-height: 1.35; color: var(--muted); letter-spacing: .03em; }

/* option rows (segmented controls) */
.opts { margin: 12px 0 2px; display: grid; gap: 8px; }
.optrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--muted); letter-spacing: .04em; }
.seg { display: flex; border-radius: 12px; border: 1px solid rgba(233,196,106,.35); background: rgba(12,10,16,.7); overflow: hidden; }
.seg button { min-width: 58px; height: 44px; padding: 0 12px; border: 0; background: none; font: 700 13px var(--serif); letter-spacing: .06em; color: var(--muted); }
.seg button + button { border-left: 1px solid rgba(233,196,106,.2); }
.seg button.on { background: var(--goldgrad); color: #2a1a05; }

.homebtns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 4px; }
button.mid { min-height: 56px; border-radius: 14px; padding: 9px 6px; border: 1px solid rgba(233,196,106,.35); background: rgba(12,10,16,.7); font: 600 13px var(--serif); letter-spacing: .06em; color: var(--gold-hi); }
button.mid small { display: block; font: 500 11px var(--sans); letter-spacing: .04em; color: var(--muted); margin-top: 3px; }
button.mid img.mi { width: 22px; height: 22px; object-fit: contain; vertical-align: -6px; margin-right: 6px; }
button.mid.span2 { grid-column: span 2; }
button.mid:active, button.wide:active { filter: brightness(1.25); }

.toggles { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 18px; margin: 8px 0 0; font-size: 13px; color: var(--muted); letter-spacing: .03em; }
.toggles label { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; }
.toggles input { width: 18px; height: 18px; margin: 0; accent-color: #c99a32; }

.pick-label { text-align: center; font: 600 11px var(--serif); letter-spacing: .22em; text-transform: uppercase; color: var(--muted); margin-top: 8px; }
.backs { display: flex; justify-content: center; gap: 14px; margin: 10px 0 6px; }
.backs button { width: 46px; height: 65px; border-radius: 6px; border: 0; padding: 0; background: center / cover no-repeat; box-shadow: 0 4px 10px rgba(0,0,0,.6); opacity: .62; transition: transform .15s, opacity .15s, box-shadow .15s; }
.backs button.on { opacity: 1; transform: translateY(-4px); box-shadow: 0 0 0 2px #07060a, 0 0 0 3.5px var(--gold-hi), 0 8px 18px rgba(233,196,106,.35); }

details { margin-top: 10px; text-align: left; font-size: 13px; color: var(--muted); border: 1px solid rgba(233,196,106,.2); border-radius: 14px; background: rgba(12,10,16,.6); padding: 0 14px; }
summary { cursor: pointer; text-align: center; min-height: 44px; line-height: 44px; font: 600 13px/44px var(--serif); letter-spacing: .1em; text-transform: uppercase; color: var(--gold-hi); }
details p { margin: 0 0 10px; line-height: 1.5; }
details b { color: var(--text); }
.fine { text-align: center; font-size: 11.5px; color: var(--muted); margin: 14px 0 6px; letter-spacing: .03em; }
.fine a { color: var(--gold); font-weight: 700; text-decoration: none; }

/* ---------- game view ---------- */
#hud { flex: none; display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 2px; }
.topbtn { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid transparent; background: var(--onyx) padding-box, var(--goldgrad) border-box; display: grid; place-items: center; flex: none; color: var(--gold-hi); padding: 0; }
.topbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.gstat { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.gstat.mid { flex: 2.2; align-items: center; }
.gstat.right { align-items: flex-end; padding-right: 4px; }
.label { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.gstat b { font: 700 20px/1.15 var(--serif); font-variant-numeric: lining-nums tabular-nums; background: var(--goldgrad); -webkit-background-clip: text; background-clip: text; color: transparent; }
#modeLabel { font: 700 13px/1.5 var(--serif); letter-spacing: .05em; color: var(--gold-hi); white-space: nowrap; }

#stage { position: relative; flex: 1; min-height: 0; margin-top: 4px; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }

#controls { flex: none; display: flex; justify-content: center; gap: 34px; margin-top: 4px; }
.boost { position: relative; width: 74px; border: 0; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.boost .medal { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; border: 2px solid transparent; background: radial-gradient(circle at 40% 30%, #2c2433, #0a080d) padding-box, var(--goldgrad) border-box; box-shadow: 0 6px 14px rgba(0,0,0,.6), inset 0 0 12px rgba(233,196,106,.15); transition: transform .15s, box-shadow .2s; }
.boost:active .medal { transform: scale(.93); box-shadow: 0 0 0 3px rgba(255,241,193,.55), 0 0 22px rgba(233,196,106,.6); }
.boost img { width: 34px; height: 34px; object-fit: contain; }
.boost span { font: 600 11px var(--serif); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.boost:disabled { opacity: .4; }

/* ---------- overlay & panels ---------- */
.overlay { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: calc(env(safe-area-inset-top) + 12px) 14px calc(env(safe-area-inset-bottom) + 12px); background: rgba(4,3,6,.72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); opacity: 0; pointer-events: none; transition: opacity .25s; }
.overlay.show { opacity: 1; pointer-events: auto; }
.panel { width: 100%; max-width: 400px; max-height: 100%; overflow-y: auto; padding: 22px 18px; border-radius: 22px; border: 1.5px solid transparent; background: linear-gradient(170deg, #1d1822, #0b090e) padding-box, var(--goldgrad) border-box; box-shadow: 0 24px 70px rgba(0,0,0,.75); text-align: center; overscroll-behavior: contain; }
.panel.tall { height: 100%; }
.panel h2 { margin: 4px 0; font: 700 24px var(--serif); letter-spacing: .08em; background: var(--goldgrad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.panel p { color: var(--muted); font-size: 13.5px; line-height: 1.45; margin: 6px 0; }
.panel p b { color: var(--gold-hi); }
.panel p.small { font-size: 12.5px; }
.panel p.final { margin: 6px 0; font: 700 44px/1.1 var(--serif); color: var(--gold-hi); font-variant-numeric: lining-nums tabular-nums; text-shadow: 0 0 22px rgba(233,196,106,.35); }
.panel img.emb { display: block; margin: 0 auto 2px; width: 72px; height: 72px; object-fit: contain; filter: drop-shadow(0 6px 12px rgba(0,0,0,.6)); animation: pop .5s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes pop { from { transform: scale(0); } to { transform: none; } }
button.wide { position: relative; overflow: hidden; display: block; width: 100%; min-height: 48px; margin: 9px 0; padding: 12px; border-radius: 13px; border: 1px solid rgba(233,196,106,.4); background: rgba(255,240,200,.04); font: 700 14px var(--serif); letter-spacing: .1em; text-transform: uppercase; color: var(--gold-hi); }
button.wide.go { border: 0; background: var(--goldgrad); color: #2a1a05; box-shadow: 0 6px 18px rgba(233,196,106,.25); }
button.wide small { display: block; margin-top: 3px; font: 600 11.5px var(--sans); letter-spacing: .04em; text-transform: none; color: var(--muted); }
button.wide.go small { color: #4a3208; }
#home > button.wide { margin: 0 0 12px; }
.badge { display: inline-block; margin: 4px 0; padding: 5px 14px; border-radius: 99px; border: 1px solid rgba(233,196,106,.5); color: var(--gold-hi); font-weight: 700; font-size: 13px; letter-spacing: .04em; }

.head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; position: sticky; top: -22px; padding: 6px 0; background: #1a1620; box-shadow: 0 -22px 0 #1a1620; z-index: 1; }
.head h2 { flex: 1; }
.back { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(233,196,106,.45); background: none; color: var(--gold-hi); font-size: 26px; line-height: 1; padding: 0 0 4px; }
.headpad { width: 44px; font: 700 13px var(--serif); color: var(--gold); }
table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; text-align: left; }
table.list td { padding: 8px 4px; border-bottom: 1px solid rgba(233,196,106,.12); color: var(--muted); }
table.list td + td { text-align: right; font: 700 14px var(--serif); font-variant-numeric: lining-nums tabular-nums; color: var(--gold-hi); white-space: nowrap; }
.achlist { list-style: none; padding: 0; margin: 6px 0; text-align: left; }
.achlist li { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; margin: 6px 0; border: 1px solid rgba(233,196,106,.1); opacity: .5; }
.achlist li.got { opacity: 1; border-color: rgba(233,196,106,.45); background: rgba(233,196,106,.06); }
.achlist .ic { font-size: 20px; color: var(--gold); width: 22px; text-align: center; }
.achlist b { display: block; font: 700 14px var(--serif); letter-spacing: .04em; color: var(--gold-hi); }
.achlist small { font-size: 12px; color: var(--muted); }

#toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 58px); transform: translate(-50%, calc(-100% - 90px)); visibility: hidden; width: max-content; max-width: 90vw; padding: 10px 18px; border-radius: 14px; border: 1.5px solid transparent; background: linear-gradient(#17131b, #0b090e) padding-box, var(--goldgrad) border-box; color: var(--gold-hi); font: 700 13.5px var(--serif); letter-spacing: .05em; text-align: center; box-shadow: 0 12px 34px rgba(0,0,0,.6); transition: transform .35s cubic-bezier(.3,1.3,.5,1), visibility 0s .35s; z-index: 40; pointer-events: none; }
#toast.show { transform: translate(-50%, 0); visibility: visible; transition-delay: 0s; }
