:root {
  --bg: #0b0a09;
  --panel: #16130f;
  --panel-2: #1f1a14;
  --line: #3a3127;
  --text: #e9dfcf;
  --muted: #9a8d7a;
  --accent: #ffb347;
  --accent-2: #ff7a2f;
  --good: #8fd18b;
  --bad: #ff6b6b;
  --info: #9fc5ff;
  --level: #d7a8ff;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, "Segoe UI", sans-serif; }
button { font: inherit; color: inherit; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { background: #4a2a10; border-color: var(--accent-2); }
button.ghost { background: transparent; }
button.small { padding: 1px 6px; font-size: 12px; }
input, select { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
h1, h2, h3 { margin: 0.6em 0 0.3em; font-weight: 600; }
h2 { font-size: 15px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; }
h3 { font-size: 13px; color: var(--muted); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }

#topbar { display: flex; gap: 16px; align-items: center; height: 38px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
#topbar .brand { font-weight: 700; color: var(--accent); letter-spacing: 0.04em; }
#topbar .spacer { flex: 1; }
.status { font-size: 12px; color: var(--muted); }
.status.ok { color: var(--good); }
.status.bad { color: var(--bad); }

.screen { height: calc(100% - 38px); }

/* Login */
#login { overflow: auto; display: flex; justify-content: center; }
.login-panel { width: min(980px, 100%); padding: 16px 24px 40px; }
.login-panel h1 { color: var(--accent); font-size: 30px; }
.tagline { color: var(--muted); margin-top: 0; }
.field { display: flex; flex-direction: column; gap: 4px; max-width: 320px; margin-bottom: 8px; }
.char-list { display: flex; flex-wrap: wrap; gap: 8px; }
.char-card { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; min-width: 180px; text-align: left; }
.char-card:hover { border-color: var(--accent); }
.char-card.dead { opacity: 0.45; cursor: default; }
.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.choices { display: flex; flex-direction: column; gap: 6px; }
.choice { text-align: left; padding: 8px 10px; border-radius: 8px; }
.choice.selected { border-color: var(--accent); background: #2a1d10; }
.choice b { display: block; }
.choice span { color: var(--muted); font-size: 12px; }
.create-form button[type=submit] { margin-top: 12px; }

/* Game layout */
#game { display: grid; grid-template-columns: 1fr 360px; min-height: 0; }
#board { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); }
#map-wrap { position: relative; flex: 1; min-height: 200px; background: #000; overflow: hidden; }
#map { display: block; width: 100%; height: 100%; cursor: crosshair; }
#side { overflow-y: auto; background: var(--panel); padding: 8px 12px 24px; }

#turnbar { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 10px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.init-chip { padding: 2px 8px; border-radius: 12px; border: 1px solid var(--line); font-size: 12px; }
.init-chip.current { border-color: #ffe066; color: #ffe066; }
.init-chip.hostile { background: #2a1212; }
.init-chip.party { background: #12202a; }
.pips { font-family: var(--mono); color: var(--accent); letter-spacing: 2px; }
.pips .spent { color: #4a3f31; }
.yourturn { color: #ffe066; font-weight: 700; }

#actionbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 10px; background: var(--panel); border-top: 1px solid var(--line); min-height: 42px; }
.act { display: inline-flex; align-items: center; gap: 6px; }
.act .cost { font-family: var(--mono); color: var(--accent); font-size: 11px; }
.act .key { font-family: var(--mono); color: var(--muted); font-size: 10px; }
.act.class, .act.feat { border-color: #5a4373; }
.act.skill { border-color: #34566b; }
.act.armed { background: #3b2a12; border-color: var(--accent); }
.act.spell { border-color: #6a4fb0; background: #1d1630; }
.act.spell .rank { font-size: 10px; color: #c9b6ff; font-family: var(--mono); }
.act.spell.lost { text-decoration: line-through; }
.act.end-turn { margin-left: auto; background: #3a1e1e; border-color: #8a3b3b; }
.act[aria-disabled="true"] { opacity: 0.4; }
.act[aria-disabled="true"]:hover { border-color: var(--line); }
.act.dragging { opacity: 0.35; }
.act.drop-target { border-color: var(--accent); background: #3b2a12; }
.act.reset-order { color: var(--muted); padding: 4px 8px; }

/* Action HUD on the map */
/* Centred in the space between the zoom hint and the dice tray. */
#action-hud { position: absolute; left: 140px; right: 380px; bottom: 12px; width: max-content; max-width: calc(100% - 160px); margin: 0 auto; display: flex; align-items: stretch; gap: 8px; padding: 6px 10px; background: rgba(15, 12, 9, 0.88); border: 1px solid var(--line); border-radius: 10px; z-index: 4; pointer-events: none; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5); }
#action-hud > div { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 0 8px; }
#action-hud > div + div { border-left: 1px solid var(--line); }
#action-hud span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }
#action-hud .pips { display: flex; gap: 6px; letter-spacing: 0; }
#action-hud .pip { font-size: 26px; line-height: 1; color: #3a3127; text-transform: none; }
#action-hud .hud-actions.mine .pip.on { color: var(--accent); text-shadow: 0 0 10px rgba(255, 179, 71, 0.55); }
#action-hud .hud-actions.mine > span { color: #ffe066; }
#action-hud .hud-reaction b { font-size: 24px; line-height: 1; color: #3a3127; }
#action-hud .hud-reaction.on b { color: #9fc5ff; text-shadow: 0 0 10px rgba(159, 197, 255, 0.5); }
#action-hud .hud-reaction.on span { color: #9fc5ff; }
#dice-tray.collapsed ~ #action-hud { right: 290px; }
#action-hud .hud-map b { font-size: 20px; line-height: 1.2; color: var(--bad); font-family: var(--mono); }
#action-hud .hud-move b, #action-hud .hud-wait b { font-size: 20px; line-height: 1.2; color: #9fc5ff; font-family: var(--mono); }
#action-hud .hud-finish { pointer-events: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 4px 14px; font-weight: 700; font-size: 14px; color: #1a140c; background: #ffc85a; border: 1px solid #ffe7a8; border-radius: 8px; box-shadow: 0 0 12px rgba(255, 200, 90, 0.35); }
#action-hud .hud-finish:hover { background: #ffd57a; }
#action-hud .hud-finish span { font-size: 10px; font-weight: 600; color: #4a3612; text-transform: uppercase; letter-spacing: 0.06em; }
/* Hurry: the caller's button, and the countdown everyone else sees until they finish. */
#action-hud .hud-hurry { background: #9fc5ff; border-color: #d4e6ff; box-shadow: 0 0 12px rgba(120, 170, 255, 0.35); }
#action-hud .hud-hurry:hover { background: #b8d4ff; }
#action-hud .hud-hurry span { color: #1d3354; }
#action-hud .hud-wait.hurrying b { color: #ffcf7a; }
#action-hud .hud-finish.urgent { background: #ff8a5c; border-color: #ffd0b8; animation: hurry-pulse 0.9s ease-in-out infinite; }
#action-hud .hud-finish.urgent span { color: #3a1408; font-size: 11px; }
.hurry-chip { font-size: 12px; font-weight: 600; color: #cfe0ff; padding: 2px 8px; border: 1px solid #3c5682; border-radius: 12px; background: #16223a; }
.hurry-chip.urgent { color: #ffe1cf; border-color: #b0482a; background: #3a1a10; animation: hurry-pulse 0.9s ease-in-out infinite; }
.init-chip.crawl.hurried { border-color: #ff8a5c; }
@keyframes hurry-pulse { 0%, 100% { box-shadow: 0 0 0 rgba(255, 138, 92, 0); } 50% { box-shadow: 0 0 14px rgba(255, 138, 92, 0.75); } }
.crawl-check { font-size: 12px; color: var(--muted); padding: 2px 8px; border: 1px solid var(--line); border-radius: 12px; }
.crawl-check.dark { color: #ffb3a1; border-color: #6b2a22; background: #2a1212; }
.init-chip.crawl.done { color: var(--good); border-color: #2f4a33; }
.init-chip.crawl.acting { color: #ffe066; border-color: #6b5a2a; }
.init-chip.crawl.you { font-weight: 700; }

#log { height: 220px; overflow-y: auto; padding: 4px 8px 8px; font-size: 12.5px; background: #0f0d0b; }
#log-resize { height: 6px; cursor: ns-resize; background: var(--line); border-top: 1px solid #2a231b; }
#log-resize:hover { background: #6b5a3a; }
#log-wrap { position: relative; display: flex; flex-direction: column; }
#log-popout { position: absolute; top: 4px; right: 18px; z-index: 2; opacity: 0.55; background: rgba(15, 13, 11, 0.9); }
#log-popout:hover { opacity: 1; }
#log-away { display: none; align-items: center; gap: 8px; padding: 5px 10px; font-size: 12px; color: var(--muted); background: #0f0d0b; border-top: 1px solid var(--line); }
#log-away span { flex: 1; }
#board.log-popped #log, #board.log-popped #log-resize, #board.log-popped #log-popout { display: none; }
#board.log-popped #log-away { display: flex; }
.tone-combat { color: #d9cbb4; }
.tone-damage { color: #ffb3a1; }
.tone-heal { color: var(--good); }
.tone-loot { color: #f5c542; }
.tone-light { color: var(--accent); }
.tone-danger { color: var(--bad); }
.tone-level { color: var(--level); }
.tone-system { color: var(--info); }
.tone-info { color: var(--muted); }

#tooltip { position: absolute; pointer-events: none; background: rgba(22, 19, 15, 0.95); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 12px; max-width: 280px; z-index: 5; }
#banner { position: absolute; top: 18%; left: 50%; transform: translateX(-50%); padding: 10px 28px; font-size: 22px; font-weight: 700; letter-spacing: 0.08em; color: #ffe066; background: rgba(0, 0, 0, 0.75); border: 1px solid #ffe066; border-radius: 8px; pointer-events: none; }
#pickup { position: absolute; left: 10px; top: 10px; width: min(340px, calc(100% - 20px)); max-height: calc(100% - 90px); display: flex; flex-direction: column; background: rgba(17, 14, 10, 0.95); border: 1px solid #6b5a3a; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55); z-index: 6; font-size: 12.5px; }
#pickup .pk-head { display: flex; align-items: baseline; gap: 8px; padding: 6px 8px 5px 10px; border-bottom: 1px solid var(--line); }
#pickup .pk-head b { color: var(--accent); font-size: 13.5px; }
#pickup .pk-head .muted { flex: 1; font-size: 11.5px; }
#pickup .pk-list { overflow-y: auto; padding: 4px 6px; }
#pickup .pk-square { padding: 3px 4px 4px; border-radius: 6px; }
#pickup .pk-square + .pk-square { border-top: 1px solid #2a231b; }
#pickup .pk-square.focus { background: rgba(255, 179, 71, 0.07); }
#pickup .pk-where { display: flex; align-items: center; gap: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: #cdb98f; padding: 2px 0; }
#pickup .pk-where .muted { text-transform: none; letter-spacing: 0; }
#pickup .pk-where button { margin-left: auto; text-transform: none; letter-spacing: 0; }
#pickup .pk-item { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
#pickup .pk-glyph { width: 18px; text-align: center; font: bold 15px ui-monospace, Consolas, monospace; }
#pickup .pk-slots { font-size: 11px; margin-left: 4px; white-space: nowrap; }
#pickup .pk-foot { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-top: 1px solid var(--line); }
#targeting { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); padding: 4px 12px; background: rgba(59, 42, 18, 0.95); border: 1px solid var(--accent); border-radius: 6px; font-size: 13px; }

/* Side panel */
.section { margin-bottom: 10px; }
.section h2 { margin-top: 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: baseline; }
.sheet-head .name { font-size: 18px; font-weight: 700; }
.bar { position: relative; height: 16px; background: #2a2219; border-radius: 4px; overflow: hidden; margin: 4px 0; }
.bar > div { height: 100%; }
.bar > span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 16px; }
.bar.hp > div { background: linear-gradient(90deg, #8a2020, #c43c3c); }
.bar.xp > div { background: linear-gradient(90deg, #5d3a8a, #9a6be0); }
.bar.light > div { background: linear-gradient(90deg, #b05a10, #ffb347); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; text-align: center; }
.stat b { display: block; font-size: 15px; }
.stat span { font-size: 10px; color: var(--muted); text-transform: uppercase; }
.attrs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.attr { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px; text-align: center; }
.attr .boost { margin-top: 2px; }
.attr.partial { border-color: #6b5a3a; }
.list { display: flex; flex-direction: column; gap: 3px; }
.row { display: flex; align-items: center; gap: 6px; justify-content: space-between; padding: 3px 6px; background: var(--panel-2); border-radius: 5px; }
.row .grow { flex: 1; min-width: 0; }
.row .desc { font-size: 11.5px; color: var(--muted); }
.row.temp { background: #1a2419; box-shadow: inset 0 0 0 1px #2f4a2f; }
.row.curse { background: #2a1717; box-shadow: inset 0 0 0 1px #5a2a2a; }
.row.boon { background: #18241a; box-shadow: inset 0 0 0 1px #2f4a33; }
.tag.curse { color: var(--bad); border-color: #5a2a2a; }
.tag.boon { color: var(--good); border-color: #2f4a33; }
.tag { font-size: 10px; padding: 0 5px; border-radius: 8px; border: 1px solid var(--line); color: var(--muted); }
.tag.lit { color: var(--accent); border-color: var(--accent); }
.tag.temp { color: #9dff9d; border-color: #4a7a4a; }
.tag.lost { color: var(--bad); border-color: #5a2a2a; }
.row.lost { opacity: 0.6; }
.note { font-size: 11.5px; color: var(--muted); margin: -2px 0 6px; }
.card.spell { background: linear-gradient(180deg, #1f1a38, #141024); border-color: #5b47a0; }

/* Dice tray */
/* Dice: d20 checks on the left, their results on the right, the last three rolls below. */
#dice-tray { position: absolute; right: 10px; bottom: 10px; width: 360px; background: #13100d; border: 1px solid var(--line); border-radius: 10px; padding: 5px 8px 6px; z-index: 4; opacity: 0.85; transition: opacity 0.25s; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5); }
#dice-tray.active, #dice-tray:hover { opacity: 1; }
#dice-tray .dice-head { display: flex; align-items: center; justify-content: space-between; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
#dice-tray .dice-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 2px; }
#dice-tray .dice-pane { min-width: 0; }
#dice-tray .dice-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; min-height: 16px; }
#dice-tray .dice-canvas { display: block; width: 100%; height: 104px; margin: 3px 0; border-radius: 8px; background: radial-gradient(ellipse at 50% 40%, #2c3a2a 0%, #18211a 70%, #111712 100%); box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.6); }
#dice-tray .dice-pane.result .dice-canvas { background: radial-gradient(ellipse at 50% 40%, #3a2c2a 0%, #211818 70%, #171111 100%); }
#dice-tray .dice-result { font-size: 13px; font-family: var(--mono); min-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#dice-tray .total { font-size: 15px; color: #fff; }
#dice-tray .total.deg-3 { color: #7dff9b; text-shadow: 0 0 8px rgba(125, 255, 155, 0.55); }
#dice-tray .total.deg-2 { color: #3fbf62; }
#dice-tray .total.deg-1 { color: #ff5c5c; }
#dice-tray .total.deg-0 { color: #a8231c; }
#dice-tray .total.heal { color: var(--good); }
#dice-tray .vs { color: var(--muted); font-family: system-ui, "Segoe UI", sans-serif; font-size: 11.5px; }
#dice-tray .dice-history { list-style: none; margin: 5px 0 0; padding: 4px 0 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 1px; }
#dice-tray .dice-history li { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 12px; white-space: nowrap; }
#dice-tray .dice-history li + li { opacity: 0.6; }
#dice-tray .dice-history .h-label { overflow: hidden; text-overflow: ellipsis; color: #d9cbb4; }
#dice-tray .dice-history .h-math { font-family: var(--mono); flex: none; }
#dice-tray .dice-history .total { font-size: 13px; }
#dice-tray.collapsed .dice-panes { display: none; }
#dice-tray.collapsed { width: 270px; }
#zoom-hint { position: absolute; left: 10px; bottom: 10px; font-size: 11px; color: var(--muted); background: rgba(0, 0, 0, 0.55); padding: 2px 8px; border-radius: 6px; opacity: 0.6; pointer-events: none; transition: opacity 0.3s; }
#zoom-hint.show { opacity: 1; color: var(--text); }
@media (max-width: 700px) {
  #action-hud { left: 10px; right: 270px; }
  #dice-tray { width: 250px; }
  #dice-tray .dice-canvas { height: 80px; }
}
.party-row { display: flex; gap: 8px; align-items: center; padding: 3px 0; }
.party-row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.party-row .dot.off { background: #555; }
.pending-badge { display: block; width: 100%; margin: 6px 0; background: #3a2450; border-color: var(--level); color: var(--level); font-weight: 600; }

/* Hub */
#hub { flex: 1; overflow-y: auto; padding: 12px 20px; }
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.shop .row { flex-direction: column; align-items: stretch; }
.hub-top { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.hub-top.delve { margin-top: 10px; padding: 8px 12px; border: 1px solid #5a4a2a; border-radius: 8px; background: #1d1912; }
.hub-top.delve label { font-weight: 600; color: var(--accent); }
.hub-top.delve select { margin-left: 6px; }
.last-run { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }

/* Level-up modal */
#modal, #camp { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal-box { width: min(1100px, 96vw); max-height: 92vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--level); border-radius: 12px; padding: 16px 20px; }
.modal-box h1 { color: var(--level); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; margin: 12px 0; }
.card { display: flex; flex-direction: column; justify-content: flex-start; gap: 6px; text-align: left; padding: 10px 12px; border-radius: 10px; background: linear-gradient(180deg, #241c2e, #17121d); border: 1px solid #4b3a5e; min-height: 210px; }
.card:hover { border-color: var(--level); transform: translateY(-2px); }
.card .title { font-weight: 700; font-size: 15px; }
.card .meta { font-size: 11px; color: var(--muted); }
.card .cost { font-family: var(--mono); color: var(--accent); }
.card.uncommon { border-color: #3f6fa8; }
.card.rare { border-color: #c79a2a; }
.card .desc { font-size: 12.5px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 30; }
.toast { padding: 6px 14px; border-radius: 6px; background: #3a1e1e; border: 1px solid var(--bad); }

/* Chat bar */
#chat-form { display: flex; align-items: center; gap: 8px; padding: 5px 8px; background: var(--panel); border-top: 1px solid var(--line); }
#shop { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; background: #241f16; border-top: 1px solid #5a4a2a; }
#shop .shop-title { font-size: 12px; color: #e0b84a; margin-right: 4px; }
#shop .ware b { color: #f5c542; font-weight: 600; }
#scavenge { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 8px; font-size: 12.5px; background: #1b1e14; border-top: 1px solid #4a5a2a; }
#scavenge .scv-title { color: #cfe28f; font-weight: 600; cursor: help; }
#scavenge .scv-pips { display: inline-flex; gap: 3px; }
#scavenge .pip { width: 12px; height: 12px; border-radius: 3px; border: 1px solid #5f6d36; background: #11130c; }
#scavenge .pip.on { background: #e0a040; border-color: #ffcf7a; box-shadow: 0 0 6px rgba(255, 170, 60, 0.55); }
#scavenge .spacer { flex: 1; }
#kickvote { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 8px; font-size: 12.5px; background: #2a1616; border-top: 1px solid #7a3a3a; }
#kickvote .kv-title { color: #f0b8a8; }
#kickvote .kv-tally { font-weight: 600; color: #ffd7a0; }
#kickvote .spacer { flex: 1; }
.party-row .party-remove { margin-left: 4px; padding: 0 6px; height: 20px; font-size: 11px; line-height: 18px; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 4px; opacity: 0.45; }
.party-row:hover .party-remove { opacity: 1; border-color: #5a3434; }
.party-row .party-remove:hover, .party-row .party-remove.armed { color: #ffb4a0; border-color: var(--bad); background: #3a1e1e; opacity: 1; }
.modal-box.kicked { width: min(460px, 92vw); text-align: center; }


/* Make Camp dialog */
.camp-box { width: min(580px, 94vw); border-color: var(--accent-2); }
.camp-box h1 { color: var(--accent); }
.camp-options { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.camp-option { display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 10px 12px; border-radius: 10px; background: #1f1912; }
.camp-option .camp-icon { font-size: 26px; line-height: 1.1; }
.camp-option b { display: block; font-size: 14.5px; margin-bottom: 2px; color: var(--text); }
.camp-option .muted { display: block; font-size: 12.5px; line-height: 1.4; }
#chat-form input { flex: 1; min-width: 0; padding: 4px 8px; }
#talk-target { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; }
#talk-target .talking b { color: #e0b84a; }
#talk-target .thinking { color: #9fc5ff; font-style: italic; }
.gm-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.05em; color: #9fc5ff; border: 1px solid #3a64a8; border-radius: 8px; padding: 0 6px; }
.chat-line.speech { padding: 4px 2px 2px; }
.chat-line.speech .said { font-style: italic; }
.tone-npc .spk { color: #e0b84a; }
.tone-npc .said { color: #f1e3c4; }
.tone-speech .spk { color: #9fc5ff; }
.tone-speech .said { color: #d6e4f5; }
.tone-narration { color: #c9b896; font-style: italic; }

/* Gear: what you have on you, then your pack */
.gear-group { display: flex; flex-direction: column; gap: 3px; }
.gear-group.equipped { padding: 4px; border-radius: 7px; background: #2a2014; box-shadow: inset 0 0 0 1px #5a4424; }
.gear-group.equipped .row { background: #3a2c18; }
.gear-group.pack { margin-top: 10px; }
.gear-caption { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 0 2px; }
.gear-group.equipped .gear-caption { color: #d9a95b; }

/* Quests and allies */
.quest { font-size: 12.5px; padding: 2px 0; color: #e0b84a; }
.quest.done { color: var(--good); }
.party-row .dot.ally { background: #6fd0ff; }

/* Tokens */
.avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 50%; object-fit: cover; background: #241e17; border: 1px solid var(--line); color: var(--muted); font-weight: 700; }
.avatar.small { width: 20px; height: 20px; font-size: 11px; }
.avatar.large { width: 40px; height: 40px; font-size: 18px; }
.sheet-head { gap: 8px; }
.sheet-head .name { margin-right: auto; }
.token-btn { padding: 0; border: 0; background: none; border-radius: 50%; }
.token-btn:hover .avatar { border-color: var(--accent); }
.char-card { display: flex; align-items: center; gap: 10px; }
.char-card-wrap { display: inline-flex; flex-direction: column; gap: 3px; }
.char-card-wrap .token-edit { align-self: flex-start; }
#token-modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.7); }
.token-box { width: min(560px, calc(100vw - 32px)); max-height: 94vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; padding: 14px 18px; }
.token-box h1 { color: var(--accent); font-size: 20px; }
.token-body { display: flex; flex-wrap: wrap; gap: 16px; margin: 10px 0; }
.token-stage { position: relative; width: 280px; height: 280px; border-radius: 8px; overflow: hidden; background: #0b0a09; border: 1px dashed var(--line); }
.token-stage canvas { display: block; cursor: grab; touch-action: none; }
.token-stage canvas:active { cursor: grabbing; }
.token-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); cursor: pointer; }
.token-empty[hidden] { display: none; }
.token-side { display: flex; flex-direction: column; gap: 10px; min-width: 180px; flex: 1; }
.token-rings { display: flex; flex-wrap: wrap; gap: 6px; }
.ring { width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 2px solid var(--line); }
.ring.selected { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.token-preview-wrap { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.token-preview { width: 80px; height: 80px; }
.modal-actions .spacer { flex: 1; }
.sound-controls { display: inline-flex; align-items: center; gap: 4px; }
.sound-controls button { padding: 2px 6px; }
.sound-controls input { width: 72px; accent-color: var(--accent); }

/* Pathfinder-style rules blocks */
.glyph { color: var(--accent); font-size: 0.85em; letter-spacing: 1px; margin-left: 2px; white-space: nowrap; }
.rb { font-size: 12.5px; line-height: 1.45; color: var(--text); }
.rb p { margin: 2px 0; }
.rb-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding-bottom: 2px; margin-bottom: 4px; border-bottom: 1px solid #6b5a3a; }
.rb-name { font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: 0.03em; }
.rb-type { font-weight: 700; font-size: 12px; text-transform: uppercase; color: var(--accent); white-space: nowrap; }
.rb-traits { display: flex; flex-wrap: wrap; gap: 3px; margin: 4px 0; }
.trait { background: #5d0000; border: 2px solid #d9c484; color: #fff; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; padding: 0 5px; line-height: 15px; }
.trait.uncommon { background: #98513d; }
.trait.rare { background: #002664; }
.rb hr { border: 0; border-top: 1px solid #4a3f31; margin: 5px 0; }
.rb-note { color: var(--bad); font-style: italic; margin-top: 6px !important; }
.rb.compact { font-size: 12px; }
.rb.compact .rb-name { font-size: 13px; }
#rules-tip { position: fixed; z-index: 50; width: 340px; max-width: calc(100vw - 16px); max-height: 70vh; overflow: hidden; background: #16130f; border: 1px solid #6b5a3a; border-radius: 8px; padding: 8px 10px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6); pointer-events: none; }
[data-ref] { cursor: help; }
button[data-ref] { cursor: pointer; }
.ref { border-bottom: 1px dotted #6b5a3a; }
.preview { margin-top: 8px; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.preview:empty { display: none; }
.tag.cond { color: #ffc48a; border-color: #6b4a2a; }
button.small.on { color: var(--good); border-color: #2f4a33; }

/* Chat cards: one per action, with its rolls as rows */
.cc { margin: 6px 0 0; background: #15120e; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.cc-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; padding: 3px 8px; font-size: 12.5px; border-bottom: 1px solid var(--line); }
.cc.side-party > .cc-head { background: #142030; }
.cc.side-hostile > .cc-head { background: #2c1515; }
.cc.side-world > .cc-head { background: #241e13; }
.cc-actor { font-weight: 700; }
.cc.side-party > .cc-head .cc-actor { color: #9fc5ff; }
.cc.side-hostile > .cc-head .cc-actor { color: #ff9a9a; }
.cc-title { color: var(--accent); font-weight: 600; }
.cc-target { color: var(--muted); }
.cc-target .arrow { margin-right: 4px; font-size: 0.85em; opacity: 0.7; }
.cc-body { padding: 3px 8px 4px; }
.cc.nested { margin: 4px 0; }
.cc.nested > .cc-head { padding: 2px 8px; font-size: 12px; }
.cr { padding: 2px 0; }
.cr + .cr { border-top: 1px solid #221c15; }
/* The outcome and damage chips sit right after the numbers (not at the card's far edge), in a column that lines up row to row. */
.cr.roll { display: grid; grid-template-columns: minmax(130px, 210px) minmax(170px, max-content) 1fr; align-items: center; gap: 2px 12px; }
.cr.init { display: flex; gap: 10px; }
.cr-label { font-size: 12px; color: #d9cbb4; }
.cr-label .paren { color: var(--muted); }
.cr-who { display: block; font-size: 11px; color: var(--muted); }
.cr-detail { color: var(--muted); }
.cr-math { display: inline-flex; align-items: center; gap: 4px; font-family: var(--mono); flex-wrap: wrap; }
.die { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; padding: 0 4px; border-radius: 4px; background: #2a241c; border: 1px solid #4a3f31; font-size: 12px; }
.die.d20 { background: #2d2618; border-color: #7a6440; font-weight: 700; min-width: 26px; }
.die.nat20 { background: #4d3b07; border-color: #ffd24a; color: #ffd24a; box-shadow: 0 0 6px rgba(255, 210, 74, 0.45); }
.die.nat1 { background: #4a1414; border-color: #ff5252; color: #ff7a7a; }
.die.many { padding: 0 6px; }
.mod { color: #c9b896; }
.mult { color: var(--accent); font-weight: 700; }
.eq { color: var(--muted); }
.total { font-size: 15px; color: #fff; }
.total.heal { color: var(--good); }
.vs { margin-left: 4px; font-family: system-ui, "Segoe UI", sans-serif; font-size: 11.5px; color: var(--muted); }
.cr-out { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 4px 6px; }
.cr-notes { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
.note { font-size: 10.5px; color: var(--muted); border: 1px dashed #4a3f31; border-radius: 8px; padding: 0 6px; }
.deg { padding: 1px 8px; border-radius: 10px; border: 1px solid var(--line); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.deg-3 { color: #8ff0a4; background: #133a1e; border-color: #2f8a4a; }
.deg-2 { color: #a9c8ff; background: #14243d; border-color: #3a64a8; }
.deg-1 { color: #ffbf80; background: #3a2410; border-color: #a0602a; }
.deg-0 { color: #ff8a8a; background: #3d1212; border-color: #a83a3a; }
.dmg { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; background: #221c15; border: 1px solid #4a3f31; color: #d6ccbc; white-space: nowrap; }
.dmg.t-fire { color: #ff9a52; border-color: #7a3d14; }
.dmg.t-cold { color: #8fd0ff; border-color: #2a5a7a; }
.dmg.t-electricity { color: #ffe45c; border-color: #7a6a14; }
.dmg.t-acid { color: #b6ec5a; border-color: #4f6a1a; }
.dmg.t-poison { color: #7fdc7f; border-color: #2f6a2f; }
.dmg.t-sonic { color: #6fe8de; border-color: #1f6a64; }
.dmg.t-force { color: #cfaeff; border-color: #5a3f8a; }
.dmg.t-vitality { color: #fff2b3; border-color: #7a6a3a; }
.dmg.t-void { color: #b08ae0; border-color: #4f3a6e; }
.dmg.t-mental { color: #ff9fd0; border-color: #7a3a5e; }
.dmg.t-spirit { color: #9fe8ff; border-color: #2a5f6e; }
.dmg.t-precision { color: #f5c542; border-color: #6e5a1f; }
.dmg.t-healing { color: var(--good); border-color: #2f4a33; }
.cr.text, .chat-line { display: flex; gap: 6px; font-size: 12.5px; }
.chat-line { padding: 3px 2px 0; }
.ic { flex: none; width: 14px; text-align: center; opacity: 0.85; }

@media (max-width: 700px) {
  .cr.roll { grid-template-columns: 1fr; }
  .cr-out { justify-content: flex-start; }
  .cr-notes { grid-column: 1; }
}

@media (max-width: 900px) {
  #game { grid-template-columns: 1fr; grid-template-rows: auto auto; height: auto; }
  #board { height: 75vh; }
  .choice-row { grid-template-columns: 1fr; }
}
