: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; }
#bgShade { position: absolute; inset: 0; background: radial-gradient(90% 60% at 50% 45%, rgba(7,6,10,.1), rgba(7,6,10,.55)), linear-gradient(180deg, rgba(7,6,10,.55), rgba(7,6,10,.1) 30%, rgba(7,6,10,.25) 75%, rgba(7,6,10,.8)); transition: background .6s; }
/* darker veil behind the well so the blocks stay readable */
#bgShade.play { background: radial-gradient(90% 60% at 50% 45%, rgba(7,6,10,.5), rgba(7,6,10,.74)), linear-gradient(180deg, rgba(7,6,10,.7), rgba(7,6,10,.45) 30%, rgba(7,6,10,.55) 75%, rgba(7,6,10,.88)); }
#bgShade.danger { background: radial-gradient(90% 60% at 50% 45%, rgba(60,8,20,.5), rgba(30,4,10,.76)), linear-gradient(180deg, rgba(60,8,20,.7), rgba(40,6,14,.45) 35%, rgba(40,6,14,.55) 70%, rgba(20,2,6,.9)); }

#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; }
.view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.view.show { display: flex; animation: viewIn .45s ease-out; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } }

/* ---------- home ---------- */
#home { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
#home::-webkit-scrollbar { display: none; }
.titleArt { position: relative; flex: none; width: 100%; aspect-ratio: 16 / 8.5; border-radius: 18px; background: 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, .panel 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 { flex: none; margin: 16px 0 0; text-align: center; font: 700 38px/1.05 var(--serif); letter-spacing: .1em; 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)); }
.tag { flex: none; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); margin: 8px 0 16px; font-size: 11px; letter-spacing: .34em; text-transform: uppercase; white-space: nowrap; }
.tag::before, .tag::after { content: ""; width: 34px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold)); }
.tag::after { transform: scaleX(-1); }

.modes { flex: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.mode { position: relative; overflow: hidden; min-width: 0; border-radius: 16px; padding: 9px 4px 9px; display: flex; flex-direction: column; align-items: center; gap: 2px; 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; }
.mode.first { background: linear-gradient(150deg, #4a0d1c, #1a0509 75%) padding-box, var(--goldgrad) border-box; }
.mode:active { transform: scale(.96); }
.mode img { width: 58%; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 4px 8px rgba(0,0,0,.6)); }
.mode b { max-width: 100%; font: 700 13px/1.2 var(--serif); letter-spacing: .04em; white-space: nowrap; background: var(--goldgrad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.mode small { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.25; min-height: 2.5em; padding: 0 2px; }
.mode .rec { font: 700 11.5px var(--serif); color: var(--gold-hi); min-height: 14px; font-variant-numeric: lining-nums; }

.homebtns { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 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: .08em; color: var(--gold-hi); }
button.mid.span2 { grid-column: span 2; }
button.mid small { display: block; font: 500 11px var(--sans); letter-spacing: .04em; color: var(--muted); margin-top: 3px; }
button.mid:active { background: rgba(233,196,106,.12); }
button.mid .mi { width: 22px; height: 22px; object-fit: contain; vertical-align: -6px; margin-right: 6px; }
button.mid svg.mi { fill: none; stroke: var(--gold); stroke-width: 1.7; stroke-linecap: round; }
.fine { flex: none; text-align: center; font-size: 11.5px; color: var(--muted); margin: 12px 0 4px; letter-spacing: .03em; line-height: 1.5; }
.fine a { color: var(--gold); font-weight: 700; text-decoration: none; }

/* ---------- game ---------- */
#gtop { 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); }
.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.right { align-items: flex-end; flex: none; }
.label { font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--muted); min-height: 13px; }
.gstat b { font: 700 20px/1.15 var(--serif); letter-spacing: .05em; white-space: nowrap; font-variant-numeric: lining-nums tabular-nums; background: var(--goldgrad); -webkit-background-clip: text; background-clip: text; color: transparent; }
#stage { position: relative; flex: 1; min-height: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }

/* touch controls: the whole grid cell is the touch target, the round medal sits in its middle */
#pad { flex: none; display: grid; grid-template-columns: repeat(12, 1fr); grid-template-rows: 58px 66px; gap: 6px 8px; margin-top: 6px; }
#pad.gest { display: none; }
.k { grid-column: span 3; position: relative; border: 0; padding: 0; background: none; display: grid; place-items: center; color: var(--gold-hi); touch-action: none; font: 700 11px var(--serif); letter-spacing: .1em; }
.k::before { content: ""; position: absolute; left: 50%; top: 50%; height: 100%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; 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 .08s, box-shadow .15s; }
.k svg, .k span { position: relative; }
.k svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 1px 1px rgba(0,0,0,.7)); }
.k.down::before { transform: translate(-50%, -50%) scale(.93); box-shadow: 0 0 0 2px rgba(255,241,193,.85), 0 0 22px rgba(233,196,106,.7), inset 0 0 14px rgba(233,196,106,.35); }
.k.drop::before { background: radial-gradient(circle at 40% 30%, #a3243f, #4a0d1c 60%, #1a0509) padding-box, var(--goldgrad) border-box; }
.k[data-k=left], .k[data-k=soft], .k[data-k=right] { grid-column: span 4; }
.k.off { opacity: .3; }

/* ---------- overlays ---------- */
.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; scrollbar-width: none; }
.panel::-webkit-scrollbar { display: none; }
.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 .big { margin: 6px 0; font: 700 40px/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); overflow-wrap: anywhere; }
.panel p { color: var(--muted); font-size: 13.5px; margin: 6px 0; line-height: 1.45; }
.panel p.sec { margin: 18px 0 2px; font: 700 12px var(--serif); letter-spacing: .22em; text-transform: uppercase; color: var(--gold); }
.panel .icon { width: 76px; height: 76px; margin: 0 auto 4px; background: center / contain no-repeat; filter: drop-shadow(0 6px 12px rgba(0,0,0,.6)); }
.panel 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 15px var(--serif); letter-spacing: .1em; text-transform: uppercase; color: var(--gold-hi); }
.panel button.wide:active { background: rgba(233,196,106,.14); }
.panel button.wide.go { border: 0; background: var(--goldgrad); color: #2a1a05; box-shadow: 0 6px 18px rgba(233,196,106,.25); }
.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; animation: pop .5s cubic-bezier(.3,1.6,.5,1) both .3s; }
@keyframes pop { from { transform: scale(0); } }
.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 { flex: none; 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); color: var(--gold-hi); font-variant-numeric: lining-nums tabular-nums; 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: .62; }
.achlist li.got { opacity: 1; border-color: rgba(233,196,106,.45); background: rgba(233,196,106,.06); }
.achlist .ic { flex: none; width: 28px; height: 28px; display: grid; place-items: center; font-size: 17px; color: var(--muted); }
.achlist .ic img { width: 28px; height: 28px; object-fit: contain; }
.achlist b { display: block; font: 700 14px var(--serif); letter-spacing: .04em; color: var(--gold-hi); } .achlist small { color: var(--muted); font-size: 12px; }

.set { text-align: left; margin: 8px 0 12px; }
.set label.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 50px; padding: 3px 2px; border-bottom: 1px solid rgba(233,196,106,.12); font-size: 13.5px; color: var(--text); }
.set input[type=checkbox] { flex: none; width: 22px; height: 22px; accent-color: #c99a32; }
.set input[type=range] { width: 46%; height: 44px; margin: 0; accent-color: #c99a32; }
.seg { flex: none; display: flex; gap: 5px; }
.seg button { min-height: 44px; border-radius: 11px; padding: 0 9px; border: 1px solid rgba(233,196,106,.35); background: transparent; font: 700 11.5px var(--serif); letter-spacing: .06em; color: var(--muted); }
.seg button.on { border-color: transparent; background: var(--goldgrad); color: #2a1a05; }
.keys { font-size: 12px; color: var(--muted); text-align: left; line-height: 1.6; margin-top: 10px; }
.keys b { color: var(--gold-hi); font-weight: 600; }

#toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 58px); transform: translate(-50%, -220%); 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; }

@media (max-width: 374px) {
  h1 { font-size: 33px; }
  .mode b { font-size: 12px; letter-spacing: .02em; }
  .tag { letter-spacing: .28em; }
  .seg button { padding: 0 7px; }
}
