/* Layout: a shared table — a slim room bar on top; players get their sheet beside the table feed, the DM gets the initiative track beside their tools */
:root {
  --bg: #e7ebe6; --surface: #f8faf7; --sunk: #eef2ed; --ink: #1b2320; --muted: #5b6962; --line: #cdd5cf;
  --accent: #2e6a52; --accent-ink: #ffffff; --pc: #2e6a52; --dm: #8a2e36; --gold: #9a6d12; --danger: #a63d32; --magic: #5a4f9c;
  --font-display: "Pridi", Georgia, serif;
  --font-body: "IBM Plex Sans Thai", system-ui, sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #121815; --surface: #1b231f; --sunk: #161d1a; --ink: #e3eae5; --muted: #95a49c; --line: #2e3a34;
  --accent: #72c29b; --accent-ink: #0e1913; --pc: #72c29b; --dm: #e3848c; --gold: #e2b452; --danger: #e5806f; --magic: #ab9ff0; color-scheme: dark } }
body.role-dm { --accent: var(--dm) }
@media (prefers-color-scheme: dark) { body.role-dm { --accent-ink: #1c1011 } }

* { box-sizing: border-box }
html, body { margin: 0 }
body { background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font-body);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: max(16px, env(safe-area-inset-top, 0px)) 96px }
[hidden] { display: none !important }
.wrap { max-width: 1280px; margin: 0 auto; display: grid; gap: 18px }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; text-wrap: balance }
h1 { font-size: 1.7rem; line-height: 1.2 }
h2 { font-size: 1.05rem; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap }
h2 small { font: 500 .72rem var(--font-body); color: var(--muted); letter-spacing: .06em; text-transform: uppercase }
h3 { font-size: .9rem }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums }
button, input, select, textarea { font: inherit; color: inherit }
button { cursor: pointer }
button:disabled { opacity: .45; cursor: not-allowed }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
.hint { font-size: .78rem; color: var(--muted); margin: 0 }
.badge { font: 500 .7rem var(--font-body); background: var(--gold); color: var(--surface); border-radius: 4px; padding: 1px 7px; letter-spacing: .04em }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: grid; gap: 12px; min-width: 0 }
input, select, textarea { background: var(--sunk); border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; min-width: 0; font-size: .95rem; color: var(--ink) }
label.f { display: grid; gap: 3px; font-size: .75rem; color: var(--muted); letter-spacing: .02em; min-width: 0 }
label.f input, label.f select { width: 100% }
.btn { border: 1px solid var(--line); background: var(--sunk); border-radius: 6px; padding: 5px 11px; font-size: .88rem }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent) }
.btn.big { padding: 10px 18px; font-size: 1rem; font-weight: 600 }
.btn.dmg { color: var(--danger); border-color: var(--danger) }
.btn.heal { color: var(--pc); border-color: var(--pc) }
.btn.ghost { background: transparent; justify-self: start }
.btn.roll { color: var(--accent); border-color: var(--accent); font-family: var(--font-num); font-weight: 600 }
.btn.roll.magic { color: var(--magic); border-color: var(--magic) }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center }
.danger-link { border: 0; background: none; color: var(--danger); font-size: .82rem; padding: 0; text-decoration: underline; justify-self: start }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px }
hr { border: 0; border-top: 1px solid var(--line); margin: 2px 0; width: 100% }

/* lobby */
.lobby { max-width: 760px; margin: 4vh auto 0; display: grid; gap: 18px }
.lobby .intro { display: grid; gap: 6px }
.lobby .intro p { margin: 0; color: var(--muted) }
.lobby .choices { display: grid; grid-template-columns: 1fr 1fr; gap: 18px }
@media (max-width: 640px) { .lobby .choices { grid-template-columns: 1fr } }
.mode-note { font-size: .82rem; border: 1px dashed var(--gold); color: var(--ink); background: var(--sunk); border-radius: 8px; padding: 8px 12px; margin: 0 }
.err { color: var(--danger); font-size: .85rem; margin: 0 }
.lobby.auth { max-width: 420px }
.auth .panel { display: grid; gap: 12px }
.auth-form { display: grid; gap: 10px }
.auth-form .hint { margin: -4px 0 0 }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit }
.rooms { display: grid; gap: 6px }
.room-row { display: flex; align-items: stretch; gap: 6px }
.room-go { flex: 1; display: grid; gap: 2px; text-align: left; background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer; color: var(--ink); font: inherit }
.room-go:hover, .room-go:focus-visible { border-color: var(--accent) }
.room-go .hint { font-size: .78rem }
.tag.dm { border-color: var(--accent); color: var(--accent) }
.room-row .copy-room { white-space: nowrap; align-self: center; font-size: .8rem }
.icon-x { border: 1px solid transparent; background: none; color: var(--muted); border-radius: 8px; padding: 0 10px; font-size: 1.1rem; cursor: pointer }
.icon-x:hover { border-color: var(--line); color: var(--danger) }
.legacy summary { cursor: pointer; font-size: .82rem; color: var(--muted) }
.legacy[open] { display: grid; gap: 8px }

/* room bar */
.roombar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px }
.roombar .code { font: 600 1.15rem var(--font-num); letter-spacing: .12em }
.roombar .who { font-size: .85rem; color: var(--muted) }
.pill { font-size: .75rem; border-radius: 99px; padding: 1px 9px; background: var(--accent); color: var(--accent-ink) }
.conn { font-size: .75rem; color: var(--muted) }
.conn.ok::before { content: "● "; color: var(--pc) }
.conn.bad::before { content: "● "; color: var(--danger) }

.layout { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); gap: 18px; align-items: start }
@media (max-width: 980px) { .layout { grid-template-columns: 1fr } }
.cols { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; min-width: 0 }
.col { display: grid; gap: 18px; min-width: 0 }

/* character chooser */
.chooser { display: grid; gap: 8px }
.chooser .opt { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: var(--sunk) }

/* sheet */
.name-input { font-family: var(--font-display) !important; font-size: 1.3rem !important; font-weight: 600 }
.abils { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px }
.abil { border: 1px solid var(--line); border-radius: 8px; padding: 8px 6px 10px; display: grid; justify-items: center; gap: 4px; text-align: center; background: var(--sunk) }
.abil .k { font: 600 .78rem var(--font-num); letter-spacing: .1em }
.abil .t { font-size: .7rem; color: var(--muted); line-height: 1.2 }
.abil input { width: 4.2em; text-align: center; background: var(--surface); padding: 3px; font-family: var(--font-num) }
.mod { border: 1.5px solid var(--accent); color: var(--accent); background: transparent; border-radius: 999px; padding: 2px 12px; font: 600 1.05rem var(--font-num) }
.mod:hover { background: var(--accent); color: var(--accent-ink) }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px }
.stat { border: 1px solid var(--line); border-radius: 8px; padding: 8px 4px; text-align: center; display: grid; gap: 2px; background: var(--sunk) }
.stat .t { font-size: .7rem; color: var(--muted) }
.stat .v { font: 600 1.25rem var(--font-num) }
.stat input { width: 100%; text-align: center; border: 0; background: transparent; font: 600 1.25rem var(--font-num); padding: 0 }
.stat button.v { border: 0; background: transparent; color: var(--accent) }
.stat button.v.magic { color: var(--magic) }
.hpbar { height: 10px; border-radius: 99px; background: var(--sunk); border: 1px solid var(--line); overflow: hidden; display: flex }
.hpbar i { display: block; height: 100%; background: var(--pc); transition: width .25s }
.hpbar i.tmp { background: var(--gold) }
.hpbar.low i:first-child { background: var(--danger) }
.hprow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center }
.hprow input { width: 5em; text-align: center; font-family: var(--font-num) }
.list { display: grid; gap: 1px }
.row { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 5px }
.row:hover { background: var(--sunk) }
.row input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0 }
.row .nm span { color: var(--muted); font-size: .75rem; margin-left: 6px; font-family: var(--font-num) }
.row button { min-width: 3.2em; border: 1px solid var(--line); background: var(--surface); border-radius: 5px; font: 600 .88rem var(--font-num); padding: 1px 6px; color: var(--accent) }
.cards { display: grid; gap: 10px }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 8px; background: var(--sunk) }
.card input, .card select { background: var(--surface); padding: 4px 7px; font-size: .88rem; width: 100% }
.card .r1 { display: grid; grid-template-columns: 1fr 32px; gap: 6px }
.card .r2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(6.2em, 1fr)); gap: 6px }
.card .r3 { display: flex; flex-wrap: wrap; gap: 8px; align-items: center }
.card .x, .item button, .spell button { border: 0; background: transparent; color: var(--muted); font-size: 1.1rem }
.card label { display: grid; gap: 2px; font-size: .68rem; color: var(--muted); min-width: 0 }
.crit-note { font-size: .75rem; color: var(--gold); font-weight: 600 }
.pips { display: inline-flex; gap: 5px; flex-wrap: wrap }
.pip { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--magic); background: var(--magic); padding: 0 }
.pip[aria-pressed="true"] { background: transparent }
.pip.ok { border-color: var(--pc); background: transparent } .pip.ok[aria-pressed="true"] { background: var(--pc) }
.pip.bad { border-color: var(--danger); background: transparent } .pip.bad[aria-pressed="true"] { background: var(--danger) }
.slots { display: grid; gap: 6px }
.slot { display: grid; grid-template-columns: 4.6em 3.6em 1fr; gap: 8px; align-items: center; font-size: .85rem }
.slot input { padding: 2px 4px; text-align: center; font-family: var(--font-num); width: 100% }
.items { display: grid; gap: 6px }
.item { display: grid; grid-template-columns: 1fr 4em 32px; gap: 6px }
.item input.q { text-align: center; font-family: var(--font-num) }
.spell { display: grid; grid-template-columns: 1fr 6.5em 32px; gap: 6px }
.ds { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; font-size: .85rem }
.conds { display: flex; flex-wrap: wrap; gap: 6px }
.cond { border: 1px solid var(--line); background: var(--sunk); border-radius: 999px; padding: 3px 11px; font-size: .82rem }
.cond[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); color: var(--surface) }
.cond.insp[aria-pressed="true"] { background: var(--gold); border-color: var(--gold) }
textarea { width: 100%; min-height: 120px; resize: vertical; line-height: 1.5 }

/* table feed: dice + log + chat */
.dice { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px }
.dice button { border: 1px solid var(--line); background: var(--sunk); border-radius: 7px; padding: 6px 0; font: 600 .85rem var(--font-num) }
.dice button:hover { border-color: var(--accent); color: var(--accent) }
.formula { display: grid; grid-template-columns: 1fr auto; gap: 6px }
.formula input { font-family: var(--font-num) }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; justify-self: start }
.seg button { border: 0; background: transparent; padding: 4px 10px; font-size: .82rem }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink) }
.log { display: grid; gap: 6px; max-height: 340px; overflow-y: auto; align-content: start }
.log .ev { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 6px 8px; border-radius: 6px; background: var(--sunk); font-size: .85rem }
.log .ev b { font: 600 1.05rem var(--font-num); grid-row: span 2; align-self: center }
.log .ev small { color: var(--muted); font-family: var(--font-num); font-size: .75rem; overflow-wrap: anywhere }
.log .ev .by { font-weight: 600 }
.log .ev.crit b { color: var(--gold) } .log .ev.fumble b { color: var(--danger) }
.log .ev.secret { border: 1px dashed var(--dm); background: transparent }
.log .chat { padding: 4px 8px; font-size: .88rem; overflow-wrap: anywhere }
.log .chat .by { font-weight: 600; color: var(--accent) }
.chatbox { display: grid; grid-template-columns: 1fr auto; gap: 6px }

/* turn order + party (shared) */
.turns { display: grid; gap: 5px }
.turn { display: grid; grid-template-columns: 2.6em 1fr auto; gap: 8px; align-items: center; padding: 5px 8px; border-radius: 7px; background: var(--sunk); border-left: 3px solid var(--dm); font-size: .9rem }
.turn.pc { border-left-color: var(--pc) }
.turn.active { background: var(--surface); box-shadow: 0 0 0 2px var(--accent) }
.turn.mine { font-weight: 600 }
.turn .i { font: 600 .95rem var(--font-num); text-align: center }
.turn .st { font-size: .75rem; color: var(--muted) }
.yourturn { background: var(--pc); color: var(--accent-ink); border-radius: 8px; padding: 8px 12px; font-weight: 600; text-align: center }
.party { display: grid; gap: 8px }
.pcard { display: grid; gap: 4px; padding: 8px 10px; border-radius: 8px; background: var(--sunk); border: 1px solid var(--line) }
.pcard .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap }
.pcard .nm { font-weight: 600 }
.pcard .meta { font-size: .75rem; color: var(--muted) }
.pcard .bar { height: 6px; border-radius: 99px; background: var(--bg); overflow: hidden }
.pcard .bar i { display: block; height: 100%; background: var(--pc) }
.pcard .bar i.low { background: var(--danger) }
.tags { display: flex; flex-wrap: wrap; gap: 4px }
.tag { font-size: .7rem; border-radius: 99px; padding: 0 7px; border: 1px solid var(--line); color: var(--muted) }
.tag.cond { border-color: var(--danger); color: var(--danger) }
.tag.blood { border-color: var(--gold); color: var(--gold) }
.tag.good { border-color: var(--pc); color: var(--pc) }

/* DM initiative track */
.roundbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between }
.round { display: flex; align-items: baseline; gap: 8px }
.round b { font: 600 2rem var(--font-num); line-height: 1 }
.now strong { font-family: var(--font-display); font-size: 1.1rem }
.track { display: grid; gap: 8px }
.cb { border: 1px solid var(--line); border-radius: 9px; background: var(--sunk); display: grid; gap: 8px; padding: 9px 10px; border-left: 4px solid var(--dm) }
.cb.pc { border-left-color: var(--pc) }
.cb.active { background: var(--surface); box-shadow: 0 0 0 2px var(--accent) }
.cb.down { opacity: .55 }
.cb .main { display: grid; grid-template-columns: 3.4em minmax(0, 1fr) 3.2em minmax(7em, 10em) auto; gap: 10px; align-items: center }
.init { width: 100%; text-align: center; font: 600 1.05rem var(--font-num); padding: 4px 2px }
.cb .who .nm { font-weight: 600; overflow-wrap: anywhere }
.ac { text-align: center; font-size: .7rem; color: var(--muted); line-height: 1.1 }
.ac b { display: block; font: 600 1.1rem var(--font-num); color: var(--ink) }
.hpc { display: grid; gap: 3px; font-size: .78rem }
.hpc .bar { height: 7px; border-radius: 99px; background: var(--bg); overflow: hidden; border: 1px solid var(--line) }
.hpc .bar i { display: block; height: 100%; background: var(--dm) }
.cb.pc .hpc .bar i { background: var(--pc) }
.hpc .bar i.low { background: var(--danger) }
.hpact { display: flex; gap: 4px; align-items: center }
.hpact input { width: 3.6em; text-align: center; font-family: var(--font-num); padding: 4px 2px }
.hpact button { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; width: 30px; height: 30px; font-weight: 600 }
.hpact .m { color: var(--danger) } .hpact .p { color: var(--pc) }
.more { border: 0 !important; background: transparent !important; color: var(--muted); font-size: 1.1rem }
.detail { display: grid; gap: 8px; border-top: 1px dashed var(--line); padding-top: 8px }
.detail .note { font-size: .82rem; color: var(--muted); margin: 0 }
.cond.sm { padding: 1px 9px; font-size: .76rem; background: var(--surface) }
.empty { border: 1.5px dashed var(--line); border-radius: 10px; padding: 22px; text-align: center; color: var(--muted) }
.mon-pick { display: grid; grid-template-columns: 1fr 4.2em; gap: 8px }
.preview { font-size: .82rem; background: var(--sunk); border-radius: 8px; padding: 8px 10px; display: grid; gap: 3px }
.custom { display: grid; grid-template-columns: 1fr 3.8em 3.8em 3.8em; gap: 6px; align-items: end }
details { border-top: 1px solid var(--line); padding-top: 8px }
summary { cursor: pointer; font-weight: 600; font-size: .9rem }
.ref { width: 100%; border-collapse: collapse; font-size: .82rem; margin-top: 6px }
.ref td { padding: 3px 4px; border-bottom: 1px solid var(--line); vertical-align: top }
.ref td:first-child { white-space: nowrap; font-weight: 500 }

/* locked sheet fields read as printed values, not greyed-out controls */
#sheet input:disabled, #sheet select:disabled, #sheet textarea:disabled { opacity: 1; color: var(--ink); background: transparent; border-color: transparent; cursor: default; -webkit-text-fill-color: var(--ink) }
#sheet select:disabled { appearance: none }
#sheet input[type="checkbox"]:disabled { opacity: .9 }
.cond:disabled, .pip:disabled { opacity: 1; cursor: default }
.pc-dm { border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 2px }
.pc-dm input { width: 4.5em; text-align: center; font-family: var(--font-num); padding: 3px 4px }
.pc-dm .btn { padding: 3px 9px; font-size: .8rem }

/* scenes: layered images, DM-only manager */
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 13px; font-size: .88rem }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent) }
.chip.add { border-style: dashed; color: var(--muted) }
.scene-grid { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(280px, 1fr); gap: 18px; align-items: start }
@media (max-width: 980px) { .scene-grid { grid-template-columns: 1fr } }
.scene-view, .scene-mgr { display: grid; gap: 10px; min-width: 0 }
.scene-list { display: flex; flex-wrap: wrap; gap: 6px }
.stage { position: relative; margin-inline: auto; max-width: 100%; background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; overflow: hidden }
.stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain }
.stage img.off { opacity: .35; outline: 2px dashed var(--dm); outline-offset: -2px }
.stage.empty { display: grid; place-items: center; min-height: 160px; width: 100%; color: var(--muted); padding: 20px; text-align: center }
.stage-wrap { min-width: 0 }

/* fullscreen: the whole scene panel covers the screen, only the map + corner buttons show */
body.stage-full { overflow: hidden }
body.stage-full #scenePanel { position: fixed; inset: 0; z-index: 40; background: #000; border: 0; border-radius: 0; padding: 0; display: grid; place-items: center; overflow: hidden }
body.stage-full #scenePanel > h2, body.stage-full #scenePanel > .hint, body.stage-full .scene-mgr,
body.stage-full .scene-view > :not(#stageBox) { display: none }
body.stage-full .scene-grid, body.stage-full .scene-view, body.stage-full #stageBox { display: contents }
body.stage-full .stage { width: min(100vw, calc(100vh * var(--ar))) !important; border: 0; border-radius: 0 }
body.stage-full .stage { width: min(100vw, calc(100dvh * var(--ar))) !important }
body.stage-full .targetbar { position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); z-index: 45; width: max-content; max-width: calc(100vw - 24px) }
.fs-ui { position: fixed; inset: 0; pointer-events: none; z-index: 44 }
.fs-btn { position: absolute; pointer-events: auto; width: 46px; height: 46px; border-radius: 50%; border: 1px solid rgb(255 255 255 / .35); background: rgb(20 24 22 / .78); color: #fff; font-size: 1.3rem; display: grid; place-items: center; box-shadow: 0 4px 14px rgb(0 0 0 / .4) }
.fs-exit { top: calc(10px + env(safe-area-inset-top, 0px)); right: calc(10px + env(safe-area-inset-right, 0px)); font-size: 1rem }
.fs-roll { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); right: calc(14px + env(safe-area-inset-right, 0px)); font-size: 1.5rem }
.fs-roll[aria-expanded="true"] { background: var(--accent); border-color: var(--accent) }
.fs-dice { position: absolute; pointer-events: auto; right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(70px + env(safe-area-inset-bottom, 0px)); width: min(280px, calc(100vw - 28px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: grid; gap: 8px; box-shadow: 0 10px 30px rgb(0 0 0 / .45) }
.fs-dice .dice { grid-template-columns: repeat(4, 1fr) }
.fs-dice .dice button { padding: 9px 0 }
.fs-dice .seg { justify-self: center }
.fs-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--sunk); border-radius: 8px; padding: 3px }
.fs-tabs button { border: 0; background: transparent; border-radius: 6px; padding: 6px 4px; font-size: .85rem; font-weight: 600; color: var(--muted) }
.fs-tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .2) }
.fs-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px }
.fs-stats button { display: grid; justify-items: center; gap: 0; padding: 6px 2px; border: 1px solid var(--line); background: var(--sunk); border-radius: 8px }
.fs-stats button:hover, .fs-stats button:focus-visible { border-color: var(--accent) }
.fs-stats b { font: 600 .78rem var(--font-num); letter-spacing: .06em }
.fs-stats b i { font-style: normal; color: var(--accent); font-size: .7rem }
.fs-stats .num { font-size: 1.15rem; font-weight: 600; color: var(--accent) }
.fs-stats small { font-size: .65rem; color: var(--muted); line-height: 1.2 }
.fs-note { margin: 0; font-size: .7rem; color: var(--muted); text-align: center }
#fsTray { display: grid; gap: 8px }
.fs-dice { max-height: calc(100vh - 110px); overflow-y: auto }
.fs-skills { max-height: 260px; overflow-y: auto }
.fs-skills button { font-size: .78rem; padding: 5px 7px }
.fs-skills i { font-style: normal; color: var(--accent); font-size: .7rem }
.fs-skills b { color: var(--accent) }
.fs-init { width: 100%; border: 1px solid var(--line); background: var(--sunk); color: var(--ink); border-radius: 8px; padding: 8px; font-weight: 600 }
.fs-init.need { background: var(--gold); border-color: var(--gold); color: #1d1608; animation: needpulse 1.4s ease-in-out infinite }
.fs-init:disabled { opacity: .8; cursor: default }
@keyframes needpulse { 50% { box-shadow: 0 0 0 4px rgb(226 180 82 / .35) } }

/* initiative prompt + combat start announcement */
.initbar { background: var(--pc); color: var(--accent-ink) }
body.stage-full .initbar { top: calc(64px + env(safe-area-inset-top, 0px)) }
.announce { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 49 }
.announce > div { display: grid; justify-items: center; gap: 6px; padding: 22px 34px; border-radius: 18px; background: rgb(14 18 16 / .88); color: #fff;
  box-shadow: 0 16px 50px rgb(0 0 0 / .55); animation: announce 3.2s ease-out forwards; text-align: center; max-width: calc(100vw - 32px) }
.announce b { font: 700 clamp(1.8rem, 6vw, 3rem) var(--font-display); color: #ffd24a; letter-spacing: .01em }
.announce span { font-size: 1rem; opacity: .9 }
@keyframes announce { 0% { opacity: 0; transform: scale(.6) } 12% { opacity: 1; transform: scale(1.08) } 20% { transform: scale(1) } 85% { opacity: 1 } 100% { opacity: 0 } }
@media (prefers-reduced-motion: reduce) { .announce > div { animation: none } .fs-init.need { animation: none } }
/* DM secret check menu */
.tmenu.sc-menu { width: min(340px, calc(100vw - 16px)); max-height: min(560px, calc(100vh - 16px)); overflow-y: auto; border-color: var(--dm) }
.sc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px }
.sc-grid button { display: flex; justify-content: space-between; align-items: center; gap: 6px; text-align: left; border: 1px solid var(--line); background: var(--sunk); border-radius: 7px; padding: 5px 8px; font-size: .82rem }
.sc-grid button:hover, .sc-grid button:focus-visible { border-color: var(--dm) }
.sc-grid i { font-style: normal; color: var(--dm); font-size: .7rem }
.sc-grid b { color: var(--dm); font-size: .9rem }
body.stage-full .toast { z-index: 46; bottom: auto; top: calc(66px + env(safe-area-inset-top, 0px)); transform: translate(-50%, -20px) }
body.stage-full .toast.show { transform: translate(-50%, 0) }
body.stage-full .tmenu { z-index: 46 }
/* bigger touch target around small tokens on phones */
.token::before { content: ""; position: absolute; inset: -6px }

/* grid + tokens sit on top of the layers, positioned in % so they scale with the map */
.stage .grid { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none }
.stage .grid path { fill: none; stroke: rgb(0 0 0 / .45); stroke-width: 1; vector-effect: non-scaling-stroke }
.stage .grid.light path { stroke: rgb(255 255 255 / .6) }
.stage .tokens { position: absolute; inset: 0; pointer-events: none }
.token { position: absolute; display: grid; place-items: center; pointer-events: auto; touch-action: none; transition: left .15s, top .15s; z-index: 1 }
.token.movable { cursor: grab }
.token.drag { transition: none; z-index: 5; cursor: grabbing }
.token.drag .disc { transform: scale(1.12) }
.disc { width: 86%; height: 86%; border-radius: 50%; border: 3px solid var(--tk); background: var(--surface); color: var(--ink); display: grid; place-items: center; overflow: hidden;
  box-shadow: 0 2px 6px rgb(0 0 0 / .45); font: 600 clamp(8px, 1.3vw, 16px) var(--font-display); transition: transform .1s }
.disc img { width: 100%; height: 100%; object-fit: cover }
.token b { position: absolute; top: 96%; left: 50%; transform: translateX(-50%); font: 500 .65rem var(--font-body); white-space: nowrap; max-width: 11em; overflow: hidden; text-overflow: ellipsis;
  background: rgb(0 0 0 / .62); color: #fff; padding: 0 5px; border-radius: 4px; pointer-events: none }
.token.mine .disc { box-shadow: 0 0 0 3px #fff, 0 2px 8px rgb(0 0 0 / .5) }
/* "on-turn", not "turn": .turn is already the turn-order row style */
.token.on-turn .disc { animation: turnpulse 1.2s ease-in-out infinite }
@keyframes turnpulse { 50% { box-shadow: 0 0 0 5px var(--gold), 0 2px 8px rgb(0 0 0 / .5) } }
.token.down { filter: grayscale(1); opacity: .6 }
@media (prefers-reduced-motion: reduce) { .token.on-turn .disc { animation: none; box-shadow: 0 0 0 4px var(--gold) } }

/* token attack menu, targeting, DM verdict */
.token.actor { cursor: pointer }
.token.movable { cursor: grab }
.token:focus-visible { outline: none }
.token:focus-visible .disc { box-shadow: 0 0 0 3px var(--accent), 0 2px 6px rgb(0 0 0 / .45) }
.tmenu { position: fixed; z-index: 30; width: min(290px, calc(100vw - 16px)); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgb(0 0 0 / .35); padding: 8px; display: grid; gap: 5px }
.tm-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 2px 6px; border-bottom: 1px solid var(--line); font-family: var(--font-display) }
.tm-x { border: 0; background: none; font-size: 1.25rem; color: var(--muted); line-height: 1 }
.tm-atk { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; column-gap: 8px; align-items: center; text-align: left; border: 1px solid transparent; background: var(--sunk); border-radius: 8px; padding: 6px 8px }
.tm-atk:hover, .tm-atk:focus-visible { border-color: var(--accent); outline: none }
.tm-atk .ic { font-size: 1.3rem; grid-row: span 2; text-align: center }
.tm-atk .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.tm-atk b { color: var(--accent); font-size: 1rem }
.tm-atk small { grid-column: 2 / -1; color: var(--muted); font-size: .74rem }
.tm-modes { justify-self: center; margin-top: 2px }
.targetbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; background: var(--gold); color: #1d1608; border-radius: 8px; padding: 8px 12px; font-weight: 600 }
.targetbar .btn { background: rgb(255 255 255 / .85); color: #1d1608; border-color: transparent }
body.targeting .token { cursor: crosshair }
body.targeting .token:hover .disc { box-shadow: 0 0 0 3px var(--danger), 0 2px 6px rgb(0 0 0 / .45) }
.log .ev .ev-dm { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .8rem; padding-top: 3px }
.verdict.hit { color: var(--danger); font-weight: 600 }
.verdict.miss { color: var(--muted) }
.btn.apply { padding: 1px 8px; font-size: .78rem }

/* tokens out of weapon range while picking a target */
body.targeting .token.far { opacity: .35; filter: grayscale(.7); cursor: not-allowed }

/* dice animation: a die tumbles in the middle of the screen, then lands on the result */
.dice-ov { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 48; opacity: 0; transition: opacity .15s }
.dice-ov.show { opacity: 1 }
.die-box { display: grid; justify-items: center; gap: 6px; padding: 18px 26px 16px; min-width: 180px; max-width: calc(100vw - 32px); background: rgb(14 18 16 / .86); color: #fff; border-radius: 18px; box-shadow: 0 14px 40px rgb(0 0 0 / .5) }
.die { width: 92px; height: 92px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font: 700 2.3rem var(--font-num);
  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%) }
.die[data-faces="6"] { clip-path: none; border-radius: 18px; width: 82px; height: 82px }
.die[data-faces="4"] { clip-path: polygon(50% 0, 100% 92%, 0 92%); padding-top: 22px }
.die[data-faces="8"], .die[data-faces="10"], .die[data-faces="12"], .die[data-faces="100"] { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%) }
.die[data-faces="100"] { font-size: 1.9rem }
.die.spin { animation: tumble .32s linear infinite }
.die.land { animation: land .38s ease-out }
.die.crit { background: var(--gold); color: #1d1608 }
.die.fumble { background: var(--danger); color: #fff }
@keyframes tumble { 0% { transform: rotate(0) scale(.88) } 50% { transform: rotate(180deg) scale(1.06) } 100% { transform: rotate(360deg) scale(.88) } }
@keyframes land { 0% { transform: scale(1.45) } 60% { transform: scale(.92) } 100% { transform: scale(1) } }
.die-label { font-size: .85rem; opacity: .85; text-align: center; overflow-wrap: anywhere }
.die-sub { font-weight: 600; font-size: 1rem; min-height: 1.2em; text-align: center }
.die-verdict { font: 700 1.9rem var(--font-display); min-height: 0; text-align: center }
.die-verdict:not(:empty) { animation: pop .35s ease-out }
.die-verdict.hit { color: #ff6b5a } .die-verdict.crit { color: #ffd24a } .die-verdict.miss { color: #b9c2bd } .die-verdict.unknown { color: #ffd24a; font-size: 1rem }
@keyframes pop { 0% { transform: scale(.4); opacity: 0 } 70% { transform: scale(1.15); opacity: 1 } 100% { transform: scale(1) } }

/* hit / miss effects on the map */
.fx-layer { position: absolute; inset: 0; pointer-events: none }
.token.fx-hit .disc { animation: fxhit .6s ease-out }
.token.fx-miss .disc { animation: fxmiss .55s ease-out }
@keyframes fxhit { 0% { box-shadow: 0 0 0 0 rgb(255 70 50 / .9) } 15% { transform: translateX(-4px) } 30% { transform: translateX(4px); box-shadow: 0 0 0 8px rgb(255 70 50 / .55) }
  45% { transform: translateX(-3px) } 60% { transform: translateX(3px) } 100% { transform: none; box-shadow: 0 0 0 0 rgb(255 70 50 / 0) } }
@keyframes fxmiss { 0% { transform: none } 35% { transform: translateX(10px) rotate(8deg); opacity: .7 } 100% { transform: none; opacity: 1 } }
.fx-ring { position: absolute; aspect-ratio: 1; transform: translate(-50%, -50%) scale(.3); border-radius: 50%; border: 4px solid #ff5a44; animation: ring .6s ease-out forwards }
.fx-ring.crit { border-color: #ffd24a }
@keyframes ring { to { transform: translate(-50%, -50%) scale(1.4); opacity: 0 } }
.fx-float { position: absolute; transform: translate(-50%, -50%); font: 700 clamp(14px, 2.2vw, 26px) var(--font-display); color: #fff; white-space: nowrap;
  text-shadow: 0 2px 6px #000, 0 0 2px #000; animation: floatup 1.4s ease-out forwards }
.fx-float.hit { color: #ff7a6a } .fx-float.crit { color: #ffd24a } .fx-float.miss { color: #dfe5e1 } .fx-float.dmg { color: #ff4d3d; font-size: clamp(16px, 2.8vw, 32px) }
@keyframes floatup { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.7) } 15% { opacity: 1; transform: translate(-50%, -70%) scale(1.15) } 100% { opacity: 0; transform: translate(-50%, -190%) scale(1) } }
@media (prefers-reduced-motion: reduce) {
  .die.spin, .die.land, .die-verdict:not(:empty), .token.fx-hit .disc, .token.fx-miss .disc { animation: none }
  .fx-ring { display: none } .fx-float { animation-duration: .01s; animation-delay: 1s } }

/* DM token list */
.tklist { display: grid; gap: 6px }
.tk { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto auto auto auto; gap: 6px; align-items: center; padding: 5px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--sunk) }
.tk .disc.sm { width: 30px; height: 30px; border-width: 2px; font-size: .7rem; box-shadow: none }
.tk input:not([type]), .tk select { padding: 3px 6px; font-size: .82rem; min-width: 0; width: 100% }
.tk .nm { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.tk input[type="color"] { width: 30px; height: 26px; padding: 0; border: 1px solid var(--line); background: none }
.tk .btn { padding: 2px 8px; font-size: .78rem; cursor: pointer }
@media (max-width: 420px) { .tk { grid-template-columns: 34px minmax(0, 1fr) auto auto; } }
.layers { display: grid; gap: 6px }
.layer { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 6px 10px; align-items: center; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--sunk) }
.layer img { width: 64px; height: 48px; object-fit: cover; border-radius: 4px; grid-row: span 2; background: var(--bg) }
.layer.off img { opacity: .4 }
.layer input { width: 100%; padding: 3px 7px; font-size: .88rem; background: var(--surface) }
.layer .btn { padding: 2px 8px; font-size: .8rem }
.btn.eye[aria-pressed="true"] { color: var(--pc); border-color: var(--pc) }
.btn.eye[aria-pressed="false"] { color: var(--muted); border-style: dashed }
label.upload { cursor: pointer; justify-self: start }

.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 30px); opacity: 0;
  background: var(--ink); color: var(--bg); border-radius: 12px; padding: 10px 18px; display: flex; gap: 14px; align-items: center;
  transition: .2s; pointer-events: none; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgb(0 0 0 / .25); z-index: 20 }
.toast.show { opacity: 1; transform: translate(-50%, 0) }
.toast b { font: 600 1.9rem var(--font-num) }
.toast.crit b { color: var(--gold) }
.toast small { display: block; opacity: .75; font-family: var(--font-num); overflow-wrap: anywhere }

@media (max-width: 560px) {
  .cb .main { grid-template-columns: 3em minmax(0, 1fr) 2.8em }
  .cb .main .hpc { grid-column: 2 / 4 } .cb .main .hpact { grid-column: 1 / -1 } }
@media (max-width: 420px) {
  .stats { grid-template-columns: repeat(2, 1fr) } .grid3 { grid-template-columns: 1fr 1fr }
  .card .r2 { grid-template-columns: 1fr 1fr } .dice { grid-template-columns: repeat(4, 1fr) } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important } }

/* ==== map.js: vision, builder, paths, action economy, joystick, loot ==== */
.stage { isolation: isolate }
.stage .mapunder, .stage .mapsvg, .stage .pathsvg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none }
.stage .mapunder { z-index: 0 }
.stage .tokens .token { z-index: 2 }
.stage .tokens .token.drag { z-index: 8 }
.token.above { z-index: 5 }
.token.unseen { visibility: hidden }
.token.hid { opacity: .5 }
.token.hid .disc { outline: 2px dashed #fff; outline-offset: 2px }
.tk-hp { position: absolute; left: 10%; right: 10%; bottom: -1px; height: 5px; border-radius: 3px; background: rgb(0 0 0 / .7); overflow: hidden; pointer-events: none; z-index: 1 }
.tk-hp > i { display: block; height: 100%; background: #4cc27a; border-radius: 3px }
.tk-hp.low > i { background: #e0524f }
.token b small { font: 600 .6rem var(--font-mono, monospace); opacity: .9 }
.vis { position: absolute; inset: 0; pointer-events: none; z-index: 4; -webkit-mask-size: 100% 100%; mask-size: 100% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat }
.vis-blur { -webkit-backdrop-filter: blur(7px) brightness(.85); backdrop-filter: blur(7px) brightness(.85); background: rgb(190 200 210 / .12) }
.vis-gray { -webkit-backdrop-filter: grayscale(1) brightness(.7) contrast(1.05); backdrop-filter: grayscale(1) brightness(.7) contrast(1.05) }
.vis-dark { background: #050608 }
.stage .pathsvg { z-index: 6 }
.pathsvg polyline { fill: none; stroke: #ffd24a; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; stroke-dasharray: 6 4 }
.pathsvg circle { fill: #ffd24a }
.pathsvg .warn { stroke: #ff9a3c } .pathsvg circle.warn { fill: #ff9a3c }
.pathsvg .bad { stroke: #ff4d4d } .pathsvg circle.bad { fill: #ff4d4d }
.path-label { position: absolute; z-index: 7; transform: translate(-50%, calc(-100% - 4px)); pointer-events: none; white-space: nowrap; font: 600 .75rem var(--font-body);
  background: rgb(14 18 16 / .85); color: #ffd24a; padding: 1px 7px; border-radius: 6px }
.path-label.warn { color: #ffb36b } .path-label.bad { color: #ff7a7a }
.stage .mapsvg { z-index: 9 }
.stage .mapsvg.edit { pointer-events: all; cursor: crosshair; touch-action: none }
.mapsvg .wall-bg, .mapsvg .door-bg { stroke: rgb(0 0 0 / .7); stroke-width: 7; stroke-linecap: round; vector-effect: non-scaling-stroke }
.mapsvg .wall { stroke: #f2ead6; stroke-width: 3.5; stroke-linecap: round; vector-effect: non-scaling-stroke }
.mapsvg .door { stroke: #d9913f; stroke-width: 4; vector-effect: non-scaling-stroke }
.mapsvg .door.open { stroke-dasharray: 3 5; opacity: .75 }
.mapsvg .door-h { fill: #d9913f; stroke: #000; stroke-width: 1.5; vector-effect: non-scaling-stroke }
.mapsvg .door-h.open { fill: #2b2b2b; stroke: #d9913f }
.mapsvg .window { stroke: #7fd0f0; stroke-width: 4; stroke-dasharray: 7 3; vector-effect: non-scaling-stroke }
.mapsvg .window.shut { stroke: #4b7d93; stroke-dasharray: none }
.mapsvg .door-h.win { fill: #7fd0f0; stroke: #000 }
.mapsvg .door-h.win.open { fill: #1d3b47; stroke: #7fd0f0 }
.mapsvg .glass { stroke: rgb(140 225 255 / .85); stroke-width: 3; stroke-dasharray: 2 4; stroke-linecap: round; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 2px rgb(140 225 255 / .9)) }
.mapsvg .preview { opacity: .7; stroke-dasharray: 4 3 }
.mapsvg .lb { fill: rgb(255 214 90 / .16); stroke: none }
.mapsvg .ld { fill: none; stroke: rgb(255 214 90 / .7); stroke-width: 1.5; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke }
.mapsvg text, .mapunder text { font-size: .6px; text-anchor: middle; dominant-baseline: central }
.mapunder .trap rect { fill: rgb(200 40 40 / .25); stroke: #e24b4b; stroke-width: 2; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke }
.mapunder .trap.found rect { fill: rgb(200 40 40 / .5); stroke-dasharray: none }
.mapunder .trap text { fill: #ffe0e0 }
.buildbar { display: grid; gap: 6px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 8px; background: var(--sunk); margin-bottom: 8px }
.f.inline { display: inline-flex; align-items: center; gap: 6px; flex-direction: row; font-size: .8rem }
.f.inline input, .f.inline select { width: auto; max-width: 11em }
.f.inline input[type=number] { width: 5em }
.tools { display: flex; flex-wrap: wrap; gap: 4px }
.tools button { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 4px 9px; font-size: .82rem }
.tools button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent) }
.buildbar .hint { margin: 0 }
/* action economy (top-left of the map) */
.econ { position: absolute; z-index: 10; top: 6px; left: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; max-width: calc(100% - 12px); pointer-events: none }
.econ button { pointer-events: auto; display: grid; justify-items: center; gap: 0; min-width: 44px; padding: 3px 5px; border-radius: 8px; border: 1px solid rgb(255 255 255 / .35);
  background: rgb(18 22 20 / .78); color: #fff; font-size: .95rem; line-height: 1.1; transition: opacity .15s }
.econ button small { font-size: .58rem; letter-spacing: .02em; opacity: .9 }
.econ button.used { opacity: .32; text-decoration: line-through }
.econ button.used.on { opacity: 1; text-decoration: none; background: var(--accent); color: var(--accent-ink) }
.econ-who, .econ-move { pointer-events: none; font-size: .72rem; background: rgb(18 22 20 / .78); color: #fff; padding: 2px 7px; border-radius: 8px }
.econ-move { color: #ffd24a }
.pips { display: inline-flex; gap: 2px; align-items: center; margin-left: 4px }
.pips i { font: 600 .62rem var(--font-num); font-style: normal; width: 15px; height: 15px; display: grid; place-items: center; border-radius: 4px; background: var(--accent); color: var(--accent-ink) }
.pips i.used { background: var(--sunk); color: var(--muted); text-decoration: line-through }
.pips em { font-size: .65rem; font-style: normal; color: var(--muted); margin-left: 2px }
/* joystick + bag (bottom-left of the map) */
.stage-btns { position: absolute; z-index: 10; left: 8px; bottom: 8px; display: grid; gap: 6px; justify-items: start; pointer-events: none }
.sbtn-row { display: flex; gap: 6px }
.sbtn { pointer-events: auto; width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgb(255 255 255 / .4); background: rgb(18 22 20 / .6); color: #fff; font-size: 1.15rem; display: grid; place-items: center }
.sbtn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent) }
.joy { pointer-events: auto; display: grid; grid-template-columns: repeat(3, 40px); grid-template-rows: repeat(3, 40px); gap: 3px; opacity: .55; transition: opacity .15s }
.joy:hover, .joy:focus-within { opacity: .85 }
.joy.off { opacity: .25 }
.joy button { border: 1px solid rgb(255 255 255 / .45); background: rgb(18 22 20 / .55); color: #fff; border-radius: 10px; font-size: 1.1rem; touch-action: manipulation }
.joy button.ok { border-radius: 50%; background: rgb(46 106 82 / .75); font-weight: 700 }
.joy button:disabled { opacity: .45 }
.joy-x { pointer-events: auto; border: 1px solid rgb(255 255 255 / .45); background: rgb(138 46 54 / .8); color: #fff; border-radius: 8px; padding: 3px 9px; font-size: .78rem }
.joy-c { display: grid; place-items: center; color: #ffd24a; font-size: .78rem; text-shadow: 0 1px 2px #000 }
/* bag + carried light: bottom-right, same side as the 🎲 button */
.stage-btns-r { position: absolute; z-index: 10; right: 8px; bottom: 8px; display: flex; gap: 6px; pointer-events: none }
.stage-full .stage-btns-r { position: fixed; right: calc(70px + env(safe-area-inset-right, 0px)); bottom: calc(17px + env(safe-area-inset-bottom, 0px)); z-index: 45 }
.econ-move.over { color: #ff8a7a }
.econ button.econ-end { background: rgb(46 106 82 / .9); border-color: rgb(140 220 180 / .6) }
.econ button.econ-end:disabled { opacity: .4 }
.joy-note { font-size: .7rem; color: #fff; background: rgb(0 0 0 / .55); padding: 1px 6px; border-radius: 5px }
@media (max-width: 640px) { .joy { grid-template-columns: repeat(3, 36px); grid-template-rows: repeat(3, 36px) } .econ button { min-width: 38px } }
/* loot */
.token.loot .disc { border-radius: 9px; border-color: #d9a441; background: rgb(30 24 12 / .85); width: 74%; height: 74% }
.loot-ic { font-size: clamp(9px, 1.4vw, 20px); line-height: 1 }
.loot-n { position: absolute; right: -2px; top: -2px; font: 600 .6rem var(--font-num); font-style: normal; background: var(--danger); color: #fff; border-radius: 99px; padding: 0 4px }
.token.loot .disc { overflow: visible; position: relative }
.disc.sm.loot { border-radius: 7px; border: 2px solid #d9a441; display: grid; place-items: center }
.loot-list { display: grid; gap: 5px }
.loot-it { background: var(--sunk); border-radius: 8px; padding: 6px 8px; display: grid; gap: 3px }
.li-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap }
.li-top b { flex: 1; min-width: 6em }
.li-top .ic { font-size: 1.15rem }
.li-top select { width: auto; font-size: .78rem; padding: 2px 4px }
.li-desc { margin: 0; font-size: .78rem; color: var(--muted); white-space: pre-wrap }
.catalog { display: grid; gap: 8px }
.cat-item { display: grid; gap: 5px; background: var(--sunk); border-radius: 8px; padding: 8px }
.cat-item .btnrow input { flex: 1 }
.cat-item select { width: auto }
.cat-item textarea { min-height: 2.6em; font-size: .85rem }
.item .ic { align-self: center }
.item:has(> .ic) { grid-template-columns: 1.6em 1fr 4em 32px }
.item .desc, .item .li-desc { grid-column: 1 / -1; font-size: .8rem }
.item:has(> .drop) { grid-template-columns: 1fr 4em auto }
.item:has(> .ic):has(> .drop) { grid-template-columns: 1.6em 1fr 4em auto }
.item .it-name { align-self: center; font-weight: 500; overflow-wrap: anywhere }
.item .drop { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 0 9px; font-size: .78rem }
.notes-ro { display: grid; gap: 6px; max-height: 260px; overflow-y: auto; margin-bottom: 8px; padding: 8px 10px; background: var(--sunk); border-radius: 8px }
.notes-ro p { margin: 0; white-space: pre-wrap; font-size: .88rem }
#noteAdd { margin-bottom: 6px }
.contestbar { background: #c9d7ff; color: #10183a }
.contestbar select, .contestbar input { width: auto; max-width: 12em }
.tm-off { margin: 0 0 6px; color: var(--danger) }
/* พับแผง */
.panel > h2:has(> .fold) { justify-content: flex-start; align-items: center }
.panel > h2:has(> .fold) > small { margin-left: auto }
.panel > h2 > .fold { margin-left: 8px; border: 1px solid var(--line); background: var(--sunk); color: var(--muted); border-radius: 6px; width: 28px; height: 26px; font-size: .85rem; line-height: 1; flex: none }
.panel > h2:not(:has(> small)) > .fold { margin-left: auto }
.panel > h2 > .fold:hover { color: var(--ink, inherit) }
.panel.folded { gap: 0; padding-bottom: 12px; padding-top: 12px }
.panel.folded > :not(h2) { display: none !important }
/* แผงลูกเต๋าและแชทใต้แผนที่ */
.feed-grid { display: grid; gap: 12px }
.feed-ctl { display: grid; gap: 10px; align-content: start }
@media (min-width: 900px) {
  .wrap > .feed .feed-grid { grid-template-columns: minmax(280px, 1fr) minmax(0, 1.6fr); align-items: start }
  .wrap > .feed .log { max-height: 210px }
}
/* ข้อความส่วนตัว */
.chatbox { grid-template-columns: auto 1fr auto }
.chatbox select { width: auto; max-width: 11em }
.chatbox.private input, .chatbox.private select { border-color: #9b7bd4; background: rgb(155 123 212 / .12) }
.log .chat.whisper { background: rgb(155 123 212 / .14); border-left: 3px solid #9b7bd4; border-radius: 6px; font-style: italic }
.log .chat.whisper .by { color: #b79cff }
.whisper-pop { position: fixed; z-index: 60; top: calc(70px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); width: min(440px, calc(100vw - 24px));
  background: #241b38; color: #f3ecff; border: 2px solid #9b7bd4; border-radius: 12px; padding: 12px 14px; box-shadow: 0 10px 34px rgb(0 0 0 / .55); animation: wpin .25s ease-out }
.whisper-pop .wp-head { display: flex; gap: 8px; align-items: center; font-size: .82rem; color: #cbb8ff }
.whisper-pop .wp-head .tm-x { margin-left: auto; color: #fff }
.whisper-pop p { margin: 8px 0 0; font-size: 1.05rem; white-space: pre-wrap; overflow-wrap: anywhere }
@keyframes wpin { from { opacity: 0; transform: translate(-50%, -10px) } to { opacity: 1; transform: translate(-50%, 0) } }
@media (prefers-reduced-motion: reduce) { .whisper-pop { animation: none } }
/* DM จัดการกระเป๋าผู้เล่น */
.dm-bag { width: min(380px, calc(100vw - 16px)) }
.dm-bag .bag-it { display: grid; gap: 5px }
.dm-bag .li-top { display: grid; grid-template-columns: 3.2em 1fr 4.2em; gap: 5px }
.dm-bag .li-top select, .dm-bag .li-top input { padding: 4px 5px; font-size: .85rem }
.dm-bag textarea { font-size: .8rem; min-height: 0; padding: 4px 6px }
.dm-bag .btnrow select { width: auto; max-width: 10em; font-size: .8rem }
/* เสียงประจำฉาก */
.audio-row { display: grid; gap: 6px; padding: 8px 10px; border-radius: 8px; background: var(--sunk) }
.audio-row .au-name { font-weight: 500; overflow-wrap: anywhere }
.audio-row input[type=range] { width: 7em }
.sbtn.pulse { animation: turnpulse 1.2s ease-in-out infinite; background: var(--accent) }
/* รายชื่อ NPC/มอนสเตอร์ในฉาก */
.scene-crit { display: grid; gap: 6px }
.scene-crit .sc-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 8px; background: var(--sunk) }
.scene-crit .sc-row .disc.sm { width: 26px; height: 26px }
.scene-crit .sc-nm { min-width: 0; display: grid; gap: 2px }
.scene-crit .sc-nm b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.scene-crit .sc-nm span { font-size: .75rem; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center }
.scene-crit .sc-nm input { width: 4.2em; padding: 2px 4px; font-size: .78rem }
.scene-crit .sc-row.in { outline: 1px solid var(--accent) }

.tm-atk.carry.on { border-color: var(--gold) }
.tm-atk.carry .ic { font-size: .9rem; color: var(--gold) }
.tklist select[data-tk="light"] { max-width: 9em }
