/* Today's Dungeon — paper, ink and pixels. Direction A (handheld battle stage) for the dungeon,
   direction B (clean cards and flat silhouettes) for the hub. Phone first. */
:root {
  --paper: #f4f1ea; --paper2: #ece7dc; --card: #fffdf7; --cream: #fbf6e6;
  --ink: #2b2630; --ink2: #4a4350; --muted: #8a8290; --line: #e2dccf; --line2: #cfc7b8;
  --red: #c8383a; --red2: #a82d2f; --gold: #c99a3a; --green: #4e9a52; --blue: #3e6db0; --violet: #7a4fa0; --stage: #263240;
  --radius: 10px; --radius-lg: 18px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
  --shadow: 0 1px 0 rgba(43, 38, 48, .06), 0 6px 18px -10px rgba(43, 38, 48, .25);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.45; }
body {
  min-height: 100vh; display: flex; flex-direction: column;
  background-image: radial-gradient(rgba(43, 38, 48, .035) 1px, transparent 1px);
  background-size: 6px 6px;
}
a { color: var(--red); }
button { font: inherit; color: inherit; }
canvas.px-text, canvas.px-sprite, .stage canvas { image-rendering: pixelated; image-rendering: crisp-edges; display: block; }

/* ── header (direction B wordmark) ── */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; max-width: 1100px; width: 100%; margin: 0 auto; }
.brand { color: var(--ink); text-decoration: none; display: flex; gap: 10px; align-items: center; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--red); display: grid; place-items: center; box-shadow: 0 3px 0 var(--red2); flex: none; }
.brand-mark canvas { width: 22px; height: 22px; }
.brand-name { font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; white-space: nowrap; }
.brand-tag { display: block; font-family: var(--mono); font-size: .62rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
.link { white-space: nowrap; background: none; border: 0; color: var(--ink2); cursor: pointer; padding: 6px 8px; border-radius: 8px; text-decoration: none; font-size: .86rem; }
.link:hover { background: var(--paper2); color: var(--ink); }

/* ── page shell: game column + (desktop) log column; ad rails live outside ── */
.shell { flex: 1; width: 100%; display: flex; justify-content: center; gap: 20px; padding: 0 16px; }
main { width: 100%; max-width: 640px; padding: 4px 0 24px; min-width: 0; }
main.wide { max-width: 1060px; }
main.run { max-width: 640px; }
@media (min-width: 1000px) { main.run { max-width: 940px; } }
.ad-rail { display: none; width: 160px; flex: none; position: sticky; top: 12px; align-self: flex-start; }
.ad-rail .ad-label, .ad-bottom .ad-label { font-size: .62rem; color: var(--muted); text-align: center; font-family: var(--mono); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 4px; }
body.ads-on .ad-rail.ready { display: block; }
@media (max-width: 1239px) { body.ads-on .ad-rail.ready { display: none; } }
.ad-bottom { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: min(760px, 100%); background: var(--card); border: 1px solid var(--line); border-bottom: 0; border-radius: 12px 12px 0 0; padding: 6px 8px 8px; z-index: 20; box-shadow: var(--shadow); }
.ad-bottom[hidden] { display: none; }
.ad-bottom .ad-toggle { position: absolute; top: -24px; left: 50%; transform: translateX(-50%); width: 44px; height: 24px; border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; background: var(--card); cursor: pointer; }
.ad-bottom.collapsed .ad-body { display: none; }
body.has-bottom-ad { padding-bottom: 110px; }

.foot { color: var(--muted); font-size: .75rem; text-align: center; padding: 18px 16px 28px; }
.foot a { color: var(--ink2); }
.loading { color: var(--muted); text-align: center; margin-top: 20vh; font-family: var(--mono); }

/* ── type ── */
h1, h2, h3, h4 { margin: .2em 0 .45em; line-height: 1.15; }
h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 1.2rem; font-weight: 750; }
h3 { font-size: 1rem; font-weight: 700; }
.label { font-family: var(--mono); font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; color: var(--red); margin: 18px 2px 8px; }
.label.ink { color: var(--muted); }
.px-heading { margin: 2px 0 10px; }
.muted { color: var(--muted); } .small { font-size: .82rem; } .tiny { font-size: .72rem; } .center { text-align: center; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* ── cards & controls ── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 12px; box-shadow: var(--shadow); }
.card.soft { box-shadow: none; }
.btn { background: var(--card); color: var(--ink); border: 1px solid var(--line2); border-radius: 9px; padding: 9px 13px; cursor: pointer; text-align: left; transition: border-color .12s, transform .06s, background .12s; }
.btn:hover:not(:disabled) { border-color: var(--ink2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--red); color: #fff; border-color: var(--red2); font-weight: 700; text-align: center; box-shadow: 0 3px 0 var(--red2); }
.btn.primary:hover:not(:disabled) { background: #d4403f; }
.btn.pill { border-radius: 999px; padding: 6px 14px; font-size: .84rem; }
.btn.danger { color: var(--red); }
.btn.sel { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); background: #fff5f2; }
.btn small { display: block; color: var(--muted); font-size: .75rem; }
.go { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: var(--red); color: #fff; border: 0; cursor: pointer; font-weight: 800; box-shadow: 0 2px 0 var(--red2); }
.chip { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--paper2); color: var(--ink2); border: 1px solid var(--line); margin: 2px 4px 2px 0; }
.chip.red { background: #fde8e6; color: var(--red2); border-color: #f4c5c0; }
.chip.gold { background: #fbf0d4; color: #8a6420; border-color: #ecd9a4; }
.chip.blue { background: #e6eefb; color: #2d5596; border-color: #c4d4f0; }
.chip.green { background: #e5f3e6; color: #2f6e33; border-color: #c2e0c4; }
.tag { font-family: var(--mono); font-size: .6rem; letter-spacing: .12em; text-transform: uppercase; color: var(--red); border: 1px solid #f0c3bf; border-radius: 999px; padding: 2px 8px; background: #fff; }
select, textarea, input[type=text] { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line2); background: #fff; color: var(--ink); font: inherit; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; color: var(--muted); }
label.field select { font-size: .92rem; color: var(--ink); }
.tabs { display: flex; gap: 6px; margin: 4px 0 12px; overflow-x: auto; }
.tabs .btn { padding: 7px 14px; border-radius: 999px; font-size: .86rem; white-space: nowrap; }
.table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.table th, .table td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.table th { font-family: var(--mono); font-size: .64rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 9px; padding: 8px; text-align: center; }
.stat b { display: block; font-size: 1.25rem; }
.stat span { font-family: var(--mono); font-size: .6rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.prompt { border-color: #ecd9a4; background: #fffbef; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 130px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 60; max-width: 90vw; font-size: .9rem; }
.toast.ok { background: var(--green); }

/* ── hub (direction B) ── */
.hub-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 10px 0 4px; }
.hub-stats { display: flex; gap: 28px; }
.hub-stats .k { font-family: var(--mono); font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.hub-stats .v { font-family: var(--mono); font-size: 1.35rem; font-weight: 700; }
.modes { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .modes { grid-template-columns: 1.4fr 1fr 1fr; } }
.mode { position: relative; background: var(--card); border: 1px solid #f0d3cf; border-radius: var(--radius-lg); padding: 16px; min-height: 180px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.mode.plain { border-color: var(--line); }
.mode .tag { position: absolute; top: 14px; right: 14px; }
.mode .art { flex: 1; display: flex; align-items: center; justify-content: center; gap: 14px; min-height: 84px; }
.mode .art .arrow { color: var(--muted); font-size: .8rem; }
.mode h3 { margin: 8px 0 2px; font-size: 1.05rem; }
.mode p { margin: 0; color: var(--ink2); font-size: .84rem; }
.mode .foot-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 8px; }
.more-links { display: flex; gap: 14px; flex-wrap: wrap; border-top: 1px solid var(--line); margin-top: 18px; padding-top: 12px; font-size: .86rem; }
.more-links .k { font-family: var(--mono); font-size: .62rem; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; align-self: center; }
.classes { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.cls-card { display: flex; gap: 10px; align-items: center; text-align: left; padding: 10px; border-radius: 12px; }
.cls-card .sil { width: 44px; height: 52px; flex: none; display: grid; place-items: center; }
.cls-card .sil canvas { max-height: 52px; width: auto; }
.cls-card b { display: block; font-size: .92rem; }
.cls-card small { display: block; color: var(--muted); font-size: .72rem; line-height: 1.3; }
.portrait { background: linear-gradient(180deg, #e9eff4, #dfe6ec); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; display: grid; place-items: center; }

/* ── dungeon (direction A) ── */
.run-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.run-head .title { font-weight: 800; font-size: 1.05rem; }
.rooms { display: flex; gap: 4px; align-items: center; }
.rooms i { width: 22px; height: 8px; border-radius: 3px; background: var(--line2); display: block; }
.rooms i.done { background: var(--green); } .rooms i.cur { background: var(--red); } .rooms i.boss { width: 30px; }
.battle { border: 2px solid var(--stage); border-radius: 12px; overflow: hidden; background: var(--stage); box-shadow: var(--shadow); }
.battle .strip { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; background: var(--stage); color: #c9d6e2; }
.battle .strip canvas { opacity: .9; }
.stage { position: relative; background: #1d1724; line-height: 0; }
.stage canvas { width: 100%; height: auto; aspect-ratio: 2 / 1; }
.dialog { background: var(--cream); border-top: 2px solid var(--stage); padding: 12px 34px 12px 14px; min-height: 64px; position: relative; font-size: .92rem; color: var(--ink); line-height: 1.4; }
.dialog p { margin: 0 0 2px; }
.dialog p.old { color: var(--muted); font-size: .82rem; }
.dialog .next { position: absolute; right: 12px; bottom: 10px; color: var(--red); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.foes { display: flex; gap: 8px; margin: 10px 0 0; overflow-x: auto; padding-bottom: 2px; }
.foe { flex: 1 1 0; min-width: 120px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: grid; grid-template-columns: auto 1fr; gap: 4px 8px; align-items: center; cursor: default; }
.foe .thumb { grid-row: span 2; width: 44px; height: 44px; display: grid; place-items: center; background: var(--paper); border-radius: 8px; }
.foe .nm { font-size: .82rem; font-weight: 700; display: flex; justify-content: space-between; gap: 4px; }
.foe .nm button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 2px; }
.foe.dead { opacity: .45; }
.foe.target { border-color: var(--red); cursor: pointer; box-shadow: 0 0 0 2px #fbd8d4; }
.foe.picked { background: #fff1ee; border-color: var(--red); box-shadow: 0 0 0 2px var(--red); }
.foe .conds { grid-column: 1 / -1; }
.bar { height: 7px; background: #e8e0cc; border-radius: 4px; overflow: hidden; border: 1px solid #3a3340; }
.bar i { display: block; height: 100%; background: #d9483b; }
.bar.ok i { background: #5fae6a; } .bar.mid i { background: #e0b040; }
.choose-head { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 2px 8px; }
.choose-head .hint { font-family: var(--mono); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.moves { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 420px) { .move { padding: 7px 8px 7px 9px; } }
.move { min-width: 0; overflow-wrap: anywhere; position: relative; background: var(--card); border: 1px solid var(--line2); border-left: 5px solid var(--muted); border-radius: 9px; padding: 9px 10px 9px 11px; cursor: pointer; text-align: left; min-height: 62px; display: flex; flex-direction: column; gap: 3px; }
.move:hover { border-color: var(--ink2); border-left-color: inherit; }
.move.k-attack { border-left-color: var(--red); } .move.k-spell { border-left-color: var(--blue); } .move.k-feature { border-left-color: var(--gold); }
.move.k-item { border-left-color: var(--green); } .move.k-move { border-left-color: #8a8290; } .move.k-go { border-left-color: var(--red); background: #fff7f5; }
.move .mt { min-height: 14px; }
.move .meta { font-family: var(--mono); font-size: .6rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.move .desc { font-size: .78rem; color: var(--ink2); line-height: 1.3; }
.move.wide { grid-column: 1 / -1; }
.kit { display: flex; gap: 6px; overflow-x: auto; margin-top: 12px; padding-bottom: 2px; }
.kit .res { flex: none; background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 6px 9px; min-width: 76px; }
.kit .res .k { font-family: var(--mono); font-size: .56rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.kit .res .v { font-weight: 700; font-size: .92rem; }
.pips { display: inline-flex; gap: 2px; vertical-align: middle; }
.pips i { width: 7px; height: 7px; border-radius: 2px; border: 1px solid var(--ink2); display: inline-block; }
.pips i.on { background: var(--blue); border-color: var(--blue); }
.log-card { margin-top: 12px; }
.log { max-height: 240px; overflow-y: auto; font-size: .82rem; line-height: 1.4; }
.log p { margin: 0 0 3px; }
.log .k-room { font-weight: 800; color: var(--ink); margin-top: 6px; }
.log .k-crit, .log .k-kill { color: var(--green); font-weight: 600; } .log .k-ecrit, .log .k-down, .log .k-death { color: var(--red); font-weight: 600; }
.log .k-heal, .log .k-good { color: #2f7a3a; } .log .k-bad, .log .k-dmg { color: #9a3a2a; } .log .k-cast { color: var(--blue); } .log .k-turn { color: var(--muted); font-family: var(--mono); font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; margin-top: 4px; }
.side-log { display: none; }
@media (min-width: 1000px) {
  .run-wrap { display: grid; grid-template-columns: minmax(0, 640px) 280px; gap: 18px; }
  .side-log { display: block; position: sticky; top: 12px; align-self: start; }
  .side-log .log { max-height: 70vh; }
  .log-card.inline { display: none; }
}
.banner { text-align: center; padding: 16px; border-radius: 12px; background: #eef7ef; border: 1px solid #c2e0c4; margin-bottom: 12px; }
.banner.dead { background: #fdecea; border-color: #f4c5c0; }
.banner.fled { background: #fbf3dd; border-color: #ecd9a4; }
.share { white-space: pre-wrap; font-family: var(--mono); font-size: .82rem; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }

/* ── modal ── */
.modal { position: fixed; inset: 0; background: rgba(30, 24, 36, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--card); border-radius: 14px; max-width: 560px; width: 100%; max-height: 86vh; overflow-y: auto; padding: 18px; position: relative; box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .5); }
.modal-close { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 1.5rem; cursor: pointer; color: var(--muted); }
.statblock h2 { color: var(--red2); }
.consent { position: fixed; left: 12px; right: 12px; bottom: 12px; max-width: 560px; margin: 0 auto; background: var(--card); border: 1px solid var(--line2); border-radius: 12px; padding: 12px 14px; z-index: 70; box-shadow: var(--shadow); font-size: .86rem; }

@media (max-width: 600px) {
  .brand-tag { display: none; }
  .top { padding: 8px 12px; }
  .nav .link { padding: 4px 5px; font-size: .74rem; }
  .nav { flex-wrap: nowrap; }
  #nav-rules { display: none; }
  .brand-name { font-size: 1rem; }
  .brand-mark { width: 28px; height: 28px; }
  .shell { padding: 0 12px; }
  .modes { grid-template-columns: 1fr 1fr; }
  .modes .mode:first-child { grid-column: 1 / -1; }
  .mode.plain { min-height: 0; padding: 12px; }
  .mode.plain .art { min-height: 52px; }
  .mode.plain .art canvas { max-height: 52px; width: auto; }
  .mode.plain p { display: none; }
  .hub-stats { gap: 18px; }
  .mode .art canvas { max-height: 84px; width: auto; }
}
.mode .art { flex-wrap: wrap; }

/* phone in landscape: stage on the left, moves on the right, nothing below the fold */
@media (orientation: landscape) and (max-height: 520px) {
  .top { display: none; }
  main.run { max-width: none; }
  .run-main { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 10px; align-items: start; }
  .run-main .run-head { grid-column: 1 / -1; margin: 2px 0 0; }
  .run-head .title { font-size: .9rem; }
  .run-left .dialog { min-height: 0; padding: 6px 28px 6px 10px; font-size: .78rem; }
  .run-left .dialog p.old { display: none; }
  .run-left .foes { margin-top: 6px; }
  .run-left .foe { min-width: 0; padding: 5px; }
  .run-right { max-height: calc(100vh - 44px); overflow-y: auto; }
  .run-right .choose-head { margin-top: 0; }
  .run-right .move { min-height: 0; padding: 6px 8px; }
  .run-right .move .desc { display: none; }
  .log-card.inline { grid-column: 1 / -1; }
  .battle .strip { padding: 3px 8px; }
  body.has-bottom-ad { padding-bottom: 0; }
}

.end-turn { width: 100%; margin-top: 8px; padding: 7px 12px; text-align: center; font-size: .82rem; color: var(--ink2); background: var(--paper2); }
.mode .art { margin-top: 18px; }
.dialog p.old { color: var(--ink2); }
.log { -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 22px); mask-image: linear-gradient(180deg, transparent 0, #000 22px); padding-top: 14px; }
@media (max-width: 600px) {
  .foes { margin-top: 8px; gap: 6px; }
  .foe { grid-template-columns: 30px 1fr; padding: 5px 6px; gap: 2px 6px; min-width: 110px; }
  .foe .thumb { width: 30px; height: 30px; grid-row: span 2; }
  .foe .thumb canvas { max-width: 28px; max-height: 28px; }
  .foe .nm { font-size: .74rem; }
  .foe .conds { display: none; }
  .move { min-height: 0; }
  .move .desc { display: block; font-size: .7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .choose-head { margin: 10px 2px 6px; }
}

.move canvas { max-width: 100%; height: auto; }
.move .meta { min-width: 0; }
.run-main, .run-left, .run-right { min-width: 0; }
html, body { overflow-x: hidden; }
@media (max-width: 600px) { .end-turn { position: sticky; bottom: 8px; z-index: 6; box-shadow: 0 6px 16px -6px rgba(43,38,48,.45); background: var(--card); border-color: var(--ink2); font-weight: 600; } }
@media (orientation: landscape) and (max-height: 520px) { .run-right .kit { flex-wrap: wrap; overflow: visible; } .run-right .kit .res { min-width: 0; flex: 1 1 70px; } }

/* ── session 3: the hub as a dungeon notice board (our own identity: stone wall, parchment, wax seals, torchlight) ── */
.board {
  position: relative; margin: 8px 0 6px; padding: 14px 14px 18px; border-radius: 14px;
  background-color: #2b2530;
  background-image:
    radial-gradient(120px 90px at 6% 0%, rgba(255, 170, 70, .28), transparent 70%),
    radial-gradient(120px 90px at 94% 0%, rgba(255, 170, 70, .28), transparent 70%),
    linear-gradient(rgba(0, 0, 0, .28) 2px, transparent 2px),
    linear-gradient(90deg, rgba(0, 0, 0, .22) 2px, transparent 2px),
    linear-gradient(90deg, rgba(0, 0, 0, .22) 2px, transparent 2px);
  background-size: auto, auto, 100% 22px, 44px 44px, 44px 44px;
  background-position: 0 0, 0 0, 0 0, 0 0, 22px 22px;
  border: 3px solid #5a3e2a; box-shadow: inset 0 0 0 2px #1d1820, 0 10px 24px -14px rgba(20, 12, 8, .7);
  color: #efe3c8;
}
.board::before, .board::after { /* two torches */
  content: ""; position: absolute; top: 10px; width: 8px; height: 22px; border-radius: 2px;
  background: linear-gradient(#ffd166 0 6px, #e86a2a 6px 10px, #5a3e2a 10px);
  box-shadow: 0 -4px 14px 6px rgba(255, 160, 60, .35);
}
.board::before { left: 10px; } .board::after { right: 10px; }
.board-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 6px 18px 4px; }
.board-head .niche { width: 70px; height: 84px; flex: none; display: grid; place-items: end center; padding-bottom: 6px; border-radius: 35px 35px 6px 6px; background: radial-gradient(60px 50px at 50% 30%, #6a5a70, #3a3040); border: 2px solid #1d1820; box-shadow: inset 0 -6px 10px rgba(0, 0, 0, .35); }
.board-head .niche canvas { max-height: 74px; width: auto; filter: drop-shadow(0 0 1px #f4ecd8) drop-shadow(0 0 1px #f4ecd8); }
.board-head .who { flex: 1; min-width: 150px; }
.board-head .eyebrow { font-family: var(--mono); font-size: .64rem; letter-spacing: .14em; text-transform: uppercase; color: #e9b65a; }
.board-head h1 { color: #fbf2dc; margin: 2px 0; text-shadow: 0 2px 0 #1d1820; }
.board-head .sub { font-size: .8rem; color: #c9bba0; }
.plaques { display: flex; gap: 8px; }
.plaque { background: linear-gradient(#6a4a30, #4e3422); border: 2px solid #2a1c12; border-radius: 6px; padding: 5px 10px 6px; text-align: center; box-shadow: inset 0 1px 0 rgba(255, 220, 160, .25); min-width: 74px; }
.plaque .k { display: block; font-family: var(--mono); font-size: .56rem; letter-spacing: .12em; text-transform: uppercase; color: #e9c98a; margin-bottom: 3px; }
.plaque canvas { margin: 0 auto; }
.board-title { display: flex; justify-content: center; margin: 12px 0 10px; }
.notices { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (min-width: 720px) { .notices { grid-template-columns: 1.5fr 1fr 1fr; } .notice.wide { grid-column: 1 / -1; } }
.notice.main, .notice.wide { grid-column: 1 / -1; }
@media (min-width: 720px) { .notice.main { grid-column: auto; } }
.notice {
  position: relative; color: #3a2418; padding: 20px 14px 14px; min-height: 150px; display: flex; flex-direction: column;
  background: #f3e4bf; background-image: radial-gradient(rgba(120, 80, 30, .08) 1px, transparent 1px), linear-gradient(170deg, rgba(255, 255, 255, .35), rgba(160, 110, 50, .12));
  background-size: 5px 5px, auto; border-radius: 3px 3px 6px 4px;
  clip-path: polygon(0 3px, 8% 0, 22% 2px, 40% 0, 63% 3px, 80% 0, 100% 2px, 100% 97%, 92% 100%, 70% 98%, 48% 100%, 26% 97%, 6% 100%, 0 98%);
  box-shadow: 0 6px 0 rgba(0, 0, 0, .25); transform: rotate(-.6deg);
}
.notice:nth-child(2) { transform: rotate(.8deg); } .notice:nth-child(3) { transform: rotate(-.4deg); } .notice:nth-child(4) { transform: rotate(.3deg); }
.notice::before { /* the nail */ content: ""; position: absolute; top: 6px; left: 50%; width: 9px; height: 9px; margin-left: -4px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #d8c9a0, #6a5a40 60%, #2a2018); }
.notice h3 { margin: 8px 0 2px; font-size: 1.02rem; color: #3a2418; }
.notice p { margin: 0; color: #5a4030; font-size: .84rem; }
.notice .art { flex: 1; display: flex; align-items: center; justify-content: center; gap: 14px; min-height: 64px; margin-top: 6px; }
.notice .art canvas { max-height: 72px; width: auto; }
.notice .foot-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 8px; }
.notice .date { font-family: var(--mono); font-size: .66rem; color: #8a6a4a; }
.notice.companion { flex-direction: row; align-items: center; gap: 14px; min-height: 0; }
.notice.companion .art { flex: none; margin: 0; min-height: 0; }
.seal { /* wax seal tag */
  position: absolute; top: 10px; right: 10px; font-family: var(--mono); font-size: .58rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: #fde8d0; background: radial-gradient(circle at 35% 30%, #d9534f, #9a2422 70%); padding: 4px 9px 4px 10px; border-radius: 12px 9px 13px 8px;
  box-shadow: 0 2px 0 #5a1414, inset 0 1px 0 rgba(255, 255, 255, .25);
}
.seal.gold { background: radial-gradient(circle at 35% 30%, #e8b84a, #9a6a1a 70%); box-shadow: 0 2px 0 #5a3a0a; color: #2a1a08; }
.seal.blue { background: radial-gradient(circle at 35% 30%, #5a86d0, #2a4a8a 70%); box-shadow: 0 2px 0 #142a5a; }
.seal.green { background: radial-gradient(circle at 35% 30%, #6ab06a, #2e6a32 70%); box-shadow: 0 2px 0 #143a18; }
.board .btn.primary { background: #8a2a2c; border-color: #4a1214; box-shadow: 0 3px 0 #4a1214; color: #fbe6c8; }
.board .btn.primary:hover:not(:disabled) { background: #9e3335; }
.board .go { background: #5a3e2a; box-shadow: 0 2px 0 #2a1c12; color: #f3e4bf; }
.board .prompt { color: var(--ink); }
.board .notice.notice:only-child { min-height: 0; }
@media (max-width: 600px) {
  .board { padding: 10px 8px 14px; }
  .board-head { padding: 4px 14px 2px; gap: 10px; }
  .board-head .niche { width: 56px; height: 68px; }
  .board-head .niche canvas { max-height: 60px; }
  .plaques { width: 100%; justify-content: flex-start; }
  .notice { padding: 18px 11px 11px; min-height: 0; }
  .notice:not(.main):not(.wide) p { display: none; }
  .notice .art { min-height: 48px; }
  .notice:not(.main) .art canvas { max-height: 44px; }
}

/* ── session 3: the five-room map strip above the stage ── */
.battle .map { background: #1d1824; line-height: 0; border-bottom: 2px solid var(--stage); }
.battle .map canvas { width: 100%; height: auto; aspect-ratio: 320 / 34; image-rendering: pixelated; display: block; }
@media (orientation: landscape) and (max-height: 520px) { .battle .map canvas { aspect-ratio: 320 / 34; } }

/* ── session 3: death saves ── */
.death { margin-top: 4px; background: #fdf1ee; border: 1px solid #f0c3bf; border-radius: 12px; padding: 4px 12px 12px; }
.death .choose-head { margin-top: 8px; }
.ds-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 6px; }
.ds-row .k { font-family: var(--mono); font-size: .6rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ds-pips { display: inline-flex; gap: 4px; margin-right: 8px; }
.ds-pips i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink2); background: #fff; }
.ds-pips.ok i.on { background: var(--green); border-color: #2f6e33; }
.ds-pips.bad i.on { background: var(--red); border-color: var(--red2); }
.ds-roll { width: 100%; font-size: 1.05rem; padding: 12px; margin-top: 4px; }
.kit .res.comp .v { color: #2f6e33; }
.hero-preview { width: 64px; height: 64px; image-rendering: pixelated; background: radial-gradient(40px 34px at 50% 55%, #e9e2d2, transparent); border-radius: 10px; flex: none; }
@media (max-width: 600px) { .kit { flex-wrap: wrap; overflow: visible; } .kit .res { flex: 1 1 70px; min-width: 0; } }
.tabs .btn.sel { border-color: #5a3e2a; box-shadow: inset 0 0 0 1px #5a3e2a; background: #f3e4bf; color: #3a2418; }

/* ── session 4: our own dungeon chrome (owner: "consistent with the dungeon, not a clone") ──
   The page is the dungeon: dark stone walls lit by torches, iron-bound panels, parchment for anything you read.
   Same palette family as the Retro Diffusion backdrops and the notice board. */
:root {
  --paper: #17141b; --paper2: #221d27; --card: #241f2a; --cream: #f3e4bf;
  --ink: #efe6d2; --ink2: #cbbfa8; --muted: #93889a; --line: #3a3240; --line2: #4f4556;
  --red: #d25a3c; --red2: #7a2a1a; --gold: #e9b65a; --green: #6ab06a; --blue: #6f9ae0; --violet: #a77fd0; --stage: #110e14;
  --radius: 6px; --radius-lg: 10px;
  --shadow: 0 3px 0 #0b090e, inset 0 1px 0 rgba(255, 220, 160, .06);
  color-scheme: dark;
}
body {
  background-color: var(--paper);
  background-image:
    radial-gradient(70vw 340px at 50% -120px, rgba(255, 160, 70, .13), transparent 70%),
    linear-gradient(rgba(0, 0, 0, .35) 2px, transparent 2px),
    linear-gradient(90deg, rgba(0, 0, 0, .28) 2px, transparent 2px),
    linear-gradient(90deg, rgba(0, 0, 0, .28) 2px, transparent 2px);
  background-size: auto, 100% 30px, 60px 60px, 60px 60px;
  background-position: 0 0, 0 0, 0 0, 30px 30px;
  background-attachment: fixed;
}
a { color: var(--gold); }
.brand { color: var(--ink); }
.brand-mark { background: linear-gradient(#3a3240, #241f2a); border: 2px solid #5a3e2a; box-shadow: 0 3px 0 #0b090e, 0 0 14px rgba(255, 160, 60, .25); border-radius: 6px; }
.link:hover { background: var(--paper2); }
.card, .mode, .foe, .kit .res, .stat, .modal-box, .consent, .ad-bottom, .ad-bottom .ad-toggle {
  background: linear-gradient(180deg, #2a2430, #211c26); border: 2px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.mode { border-color: #5a3e2a; }
.btn { background: #2a2430; color: var(--ink); border: 2px solid var(--line2); border-radius: 6px; box-shadow: 0 2px 0 #0b090e; }
.btn:hover:not(:disabled) { border-color: var(--gold); }
.btn.primary { background: linear-gradient(#c4503a, #9a3424); color: #fbe6c8; border-color: #4a1610; box-shadow: 0 3px 0 #4a1610, inset 0 1px 0 rgba(255, 220, 160, .25); }
.btn.primary:hover:not(:disabled) { background: linear-gradient(#d45a42, #a83a28); }
.btn.sel { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); background: #3a2f22; }
.go { background: #9a3424; box-shadow: 0 2px 0 #4a1610; color: #fbe6c8; }
.chip { background: #2e2834; color: var(--ink2); border-color: var(--line2); }
.chip.red { background: #3a1e1a; color: #f0a090; border-color: #6a2a20; }
.chip.gold { background: #3a2f18; color: #f0cf80; border-color: #6a5420; }
.chip.blue { background: #1c2840; color: #a8c4f0; border-color: #2e4470; }
.chip.green { background: #1c3220; color: #a8dca8; border-color: #2e5a32; }
.tag { background: #2a2430; border-color: #6a2a20; color: #f0a090; }
select, textarea, input[type=text] { background: #1b171f; color: var(--ink); border: 2px solid var(--line2); border-radius: 6px; }
.prompt { border-color: #6a5420; background: linear-gradient(180deg, #2e2818, #231e14); }
.toast { background: #3a3240; color: var(--ink); border: 2px solid var(--line2); }
.portrait { background: radial-gradient(70px 60px at 50% 45%, #4a4052, #2a2430); border-color: var(--line); }
.battle { border: 3px solid #3a2a1e; border-radius: 8px; box-shadow: 0 4px 0 #0b090e, 0 0 0 1px #5a3e2a; }
.battle .strip { background: #110e14; }
/* the text box under the stage is a parchment scroll, like the notices on the board */
.dialog { background: var(--cream); color: #3a2418; border-top: 3px solid #5a3e2a; }
.dialog p.old { color: #7a5a40; }
.dialog .next { color: #9a3424; }
.foe .thumb { background: #17141b; border: 1px solid var(--line); }
.foe.target { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(233, 182, 90, .3); }
.foe.picked { background: #3a2f22; border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.bar { background: #120f15; border-color: #000; }
.move { background: linear-gradient(180deg, #2a2430, #221d27); border: 2px solid var(--line2); border-left-width: 5px; border-radius: 6px; box-shadow: 0 2px 0 #0b090e; }
.move:hover { border-color: var(--gold); }
.move.k-go { background: linear-gradient(180deg, #3a241e, #2a1c18); }
.move.k-move { border-left-color: #6a6070; }
.pips i { border-color: var(--ink2); }
.log .k-heal, .log .k-good { color: #8fd08f; } .log .k-bad, .log .k-dmg { color: #f0907a; }
.banner { background: #1c3220; border: 2px solid #2e5a32; color: var(--ink); }
.banner.dead { background: #3a1e1a; border-color: #6a2a20; }
.banner.fled { background: #3a2f18; border-color: #6a5420; }
.share { background: #1b171f; border-color: var(--line); }
.modal { background: rgba(8, 6, 10, .7); }
.statblock h2 { color: var(--gold); }
.death { background: #2e1a18; border: 2px solid #6a2a20; }
.ds-pips i { background: #1b171f; }
.end-turn { background: #2a2430; }
@media (max-width: 600px) { .end-turn { background: #2a2430; border-color: var(--gold); box-shadow: 0 6px 16px -6px rgba(0, 0, 0, .7); } }
.hero-preview { background: radial-gradient(40px 34px at 50% 55%, #4a4052, transparent); }
.tabs .btn.sel { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); background: #3a2f22; color: var(--ink); }
.board { border-color: #5a3e2a; }
.foot { color: var(--muted); }
.foot a { color: var(--ink2); }

/* ── session 4: tap-to-inspect ── */
.info-dot { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%;
  font: 700 .72rem/1 var(--mono); font-style: italic; color: var(--ink); background: #3a3240; border: 1px solid var(--line2); cursor: help; z-index: 2; }
.info-dot:hover, .info-dot:focus-visible { background: var(--gold); color: #2a1a08; outline: none; }
.field .info-dot, .row .info-dot { position: static; display: inline-grid; margin-left: 6px; width: 18px; height: 18px; vertical-align: middle; }
.move { padding-right: 32px; }
.chip.tap, .res.tap { cursor: help; font: inherit; }
.chip.tap { font-size: .72rem; text-decoration: underline dotted; text-underline-offset: 3px; }
.res.tap { text-align: left; color: var(--ink); }
.inspect .eyebrow { font-family: var(--mono); font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.inspect h2 { margin: 2px 0 8px; color: var(--ink); }
.inspect .effect { background: var(--cream); color: #3a2418; border: 2px solid #5a3e2a; border-radius: 6px; padding: 8px 10px; margin-bottom: 10px; }
.inspect .effect p { margin: 2px 0; font-size: .92rem; }
.inspect .effect p:first-child { font-family: var(--mono); font-size: .74rem; color: #7a5a40; }
.inspect .effect p:only-child { font-family: var(--sans); font-size: .92rem; color: #3a2418; }
.inspect details summary { cursor: pointer; font-family: var(--mono); font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 6px 0; }
.inspect details p { color: var(--ink2); }

/* ── session 4: the dice tray (cosmetic; the numbers come from the server's log) ── */
.run-head { align-items: center; }
.dice-toggle { margin-left: auto; font: 600 .7rem var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: #2a2430; border: 2px solid var(--line2); border-radius: 6px; padding: 3px 8px; cursor: pointer; }
.dice-toggle.on { color: var(--gold); border-color: #6a5420; }
.dice-tray { display: none; align-items: center; gap: 10px; }
.dice-tray.on { display: flex; }
.side-log .dice-tray { background: linear-gradient(180deg, #2a2430, #211c26); border: 2px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px; margin-bottom: 12px; min-height: 76px; }
.dice-tray.overlay { position: absolute; top: 34px; right: 8px; z-index: 3; flex-direction: column; gap: 2px; pointer-events: none; }
.die { width: 52px; height: 52px; display: grid; place-items: center; flex: none; color: #2a1a08; font: 800 1.15rem var(--mono);
  background: linear-gradient(160deg, #fbf0d0, #e3c98a); filter: drop-shadow(0 3px 0 #0b090e); }
.die.d20 { clip-path: polygon(50% 0, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%); }
.die.dmg { border-radius: 8px; background: linear-gradient(160deg, #e9d6c0, #b9967a); }
.die.crit { background: linear-gradient(160deg, #fff4b0, #e9b65a); color: #5a2a00; }
.die.fumble { background: linear-gradient(160deg, #e0a090, #9a3424); color: #fbe6c8; }
.die.good { background: linear-gradient(160deg, #cfe9c8, #6ab06a); }
.die.bad { background: linear-gradient(160deg, #f0c0b0, #c4503a); color: #fbe6c8; }
.die.tumble { animation: tumble .5s linear infinite; }
@keyframes tumble { 0% { transform: rotate(0) scale(.9); } 50% { transform: rotate(180deg) scale(1.05); } 100% { transform: rotate(360deg) scale(.9); } }
.dice-cap { font: 600 .66rem var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink2); max-width: 140px; }
.dice-tray.overlay .die { width: 40px; height: 40px; font-size: .95rem; }
.dice-tray.overlay .dice-cap { background: rgba(17, 14, 20, .8); color: #efe6d2; padding: 1px 5px; border-radius: 4px; font-size: .56rem; max-width: 96px; text-align: center; }
@media (prefers-reduced-motion: reduce) { .die.tumble { animation: none; } }

/* ── session 4: visual-review fixes ── */
html { background: var(--paper); }
body { background-attachment: scroll; background-repeat: no-repeat, repeat, repeat, repeat; } /* the stone runs the full page height */
.move.has-info { padding-right: 34px !important; }
.move .mt canvas { max-width: 100%; height: auto; }
.info-dot.static { position: static; display: inline-grid; width: 20px; height: 20px; margin-left: 4px; padding: 0; vertical-align: middle; }
.foe .nm .info-dot.static { color: var(--ink); background: #3a3240; border: 1px solid var(--line2); }
.info-dot.mini { width: 14px; height: 14px; font-size: .56rem; margin-left: 5px; }
/* the phone die: pinned in the stage's top-right corner, caption to its left, small */
.dice-tray.overlay { top: 6px; right: 6px; flex-direction: row-reverse; align-items: center; gap: 4px; }
.dice-tray.overlay:not(.rolled) { display: none; }
.dice-tray.overlay .die { width: 34px; height: 34px; font-size: .82rem; }
/* desktop: the panel is always there, waiting for the first roll */
.side-log .dice-tray { display: flex; }
.die.idle { opacity: .45; }
.die.tumble { animation: wobble .18s linear infinite; }
@keyframes wobble { 0% { transform: rotate(-14deg) scale(.95); } 50% { transform: rotate(14deg) scale(1.04); } 100% { transform: rotate(-14deg) scale(.95); } }
.log { padding-top: 24px; }
@media (min-width: 1000px) {
  .move .meta { font-size: .68rem; }
  .move .desc { font-size: .84rem; }
  .kit .res .k { font-size: .66rem; }
}
