: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; }

#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; }
/* dark veil so the ivory tiles stay readable over the video */
#bgShade { position: absolute; inset: 0; background: radial-gradient(95% 62% at 50% 46%, rgba(7,6,10,.62), rgba(7,6,10,.5)), linear-gradient(180deg, rgba(7,6,10,.7), rgba(7,6,10,.25) 28%, rgba(7,6,10,.35) 72%, rgba(7,6,10,.85)); transition: background .4s; }
body.athome #bgShade { background: radial-gradient(90% 60% at 50% 45%, rgba(7,6,10,.35), rgba(7,6,10,.62)), linear-gradient(180deg, rgba(7,6,10,.6), rgba(7,6,10,.3) 30%, rgba(7,6,10,.45) 75%, rgba(7,6,10,.85)); }

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

/* ---------- game header ---------- */
#hud { flex: none; display: flex; align-items: center; gap: 10px; height: 48px; }
.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; }
.topbtn:active { transform: scale(.94); }
.gstat { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.gstat.mid { align-items: center; } .gstat.right { align-items: flex-end; }
.label { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.gstat b { font: 700 21px var(--serif); font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; background: var(--goldgrad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.gstat.mid b { font-size: 26px; line-height: 1.1; }

/* ---------- stage ---------- */
#stage { position: relative; flex: 1; min-height: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }

/* ---------- tools ---------- */
#controls { flex: none; display: flex; justify-content: center; gap: 22px; margin-top: 6px; }
.tool { position: relative; width: 72px; min-height: 66px; border: 0; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tool .medal { width: 50px; height: 50px; 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 5px 12px rgba(0,0,0,.55), inset 0 0 12px rgba(233,196,106,.15); transition: transform .12s; }
.tool:active .medal { transform: scale(.93); }
.tool img { width: 34px; height: 34px; object-fit: contain; }
.tool span { font: 600 11px var(--serif); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.tool em { position: absolute; top: -3px; right: 4px; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 10px; background: var(--goldgrad); color: #2a1a05; font: 800 11px/20px var(--sans); font-style: normal; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
.tool.empty { opacity: .4; } .tool.empty em { background: #4a4150; color: #fff; }

/* ---------- 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; }
body.athome .overlay { background: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
.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 23px var(--serif); letter-spacing: .08em; background: var(--goldgrad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.panel .bignum { margin: 6px 0; font: 700 42px var(--serif); color: var(--gold-hi); font-variant-numeric: lining-nums tabular-nums; text-shadow: 0 0 22px rgba(233,196,106,.35); }
.panel p { color: var(--muted); font-size: 13.5px; line-height: 1.45; margin: 6px 0; }
.panel img.emb { width: 64px; height: 64px; object-fit: contain; filter: drop-shadow(0 6px 12px rgba(0,0,0,.6)); }
button.wide { position: relative; overflow: hidden; display: block; width: 100%; min-height: 46px; margin: 9px 0; padding: 12px; border-radius: 13px; border: 1px solid rgba(233,196,106,.4); background: rgba(255,240,200,.04); font: 700 14.5px 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:active { transform: scale(.98); }
.winstars { font-size: 52px; letter-spacing: 8px; line-height: 1.1; margin: 6px 0; }
.winstars span { display: inline-block; color: rgba(255,240,200,.13); }
.winstars span.on { background: var(--goldgrad); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 12px rgba(233,196,106,.6)); animation: starPop .6s cubic-bezier(.3,1.6,.5,1) both; animation-delay: calc(.3s + var(--i) * .3s); }
@keyframes starPop { from { transform: scale(0) rotate(-40deg); opacity: 0; } }
.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 { 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; flex: none; }
.headpad { width: 44px; font-size: 13px; color: var(--gold); flex: none; }
table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; text-align: left; }
table.list td { padding: 9px 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); color: var(--gold-hi); font-variant-numeric: lining-nums tabular-nums; }
.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 { width: 30px; height: 30px; flex: none; object-fit: contain; }
.achlist li:not(.got) .ic { filter: grayscale(1) brightness(.7); }
.achlist b { display: block; font: 700 14px var(--serif); letter-spacing: .04em; color: var(--gold-hi); }
.achlist small { color: var(--muted); font-size: 12px; }

#toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 58px); transform: translate(-50%, -260%); 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); opacity: 0; transition: transform .35s cubic-bezier(.3,1.3,.5,1), opacity .25s; z-index: 40; pointer-events: none; }
#toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- home (drawn in the overlay panel, styled as a full view) ---------- */
.panel.home { max-width: 560px; height: 100%; padding: 0 2px; border: 0; border-radius: 0; background: none; box-shadow: none; text-align: left; animation: viewIn .45s ease-out; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } }
.titleArt { position: relative; width: 100%; aspect-ratio: 16 / 8.5; border-radius: 18px; background: url(media/title-lux.webp) center / cover no-repeat; box-shadow: 0 14px 40px rgba(0,0,0,.6); overflow: hidden; margin-bottom: 16px; }
.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; } }
.crest { display: block; width: 74px; height: 74px; object-fit: contain; margin: 10px auto 4px; filter: drop-shadow(0 8px 16px rgba(0,0,0,.6)); }
h1 { margin: 0; text-align: center; white-space: nowrap; font: 700 clamp(24px, 7.4vw, 36px)/1.05 var(--serif); letter-spacing: .07em; 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)); }
.panel p.tag { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); margin: 8px 0 16px; font-size: 11px; letter-spacing: .32em; text-transform: uppercase; white-space: nowrap; }
.tag::before, .tag::after { content: ""; width: 30px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold)); }
.tag::after { transform: scaleX(-1); }
.cards { display: grid; grid-template-columns: 1fr; gap: 10px; }
.card { position: relative; overflow: hidden; min-height: 64px; border-radius: 16px; padding: 10px 14px; display: flex; align-items: center; gap: 12px; 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 { padding: 14px; background: linear-gradient(135deg, #4a0d1c, #1a0509 70%) padding-box, var(--goldgrad) border-box; }
.card.daily { background: linear-gradient(135deg, #0f3a2c, #04140f 70%) padding-box, var(--goldgrad) border-box; }
.card:active { transform: scale(.97); }
.card img { width: 46px; height: 46px; flex: none; 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: 60px; height: 60px; }
@keyframes bob { 50% { transform: translateY(-3px); } }
.card b { display: block; font: 700 17px var(--serif); letter-spacing: .06em; background: var(--goldgrad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.card.big b { font-size: 21px; }
.card small { display: block; margin-top: 2px; font-size: 12px; line-height: 1.35; color: var(--muted); letter-spacing: .03em; }
.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 12.5px var(--serif); letter-spacing: .06em; color: var(--gold-hi); text-align: center; }
button.mid small { display: block; font: 500 11px var(--sans); letter-spacing: .04em; color: var(--muted); margin-top: 3px; }
button.mid.span2 { grid-column: span 2; }
button.mid img.mi { width: 22px; height: 22px; object-fit: contain; vertical-align: -6px; margin-right: 6px; }
button.mid:active { background: rgba(233,196,106,.12); }
.toggles { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 16px; margin: 10px 0 2px; 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; }
details { margin-top: 4px; border: 1px solid rgba(233,196,106,.25); border-radius: 14px; background: rgba(12,10,16,.6); }
summary { cursor: pointer; text-align: center; min-height: 44px; line-height: 44px; font: 600 12.5px/44px var(--serif); letter-spacing: .1em; text-transform: uppercase; color: var(--gold-hi); }
details p { padding: 0 14px; margin: 0 0 10px; }
details b { color: var(--text); }
.panel p.fine { text-align: center; font-size: 11.5px; color: var(--muted); margin: 12px 0 8px; letter-spacing: .03em; }
.fine a { color: var(--gold); font-weight: 700; text-decoration: none; }
