:root {
  --bg: #15110e;
  --bg2: #1b1612;
  --panel: #211a15;
  --panel2: #2b231c;
  --panel3: #352b22;
  --line: #3d3127;
  --line2: #54443a;
  --text: #f1e8da;
  --muted: #a99a85;
  --faint: #776a5a;
  --accent: #e8913a;
  --accent-2: #c2571a;
  --accent-ink: #1b120a;
  --gold: #f2c14e;
  --good: #4ade80;
  --bad: #ef4444;
  --warn: #f59e0b;
  --blue: #60a5fa;
  --purple: #c084fc;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --font: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --display: 'Cinzel', Georgia, serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--display); letter-spacing: .02em; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(28px, 5vw, 46px); }
h2 { font-size: 24px; }
h3 { font-size: 17px; }
p { margin: 0 0 1em; }
small, .muted { color: var(--muted); }
.faint { color: var(--faint); }
hr { border: none; border-top: 1px solid var(--line); margin: 20px 0; }
code { background: var(--panel2); padding: 1px 6px; border-radius: 5px; font-size: 13px; }
::selection { background: var(--accent); color: var(--accent-ink); }

/* ---------- buttons & inputs ---------- */
button, .btn {
  font: 600 14px var(--font); color: var(--text); background: var(--panel2); border: 1px solid var(--line2);
  border-radius: 8px; padding: 8px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
button:hover, .btn:hover { background: var(--panel3); border-color: var(--faint); text-decoration: none; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary, button.primary { background: linear-gradient(180deg, #f0a04b, var(--accent-2)); border-color: #d4772a; color: #1b0f05; }
.btn-primary:hover, button.primary:hover { background: linear-gradient(180deg, #f5ad5c, #cf6320); }
button.danger, .btn-danger { background: #3a1716; border-color: #7f1d1d; color: #fca5a5; }
button.danger:hover { background: #4c1d1b; }
button.ghost, .btn-ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--panel2); }
button.small, .btn.small { padding: 4px 9px; font-size: 12.5px; border-radius: 6px; }
button.icon { padding: 6px; width: 32px; height: 32px; justify-content: center; }
button.active, .tool.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

input, select, textarea {
  font: 14px var(--font); color: var(--text); background: var(--bg2); border: 1px solid var(--line2); border-radius: 8px;
  padding: 8px 10px; width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232, 145, 58, .18); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
input[type=range] { padding: 0; accent-color: var(--accent); background: none; border: none; }
input[type=color] { padding: 2px; height: 34px; width: 48px; }
textarea { resize: vertical; min-height: 80px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; margin: 6px 0; cursor: pointer; }
.error { color: #fca5a5; background: #3a1716; border: 1px solid #7f1d1d; padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.notice { background: var(--panel2); border: 1px solid var(--line2); padding: 10px 14px; border-radius: 8px; font-size: 14px; }
.notice.gold { border-color: #a16207; background: #2c2210; }
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--panel3); color: var(--muted); }
.pill.gold { background: #4a3510; color: var(--gold); }
.pill.green { background: #13361f; color: var(--good); }
.pill.red { background: #3a1716; color: #fca5a5; }

/* ---------- layout ---------- */
.ad-top { background: #0d0a08; border-bottom: 1px solid var(--line); display: flex; justify-content: center; align-items: center; min-height: 60px; padding: 4px 16px; }
.ad-top .house { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 14px; flex-wrap: wrap; justify-content: center; }
.ad-top .house b { color: var(--gold); }
.ad-top .ad-label { font-size: 10px; color: var(--faint); text-transform: uppercase; letter-spacing: .1em; margin-right: 8px; }
.nav { display: flex; align-items: center; gap: 16px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: rgba(21, 17, 14, .92); position: sticky; top: 0; z-index: 30; backdrop-filter: blur(8px); }
.nav .brand { font-family: var(--display); font-weight: 800; font-size: 21px; color: var(--text); display: flex; align-items: center; gap: 9px; letter-spacing: .04em; }
.nav .brand img { width: 30px; height: 30px; }
.nav .links { display: flex; gap: 4px; flex: 1; }
.nav .links a { color: var(--muted); padding: 6px 10px; border-radius: 7px; font-weight: 500; }
.nav .links a:hover, .nav .links a.on { color: var(--text); background: var(--panel2); text-decoration: none; }
.nav .right { display: flex; gap: 8px; align-items: center; }
.nav .burger { display: none; }
#app { flex: 1; display: flex; flex-direction: column; }
.page { width: 100%; max-width: 1100px; margin: 0 auto; padding: 32px 20px 60px; }
.page.narrow { max-width: 460px; }
.page.mid { max-width: 820px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 30px 0 14px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.footer { border-top: 1px solid var(--line); padding: 26px 20px; color: var(--faint); font-size: 12.5px; text-align: center; }
.footer a { color: var(--muted); margin: 0 8px; }
.boot { margin: 20vh auto; color: var(--muted); font-family: var(--display); }
.empty { text-align: center; padding: 30px; color: var(--muted); border: 1px dashed var(--line2); border-radius: var(--radius); }

/* ---------- landing ---------- */
.hero { position: relative; overflow: hidden; padding: 70px 20px 60px; text-align: center; background: radial-gradient(ellipse at 50% 0%, #3b2415 0%, transparent 65%), var(--bg); border-bottom: 1px solid var(--line); }
.hero h1 { font-size: clamp(34px, 6.5vw, 64px); margin-bottom: 14px; background: linear-gradient(180deg, #fff3da, #f0a04b); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { font-size: clamp(16px, 2.2vw, 20px); color: var(--muted); max-width: 640px; margin: 0 auto 26px; }
.hero .cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero .cta .btn { padding: 12px 22px; font-size: 16px; }
.hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .35; pointer-events: none; }
.hero > *:not(canvas) { position: relative; }
.features { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.feature { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.feature .ico { font-size: 26px; margin-bottom: 6px; }
.feature h3 { font-family: var(--font); font-weight: 700; font-size: 16px; letter-spacing: 0; }
.feature p { color: var(--muted); font-size: 14px; margin: 0; }
.price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; max-width: 760px; margin: 0 auto; }
.price { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 26px; }
.price.pro { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.price .amt { font-family: var(--display); font-size: 40px; font-weight: 800; }
.price ul { padding-left: 18px; color: var(--muted); }
.price li { margin: 6px 0; }

/* ---------- game list / characters ---------- */
.game-card { display: flex; flex-direction: column; gap: 10px; }
.game-card .title { font-family: var(--display); font-size: 18px; font-weight: 600; }
.char-card { display: flex; gap: 12px; align-items: center; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--panel3); border: 2px solid var(--line2); display: grid; place-items: center; font-weight: 700; font-size: 20px; flex: none; overflow: hidden; background-size: cover; background-position: center; }
.usage { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.meter { height: 6px; background: var(--panel3); border-radius: 99px; overflow: hidden; width: 120px; display: inline-block; vertical-align: middle; margin-left: 6px; }
.meter > i { display: block; height: 100%; background: var(--accent); }

/* ---------- character sheet ---------- */
.sheet { display: grid; grid-template-columns: 220px 1fr; gap: 16px; }
.sheet .abilities { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.ability { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px; text-align: center; }
.ability .lbl { font-size: 11px; font-weight: 700; letter-spacing: .1em; color: var(--muted); }
.ability .mod { font-size: 24px; font-weight: 700; font-family: var(--display); cursor: pointer; }
.ability .mod:hover { color: var(--accent); }
.ability input { text-align: center; padding: 3px; width: 56px; margin: 0 auto; display: block; }
.statline { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.stat { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px; text-align: center; }
.stat .lbl { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.stat input { text-align: center; font-size: 18px; font-weight: 700; padding: 3px; }
.stat .val { font-size: 20px; font-weight: 700; }
.skill-list { columns: 2; column-gap: 16px; font-size: 13.5px; }
.skill { display: flex; align-items: center; gap: 6px; break-inside: avoid; padding: 2px 0; }
.skill .bonus { width: 30px; text-align: right; font-weight: 700; cursor: pointer; }
.skill .bonus:hover { color: var(--accent); }
.skill select { width: auto; padding: 1px 2px; font-size: 12px; }
.attack-row { display: grid; grid-template-columns: 1.4fr .8fr .5fr 1fr 1fr auto; gap: 6px; align-items: center; margin-bottom: 6px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: none; background: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: 8px 12px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- modal & toasts ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 100; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; box-shadow: var(--shadow); width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; padding: 22px; }
.modal.wide { max-width: 860px; }
.modal h2 { margin-bottom: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--panel3); border: 1px solid var(--line2); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); animation: rise .2s; font-size: 14px; max-width: 90vw; }
.toast.err { border-color: #7f1d1d; background: #3a1716; }
.toast.big { font-family: var(--display); font-size: 22px; padding: 14px 26px; border-color: var(--accent); }
@keyframes fade { from { opacity: 0 } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) } }

/* ---------- admin ---------- */
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th, table.list td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.table-wrap { overflow-x: auto; }
.statcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.statcards .card { padding: 14px; }
.statcards .num { font-size: 28px; font-weight: 700; font-family: var(--display); }

/* ---------- rules / glossary ---------- */
.def { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.def .head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.def .head img { width: 28px; height: 28px; }
.def .head b { font-size: 16px; }
.def .simple { color: var(--text); }
.def .complex { color: var(--muted); font-size: 14px; margin-top: 6px; }
.def details summary { cursor: pointer; color: var(--accent); font-size: 13px; margin-top: 6px; }
.defs { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.mode-toggle { display: inline-flex; background: var(--panel2); border: 1px solid var(--line2); border-radius: 99px; padding: 3px; }
.mode-toggle button { border: none; border-radius: 99px; padding: 5px 12px; background: none; }
.mode-toggle button.on { background: var(--accent); color: var(--accent-ink); }

@media (max-width: 760px) {
  .nav { padding: 8px 12px; gap: 8px; }
  .nav .links { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; background: var(--panel); border-bottom: 1px solid var(--line); padding: 8px; }
  .nav.open .links { display: flex; }
  .nav .burger { display: inline-flex; }
  .nav .right .hide-sm { display: none; }
  .page { padding: 20px 16px 50px; }
  .sheet { grid-template-columns: 1fr; }
  .sheet .abilities { grid-template-columns: repeat(3, 1fr); }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .skill-list { columns: 1; }
  .attack-row { grid-template-columns: 1fr 1fr; }
  .ad-top { min-height: 50px; }
}

/* =====================================================================
   Game table
   ===================================================================== */
body.in-game { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
body.in-game .nav { display: none; }
body.in-game #app { min-height: 0; overflow: hidden; }
.table { flex: 1; display: flex; flex-direction: column; min-height: 0; background: #0e0b09; }
.table-top { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--bg2); flex-wrap: nowrap; overflow: hidden; }
.table-top .game-name { font-family: var(--display); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.presence { display: flex; gap: 4px; overflow: hidden; }
.presence .who { font-size: 12px; background: var(--panel2); border: 1px solid var(--line); padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.conn { font-size: 12px; white-space: nowrap; color: var(--muted); }
.conn.online { color: var(--good); }
.conn.offline, .conn.deleted { color: var(--warn); }
.table-main { flex: 1; display: flex; min-height: 0; position: relative; }
.toolbar { width: 48px; flex: none; display: flex; flex-direction: column; gap: 4px; padding: 6px; background: var(--bg2); border-right: 1px solid var(--line); overflow-y: auto; align-items: center; }
.toolbar .tool { width: 36px; height: 36px; padding: 0; justify-content: center; font-size: 17px; border-radius: 8px; flex: none; }
.toolbar .sep { height: 1px; width: 70%; background: var(--line2); margin: 4px 0; flex: none; }
.canvas-wrap { flex: 1; position: relative; min-width: 0; overflow: hidden; }
.table-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: default; }
.side { width: 340px; flex: none; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); min-height: 0; }
.ptabs { display: flex; gap: 2px; padding: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; scrollbar-width: thin; }
.ptabs button { flex: none; padding: 6px 8px; font-size: 15px; background: none; border-color: transparent; position: relative; }
.ptabs button .lbl { display: none; }
.ptabs button.on { background: var(--panel3); border-color: var(--line2); }
.ptabs button .badge { position: absolute; top: 0; right: 0; background: var(--bad); color: #fff; font-size: 10px; border-radius: 99px; padding: 0 5px; line-height: 15px; }
.pbody { flex: 1; overflow-y: auto; padding: 10px; min-height: 0; font-size: 14px; }
.pbody h3 { font-size: 15px; margin-bottom: 8px; }
.psec { margin-bottom: 16px; }
.psec h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.psec .field { margin-bottom: 8px; }
.side-toggle { display: none; }
.notice { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13.5px; }
.empty { color: var(--faint); padding: 10px 0; font-size: 13.5px; }

/* turn banner & overlays on the canvas */
.turn-banner { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: rgba(27, 22, 18, .92); border: 1px solid var(--accent); border-radius: 99px; padding: 6px 16px; display: flex; gap: 12px; align-items: center; font-size: 13.5px; box-shadow: var(--shadow); z-index: 5; max-width: calc(100% - 20px); white-space: nowrap; overflow: hidden; }
.turn-banner .round { color: var(--muted); font-size: 12px; }
.turn-banner .now { font-family: var(--display); font-weight: 800; color: var(--gold); }
.turn-banner .next { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.turn-banner button { padding: 3px 10px; font-size: 12px; }
.token-card { position: absolute; top: 56px; left: 10px; width: 300px; max-height: calc(100% - 130px); overflow-y: auto; background: rgba(33, 26, 21, .97); border: 1px solid var(--line2); border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); z-index: 6; font-size: 13.5px; }
.token-card .hpline { display: flex; gap: 6px; align-items: center; margin-top: 4px; font-size: 15px; }
.token-card input, .token-card select { padding: 5px 8px; font-size: 13px; }
.token-card select.small { margin-top: 6px; }
.actions-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.cond-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.cond { display: inline-flex; align-items: center; gap: 4px; background: var(--panel2); border: 1px solid var(--line2); border-radius: 99px; padding: 2px 8px 2px 3px; font-size: 12px; cursor: pointer; }
.cond img { width: 18px; height: 18px; }
.cond .x { margin-left: 2px; color: var(--muted); cursor: pointer; }
.cond .x:hover { color: var(--bad); }
.target-bar { position: absolute; bottom: 64px; left: 50%; transform: translateX(-50%); background: rgba(27, 22, 18, .95); border: 1px solid var(--accent); border-radius: 12px; padding: 8px 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; z-index: 7; box-shadow: var(--shadow); max-width: calc(100% - 20px); font-size: 13.5px; }
.dicebar { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; align-items: center; background: rgba(27, 22, 18, .9); border: 1px solid var(--line2); border-radius: 12px; padding: 5px; z-index: 5; max-width: calc(100% - 20px); overflow-x: auto; }
.dicebar .die { padding: 5px 8px; font-size: 12.5px; font-weight: 700; }
.dicebar input { width: 110px; padding: 5px 8px; font-size: 13px; }
.dicebar select { width: auto; padding: 5px; font-size: 12.5px; }

/* party / token lists */
.tok-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; font-size: 13.5px; }
.tok-row:hover { background: var(--panel2); }
.tok-row.on { background: var(--panel3); border-color: var(--accent); }
.tok-row .dot { width: 26px; height: 26px; border-radius: 50%; flex: none; background-size: cover; background-position: center; border: 2px solid rgba(255, 255, 255, .2); }
.tok-row .conds { display: flex; gap: 2px; }
.tok-row .conds img { width: 16px; height: 16px; }
.hpmini { display: inline-block; width: 60px; height: 6px; background: #3a1716; border-radius: 99px; overflow: hidden; flex: none; }
.hpmini > i { display: block; height: 100%; border-radius: 99px; transition: width .4s; }
.token-card .hpmini { width: 100%; height: 8px; }
.bestiary { max-height: 260px; overflow-y: auto; margin-top: 6px; }

/* initiative */
.init-list { display: flex; flex-direction: column; gap: 4px; }
.init-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); font-size: 13.5px; }
.init-row.cur { border-color: var(--gold); background: #3a2b12; box-shadow: 0 0 0 1px var(--gold) inset; }
.init-row.skip { opacity: .45; }
.init-row .init-n { width: 28px; text-align: center; font-weight: 800; font-family: var(--display); color: var(--accent); }

/* log & chat */
.logwrap { display: flex; flex-direction: column; height: 100%; min-height: 300px; }
.pbody:has(.logwrap) { display: flex; flex-direction: column; }
.logwrap .log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-bottom: 8px; min-height: 0; }
.entry { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; font-size: 13px; }
.entry .who { font-weight: 700; color: var(--accent); margin-right: 6px; }
.entry.sys { background: none; border-style: dashed; color: var(--muted); font-size: 12.5px; }
.entry.chat.whisper { border-color: var(--purple); }
.entry.chat.mentioned { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--panel2)); box-shadow: inset 3px 0 0 var(--accent); }
.entry .mention { color: var(--accent); font-weight: 700; background: color-mix(in srgb, var(--accent) 16%, transparent); border-radius: 4px; padding: 0 3px; }
.chat-input { position: relative; }
.chat-ac { position: absolute; left: 0; right: 0; bottom: calc(100% + 4px); z-index: 30; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.4); padding: 4px; display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; }
.chat-ac[hidden] { display: none; }
.chat-ac .ac-item { display: flex; align-items: baseline; gap: 6px; width: 100%; text-align: left; background: none; border: 0; padding: 6px 8px; border-radius: 6px; font-size: 13px; }
.chat-ac .ac-item small { margin-left: auto; white-space: nowrap; }
.chat-ac .ac-item.on, .chat-ac .ac-item:hover { background: var(--panel2); }
.entry.action { border-left: 3px solid var(--accent); }
.rollline { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rollline .total { font-size: 20px; font-weight: 800; font-family: var(--display); min-width: 36px; text-align: center; background: var(--bg2); border-radius: 6px; padding: 0 6px; }
.rollline .total.crit { color: var(--good); }
.rollline .total.fumble { color: var(--bad); }
.entry small, .entry .faint { font-size: 12px; }

/* map / build panel */
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; }
.asset-grid .asset { flex-direction: column; padding: 4px; font-size: 10.5px; font-weight: 500; white-space: normal; line-height: 1.15; text-align: center; height: auto; gap: 2px; }
.asset-grid .asset img, .asset-grid .asset canvas { width: 44px; height: 44px; object-fit: contain; }
.terrain-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 5px; }
.swatch { height: 44px; padding: 0; border-radius: 8px; background-size: cover; font-size: 10px; align-items: flex-end; justify-content: center; text-shadow: 0 1px 2px #000; overflow: hidden; }
.swatch.active { outline: 2px solid var(--accent); outline-offset: 1px; }
.track-list { display: flex; flex-wrap: wrap; gap: 4px; }
.pending { background: var(--panel2); border: 1px solid var(--warn); border-radius: 8px; padding: 8px; margin-bottom: 6px; font-size: 13px; }
.def.small { padding: 10px 12px; margin-bottom: 8px; font-size: 13.5px; }

@media (min-width: 1300px) {
  .side { width: 380px; }
  .ptabs button .lbl { display: inline; font-size: 12px; }
}
@media (max-width: 900px) {
  .side { position: absolute; right: 0; top: 0; bottom: 0; width: min(360px, 92vw); z-index: 20; transform: translateX(100%); transition: transform .2s; box-shadow: var(--shadow); }
  .table.side-open .side { transform: none; }
  .side-toggle { display: inline-flex; }
  .table-top .presence { display: none; }
  .token-card { width: min(300px, calc(100% - 20px)); top: auto; bottom: 64px; max-height: 50%; }
  .target-bar { bottom: auto; top: 56px; }
}
@media (max-width: 560px) {
  .toolbar { width: 42px; padding: 4px; }
  .toolbar .tool { width: 32px; height: 32px; font-size: 15px; }
  .turn-banner .next { display: none; }
  .table-top { gap: 6px; padding: 5px 6px; }
  .table-top .pill { display: none; }
  .dicebar .die { padding: 4px 6px; }
}
body.in-game .ad-top { min-height: 0; padding: 3px 10px; }
body.in-game .ad-top .house { font-size: 12.5px; gap: 8px; flex-wrap: nowrap; overflow: hidden; }
body.in-game .ad-top .house button, body.in-game .ad-top .house .btn { padding: 2px 9px; font-size: 12px; }
@media (max-width: 560px) { body.in-game .ad-top .house > :not(.ad-label):not(a):not(button) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } }
.ic { flex: none; display: block; }
.feature .ico .ic { color: var(--accent); }
.ptabs button { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.ptabs button.on { color: var(--text); }

/* ---------- community library ---------- */
.lib-cats { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 18px; }
.lib-cats button { background: var(--panel2); border-radius: 99px; padding: 6px 12px; font-size: 13px; color: var(--muted); }
.lib-cats button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.lib-card { display: flex; flex-direction: column; align-items: stretch; padding: 0; overflow: hidden; text-align: left; white-space: normal; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); gap: 0; font-weight: 400; }
.lib-card:hover { border-color: var(--accent); background: var(--panel); }
.lib-thumb { aspect-ratio: 4 / 3; background: #0f0c0a repeating-conic-gradient(#1a1512 0 25%, #14110e 0 50%) 0 0 / 20px 20px; display: grid; place-items: center; overflow: hidden; }
.lib-thumb img { width: 100%; height: 100%; object-fit: contain; }
.lib-thumb.placeholder { color: var(--faint); background: var(--panel2); }
.lib-thumb.big { aspect-ratio: auto; max-height: 420px; border-radius: 10px; min-height: 180px; }
.lib-thumb.big img { max-height: 420px; }
.lib-meta { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.lib-meta b { font-size: 14.5px; }
.lib-meta small { color: var(--muted); font-size: 12px; }
.lib-stats { display: flex; gap: 10px; color: var(--faint); font-size: 12px; margin-top: 4px; align-items: center; }
.lib-stats span { display: inline-flex; align-items: center; gap: 3px; }
.lib-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.statblock { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 14px; }
.statblock > * + * { margin-top: 4px; }
.lib-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.lib-pick button { flex-direction: column; align-items: flex-start; white-space: normal; text-align: left; padding: 14px; gap: 4px; font-weight: 400; }
.lib-pick button .ic { color: var(--accent); }
.lib-pick button small { color: var(--muted); }
.lib-preview { width: 120px; height: 90px; border: 1px dashed var(--line2); border-radius: 8px; display: grid; place-items: center; overflow: hidden; }
.lib-preview img { max-width: 100%; max-height: 100%; }
button.active .ic { color: inherit; }
@media (max-width: 760px) { .lib-detail { grid-template-columns: 1fr; } }
.scene-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22vw; }
.scene-name select { padding: 3px 6px; font-size: 12.5px; width: auto; max-width: 22vw; }
@media (max-width: 560px) { .scene-name { display: none; } }
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--accent); }
tr.banned td { opacity: .6; }
.lib-card.mod { cursor: default; }
.lib-card.mod .lib-thumb { cursor: zoom-in; }
td .check { font-size: 13px; margin: 2px 0; }
.statcards .card + .card { margin-top: 0; }
.member-row { padding: 8px 10px; border: 1px solid var(--line, rgba(255,255,255,.08)); border-radius: 10px; margin-bottom: 8px; }
.member-row .pill { margin-left: 4px; }
.measure-bar { bottom: auto; top: 10px; }
.tool:disabled { opacity: .35; cursor: default; }
.table.editing .canvas-wrap::after { content: 'Editing map'; position: absolute; top: 10px; right: 10px; padding: 4px 10px; border-radius: 999px; background: var(--accent); color: #1b1612; font-size: 12px; font-weight: 700; pointer-events: none; z-index: 6; }
.table.editing .canvas-wrap { outline: 2px solid var(--accent); outline-offset: -2px; }
.bug-shot { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; border: 1px solid var(--line); margin-bottom: 8px; }
.avatar-lg { width: 72px; height: 72px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-size: 28px; font-weight: 700; overflow: hidden; flex: none; margin-right: 8px; }
.avatar-lg img, .avatar-sm, .avatar-xs { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.avatar-sm { width: 24px; height: 24px; margin-right: 6px; display: inline-block; vertical-align: middle; }
.avatar-xs { width: 16px; height: 16px; margin-right: 4px; display: inline-block; vertical-align: -3px; }
.me-btn { display: inline-flex; align-items: center; }
.qr-box { background: #fff; border-radius: 10px; padding: 8px; width: max-content; margin: 6px 0 10px; min-height: 40px; color: #222; }
.qr-box svg { display: block; width: 180px; height: 180px; }
code.secret { font-family: ui-monospace, monospace; letter-spacing: .5px; word-break: break-all; }
pre.backup-codes { font-family: ui-monospace, monospace; font-size: 16px; line-height: 1.7; background: rgba(0,0,0,.25); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; columns: 2; user-select: all; }

/* DM: view the table as a player */
.viewas-btn { border-radius: 99px; font-size: 12px; padding: 3px 10px; gap: 4px; }
.menu { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.45); padding: 6px; z-index: 200; min-width: 230px; max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.menu-head { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 4px 10px 6px; }
.menu-item { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; width: 100%; background: none; border: 0; text-align: left; padding: 7px 10px; border-radius: 6px; font-size: 13.5px; }
.menu-item:hover { background: var(--panel2); }
.menu-item.on { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--text); }
.viewas-banner { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 15; display: flex; align-items: center; gap: 10px; background: color-mix(in srgb, var(--accent) 22%, var(--panel)); border: 1px solid var(--accent); border-radius: 10px; padding: 6px 8px 6px 12px; font-size: 13px; max-width: calc(100% - 24px); }
.viewas-banner[hidden] { display: none; }

/* top bar mute */
.mute-btn { padding: 4px 8px; }
.mute-btn.on { color: var(--bad); border-color: var(--bad); }
.sound-groups { display: grid; grid-template-columns: 1fr; gap: 0; }
/* blinded player: the map goes dark */
.blind-overlay { position: absolute; inset: 0; z-index: 12; background: #000; display: grid; place-items: center; text-align: center; color: #a8a29e; animation: blindIn .6s ease-out; }
.blind-overlay[hidden] { display: none; }
.blind-overlay b { display: block; font-family: var(--display); font-size: 28px; color: #e7e5e4; letter-spacing: .04em; }
.blind-overlay small { font-size: 13px; }
@keyframes blindIn { from { opacity: 0; } to { opacity: 1; } }
/* victory / defeat */
.outcome-back { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; background: rgba(0,0,0,.55); animation: blindIn .3s ease-out; }
.outcome { text-align: center; padding: 28px 40px; border-radius: 16px; background: var(--panel); border: 2px solid var(--accent); box-shadow: 0 20px 60px rgba(0,0,0,.6); animation: outcomePop .5s cubic-bezier(.2,1.6,.4,1); }
.outcome-back.lose .outcome { border-color: var(--bad); }
.outcome-title { font-family: var(--display); font-size: 64px; font-weight: 800; line-height: 1; color: var(--accent); text-shadow: 0 0 30px color-mix(in srgb, var(--accent) 60%, transparent); }
.outcome-back.lose .outcome-title { color: var(--bad); text-shadow: 0 0 30px rgba(220,38,38,.5); }
@keyframes outcomePop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
