/* Skycoil: parchment and indigo ink by day, indigo night by night.
   Blue = Points, red = Mult (as in the calculator), gold ladders, green snakes. */

@font-face { font-family: 'Baloo 2'; font-weight: 500; font-display: swap; src: url(/fonts/baloo-2-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Baloo 2'; font-weight: 600; font-display: swap; src: url(/fonts/baloo-2-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Baloo 2'; font-weight: 700; font-display: swap; src: url(/fonts/baloo-2-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Baloo 2'; font-weight: 800; font-display: swap; src: url(/fonts/baloo-2-latin-800-normal.woff2) format('woff2'); }

:root {
  --ts: 1;
  --bg: #f4ead4; --bg2: #eadcbd; --paper: #fbf5e6; --ink: #282255; --ink2: #5f5785; --muted: #7d7499; --line: #c9b78c;
  --gold: #c38b22; --gold-hi: #f3c95b; --gold-ink: #7a5208; --vesh: #6d3cc0; --vesh2: #23946a;
  --tile-a: #f8efd9; --tile-b: #efe1c1; --tile-line: #c8b383; --tile-num: #8f7f59;
  --ember: #f5a524; --ember-deep: #c2560e; --good: #22895c; --bad: #c0392b; --primary: #3b2f8f; --primary-ink: #fff;
  --flood: rgba(64, 132, 199, .22); --flood-line: rgba(64, 132, 199, .5);
  --shadow: 0 6px 20px rgba(40, 34, 85, .16); --radius: 18px; --rival: #e8a33d;
  --sky1: #1d1747; --sky2: #3b2f8f;
  --pts: #2f6fd6; --mult: #d8423a; --boss: #8b3fd1;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141030; --bg2: #1d1842; --paper: #221c4d; --ink: #f2e9d4; --ink2: #c4badf; --muted: #9a90c0; --line: #3d3576;
    --gold: #e0a93a; --gold-hi: #ffd977; --gold-ink: #ffe3a1; --vesh: #9c6bff; --vesh2: #3fd39a;
    --tile-a: #2c2659; --tile-b: #251f4e; --tile-line: #4a4287; --tile-num: #9d93c9;
    --primary: #f3c95b; --primary-ink: #231b4b; --flood: rgba(80, 150, 230, .2); --flood-line: rgba(120, 180, 250, .45);
    --shadow: 0 8px 26px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141030; --bg2: #1d1842; --paper: #221c4d; --ink: #f2e9d4; --ink2: #c4badf; --muted: #9a90c0; --line: #3d3576;
  --gold: #e0a93a; --gold-hi: #ffd977; --gold-ink: #ffe3a1; --vesh: #9c6bff; --vesh2: #3fd39a;
  --tile-a: #2c2659; --tile-b: #251f4e; --tile-line: #4a4287; --tile-num: #9d93c9;
  --primary: #f3c95b; --primary-ink: #231b4b; --flood: rgba(80, 150, 230, .2); --flood-line: rgba(120, 180, 250, .45);
  --shadow: 0 8px 26px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body {
  font: 500 calc(15.5px * var(--ts))/1.4 'Baloo 2', ui-rounded, system-ui, sans-serif;
  overscroll-behavior: none; touch-action: manipulation;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}
input, textarea { user-select: text; -webkit-user-select: text; font: inherit; font-size: max(16px, 1em); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
h1, h2, h3 { margin: 0; line-height: 1.1; font-weight: 800; }
p { margin: .3em 0; }
small { font-size: .82em; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.pad { padding: 0 16px; }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.center { justify-content: center; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.ic { width: 1.4em; height: 1.4em; flex: none; }
.ic.flip { transform: scaleX(-1); }
:focus-visible { outline: 3px solid var(--gold-hi); outline-offset: 2px; border-radius: 8px; }

#app { min-height: 100%; }
.loading { display: grid; place-items: center; height: 100vh; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--gold); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 8px 18px; border-radius: 14px; border: 2px solid var(--line);
  background: var(--paper); color: var(--ink); font-weight: 700; box-shadow: 0 2px 0 var(--line);
}
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.big { min-height: 56px; font-size: 1.1em; width: 100%; }
.btn.sm { min-height: 38px; padding: 4px 12px; border-radius: 12px; }
.btn small { display: block; font-weight: 600; opacity: .8; }
.btn span { text-align: left; }
.icon-btn { width: 42px; height: 42px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 12px; flex: none; }
.icon-btn:active { background: var(--bg2); }

/* ------------------------------------------------------------------ pages */
.page { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 8px) 12px calc(env(safe-area-inset-bottom) + 24px); }
.page-head { display: flex; align-items: center; gap: 6px; margin: 4px 0 12px; }
.page-head h1 { font-size: 1.5em; }
.card { background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card h2 { font-size: 1.15em; margin-bottom: 8px; }
.card h3 { font-size: 1em; margin: 12px 0 6px; }
.input { width: 100%; min-height: 48px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); padding: 8px 12px; margin: 4px 0; }
.input.pin { letter-spacing: .4em; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs.scroll { overflow-x: auto; padding: 0 2px 4px; scrollbar-width: none; }
.tab { flex: none; min-height: 40px; padding: 4px 14px; border-radius: 999px; border: 2px solid var(--line); background: var(--paper); font-weight: 700; }
.tab.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seg { display: flex; background: var(--bg2); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 10px; background: transparent; font-weight: 700; }
.seg button.on { background: var(--paper); box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.lbl { font-weight: 700; margin: 10px 0 4px; color: var(--ink2); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 6px; }
.toggle small { display: block; color: var(--muted); }
.toggle input { width: 26px; height: 26px; accent-color: var(--gold); }
.foot { text-align: center; font-size: .82em; margin-top: 18px; }
.kicker { text-transform: uppercase; letter-spacing: .12em; font-size: .78em; font-weight: 800; color: var(--gold-ink); }

/* ------------------------------------------------------------------ title */
.page.title { position: relative; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding-top: calc(env(safe-area-inset-top) + 8px); }
body[data-screen="title"], body[data-screen="summary"] { background: linear-gradient(180deg, var(--sky1), var(--sky2) 55%, var(--bg) 100%); }
.sky-wrap { position: absolute; inset: 0 0 auto 0; height: 62vh; pointer-events: none; overflow: hidden; }
.sky { width: 100%; height: 100%; }
.bgstar { fill: #fff6dd; opacity: .6; animation: twinkle 4s ease-in-out infinite; }
.wonstar path { fill: var(--gold-hi); }
.wonstar .halo { fill: rgba(255, 217, 119, .18); }
@keyframes twinkle { 50% { opacity: .2; } }
.title-top { position: relative; display: flex; justify-content: space-between; align-items: center; color: #f6edd6; }
.title-top .icon-btn { color: #f6edd6; }
.me-chip { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.12); border: 0; border-radius: 999px; padding: 4px 14px 4px 4px; color: #f6edd6; font-weight: 700; min-height: 44px; }
.ava-sm, .ava-md, .ava-lg { display: inline-block; width: 34px; height: 34px; flex: none; }
.ava-md { width: 46px; height: 46px; }
.ava-lg { width: 72px; height: 72px; }
.ava-sm svg, .ava-md svg, .ava-lg svg { width: 100%; height: 100%; }
.hero { position: relative; text-align: center; color: #f6edd6; padding: 6vh 0 3vh; }
.logo svg { width: 120px; height: 120px; }
.logo-ladder { stroke: var(--gold-hi); stroke-width: 4; fill: none; stroke-linecap: round; }
.logo-snake { stroke: #a77bff; stroke-width: 9; fill: none; stroke-linecap: round; }
.logo-head { fill: #a77bff; }
.logo-sun { fill: #fff3c4; }
.wordmark { font-size: 2.8em; letter-spacing: .14em; margin-top: 4px; text-shadow: 0 3px 0 rgba(0,0,0,.25); }
.tag { opacity: .9; font-weight: 600; }
.stars-note { color: var(--gold-hi); font-weight: 700; }
.title-menu { position: relative; display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-grid .btn:last-child:nth-child(odd) { grid-column: span 2; }

/* ------------------------------------------------------------------ game */
body[data-screen="game"] { overflow: hidden; }
.game {
  height: 100vh; height: 100dvh; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 6px;
  padding: calc(env(safe-area-inset-top) + 4px) 10px calc(env(safe-area-inset-bottom) + 8px);
}
.g-top { display: flex; align-items: center; gap: 6px; min-height: 42px; }
.floor-name b { font-size: 1.2em; }
.floor-name small { color: var(--muted); font-weight: 700; }
.boss-chip { display: flex; align-items: center; gap: 4px; border: 2px solid var(--boss); color: var(--boss); background: color-mix(in srgb, var(--boss) 12%, var(--paper)); border-radius: 999px; padding: 2px 12px 2px 8px; font-weight: 800; min-height: 36px; }
.boss-chip .ic { width: 1.2em; height: 1.2em; }

.scorebox { position: relative; background: var(--paper); border: 2px solid var(--line); border-radius: 16px; padding: 6px 10px 8px; box-shadow: var(--shadow); }
.score-line { display: flex; align-items: baseline; gap: 8px; }
.lbl-s { font-size: .8em; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.score-num { flex: 1; font-size: 1.15em; }
.score-num b { font-size: 1.35em; }
.score-num span { color: var(--muted); font-weight: 700; }
.pips { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; max-width: 46%; }
.pips i { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); }
.pips i.used { background: var(--line); }
.bar { height: 12px; border-radius: 8px; background: var(--bg2); overflow: hidden; margin: 4px 0 6px; }
.bar-fill { height: 100%; width: 0; border-radius: 8px; background: linear-gradient(90deg, var(--gold), var(--gold-hi)); transition: width .25s; }
.bar-fill.full { background: linear-gradient(90deg, var(--good), #4fd18b); }
.calc { display: flex; align-items: center; gap: 6px; }
.chip-p, .chip-m { display: flex; align-items: baseline; justify-content: center; gap: 6px; min-width: 96px; padding: 2px 10px; border-radius: 12px; color: #fff; }
.chip-p { background: var(--pts); }
.chip-m { background: var(--mult); }
.chip-p small, .chip-m small { font-size: .7em; font-weight: 800; opacity: .85; text-transform: uppercase; }
.chip-p b, .chip-m b { font-size: 1.35em; display: inline-block; }
.times { font-weight: 800; font-size: 1.2em; color: var(--muted); }
.calc-eq { flex: 1; text-align: right; font-weight: 800; font-size: 1.1em; color: var(--muted); }
.calc-eq.big { font-size: 1.5em; color: var(--gold-ink); animation: land .3s ease-out; }
.bump { animation: bump .28s ease-out; }
@keyframes bump { 50% { transform: scale(1.25); } }
.calc-float { position: absolute; right: 10px; bottom: -12px; z-index: 5; background: var(--ink); color: var(--bg); font-weight: 800; font-size: .85em; border-radius: 10px; padding: 1px 10px; animation: floatUp 1.2s ease-out forwards; pointer-events: none; white-space: nowrap; }
@keyframes floatUp { 0% { opacity: 0; transform: translateY(6px); } 15% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }
@keyframes land { 0% { transform: scale(1.3); } 100% { transform: none; } }

.board-area { flex: 1; min-height: 0; container-type: size; display: grid; place-items: center; }
.board-wrap { position: relative; }
.board { width: 100%; height: 100%; display: block; touch-action: manipulation; }
.track { fill: none; stroke: var(--line); stroke-width: 6; stroke-dasharray: 2 14; stroke-linecap: round; opacity: .8; }
.chev { fill: none; stroke: var(--tile-num); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: .55; }
.lap-t { font: 800 15px 'Baloo 2', sans-serif; fill: var(--gold-ink); text-anchor: middle; paint-order: stroke; stroke: var(--bg); stroke-width: 4; }
.tile .tbg { fill: var(--tile-a); stroke: var(--tile-line); stroke-width: 2; }
.tile.empty .tbg { fill: color-mix(in srgb, var(--tile-a) 70%, transparent); stroke-dasharray: 6 6; }
.tile .dot { fill: var(--tile-num); opacity: .5; }
.tile.start .tbg { fill: color-mix(in srgb, var(--gold-hi) 30%, var(--tile-a)); stroke: var(--gold); }
.start-t { font: 800 21px 'Baloo 2', sans-serif; fill: var(--gold-ink); text-anchor: middle; letter-spacing: .06em; }
.tile.c-gold .tbg { fill: color-mix(in srgb, var(--gold-hi) 40%, var(--tile-a)); stroke: var(--gold); }
.tile.c-blue .tbg { fill: color-mix(in srgb, var(--pts) 22%, var(--tile-a)); stroke: var(--pts); }
.tile.c-red .tbg { fill: color-mix(in srgb, var(--mult) 22%, var(--tile-a)); stroke: var(--mult); }
.tile.c-green .tbg { fill: color-mix(in srgb, var(--vesh2) 24%, var(--tile-a)); stroke: var(--vesh2); }
.tile.c-gold .tic { color: var(--gold-ink); } .tile.c-blue .tic { color: var(--pts); } .tile.c-red .tic { color: var(--mult); } .tile.c-green .tic { color: var(--vesh2); }
.tile .tic { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tile.muted { opacity: .38; }
.lv { font: 800 22px 'Baloo 2', sans-serif; fill: var(--ink); text-anchor: end; }
.grow-t { font: 800 17px 'Baloo 2', sans-serif; fill: var(--vesh2); text-anchor: middle; }
.up-t { font: 800 13px 'Baloo 2', sans-serif; fill: var(--good); text-anchor: middle; letter-spacing: .04em; }
.tile.hl .tbg { stroke: var(--gold); stroke-width: 5; animation: glow 1s ease-in-out infinite alternate; }
.tile.hl.lvl .tbg { stroke: var(--good); }
@keyframes glow { from { stroke-opacity: .45; } to { stroke-opacity: 1; } }
.tile.flash .tbg { animation: tflash .5s ease-out; }
.tile.placed .tbg { animation: tflash .6s ease-out; }
@keyframes tflash { 0% { filter: brightness(1.5) drop-shadow(0 0 10px var(--gold-hi)); } 100% { filter: none; } }
.ladder, .snake { pointer-events: none; opacity: .8; }
.l-rail { stroke: var(--gold); stroke-width: 6; fill: none; stroke-linecap: round; }
.l-rung { stroke: var(--gold); stroke-width: 4; fill: none; stroke-linecap: round; }
.s-body { stroke: var(--vesh2); stroke-width: 15; fill: none; stroke-linecap: round; opacity: .85; }
.s-belly { stroke: #fff; stroke-width: 3; fill: none; stroke-dasharray: 3 10; stroke-linecap: round; opacity: .6; }
.s-head { fill: var(--vesh2); stroke: rgba(0,0,0,.25); stroke-width: 2; }
.s-eye { fill: #ffe46b; }
.s-tail { fill: var(--vesh2); }
.token { pointer-events: none; transition: transform .12s ease-out; }
.reduce .token { transition: none; }
.tok-glow { fill: rgba(255, 186, 60, .32); }
.tok-core { fill: var(--ember); stroke: #fff2c2; stroke-width: 4; }
.tok-shine { fill: rgba(255,255,255,.75); }
.pops { position: absolute; inset: 0; pointer-events: none; }
.pop { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; font-weight: 800; font-size: 1.05em; border-radius: 10px; padding: 0 8px; z-index: 3; animation: popUp 1.1s ease-out forwards; color: #fff; background: var(--pts); box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.pop.small { font-size: .8em; background: color-mix(in srgb, var(--pts) 70%, transparent); padding: 0 5px; }
.pop.mult { background: var(--mult); }
.pop.x { background: linear-gradient(90deg, var(--mult), var(--gold)); font-size: 1.15em; }
.pop.info { background: var(--paper); color: var(--ink); border: 2px solid var(--gold); }
.pop.muted { border-color: var(--muted); color: var(--muted); }
@keyframes popUp { 0% { opacity: 0; transform: translate(-50%, -20%) scale(.7); } 15% { opacity: 1; transform: translate(-50%, -75%) scale(1.08); } 75% { opacity: 1; transform: translate(-50%, -105%); } 100% { opacity: 0; transform: translate(-50%, -130%); } }
.roll-fx { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 4; }
.die-face { width: 84px; height: 84px; border-radius: 20px; display: grid; place-items: center; font-size: 3em; font-weight: 800; background: var(--paper); color: var(--ink); border: 4px solid var(--ink); box-shadow: 0 8px 20px rgba(0,0,0,.3); }
.die-face.again { border-color: var(--pts); }
.die-face.done { animation: land .3s ease-out; }
.banner { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 6; display: grid; justify-items: center; padding: 14px 26px; border-radius: 20px; background: var(--paper); border: 3px solid var(--gold); box-shadow: var(--shadow); pointer-events: none; text-align: center; animation: land .35s ease-out; }
.banner b { font-size: 1.6em; }
.banner.good { border-color: var(--good); }
.banner.good b { color: var(--good); }
.banner.bad { border-color: var(--bad); }
.banner.bad b { color: var(--bad); }
.intro-wrap { position: absolute; inset: 0; display: grid; place-items: center; z-index: 7; background: color-mix(in srgb, var(--bg) 55%, transparent); border-radius: 14px; animation: fadeIn .2s; }
.intro-wrap.out { opacity: 0; transition: opacity .2s; }
.intro { display: grid; justify-items: center; gap: 2px; text-align: center; background: var(--paper); border: 3px solid var(--gold); border-radius: 20px; padding: 12px 22px; max-width: 88%; box-shadow: var(--shadow); }
.intro.boss { border-color: var(--boss); }
.intro-target { font-size: 1.8em; line-height: 1.05; }
.intro-boss { display: flex; gap: 8px; align-items: center; text-align: left; color: var(--boss); margin-top: 6px; }
.intro-boss b { color: var(--boss); }
.intro-tip { font-weight: 700; }
@keyframes fadeIn { from { opacity: 0; } }

.charms { display: flex; gap: 6px; justify-content: center; min-height: 46px; }
.charm { position: relative; width: 46px; height: 46px; border-radius: 14px; border: 2px solid var(--line); background: var(--paper); display: grid; place-items: center; padding: 0; color: var(--ink); }
.charm .ic { width: 26px; height: 26px; }
.charm.r2 { border-color: var(--pts); }
.charm.r3 { border-color: var(--gold); background: color-mix(in srgb, var(--gold-hi) 25%, var(--paper)); }
.charm.empty { border-style: dashed; background: transparent; opacity: .45; }
.ch-n { position: absolute; right: -6px; bottom: -6px; font-style: normal; font-size: 11px; font-weight: 800; background: var(--mult); color: #fff; border-radius: 8px; padding: 0 4px; line-height: 16px; }

.tray { display: grid; gap: 6px; }
.hint { margin: 0; min-height: 1.4em; text-align: center; font-weight: 700; color: var(--ink2); font-size: .92em; }
.offers { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; min-height: 92px; transition: opacity .2s; }
.offers.dim { opacity: .35; pointer-events: none; }
.offer { display: grid; justify-items: center; align-content: start; gap: 0; text-align: center; padding: 6px 4px; border-radius: 14px; border: 2px solid var(--line); background: var(--paper); min-height: 92px; }
.offer .o-ic .ic { width: 28px; height: 28px; }
.offer b { font-size: .95em; line-height: 1.1; }
.offer small { font-size: .74em; line-height: 1.15; color: var(--ink2); }
.offer.c-gold .o-ic { color: var(--gold-ink); } .offer.c-blue .o-ic { color: var(--pts); } .offer.c-red .o-ic { color: var(--mult); } .offer.c-green .o-ic { color: var(--vesh2); }
.offer.sel { border-color: var(--gold); background: color-mix(in srgb, var(--gold-hi) 28%, var(--paper)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold-hi) 55%, transparent); }
.o-up { color: var(--good); font-size: .8em; }
.no-offers { grid-column: 1 / -1; text-align: center; align-self: center; }
.roll-btn { min-height: 58px; font-size: 1.3em; border-radius: 18px; }
.roll-btn small { font-size: .65em; opacity: .8; font-weight: 700; }
.roll-btn .ic { width: 1.3em; height: 1.3em; }
.roll-btn:disabled { opacity: .55; }

/* lists in sheets and pages */
.offer-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.offer-list .offer { cursor: default; }
.charm-list { display: grid; gap: 8px; }
.charm-card { display: flex; align-items: center; gap: 12px; text-align: left; border: 2px solid var(--line); background: var(--bg); border-radius: 14px; padding: 10px 12px; min-height: 60px; color: var(--ink); }
.charm-card b { display: block; }
.charm-card small { display: block; color: var(--ink2); }
.charm-card .ch-ic .ic { width: 30px; height: 30px; }
.charm-card.r2 { border-color: var(--pts); }
.charm-card.r3 { border-color: var(--gold); background: color-mix(in srgb, var(--gold-hi) 18%, var(--bg)); }
.charm-card.boss { border-color: var(--boss); }
.charm-card.boss .ch-ic { color: var(--boss); }
.rules ol { padding-left: 20px; }
.rules li { margin: 6px 0; }
.rules h3 { margin: 16px 0 8px; }
.floor-list { display: grid; gap: 4px; }
.fl-row { display: flex; gap: 10px; align-items: center; padding: 4px 8px; border-radius: 10px; background: var(--bg); }
.fl-row.failed { box-shadow: inset 3px 0 0 var(--bad); }
.bad-t { color: var(--bad); font-weight: 700; }
.btn.danger { color: var(--bad); }
@media (max-height: 700px) {
  .offer small { font-size: .68em; }
  .offers, .offer { min-height: 84px; }
  .roll-btn { min-height: 52px; }
}

/* sheets */
.sheet-wrap { position: fixed; inset: 0; z-index: 100; background: rgba(10, 6, 30, 0); display: flex; align-items: flex-end; justify-content: center; transition: background .2s; }
.sheet-wrap.open { background: rgba(10, 6, 30, .45); }
.sheet { width: 100%; max-width: 560px; max-height: 86vh; display: flex; flex-direction: column; background: var(--paper); border-radius: 22px 22px 0 0; border: 2px solid var(--line); border-bottom: 0; box-shadow: var(--shadow); transform: translateY(100%); transition: transform .2s ease-out; padding-bottom: env(safe-area-inset-bottom); }
.sheet-wrap.open .sheet { transform: none; }
.sheet-head { display: flex; align-items: flex-start; gap: 8px; padding: 14px 14px 6px 18px; }
.sheet-title { flex: 1; }
.sheet-title h2 { font-size: 1.3em; }
.sheet-sub { color: var(--ink2); margin: 2px 0 0; }
.sheet-body { overflow-y: auto; padding: 4px 16px 18px; }
.choice-row { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.choice-col { display: grid; gap: 8px; }
.choice-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.choice { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 52px; border: 2px solid var(--line); background: var(--bg); border-radius: 14px; padding: 8px 12px; text-align: center; }
.choice-col .choice { align-items: stretch; text-align: left; }
.choice.dis { opacity: .5; }
.choice .why { color: var(--bad); }
.choice .cost { display: inline-flex; align-items: center; gap: 2px; color: var(--gold-ink); font-weight: 800; margin-left: 6px; }
.choice .cost .ic { width: 16px; height: 16px; }
.choice-cards .choice { padding: 6px; border: 0; background: transparent; }
.shrine-card { display: flex; align-items: center; gap: 10px; }
.shrine-card .gcard { flex: none; }
.shrine-card > span:nth-child(2) { display: grid; gap: 2px; flex: 1; }
.shrine-card small { color: var(--muted); }
.inspect { display: grid; justify-items: center; gap: 6px; text-align: center; }
.inspect-ic { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 18px; background: var(--bg2); }
.inspect-ic .ic { width: 40px; height: 40px; }
.inspect p { font-size: 1.05em; }
.die-faces-big { display: grid; gap: 6px; text-align: left; }
.face-row { display: flex; align-items: center; gap: 10px; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.log li { padding: 2px 8px; border-left: 3px solid var(--gold); font-size: .95em; }
.log li.theirs { border-left-color: var(--rival); color: var(--ink2); }
.log li.log-turn { border: 0; margin-top: 8px; font-weight: 800; color: var(--muted); font-size: .85em; text-transform: uppercase; letter-spacing: .06em; }
.menu { display: grid; gap: 8px; }
.menu-item { display: flex; align-items: center; gap: 12px; min-height: 52px; border: 2px solid var(--line); background: var(--bg); border-radius: 14px; padding: 6px 14px; font-weight: 700; text-align: left; }
.satchel h3 { margin: 12px 0 6px; }
.sat-die { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.die-faces-row { display: flex; gap: 4px; }
.face-btn { border: 0; background: transparent; padding: 0; }
.sat-relics { display: grid; gap: 6px; }
.sat-relic { display: flex; gap: 10px; align-items: center; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); padding: 6px 10px; }
.sat-relic small { display: block; color: var(--muted); }
.sat-deck { display: flex; flex-wrap: wrap; gap: 8px; }
.sat-card { position: relative; border: 0; background: transparent; padding: 0; }
.sat-card .n { position: absolute; right: -4px; bottom: -4px; background: var(--ink); color: var(--bg); border-radius: 8px; padding: 0 5px; font-size: .8em; }
.rules ol { padding-left: 20px; }
.rules li { margin: 4px 0; }
.id-form { display: grid; gap: 8px; }

/* codex / stats / summary */
.codex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; padding: 4px; }
.codex-grid.cards { grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); justify-items: center; }
.codex-grid:not(.cards) { grid-template-columns: 1fr; }
.codex-item { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; text-align: left; border: 2px solid var(--line); background: var(--paper); border-radius: 14px; padding: 8px 12px; }
.codex-item > :first-child { grid-row: span 2; }
.codex-item small { color: var(--muted); }
.codex-item .ic { width: 32px; height: 32px; }
.codex-item.unknown { opacity: .4; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.stat-tile { background: var(--bg); border-radius: 12px; padding: 8px; text-align: center; }
.stat-tile b { display: block; font-size: 1.5em; }
.stat-tile small { color: var(--muted); }
.history { display: grid; gap: 6px; }
.hist-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 12px; background: var(--bg); }
.hist-row small { display: block; color: var(--muted); }
.hist-row.won { box-shadow: inset 3px 0 0 var(--gold); }
.lb-list { display: grid; gap: 6px; }
.lb-row { display: flex; align-items: center; gap: 10px; min-height: 42px; }
.lb-row.me { font-weight: 800; color: var(--gold-ink); }
.lb-card { background: var(--bg); border-radius: 12px; padding: 4px 10px; }
.lb-sub { display: flex; gap: 12px; flex-wrap: wrap; font-size: .8em; color: var(--muted); padding: 0 0 4px 44px; }
.daily-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.daily-row small { display: block; color: var(--muted); }
.trial.focus { border-color: var(--gold); }
.page.summary { position: relative; }
.page.summary .sky-wrap { height: 40vh; }
.sum-head { position: relative; text-align: center; display: grid; justify-items: center; gap: 8px; padding: 24px 0 16px; }
body[data-screen="summary"] .sum-head { color: #f6edd6; }
.sum-head h1 { font-size: 1.8em; }
.score { text-align: center; }
.score b { display: block; font-size: 2.6em; color: var(--gold-ink); }
.realm-results { display: grid; gap: 4px; }
.rr { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; padding: 4px 8px; border-radius: 10px; }
.rr .ic { grid-row: span 2; color: var(--muted); }
.rr.won .ic { color: var(--gold); }
.rr small { color: var(--muted); }
.unlock { border-color: var(--gold); }

#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 160px); transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 12px; font-weight: 700; opacity: 0; transition: .2s; z-index: 200; max-width: 88vw; text-align: center; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* short phones: tighten the chrome so the board keeps its size */
@media (max-height: 700px) {
  .race { gap: 0; padding-bottom: 2px; }
  .rival-chip, .realm-chip { min-height: 40px; }
  .hand { min-height: 96px; padding-top: 4px; }
  .gcard { height: 90px; padding-top: 16px; }
  .die-btn { min-height: 50px; }
  .prompt { min-height: 40px; }
}
/* landscape tablets and desktop: board left, controls right */
@media (min-aspect-ratio: 3/2) and (min-width: 820px) {
  .game { max-width: 1180px; display: grid; grid-template-columns: minmax(0, 1fr) 380px; grid-template-rows: auto auto 1fr; column-gap: 16px; }
  .top { grid-column: 2; grid-row: 1; }
  .board-area { grid-column: 1; grid-row: 1 / span 3; }
  .prompt { grid-column: 2; grid-row: 2; }
  .tray { grid-column: 2; grid-row: 3; align-self: start; }
  .hand { flex-wrap: wrap; }
}

.reduce *, .reduce *::before, .reduce *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
}
.row.gap > div > b, .row.gap > div > small { display: block; }
.sheet-wrap:not(.open) { pointer-events: none; }
.codex-grid.cards .codex-item.unknown { width: 70px; height: 100px; padding: 0; display: grid; place-items: center; grid-template-columns: 1fr; grid-template-rows: 1fr auto; border-radius: 11px; border-style: dashed; }
.codex-grid.cards .codex-item.unknown > :first-child { grid-row: auto; align-self: end; }
.codex-grid.cards .codex-item.unknown b { align-self: start; font-size: 12px; }
