/* HeroQuest: the look of the 1989 box. Crimson and gold on black, parchment
   for Mentor's quest book, dark iron for the table edge, red plastic heroes. */

@font-face { font-family: 'Grenze Gotisch'; src: url(../fonts/gotisch.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Grenze'; src: url(../fonts/grenze.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'IM Fell English'; src: url(../fonts/fell.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'IM Fell English'; src: url(../fonts/fell-italic.woff2) format('woff2'); font-style: italic; font-display: swap; }

:root {
  --void: #0d0a08;
  --iron: #221b17;
  --iron-2: #2e241e;
  --iron-3: #3b2f27;
  --iron-edge: #5d4838;
  --crimson: #8f1d14;
  --crimson-hi: #b9342a;
  --crimson-deep: #4a0c07;
  --gold: #e8b13d;
  --gold-hi: #ffe39a;
  --gold-deep: #9c5e0e;
  --parchment: #e7d4a9;
  --parchment-2: #d6bd88;
  --ink: #3a2412;
  --ink-soft: #6a4a2c;
  --ink-red: #8c1c13;
  --bp: #d8402e;
  --mp: #5b8fdc;
  --text: #ecdcbc;
  --text-dim: #b6a07e;
  --display: 'Grenze Gotisch', 'Grenze', serif;
  --ui: 'Grenze', 'Georgia', serif;
  --book: 'IM Fell English', 'Georgia', serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--void); color: var(--text); font-family: var(--ui); font-size: 17px; line-height: 1.35; overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
.ico { width: 1.2em; height: 1.2em; display: block; flex: none; }

#board, #board3d { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#board3d { visibility: hidden; }
/* The 3D dungeon fades to black at the edges, as if seen by torchlight. */
#vignette3d { display: none; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse 75% 70% at 50% 48%, transparent 55%, rgba(4, 3, 6, 0.55) 85%, rgba(4, 3, 6, 0.85) 100%); }
#rotate-btn { display: none; }
body.view3d #rotate-btn { display: grid; }
.loading3d { position: fixed; inset: 0; z-index: 70; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(8,6,5,.92); color: var(--parchment); font-family: var(--book); font-style: italic; font-size: 19px; text-align: center; padding: 20px; }
.loading3d.on { display: flex; }
.loading3d .bar { width: min(280px, 70vw); height: 8px; border-radius: 4px; background: #2b1d17; overflow: hidden; border: 1px solid var(--iron-edge); }
.loading3d .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-deep), var(--gold)); transition: width .2s; }

/* ------------------------------------------------------------ screens */
.screen { position: fixed; inset: 0; z-index: 20; display: none; flex-direction: column; background: var(--void); }
.screen.on { display: flex; animation: screen-in .35s ease both; }
@keyframes screen-in { from { opacity: 0; } }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 16px max(16px, var(--safe-l)) 24px max(16px, var(--safe-r)); }
.screen-head { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 14px 10px; background: linear-gradient(var(--crimson-deep), #2a0805); border-bottom: 2px solid var(--gold-deep); box-shadow: 0 2px 0 #000; }
.screen-head h2 { font-family: var(--display); font-weight: 700; font-size: 28px; color: var(--gold); letter-spacing: .01em; text-shadow: 0 2px 0 #000; line-height: 1.1; }
.screen-foot { display: flex; gap: 10px; padding: 12px 16px calc(12px + var(--safe-b)); background: linear-gradient(#1b1411, #120d0a); border-top: 1px solid var(--iron-edge); }
.screen-foot.two > * { flex: 1; }
.screen-foot .btn { flex: 1; }
.screen-foot.on-parchment { background: linear-gradient(#2a1d14, #1a120c); border-top: 2px solid var(--gold-deep); }
.paper-screen { background: radial-gradient(120% 80% at 50% 0%, #2c211b, var(--void) 70%); }
.lead { color: var(--text-dim); font-family: var(--book); font-style: italic; font-size: 18px; max-width: 60ch; margin-bottom: 14px; }
.hint { color: var(--text-dim); font-size: 15px; margin: 2px 0 8px; }
.setting-block { margin-top: 22px; }
.setting-block h3 { font-family: var(--display); font-weight: 700; font-size: 22px; color: var(--gold); margin-bottom: 6px; }

/* ------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 8px 18px; border-radius: 6px; font-weight: 600; font-size: 18px; color: var(--parchment); background: linear-gradient(#3e3129, #2a201a); border: 1px solid #6b5443; box-shadow: inset 0 1px 0 rgba(255,235,200,.12), 0 2px 0 #000; transition: transform .08s, filter .15s; }
.btn:active { transform: translateY(1px); filter: brightness(1.15); }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn.primary { color: var(--gold-hi); background: linear-gradient(#b3291e, #7a150e 60%, #5c0e09); border: 1px solid #e0a040; box-shadow: inset 0 1px 0 rgba(255,200,150,.35), inset 0 -2px 0 rgba(0,0,0,.25), 0 2px 0 #000, 0 0 0 1px #2a0603; text-shadow: 0 1px 0 #3a0603; }
.btn.big { min-height: 56px; font-size: 21px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 6px; color: var(--gold); }
.icon-btn:active { background: rgba(255,220,150,.08); }
.icon-btn .ico { width: 26px; height: 26px; }

.seg { display: flex; gap: 6px; flex-wrap: nowrap; }
.seg.wrap { flex-wrap: wrap; margin-bottom: 8px; }
.seg + .seg { margin-top: 8px; }
.seg button { flex: 1; min-height: 44px; padding: 6px 8px; border-radius: 6px; background: var(--iron-2); border: 1px solid var(--iron-edge); color: var(--text-dim); font-weight: 600; font-size: 16px; line-height: 1.15; }
.seg.wrap button { flex: 1 1 30%; }
.seg button small { display: block; font-weight: 400; font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.seg button.on { background: linear-gradient(#8f1d14, #5c0e09); border-color: var(--gold); color: var(--gold-hi); }
.seg button.on small { color: var(--parchment); }
.seg.tall button { padding: 8px 6px; }

/* ------------------------------------------------------------ title */
.title-screen { background: radial-gradient(90% 60% at 50% 45%, #3d0e09 0%, #1d0605 45%, var(--void) 80%); align-items: center; padding: 0 22px calc(14px + var(--safe-b)); }
.title-inner { width: 100%; max-width: 460px; padding-top: calc(18px + var(--safe-t)); display: flex; flex-direction: column; align-items: center; text-align: center; flex: none; }
#title-art { flex: 1; width: calc(100% + 44px); min-height: 120px; margin: 0 -22px; pointer-events: none; }
.logo { margin: 14px 0 2px; line-height: .9; }
.logo-word {
  display: inline-block; font-family: var(--display); font-weight: 900; font-size: clamp(64px, 19vw, 108px); letter-spacing: -.01em;
  background: linear-gradient(180deg, #fff3c4 0%, #ffd25a 32%, #f29a1e 58%, #c2560a 82%, #ffcf6a 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 2px #5a0b06;
  filter: drop-shadow(0 3px 0 #2a0402) drop-shadow(0 6px 0 #120201) drop-shadow(0 10px 18px rgba(0,0,0,.8));
  transform: perspective(500px) rotateX(8deg);
}
.tagline { font-family: var(--book); font-style: italic; font-size: 19px; color: var(--parchment-2); margin: 8px 0 0; max-width: 26ch; text-shadow: 0 1px 2px #000; }
.menu { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 340px; flex: none; }
.menu .btn { width: 100%; flex-direction: column; gap: 0; line-height: 1.15; }
.menu .sub { font-weight: 400; font-size: 14px; color: var(--text-dim); display: block; }
.menu .btn.primary .sub { color: var(--parchment); }
.menu .view-pick button { min-height: 40px; font-size: 15px; }
.foot-note { flex: none; margin-top: 10px; text-align: center; font-size: 13px; color: rgba(230,210,170,.45); max-width: 40ch; }

/* ------------------------------------------------------------ hero cards */
.hero-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 720px) { .hero-grid { grid-template-columns: repeat(4, 1fr); } }
.hero-card { position: relative; border-radius: 8px; padding: 8px 8px 10px; background: linear-gradient(#efe0bb, #d9c08f); color: var(--ink); border: 3px solid var(--crimson); box-shadow: 0 0 0 2px #1a0503, 0 6px 14px rgba(0,0,0,.6); display: flex; flex-direction: column; align-items: center; }
.hero-card.off { filter: grayscale(.8) brightness(.55); }
.hero-card canvas { width: 100%; aspect-ratio: 1 / 1.05; background: radial-gradient(60% 55% at 50% 60%, #6a5a48, #2e241c); border-radius: 4px; border: 1px solid #6b4a28; }
.hero-card h3 { font-family: var(--display); font-weight: 700; font-size: 25px; color: var(--crimson); margin: 4px 0 0; line-height: 1; }
.stats { display: flex; gap: 10px; justify-content: center; font-weight: 700; font-size: 17px; margin: 4px 0 6px; color: var(--ink); }
.stats span { display: inline-flex; align-items: center; gap: 2px; }
.stats .ico { width: 17px; height: 17px; }
.stats .bp { color: var(--crimson); }
.stats .mp { color: #2d5ea8; }
.hero-card .seg { width: 100%; gap: 4px; margin-top: auto; }
.hero-card .seg button { min-height: 38px; font-size: 15px; background: rgba(60,36,20,.12); border-color: rgba(60,36,20,.35); color: var(--ink-soft); padding: 4px; }
.hero-card .seg button.on { background: linear-gradient(#a8261b, #6d120c); color: var(--gold-hi); border-color: #5a0b06; }
.hero-card p { font-family: var(--book); font-size: 14px; line-height: 1.25; text-align: center; color: var(--ink-soft); margin-bottom: 6px; }

/* ------------------------------------------------------------ parchment */
.parchment-screen { background: #1a120c; }
.parchment {
  color: var(--ink); font-family: var(--book); font-size: 19px; line-height: 1.5;
  background:
    radial-gradient(120% 90% at 50% 40%, rgba(255,246,220,.55), rgba(255,246,220,0) 60%),
    radial-gradient(80% 60% at 10% 0%, rgba(120,70,20,.25), transparent 60%),
    radial-gradient(80% 60% at 100% 100%, rgba(120,70,20,.3), transparent 60%),
    linear-gradient(#e9d6a9, #dcc290);
  padding-top: calc(28px + var(--safe-t));
  padding-left: max(22px, var(--safe-l)); padding-right: max(22px, var(--safe-r));
  box-shadow: inset 0 0 60px rgba(90,50,10,.45);
}
.parchment > * { max-width: 34em; margin-left: auto; margin-right: auto; }
.parchment .kicker { font-family: var(--ui); font-size: 16px; color: var(--ink-soft); text-align: center; margin-bottom: 2px; }
.parchment h2 { font-family: var(--display); font-weight: 700; font-size: 38px; line-height: 1.02; color: var(--ink-red); text-align: center; margin-bottom: 16px; }
.parchment p { margin-bottom: 14px; }
.parchment .tale::first-letter { font-family: var(--display); font-weight: 900; float: left; font-size: 3.4em; line-height: .8; margin: .06em .08em 0 0; color: var(--ink-red); }
.parchment .note { border-top: 1px solid rgba(90,50,20,.35); padding-top: 12px; margin-top: 4px; }
.parchment .goal { display: flex; gap: 10px; align-items: flex-start; font-family: var(--ui); font-weight: 600; font-size: 18px; color: var(--ink); background: rgba(140,28,19,.08); border-left: 3px solid var(--ink-red); padding: 10px 12px; border-radius: 0 6px 6px 0; margin: 6px auto 14px; }
.parchment .goal .ico { color: var(--ink-red); width: 22px; height: 22px; margin-top: 1px; }
.parchment .facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-family: var(--ui); font-size: 16px; color: var(--ink-soft); }
.parchment .facts b { color: var(--ink); font-weight: 600; }
.parchment .hint { color: var(--ink-soft); }
.parchment .sign { font-style: italic; text-align: right; color: var(--ink-soft); }
.parchment .hero-lines { display: grid; gap: 8px; font-family: var(--ui); font-size: 17px; }
.parchment .hero-line { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dotted rgba(90,50,20,.35); padding-bottom: 6px; }
.parchment .hero-line .dead { color: var(--ink-red); }
.parchment .seal { width: 84px; height: 84px; margin: 4px auto 12px; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #c8392c, #7c120b 70%); color: #f4c7a0; box-shadow: 0 3px 6px rgba(0,0,0,.4), inset 0 -3px 6px rgba(0,0,0,.35); font-family: var(--display); font-size: 40px; }
.parchment .seal.lost { background: radial-gradient(circle at 40% 35%, #4a4a4a, #161616 70%); color: #bbb; }
.map-fig { margin: 16px auto 8px; text-align: center; }
.map-fig canvas { width: 100%; max-width: 300px; height: auto; display: block; margin: 0 auto; transform: rotate(-.6deg); box-shadow: 0 2px 8px rgba(60,30,10,.35); }
.map-fig figcaption { font-family: var(--ui); font-size: 14px; color: var(--ink-soft); margin-top: 6px; }
.lineup { display: flex; justify-content: center; gap: 4px; margin: 4px auto 14px; }
.lineup canvas { width: 64px; height: 74px; }
.lineup canvas.fallen { opacity: .55; transform: rotate(-80deg) translateX(-14px) scale(.9); }
.item .btn + .btn { margin-left: -4px; }
.rules h3 { font-family: var(--display); font-weight: 700; color: var(--ink-red); font-size: 25px; margin: 18px 0 6px; }
.rules ul { padding-left: 1.1em; margin: 0 0 12px; }
.rules li { margin-bottom: 6px; }

/* ------------------------------------------------------------ quest book */
.book-intro { font-family: var(--book); font-size: 18px; color: var(--parchment-2); font-style: italic; margin-bottom: 16px; max-width: 60ch; }
.chapter-list { display: grid; gap: 8px; margin-bottom: 18px; }
.chapter { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 8px; background: var(--iron); border: 1px solid var(--iron-edge); }
.chapter .num { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 50%; font-family: var(--display); font-weight: 700; font-size: 19px; color: var(--text-dim); border: 1px solid var(--iron-edge); }
.chapter.done .num { background: radial-gradient(circle at 40% 35%, #c8392c, #7c120b 70%); color: #f4c7a0; border-color: #300; }
.chapter.next { border-color: var(--gold); background: linear-gradient(90deg, #3a1510, var(--iron)); }
.chapter.next .num { color: var(--gold-hi); border-color: var(--gold); }
.chapter .what b { display: block; font-weight: 600; font-size: 18px; color: var(--text); }
.chapter .what span { font-size: 15px; color: var(--text-dim); }
.chapter.locked { opacity: .5; }
.party-list { display: grid; gap: 8px; }
.party-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--iron); border: 1px solid var(--iron-edge); }
.party-row canvas { width: 48px; height: 52px; flex: none; }
.party-row .who { flex: 1; min-width: 0; }
.party-row .who b { font-family: var(--display); font-weight: 700; font-size: 21px; color: var(--gold); display: block; line-height: 1; }
.party-row .who span { font-size: 15px; color: var(--text-dim); }
.party-row .gold { display: inline-flex; align-items: center; gap: 4px; color: var(--gold); font-weight: 700; }
.party-row.fallen { border-style: dashed; }
.party-row.fallen b { color: var(--text-dim); text-decoration: line-through; }
.section-title { font-family: var(--display); font-weight: 700; font-size: 23px; color: var(--gold); margin: 18px 0 8px; }

/* ------------------------------------------------------------ armoury */
.tabs { display: flex; gap: 4px; padding: 8px 12px 0; background: #160f0c; border-bottom: 1px solid var(--iron-edge); overflow-x: auto; }
.tabs button { padding: 10px 14px; border-radius: 6px 6px 0 0; color: var(--text-dim); font-weight: 600; white-space: nowrap; border: 1px solid transparent; border-bottom: 0; }
.tabs button.on { color: var(--gold-hi); background: var(--iron-2); border-color: var(--iron-edge); }
.purse { display: flex; align-items: center; gap: 6px; font-size: 20px; color: var(--gold); font-weight: 700; margin-bottom: 10px; }
.items { display: grid; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; background: var(--iron); border: 1px solid var(--iron-edge); }
.item .what { flex: 1; min-width: 0; }
.item .what b { font-weight: 600; font-size: 18px; display: block; }
.item .what span { font-size: 15px; color: var(--text-dim); }
.item .btn { min-height: 40px; padding: 6px 12px; font-size: 16px; flex: none; }
.item.owned { border-color: var(--gold-deep); }
.item.owned .what b::after { content: ' (yours)'; color: var(--gold); font-weight: 400; font-size: 15px; }
.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 14px; }
.slot { padding: 8px 10px; border-radius: 6px; background: #1a1411; border: 1px solid var(--iron-edge); font-size: 15px; }
.slot small { display: block; color: var(--text-dim); font-size: 13px; }

/* ------------------------------------------------------------ HUD */
.hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; display: none; }
.hud.on { display: block; }
.hud > * { pointer-events: auto; }
.topbar { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 4px; padding: calc(4px + var(--safe-t)) 6px 4px; background: linear-gradient(rgba(20,8,6,.94), rgba(20,8,6,.78)); border-bottom: 1px solid rgba(232,177,61,.35); }
.quest-name { flex: 1; min-width: 0; text-align: center; line-height: 1.1; }
.quest-name #hud-title { display: block; font-family: var(--display); font-weight: 700; font-size: 21px; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quest-name #hud-round { font-size: 14px; color: var(--text-dim); }
.party-strip { position: absolute; left: 6px; top: calc(56px + var(--safe-t)); display: flex; flex-direction: column; gap: 6px; pointer-events: auto; }
.pmini { width: 50px; padding: 3px 3px 4px; border-radius: 8px; background: rgba(26,18,14,.86); border: 1px solid var(--iron-edge); display: flex; flex-direction: column; align-items: center; }
.pmini canvas { width: 40px; height: 44px; }
.pmini .bar { width: 100%; height: 5px; border-radius: 3px; background: #2b1d17; overflow: hidden; margin-top: 2px; }
.pmini .bar i { display: block; height: 100%; background: var(--bp); }
.pmini .n { font-size: 12px; font-weight: 700; color: var(--text); line-height: 1; margin-top: 2px; }
.pmini.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 12px rgba(232,177,61,.4); }
.pmini.dead { opacity: .35; }
.pmini.out { opacity: .55; border-style: dashed; }
.pmini .ctl { font-size: 11px; color: var(--text-dim); line-height: 1; }
.info-col { position: absolute; left: 64px; right: 8px; top: calc(54px + var(--safe-t)); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.objective { display: flex; align-items: flex-start; gap: 6px; font-size: 15px; line-height: 1.25; color: var(--parchment); text-shadow: 0 1px 2px #000, 0 0 6px #000; }
.objective .ico { color: var(--gold); width: 18px; height: 18px; margin-top: 1px; }
.banners { display: flex; flex-direction: column; gap: 6px; }
.banner { pointer-events: auto; font-family: var(--book); font-size: 17px; line-height: 1.3; color: var(--ink); padding: 8px 12px; border-radius: 4px; background: linear-gradient(#ecdcb2, #d9c08c); box-shadow: 0 3px 10px rgba(0,0,0,.6), inset 0 0 18px rgba(120,70,20,.3); border-left: 4px solid var(--ink-soft); animation: banner-in .3s ease both; max-width: 520px; }
.banner.out { animation: banner-out .4s ease both; }
.banner.dm, .banner.taunt, .banner.chaos, .banner.death, .banner.boss, .banner.monster, .banner.trap { border-left-color: var(--ink-red); }
.banner.taunt, .banner.boss { font-style: italic; color: #5a0e08; }
.banner.quest { border-left-color: var(--gold-deep); font-weight: 600; }
.banner.loot { border-left-color: #b88a1a; }
@keyframes banner-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes banner-out { to { opacity: 0; transform: translateX(30px); } }
.turn-flag { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); font-family: var(--display); font-weight: 900; font-size: 44px; color: var(--gold); text-shadow: 0 3px 0 #2a0402, 0 0 24px rgba(0,0,0,.9); pointer-events: none; opacity: 0; white-space: nowrap; }
.turn-flag.show { animation: flag 1.3s ease both; }
.turn-flag.zargon { color: #ff5a3a; }
@keyframes flag { 0% { opacity: 0; transform: translate(-50%, -40%) scale(.9); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -56%); } }

.dock { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 max(8px, var(--safe-l)) calc(8px + var(--safe-b)) max(8px, var(--safe-r)); display: flex; flex-direction: column; align-items: stretch; pointer-events: none; }
.dock > * { pointer-events: auto; max-width: 560px; width: 100%; margin: 0 auto; }
.prompt { min-height: 0; text-align: center; font-size: 16px; color: var(--parchment); text-shadow: 0 1px 2px #000, 0 0 8px #000; margin-bottom: 6px; pointer-events: none; }
.chips { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px; border-radius: 20px; font-weight: 600; font-size: 16px; color: var(--gold-hi); background: linear-gradient(#9c2219, #5c0e09); border: 1px solid var(--gold); box-shadow: 0 2px 8px rgba(0,0,0,.6); }
.chip .ico { width: 18px; height: 18px; }
.chip.quiet { background: rgba(30,22,18,.92); color: var(--parchment); border-color: var(--iron-edge); }
.hero-panel { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px 10px 0 0; background: linear-gradient(#2c221c, #1c1511); border: 1px solid var(--iron-edge); border-bottom: 0; box-shadow: 0 -4px 16px rgba(0,0,0,.5); }
.hero-panel canvas { width: 44px; height: 50px; flex: none; }
.hero-panel .who { flex: 1; min-width: 0; }
.hero-panel .who b { font-family: var(--display); font-weight: 700; font-size: 22px; color: var(--gold); line-height: 1; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-panel .who span { font-size: 14px; color: var(--text-dim); }
.meters { display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.pips { display: flex; gap: 2px; }
.pips i { width: 9px; height: 9px; border-radius: 2px; background: #3a2a22; }
.pips.bp i.on { background: var(--bp); box-shadow: 0 0 4px rgba(216,64,46,.6); }
.pips.mp i.on { background: var(--mp); }
.dicecount { display: flex; gap: 8px; font-weight: 700; font-size: 15px; color: var(--parchment); }
.dicecount span { display: inline-flex; align-items: center; gap: 2px; }
.dicecount .ico { width: 15px; height: 15px; }
.actions { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 6px; border-radius: 0 0 10px 10px; background: linear-gradient(#1c1511, #140f0c); border: 1px solid var(--iron-edge); border-top: 1px solid rgba(232,177,61,.25); }
.act { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--parchment); background: linear-gradient(#3a2e26, #261d18); border: 1px solid #5a4636; }
.act .ico { width: 24px; height: 24px; color: var(--gold); }
.act b { font-size: 20px; line-height: 1; color: var(--gold-hi); }
.act:active { filter: brightness(1.25); }
.act[disabled] { opacity: .32; pointer-events: none; }
.act.info { background: #18120f; border-style: dashed; color: var(--text-dim); }
.act.info.spent b { color: var(--text-dim); }
.act.hot { background: linear-gradient(#a8261b, #66110b); border-color: var(--gold); }
.act.hot .ico { color: var(--gold-hi); }
.act.on { box-shadow: inset 0 0 0 2px var(--gold-hi); }
.waiting { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 58px; padding: 0 8px; font-size: 16px; color: var(--text-dim); }
.waiting .btn { min-height: 44px; font-size: 16px; padding: 4px 14px; white-space: nowrap; flex: none; }

/* ------------------------------------------------------------ dice */
.dice-tray { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.92); z-index: 40; min-width: min(340px, 92vw); max-width: 94vw; padding: 12px 16px 14px; border-radius: 12px; background: rgba(18,12,9,.92); border: 1px solid var(--gold-deep); box-shadow: 0 10px 40px rgba(0,0,0,.8); opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; }
.dice-tray.show { opacity: 1; transform: translate(-50%, -50%) scale(1); pointer-events: auto; }
.dice-row + .dice-row { margin-top: 10px; }
.dice-label { font-size: 15px; color: var(--text-dim); margin-bottom: 6px; text-align: center; }
.dice-set { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; min-height: 46px; align-items: center; }
.dice-none { color: var(--text-dim); font-style: italic; }
.dice-result { text-align: center; margin-top: 10px; font-family: var(--display); font-weight: 700; font-size: 28px; color: var(--gold-hi); opacity: 0; transform: scale(.8); transition: opacity .2s, transform .2s; }
.dice-result.show { opacity: 1; transform: scale(1); }
.dice-result.bad { color: #ff6a50; }
.dice-result.good { color: #9ee07a; }
.die { --s: 44px; width: var(--s); height: var(--s); perspective: 300px; transition: opacity .2s, filter .2s; }
.compact .die { --s: 36px; }
.cube { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; }
.face { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 8px; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.die.combat .face { background: radial-gradient(circle at 35% 30%, #ffffff, #e8e2d6 70%, #cfc6b4); color: #141010; box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); }
.die.combat .face .ico { width: 78%; height: 78%; }
.die.move .face { background: radial-gradient(circle at 35% 30%, #e0473a, #a3180f 70%, #7a0f08); box-shadow: inset 0 0 0 1px rgba(0,0,0,.35); }
.die.move .pips { width: 100%; height: 100%; fill: #fff4e0; }
.face.front { transform: translateZ(calc(var(--s) / 2)); }
.face.back { transform: rotateY(180deg) translateZ(calc(var(--s) / 2)); }
.face.right { transform: rotateY(90deg) translateZ(calc(var(--s) / 2)); }
.face.left { transform: rotateY(-90deg) translateZ(calc(var(--s) / 2)); }
.face.top { transform: rotateX(90deg) translateZ(calc(var(--s) / 2)); }
.face.bottom { transform: rotateX(-90deg) translateZ(calc(var(--s) / 2)); }
.die.hit { filter: drop-shadow(0 0 6px rgba(255,214,110,.95)); }
.die.dud { opacity: .45; }

/* ------------------------------------------------------------ sheets, cards, toast */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: none; background: rgba(5,3,2,.55); }
.sheet-wrap.on { display: block; animation: screen-in .2s ease both; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 84%; overflow-y: auto; touch-action: pan-y; margin: 0 auto; max-width: 560px; padding: 16px 16px calc(16px + var(--safe-b)); border-radius: 14px 14px 0 0; background: linear-gradient(#2c221c, #1a1310); border: 1px solid var(--iron-edge); border-bottom: 0; box-shadow: 0 -10px 40px rgba(0,0,0,.7); animation: sheet-in .25s ease both; }
@keyframes sheet-in { from { transform: translateY(30px); opacity: 0; } }
.sheet h3 { font-family: var(--display); font-weight: 700; font-size: 26px; color: var(--gold); margin-bottom: 4px; line-height: 1.05; }
.sheet .sub { color: var(--text-dim); font-size: 15px; margin-bottom: 12px; }
.sheet .list { display: grid; gap: 8px; }
.sheet .opt { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; min-height: 54px; padding: 10px 12px; border-radius: 8px; background: var(--iron-2); border: 1px solid var(--iron-edge); }
.sheet .opt .ico { width: 26px; height: 26px; color: var(--gold); }
.sheet .opt b { display: block; font-weight: 600; font-size: 18px; }
.sheet .opt span { display: block; font-size: 14px; color: var(--text-dim); line-height: 1.25; }
.sheet .opt[disabled] { opacity: .45; pointer-events: none; }
.sheet .opt.fire { border-left: 4px solid #e0602a; }
.sheet .opt.air { border-left: 4px solid #a9d6e8; }
.sheet .opt.earth { border-left: 4px solid #8aa04a; }
.sheet .opt.water { border-left: 4px solid #3f7fd0; }
.sheet .opt.scroll { border-left: 4px solid var(--parchment-2); }
.sheet .close { position: absolute; right: 8px; top: 8px; }
.sheet .stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 8px 0 12px; text-align: center; }
.sheet .stat-grid div { background: #1a1411; border: 1px solid var(--iron-edge); border-radius: 6px; padding: 6px 2px; }
.sheet .stat-grid b { display: block; font-size: 22px; color: var(--gold-hi); line-height: 1; }
.sheet .stat-grid small { font-size: 12px; color: var(--text-dim); }
.sheet .log { display: grid; gap: 4px; font-size: 15px; }
.sheet .log p { color: var(--text-dim); border-bottom: 1px solid rgba(90,70,54,.4); padding-bottom: 3px; }
.sheet .log p.dm, .sheet .log p.taunt, .sheet .log p.boss, .sheet .log p.death { color: #e08a74; font-style: italic; }
.sheet .log p.quest { color: var(--gold); }
.sheet .row { display: flex; gap: 8px; margin-top: 12px; }
.sheet .row .btn { flex: 1; }
.sheet .toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; padding: 6px 4px; border-bottom: 1px solid rgba(90,70,54,.5); font-size: 18px; }
.sheet .toggle .seg { flex: none; }
.sheet .toggle .seg button { min-width: 64px; }

.card-pop { position: fixed; left: 50%; top: 44%; z-index: 45; width: min(250px, 70vw); transform: translate(-50%, -50%) rotateY(90deg); padding: 14px 14px 16px; border-radius: 12px; background: linear-gradient(#efdfb6, #d6bb86); color: var(--ink); border: 4px solid #8a5a1a; box-shadow: 0 0 0 2px #2a1503, 0 16px 40px rgba(0,0,0,.8); text-align: center; opacity: 0; pointer-events: none; transition: transform .35s ease, opacity .2s; }
.card-pop.show { transform: translate(-50%, -50%) rotateY(0); opacity: 1; pointer-events: auto; }
.card-pop .kind { font-size: 15px; color: var(--ink-soft); }
.card-pop h4 { font-family: var(--display); font-weight: 700; font-size: 28px; color: var(--ink-red); margin: 2px 0 8px; line-height: 1; }
.card-pop .art { width: 76px; height: 76px; margin: 0 auto 8px; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff4d0, #c8a060); color: #5a3a10; }
.card-pop .art .ico { width: 46px; height: 46px; }
.card-pop.bad .art { background: radial-gradient(circle at 40% 35%, #ffd0c0, #a0402a); color: #3a0a04; }
.card-pop p { font-family: var(--book); font-size: 17px; line-height: 1.3; }

.toast { position: fixed; left: 50%; bottom: calc(190px + var(--safe-b)); transform: translateX(-50%); z-index: 60; max-width: 88vw; padding: 10px 16px; border-radius: 8px; background: rgba(20,12,9,.95); border: 1px solid var(--gold-deep); color: var(--parchment); font-size: 16px; opacity: 0; pointer-events: none; transition: opacity .2s; text-align: center; }
.toast.show { opacity: 1; }

@media (min-width: 900px) {
  .party-strip { top: calc(64px + var(--safe-t)); left: 12px; }
  .info-col { left: 80px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.zargon-eye { width: 44px; height: 50px; display: grid; place-items: center; color: #ff5a3a; }
.zargon-eye .ico { width: 34px; height: 34px; }
