/* ============================================================================
   Table Log — site stylesheet
   ----------------------------------------------------------------------------
   Extracted verbatim from the original single-file index.html <style> block as
   part of the multi-page refactor. Every page (index / riftbound / mtg / dnd /
   admin / reader) loads THIS one stylesheet, so a selector that is shared across
   screens keeps working no matter which page it renders on. Do not split rules
   out of here per-page unless you are certain no other page uses them.

   Section map:
     1.  Design tokens (dark + light theme) and global resets
     2.  Layout shell (.wrap), game tabs, headers, turn rows
     3.  Cards
     4.  Conquest / life counters (Riftbound + MTG shared)
     5.  Battlefields, toggles
     6.  MTG player grid + commander-damage table
     7.  D&D tools: sub-tabs, inputs, result lists, stat blocks
     8.  Initiative tracker (rows, conditions, death saves)
     9.  Character sheets + notes
     10. Screens / game-select / nav
     11. Maps: stage, viewport, tokens, lens, crop, layers, fog
     12. Admin panel
     13. Auth link styles + verify banner
     14. Book reader
     15. Library search
     16. Battle screen
     17. Dice roller + theme toggle (fixed, global)
     18. Spell browser / entry modals / level-up configurator
     19. General interaction polish + responsive breakpoints
   ============================================================================ */

/* -- 1. Design tokens + global resets ------------------------------------- */
:root{
  --void:#141019; --surface:#1D1826; --surface-2:#241E30; --surface-3:#2C2438; --line:rgba(237,233,242,0.09); --field-border:rgba(237,233,242,0.28);
  --ink:#EDE9F2; --ink-dim:#9C93AE; --ink-faint:#6A6280;
  --fury:#E5484D; --order:#D4B106; --body:#4E9F5B; --chaos:#A468C7; --mind:#3E8FD0; --calm:#3AAFA0;
  --danger:#E5484D; --safe-top:env(safe-area-inset-top,0px); --safe-bottom:env(safe-area-inset-bottom,0px);
  --body-gradient: radial-gradient(circle at 15% 0%, #221b30 0%, var(--void) 60%);
}
:root[data-theme="light"]{
  --void:#F3F1F8; --surface:#FFFFFF; --surface-2:#F1EDF7; --surface-3:#E6E0F0; --line:rgba(30,20,50,0.12); --field-border:rgba(30,20,50,0.32);
  --ink:#1D1826; --ink-dim:#544D66; --ink-faint:#83798F;
  --fury:#C6353A; --order:#8A6A00; --body:#256B32; --chaos:#7B3FA0; --mind:#1F5F9E; --calm:#207468;
  --danger:#C6353A;
  --body-gradient: radial-gradient(circle at 15% 0%, #FFFFFF 0%, var(--void) 60%);
}
*{ box-sizing:border-box; -webkit-tap-highlight-color:transparent; touch-action:manipulation; }
html,body{ height:100%; }
body{
  margin:0; background:var(--body-gradient); transition:background .2s ease;
  color:var(--ink); font-family:'Inter',sans-serif; min-height:100vh; min-height:100dvh;
  padding-top:var(--safe-top); padding-bottom:calc(var(--safe-bottom) + 16px); overscroll-behavior:none;
}
.wrap{ max-width:640px; margin:0 auto; padding:0 14px; }

/* -- 2. Game tabs / headers / turn rows ----------------------------------- */
.game-tabs{ display:flex; gap:8px; padding:14px 0 0; }
.game-tab{
  flex:1; padding:12px 8px; text-align:center; border-radius:12px; border:1px solid var(--line);
  background:var(--surface); color:var(--ink-dim); font-family:'Cinzel',serif; font-weight:700;
  font-size:clamp(12px,3.4vw,15px); letter-spacing:.03em; cursor:pointer; min-height:46px;
}
.game-tab.active{ color:var(--ink); border-color:var(--chaos); background:var(--surface-2); }

header{ text-align:center; padding:16px 0 4px; }
.eyebrow{ font-family:'JetBrains Mono',monospace; font-size:10.5px; letter-spacing:.2em; color:var(--ink-dim); text-transform:uppercase; margin:0 0 4px; }
h1{ font-family:'Cinzel',serif; font-weight:900; font-size:clamp(19px,5.5vw,26px); margin:0; letter-spacing:.03em;
    background:linear-gradient(90deg, var(--chaos), var(--mind) 45%, var(--order) 90%);
    -webkit-background-clip:text; background-clip:text; color:transparent;
    filter:drop-shadow(0 0 14px rgba(164,104,199,0.35)); }
.turn-row{ display:flex; align-items:center; justify-content:center; gap:10px; margin-top:10px; }
.turn-btn{ width:38px; height:38px; border-radius:50%; border:1px solid var(--line); background:var(--surface); color:var(--ink); font-size:18px; }
.turn-label{ font-family:'JetBrains Mono',monospace; font-size:13px; color:var(--ink-dim); min-width:96px; text-align:center; }

/* -- 3. Cards ------------------------------------------------------------- */
.card{ background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:14px; margin-top:12px;
       border-top:2px solid var(--card-accent, var(--chaos)); box-shadow:0 8px 24px -12px rgba(0,0,0,0.5); }
.card h2{ font-family:'Cinzel',serif; font-size:13px; letter-spacing:.08em; text-transform:uppercase; color:var(--ink-dim); margin:0 0 10px; font-weight:700; }
#dnd-panel-creatures .card{ --card-accent: var(--body); }
#dnd-panel-init .card{ --card-accent: var(--fury); }
#dnd-panel-campaigns .card{ --card-accent: var(--order); }
#dnd-panel-maps .card{ --card-accent: var(--mind); }
#dnd-panel-chars .card{ --card-accent: var(--chaos); }
#dnd-panel-admin .card{ --card-accent: var(--fury); }
#dnd-panel-notes .card{ --card-accent: var(--calm); }
.dnd-panel{ display:flex; flex-direction:column; gap:12px; }
.dnd-panel .card{ margin-top:0; }
#dnd-sub-creatures.active{ background:var(--body); border-color:var(--body); color:var(--void); }
#dnd-sub-init.active{ background:var(--fury); border-color:var(--fury); color:var(--void); }
#dnd-sub-campaigns.active{ background:var(--order); border-color:var(--order); color:var(--void); }
#dnd-sub-maps.active{ background:var(--mind); border-color:var(--mind); color:var(--void); }
#dnd-sub-chars.active{ background:var(--chaos); border-color:var(--chaos); color:var(--void); }
#dnd-sub-admin.active{ background:var(--fury); border-color:var(--fury); color:var(--void); }
#dnd-sub-notes.active{ background:var(--calm); border-color:var(--calm); color:var(--void); }

/* -- 4. Conquest / life counters (Riftbound + MTG shared) ----------------- */
.duo{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.side{ background:var(--surface-2); border-radius:14px; padding:12px 8px; text-align:center; position:relative; overflow:hidden; }
.side.win{ box-shadow:0 0 0 2px var(--order) inset; }
.name-input{
  width:100%; background:transparent; border:none; color:var(--ink); text-align:center;
  font-family:'Inter',sans-serif; font-weight:600; font-size:14px; padding:4px; border-bottom:1px solid transparent;
}
.name-input:focus{ outline:none; border-bottom:1px solid var(--chaos); }
.count{ font-family:'JetBrains Mono',monospace; font-weight:700; font-size:clamp(38px,12vw,54px); line-height:1; margin:6px 0; letter-spacing:-.02em; }
.bar{ height:6px; border-radius:4px; background:var(--surface-3); overflow:hidden; margin:6px 0 10px; }
.bar-fill{ height:100%; background:var(--order); transition:width .25s ease; }
.banner{ font-family:'Cinzel',serif; font-size:12px; color:var(--order); min-height:16px; font-weight:700; }
.btn-row{ display:flex; gap:6px; justify-content:center; }
.btn{
  min-width:44px; min-height:44px; border-radius:10px; border:1px solid var(--line); background:var(--surface-3);
  color:var(--ink); font-family:'JetBrains Mono',monospace; font-weight:700; font-size:16px; flex:1;
}
.btn:active{ background:var(--chaos); }
.btn.minus:active{ background:var(--fury); }

.target-row{ display:flex; align-items:center; justify-content:center; gap:8px; margin-top:12px; font-size:12px; color:var(--ink-dim); }
.target-row input{
  width:52px; background:var(--surface-2); border:1px solid var(--line); border-radius:8px; color:var(--ink);
  text-align:center; padding:8px 4px; font-family:'JetBrains Mono',monospace; font-size:14px; min-height:36px;
}
.reset-btn{
  display:block; margin:14px auto 0; background:none; border:1px solid var(--line); color:var(--ink-faint);
  padding:9px 16px; border-radius:10px; font-size:12px; min-height:40px;
}

/* -- 5. Battlefields + toggles -------------------------------------------- */
.bf-list{ display:flex; flex-direction:column; gap:8px; }
.bf-row{ display:flex; align-items:center; gap:8px; background:var(--surface-2); border-radius:12px; padding:8px 10px; }
.bf-name{ flex:1; background:transparent; border:none; color:var(--ink); font-size:13px; font-weight:600; min-width:0; }
.bf-name:focus{ outline:none; }
.bf-pick{ display:flex; gap:4px; }
.bf-opt{
  min-width:44px; min-height:36px; border-radius:8px; border:1px solid var(--line); background:var(--surface-3);
  color:var(--ink-dim); font-size:11px; font-weight:600; padding:0 8px;
}
.bf-opt.sel-a{ background:var(--mind); color:var(--void); border-color:var(--mind); }
.bf-opt.sel-b{ background:var(--fury); color:var(--void); border-color:var(--fury); }
.bf-opt.sel-c{ background:var(--surface-3); color:var(--order); border-color:var(--order); }

.toggle-row{ display:flex; align-items:center; justify-content:space-between; }
.toggle{ display:flex; gap:6px; }
.toggle button{ padding:9px 14px; border-radius:10px; border:1px solid var(--line); background:var(--surface-2); color:var(--ink-dim); font-size:13px; font-weight:600; min-height:40px; }
.toggle button.on{ background:var(--calm); color:var(--void); border-color:var(--calm); }

/* -- 6. MTG player grid + commander-damage table -------------------------- */
.player-count-row{ display:flex; gap:6px; justify-content:center; margin-bottom:10px; }
.pc-btn{ min-width:44px; min-height:38px; border-radius:10px; border:1px solid var(--line); background:var(--surface-2); color:var(--ink-dim); font-size:13px; font-weight:700; }
.pc-btn.on{ background:var(--chaos); color:var(--void); border-color:var(--chaos); }
.preset-row{ display:flex; gap:6px; justify-content:center; margin-bottom:10px; }
.preset-btn{ padding:8px 14px; border-radius:10px; border:1px solid var(--line); background:var(--surface-2); color:var(--ink-dim); font-size:12px; font-weight:600; min-height:38px; }
.players-grid{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.p-card{ background:var(--surface-2); border-radius:14px; padding:10px; text-align:center; }
.p-card.dead{ opacity:.4; }
.p-life{ font-family:'JetBrains Mono',monospace; font-weight:700; font-size:clamp(30px,9vw,40px); margin:4px 0; }
.p-sub{ display:flex; justify-content:center; gap:14px; font-size:10.5px; color:var(--ink-dim); margin-top:6px; font-family:'JetBrains Mono',monospace; }
.p-sub .flag{ color:var(--fury); font-weight:700; }
.small-btn-row{ display:flex; gap:4px; margin-top:6px; }
.small-btn{ flex:1; min-height:38px; border-radius:8px; border:1px solid var(--line); background:var(--surface-3); color:var(--ink); font-size:13px; font-weight:700; }

.cd-table{ width:100%; border-collapse:collapse; font-size:12px; }
.cd-table th{ color:var(--ink-faint); font-weight:600; padding:6px 4px; text-align:center; font-size:10.5px; }
.cd-table td{ text-align:center; padding:4px; }
.cd-cell{ display:flex; align-items:center; justify-content:center; gap:4px; }
.cd-val{ min-width:20px; font-family:'JetBrains Mono',monospace; font-weight:700; }
.cd-val.lethal{ color:var(--fury); }
.cd-btn{ width:26px; height:26px; border-radius:6px; border:1px solid var(--line); background:var(--surface-3); color:var(--ink); font-size:13px; padding:0; }

.hidden{ display:none !important; }
footer{ text-align:center; padding:20px 14px 6px; font-size:10.5px; color:var(--ink-faint); font-family:'JetBrains Mono',monospace; }

/* -- 7. D&D tools: sub-tabs, inputs, result lists, stat blocks ------------ */
.sub-tab{
  flex:1; padding:10px 6px; text-align:center; border-radius:10px; border:1px solid var(--line);
  background:var(--surface); color:var(--ink-dim); font-family:'Inter',sans-serif; font-weight:600;
  font-size:clamp(10.5px,3vw,12.5px); cursor:pointer; min-height:42px;
}
.sub-tab.active{ color:var(--void); border-color:var(--body); background:var(--body); }
.dnd-panel{ margin-top:0; }
.wide-input{
  width:100%; background:var(--surface-2); border:1px solid var(--line); border-radius:10px; color:var(--ink);
  padding:10px 12px; font-family:'Inter',sans-serif; font-size:13px; min-height:44px; resize:vertical;
}
.wide-input:focus{ outline:none; border-color:var(--chaos); }
.result-list{ display:flex; flex-direction:column; gap:8px; margin-top:10px; }
.result-item{
  background:var(--surface-2); border-radius:12px; padding:10px 12px; display:flex; justify-content:space-between;
  align-items:center; gap:8px; cursor:pointer; border:1px solid transparent;
}
.result-item:active{ border-color:var(--chaos); }
.result-item .rname{ font-weight:600; font-size:13px; }
.result-item .rsub{ font-size:11px; color:var(--ink-dim); font-family:'JetBrains Mono',monospace; }
.icon-btn{
  min-width:36px; min-height:36px; border-radius:8px; border:1px solid var(--line); background:var(--surface-3);
  color:var(--ink-dim); font-size:14px;
}
.stat-block{ background:var(--surface-2); border-radius:14px; padding:14px; margin-top:12px; }
.stat-block h3{ font-family:'Cinzel',serif; margin:0 0 2px; font-size:16px; }
.stat-block .stype{ font-size:11px; color:var(--ink-dim); font-style:italic; margin-bottom:8px; }
.stat-grid{ display:grid; grid-template-columns:repeat(6,1fr); gap:4px; margin:10px 0; text-align:center; }
.stat-grid div{ background:var(--surface-3); border-radius:8px; padding:6px 2px; }
.stat-grid .slabel{ font-size:9px; color:var(--ink-faint); text-transform:uppercase; }
.stat-grid .sval{ font-family:'JetBrains Mono',monospace; font-weight:700; font-size:13px; }
.stat-meta{ font-size:12px; color:var(--ink-dim); line-height:1.6; }
.stat-actions p{ font-size:12px; line-height:1.5; margin:4px 0 10px; }
.stat-actions b{ color:var(--ink); }

/* -- 8. Initiative tracker ------------------------------------------------ */
.init-list{ display:flex; flex-direction:column; gap:6px; }
.init-row{
  display:flex; align-items:center; gap:8px; background:var(--surface-2); border-radius:10px; padding:8px 10px;
  border-left:3px solid var(--surface-3);
}
.init-row.active-turn{ border-left-color:var(--order); background:var(--surface-3); }
.init-row .init-roll{ font-family:'JetBrains Mono',monospace; font-weight:700; min-width:26px; text-align:center; color:var(--chaos); }
.init-row .init-roll-input{ font-family:'JetBrains Mono',monospace; font-weight:700; width:32px; text-align:center; color:var(--chaos); background:var(--surface-3); border:1px solid var(--line); border-radius:6px; padding:4px 2px; }
.init-row .init-hp-input{ font-family:'JetBrains Mono',monospace; font-weight:700; width:44px; text-align:center; color:var(--ink); background:var(--surface-3); border:1px solid var(--line); border-radius:6px; padding:4px 2px; }
.init-row .init-name{ flex:1; font-size:13px; font-weight:600; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.init-row .init-name.pc{ color:var(--mind); }
.init-row .init-hp{ display:flex; align-items:center; gap:4px; font-family:'JetBrains Mono',monospace; font-size:12px; }
.init-row .init-hp button{ width:24px; height:24px; border-radius:6px; border:1px solid var(--line); background:var(--surface-3); color:var(--ink); font-size:12px; padding:0; }
.init-row .init-remove{ width:28px; height:28px; border-radius:8px; border:1px solid var(--line); background:transparent; color:var(--fury); font-size:14px; }
.init-inspect{ width:28px; height:28px; border-radius:8px; border:1px solid var(--line); background:transparent; color:var(--mind); font-size:13px; cursor:pointer; }
.init-entry{ margin-bottom:2px; }
.init-detail{ background:var(--surface-2); border:1px solid var(--field-border); border-radius:10px; padding:10px 12px; margin:2px 0 8px; }
.stat-card .stat-top{ font-size:13px; margin-bottom:6px; }
.stat-abils{ display:flex; flex-wrap:wrap; gap:8px; margin-bottom:6px; }
.stat-abils span{ font-family:'JetBrains Mono',monospace; font-size:12px; background:var(--surface-3); border:1px solid var(--line); border-radius:6px; padding:2px 6px; }
.stat-abils i{ color:var(--ink-faint); font-style:normal; margin-right:3px; }
.stat-line{ font-size:12px; margin-bottom:6px; color:var(--ink-dim); }
.stat-section{ margin-top:6px; }
.stat-h{ text-transform:uppercase; letter-spacing:.05em; font-size:10px; color:var(--chaos); margin-bottom:2px; }
.stat-action{ font-size:12px; margin-bottom:4px; line-height:1.4; }
.stat-notes{ font-size:12px; color:var(--ink-dim); white-space:pre-wrap; }

.add-combatant-grid{ display:grid; grid-template-columns:2fr 1fr 1fr auto; gap:6px; margin-bottom:10px; }
.add-combatant-grid input{
  background:var(--surface-2); border:1px solid var(--line); border-radius:8px; color:var(--ink); padding:8px; font-size:13px; min-height:40px; min-width:0;
}
.pc-toggle{ display:flex; align-items:center; gap:4px; font-size:11px; color:var(--ink-dim); white-space:nowrap; }

/* -- 9. Character sheets + notes ------------------------------------------ */
.char-form-grid{ display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-bottom:8px; }
.char-form-grid input{
  background:var(--surface-2); border:1px solid var(--line); border-radius:10px; color:var(--ink); padding:10px; font-size:13px; min-height:42px;
}
.char-card{ background:var(--surface-2); border-radius:12px; padding:12px; }
.char-card .rname{ font-weight:700; font-size:14px; }
.char-card .rsub{ font-size:11px; color:var(--ink-dim); margin-top:2px; }
.char-card .notes-text{ font-size:12px; color:var(--ink-dim); margin-top:6px; line-height:1.5; }
.char-card a{ color:var(--calm); font-size:11px; }
.char-card .char-actions{ display:flex; justify-content:flex-end; margin-top:6px; }

.note-card{ background:var(--surface-2); border-radius:12px; padding:12px; }
.note-card .rname{ font-weight:700; font-size:14px; }
.note-card .rsub{ font-size:10.5px; color:var(--ink-faint); font-family:'JetBrains Mono',monospace; margin-bottom:6px; }
.note-card .note-body{ font-size:12.5px; line-height:1.55; white-space:pre-wrap; }
.note-card .char-actions{ display:flex; justify-content:flex-end; margin-top:6px; }
.ability-input{ width:100%; background:transparent; border:none; color:var(--ink); text-align:center; font-family:'JetBrains Mono',monospace; font-weight:700; font-size:13px; }
.ability-input:focus{ outline:none; }
#account-card{ margin-top:12px; }

/* -- 10. Screens / game-select / nav -------------------------------------- */
.game-select-grid{ display:flex; flex-direction:column; gap:12px; margin-top:20px; }
.game-select-card{
  padding:28px 20px; border-radius:18px; border:1px solid var(--line); background:var(--surface);
  color:var(--ink); font-family:'Cinzel',serif; font-weight:800; font-size:20px; text-align:left;
  border-left:4px solid var(--gsc-accent, var(--chaos)); box-shadow:0 8px 24px -12px rgba(0,0,0,0.5);
}
.game-select-card:active{ background:var(--surface-2); }
.vis-btn{ padding:9px 14px; border-radius:10px; border:1px solid var(--line); background:var(--surface-2); color:var(--ink-dim); font-size:12px; font-weight:600; flex:1; }
.vis-btn.on{ background:var(--calm); color:var(--void); border-color:var(--calm); }

/* spacing between the D&D sub-tabs and the content below them */
#game-dnd .game-tabs{ margin-bottom:12px; }
.dnd-panel{ margin-top:0; }

/* -- 11. Maps: stage, viewport, tokens, lens, crop, layers, fog ----------- */
.map-stage{ position:relative; margin-top:10px; }
#map-canvas{ display:block; }
/* The camera transform is applied to #map-stage itself rather than an inner wrapper:
   it is already the containing block for the absolutely positioned token/lens/crop
   layers, so scaling it keeps every overlay in register. #map-viewport just clips. */
#map-stage{ position:relative; transform-origin:50% 50%; will-change:transform; }
/* touch-action:none so a two-finger pinch reaches the handler as touchmove instead
   of the browser deciding partway through that it was a scroll and taking it over.
   The canvas inside already opts out for the same reason. */
#map-viewport{ position:relative; overflow:hidden; border-radius:12px; touch-action:none; }

.layer-row{ display:flex; align-items:center; gap:8px; padding:5px 0; border-bottom:1px solid var(--line); }
.layer-row:last-child{ border-bottom:0; }
.layer-row .lname{ flex:1; font-size:12px; color:var(--ink); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.layer-row .lvis{ cursor:pointer; background:none; border:0; font-size:15px; line-height:1; padding:2px 4px; color:var(--ink); }
.layer-row .lvis.off{ opacity:.35; }
.layer-row input[type=range]{ width:82px; }
.layer-row .lbtn{ cursor:pointer; background:var(--surface-3); border:1px solid var(--line); color:var(--ink-dim); border-radius:6px; font-size:11px; padding:2px 6px; line-height:1.4; }
.layer-row .lbtn:hover{ color:var(--ink); }
/* Marks the Fog tool button while fog is active on this map. */
#map-mode-fog.has-fog{ box-shadow:inset 0 0 0 1px var(--chaos); }

/* Whose turn it is, readable from across the room. */
.map-token.tok-active-turn{ box-shadow:0 0 0 3px var(--order), 0 0 18px 4px rgba(212,177,6,0.55); z-index:5; }

.init-ac-input{ width:42px; text-align:center; background:var(--surface-2); border:1px solid var(--line);
                color:var(--ink); border-radius:8px; font-size:12px; padding:4px 2px; }
.init-cond{ background:none; border:0; color:var(--ink-dim); cursor:pointer; font-size:14px; padding:2px 4px; }
.init-cond:hover{ color:var(--order); }
.init-name.downed{ color:var(--ink-faint); text-decoration:line-through; }
.init-chips{ display:flex; flex-wrap:wrap; gap:5px; align-items:center; padding:2px 0 6px 4px; }
.cond-chip{ font-size:10px; text-transform:uppercase; letter-spacing:.05em; padding:2px 7px; border-radius:99px;
            border:1px solid var(--chaos); color:var(--chaos); background:rgba(164,104,199,0.12); cursor:pointer; }
.cond-chip:hover{ background:rgba(164,104,199,0.28); }
.death-saves{ font-size:10px; color:var(--ink-faint); display:inline-flex; align-items:center; gap:3px; }
.ds-pip{ width:16px; height:16px; border-radius:50%; border:1px solid var(--line); background:var(--surface-2);
         color:var(--ink-faint); font-size:9px; line-height:1; cursor:pointer; padding:0; }
.ds-pip.succ.on{ background:var(--body); border-color:var(--body); color:var(--void); }
.ds-pip.fail.on{ background:var(--fury); border-color:var(--fury); color:var(--void); }
.cond-picker{ margin-top:10px; padding:10px; border:1px solid var(--chaos); border-radius:12px; background:var(--surface-2); }
.cond-grid{ display:flex; flex-wrap:wrap; gap:6px; }
.cond-opt{ font-size:11px; padding:4px 9px; border-radius:99px; border:1px solid var(--line);
           background:var(--surface); color:var(--ink-dim); cursor:pointer; }
.cond-opt.on{ background:var(--chaos); border-color:var(--chaos); color:var(--void); }
.combatant-count{ width:44px; margin-left:auto; text-align:center; background:var(--surface-2);
                  border:1px solid var(--line); color:var(--ink); border-radius:8px; font-size:12px; padding:3px 2px; }

/* Pre-placed tokens: obvious to the DM, invisible to players. */
.map-token.tok-hidden{ opacity:.42; filter:grayscale(.6); outline:2px dashed var(--order); outline-offset:-2px; }
.tokrow{ display:flex; align-items:center; gap:8px; padding:5px 0; border-bottom:1px solid var(--line); }
.tokrow:last-child{ border-bottom:0; }
.tokrow.off .tokname{ color:var(--ink-faint); text-decoration:line-through; }
.tokrow .tokname{ flex:1; font-size:12px; color:var(--ink); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.tokeye{ cursor:pointer; background:none; border:0; font-size:14px; line-height:1; padding:2px 4px; }

/* -- 12. Admin panel ------------------------------------------------------ */
.adm-row{ display:flex; align-items:center; gap:8px; padding:8px 0; border-bottom:1px solid var(--line); flex-wrap:wrap; }
.adm-row:last-child{ border-bottom:0; }
.adm-main{ flex:1; min-width:150px; }
.adm-name{ font-size:13px; color:var(--ink); font-weight:600; }
.adm-sub{ font-size:11px; color:var(--ink-faint); word-break:break-all; }
.adm-tag{ font-size:10px; padding:1px 6px; border-radius:99px; border:1px solid var(--line); color:var(--ink-dim); }
.adm-tag.admin{ color:var(--order); border-color:var(--order); }
.adm-tag.off{ color:var(--danger); border-color:var(--danger); }
.adm-btn{ cursor:pointer; background:var(--surface-3); border:1px solid var(--line); color:var(--ink-dim); border-radius:6px; font-size:11px; padding:4px 8px; }
.adm-btn:hover{ color:var(--ink); }
.adm-btn.danger{ color:var(--danger); border-color:var(--danger); }
.adm-stat{ display:flex; justify-content:space-between; padding:4px 0; border-bottom:1px solid var(--line); font-size:12px; }
.adm-stat:last-child{ border-bottom:0; }
.adm-stat b{ color:var(--ink); font-family:'JetBrains Mono',monospace; }

/* -- 13. Auth link styles + verify banner --------------------------------- */
.linkish{ background:none; border:0; padding:0; color:var(--mind); font-size:12px; cursor:pointer; text-decoration:underline; font-family:inherit; }
.linkish:hover{ color:var(--ink); }
#verify-banner{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; background:rgba(212,177,6,0.10); border:1px solid var(--order); border-radius:10px; padding:8px 12px; margin-top:10px; }
#verify-banner .vb-text{ flex:1; min-width:180px; font-size:12px; color:var(--ink-dim); }

/* -- 14. Book reader ------------------------------------------------------ */
.reader-layout{ display:grid; grid-template-columns:1fr; gap:14px; }
@media (min-width: 1000px){ .reader-layout{ grid-template-columns:320px 1fr; align-items:start; } }
#reader-canvas-wrap{ margin-top:10px; overflow:auto; max-height:78vh; background:var(--surface-2); border-radius:10px; text-align:center; }
#reader-canvas{ max-width:100%; height:auto; display:inline-block; }
.hit{ padding:7px 8px; border-bottom:1px solid var(--line); cursor:pointer; }
.hit:last-child{ border-bottom:0; }
.hit:hover{ background:var(--surface-3); }
.hit .hit-page{ font-size:11px; color:var(--order); font-family:'JetBrains Mono',monospace; }
.hit .hit-snip{ font-size:12px; color:var(--ink-dim); margin-top:2px; line-height:1.45; }
.hit .hit-snip mark{ background:rgba(212,177,6,0.30); color:var(--ink); border-radius:3px; padding:0 2px; }
.ocr-chip{ font-size:10px; padding:1px 6px; border-radius:99px; border:1px solid var(--line); color:var(--ink-faint); }
.ocr-chip.ready{ color:var(--body); border-color:var(--body); }
.ocr-chip.working{ color:var(--order); border-color:var(--order); }
#map-token-layer{ position:absolute; left:0; top:0; pointer-events:none; }
#map-token-layer .map-token{ pointer-events:auto; }
#map-lens{ position:absolute; border-radius:50%; overflow:hidden; border:4px solid rgba(255,255,255,.92); box-shadow:0 0 0 2px rgba(0,0,0,.55), 0 10px 30px rgba(0,0,0,.55); cursor:grab; z-index:25; touch-action:none; }
#map-lens.hidden{ display:none; }
#map-lens-canvas{ display:block; width:100%; height:100%; }
#map-crop-overlay{ position:absolute; inset:0; z-index:24; cursor:crosshair; touch-action:none; }
#map-crop-overlay.hidden{ display:none; }
#map-crop-rect{ position:absolute; display:none; border:2px dashed #fff; background:rgba(90,141,239,.16); box-shadow:0 0 0 9999px rgba(0,0,0,.4); pointer-events:none; }
#map-crop-btn.on{ background:var(--chaos); border-color:var(--chaos); color:var(--void); }
#map-lens::after{ content:''; position:absolute; inset:0; border-radius:50%; background:radial-gradient(circle at 32% 26%, rgba(255,255,255,.30), rgba(255,255,255,0) 46%); pointer-events:none; }
#map-lens-toggle.on{ background:var(--mind); border-color:var(--mind); color:var(--void); }
#lens-zoom-ctrl{ position:absolute; top:6px; left:50%; transform:translateX(-50%); display:flex; gap:8px; z-index:2; }
#lens-zoom-ctrl button{ width:32px; height:32px; border-radius:50%; border:1px solid rgba(255,255,255,.55); background:rgba(10,10,16,.72); color:#fff; font-size:19px; line-height:1; cursor:pointer; display:flex; align-items:center; justify-content:center; padding:0; }
.token-grid{ display:flex; flex-wrap:wrap; gap:10px; }
.token-asset{ width:64px; text-align:center; }
.token-asset .tok-img{ width:56px; height:56px; border-radius:50%; background-size:cover; background-position:center; background-color:var(--surface-3); margin:0 auto; }
.token-asset .tok-name{ font-size:10px; color:var(--ink-dim); margin-top:2px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.token-override-row{ display:flex; align-items:center; gap:10px; padding:4px 0; }
.token-override-row .tok-thumb{ width:44px; height:44px; border-radius:50%; background-size:cover; background-position:center; background-color:var(--surface-3); flex-shrink:0; }
.tb-none{ border:3px solid #fff; }
.tb-gold{ border:3px solid #e0c060; box-shadow:0 0 0 2px #7a5a10; }
.tb-iron{ border:3px solid #9aa3ad; box-shadow:0 0 0 2px #3a4048; }
.tb-wood{ border:3px solid #8a5a28; box-shadow:0 0 0 2px #4a2f14; }
.tb-silver{ border:3px solid #d8dde3; box-shadow:0 0 0 2px #7a8088; }
.tb-blood{ border:3px solid #c0392b; box-shadow:0 0 0 2px #5a1510; }
.tb-arcane{ border:3px solid #8a63d8; box-shadow:0 0 0 2px #3a1f6a; }
.init-reroll{ width:28px; height:28px; border-radius:8px; border:1px solid var(--line); background:transparent; color:var(--chaos); font-size:13px; cursor:pointer; }
.char-form-grid .fld{ display:flex; flex-direction:column; gap:3px; }
.char-form-grid .fld > span{ font-size:9.5px; text-transform:uppercase; letter-spacing:.04em; color:var(--ink-faint); padding-left:2px; }
.char-form-grid .fld > input, .char-form-grid .fld > select{ width:100%; }

/* Level-up configurator: each decision is its own numbered block, so the order
   you make the choices in is the order they appear down the card. */
.lu-step{ border:1px solid var(--line); border-radius:10px; padding:10px; margin-bottom:8px; background:var(--surface-2); }
.lu-step-head{ font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--ink-dim); margin-bottom:8px; display:flex; align-items:center; gap:7px; }
.lu-num{ display:inline-flex; align-items:center; justify-content:center; width:18px; height:18px; border-radius:50%; background:var(--calm); color:var(--void); font-size:10px; font-weight:700; flex:0 0 auto; }
.lu-gain{ display:flex; gap:7px; align-items:baseline; padding:4px 0; border-bottom:1px solid var(--line); }
.lu-gain:last-child{ border-bottom:none; }
.lu-gain b{ color:var(--ink); font-weight:600; }
.lu-tag{ font-size:9px; text-transform:uppercase; letter-spacing:.04em; padding:1px 6px; border-radius:10px; background:var(--body); color:var(--void); font-weight:700; flex:0 0 auto; }
.map-tool-group{ display:flex; flex-wrap:wrap; align-items:center; gap:6px; }
#map-color-custom{ width:34px; height:32px; padding:0; border:1px solid var(--field-border); border-radius:8px; background:none; cursor:pointer; }
.map-swatch{ width:26px; height:26px; border-radius:50%; border:1px solid var(--void); padding:0; cursor:pointer; box-shadow:0 1px 3px rgba(0,0,0,.4); }
.map-swatch:hover{ transform:scale(1.12); }
.map-brush-label{ font-size:11px; color:var(--ink-dim); display:flex; align-items:center; gap:4px; }
.map-tool-sep{ width:1px; height:24px; background:var(--line); display:inline-block; }
.tray-item{ width:40px; height:40px; border-radius:10px; border:1px solid var(--line); background:var(--surface-3) center/70% no-repeat; color:var(--ink); font-size:20px; line-height:1; cursor:pointer; display:flex; align-items:center; justify-content:center; padding:0; }
.tray-item:hover{ border-color:var(--chaos); }
.tray-item.sel{ border-color:var(--chaos); box-shadow:0 0 0 2px var(--chaos); }
.map-token{ position:absolute; width:38px; height:38px; border-radius:50%; border:3px solid #ffffff; box-shadow:0 0 0 3px rgba(0,0,0,.92), 0 3px 8px rgba(0,0,0,.55); background-size:cover; background-position:center; cursor:grab; touch-action:none; display:flex; align-items:center; justify-content:center; font-size:11px; font-weight:700; color:#ffffff; text-shadow:0 1px 2px rgba(0,0,0,.95); font-family:'JetBrains Mono',monospace; }
.map-token.pc{ background-color:var(--mind); }
.map-token.npc{ background-color:var(--body); }
#screen-battle.present header,
#screen-battle.present .toggle-row,
#screen-battle.present #map-dm-tools,
#screen-battle.present #map-token-tray-wrap,
#screen-battle.present #map-save-draw,
#screen-battle.present footer{ display:none !important; }
#screen-battle.present #map-draw-card.card{ border:none; background:transparent; padding:0; box-shadow:none; }
#screen-battle.present #map-canvas{ margin-top:0; }
#map-live-toggle.on{ background:#dc2626; border-color:#dc2626; color:#fff; }
.map-token.obj{ border:none; box-shadow:0 2px 5px rgba(0,0,0,.6); background-color:transparent; border-radius:6px; background-size:contain; background-repeat:no-repeat; background-position:center; color:transparent; }
#map-fullscreen-btn{ position:fixed; top:14px; right:14px; z-index:60; width:46px; height:46px; border-radius:12px; border:1px solid var(--field-border); background:rgba(0,0,0,.55); color:#fff; font-size:22px; display:none; align-items:center; justify-content:center; cursor:pointer; }
#screen-battle.present #map-fullscreen-btn{ display:flex; }
#screen-battle.present #map-draw-card.card{ padding:0; }
#screen-battle.present #map-stage{ display:flex; align-items:center; justify-content:center; min-height:100vh; }
#screen-battle.present #map-viewport{ min-height:100vh; border-radius:0; }
/* In presentation mode the camera bar floats over the map instead of pushing it. */
#screen-battle.present #map-cam-bar{ position:fixed; bottom:14px; left:50%; transform:translateX(-50%); z-index:60; background:rgba(0,0,0,.6); border-radius:12px; padding:6px 10px; margin:0; width:auto; backdrop-filter:blur(4px); }
#screen-battle.present #map-cam-bar .rsub{ display:none; }
#screen-battle.present #map-fog-bar,
#screen-battle.present #map-layers-panel{ display:none; }
#map-exit-btn{ position:fixed; top:14px; left:14px; z-index:60; width:46px; height:46px; border-radius:12px; border:1px solid var(--field-border); background:rgba(0,0,0,.55); color:#fff; font-size:20px; display:none; align-items:center; justify-content:center; cursor:pointer; }
#screen-battle.present #map-exit-btn{ display:flex; }
#follow-waiting{ position:fixed; inset:0; z-index:55; background:var(--void); display:flex; align-items:center; justify-content:center; text-align:center; padding:24px; }
#follow-waiting .fw-title{ font-family:'Cinzel',serif; font-size:30px; color:var(--ink); margin-bottom:10px; letter-spacing:1px; }
#follow-waiting .fw-sub{ color:var(--ink-dim); font-size:15px; }
#follow-waiting.has-bg{ background-size:cover; background-position:center; }
#follow-waiting.has-bg::before{ content:''; position:absolute; inset:0; background:rgba(6,6,10,0.5); }
#follow-waiting .fw-inner{ position:relative; z-index:1; }
#follow-waiting.has-bg .fw-title{ text-shadow:0 2px 14px rgba(0,0,0,0.95); }
#follow-waiting.has-bg .fw-sub{ color:#e8e8ee; text-shadow:0 2px 14px rgba(0,0,0,0.95); }
.tok-label{ position:absolute; top:calc(100% + 3px); left:50%; transform:translateX(-50%); font-size:10px; font-weight:700; color:#fff; background:rgba(0,0,0,.72); padding:1px 6px; border-radius:6px; white-space:nowrap; pointer-events:none; text-shadow:none; font-family:'Inter',sans-serif; letter-spacing:.2px; max-width:120px; overflow:hidden; text-overflow:ellipsis; }
#map-present-btn.on{ background:var(--order); border-color:var(--order); color:var(--void); }
.token-tray{ display:flex; flex-wrap:wrap; gap:6px; margin-top:10px; }
.token-chip{ display:flex; align-items:center; gap:6px; padding:4px 10px 4px 4px; border-radius:20px; border:1px solid var(--line); background:var(--surface-3); color:var(--ink); font-size:12px; cursor:pointer; }
.token-chip .swatch{ width:22px; height:22px; border-radius:50%; background-size:cover; background-position:center; background-color:var(--surface-2); }
.map-vis-row{ display:flex; align-items:center; gap:6px; }
.pill-toggle{ padding:5px 10px; border-radius:20px; border:1px solid var(--line); background:var(--surface-2); color:var(--ink-dim); font-size:11px; font-weight:600; cursor:pointer; }
.pill-toggle.on{ background:var(--calm); color:var(--void); border-color:var(--calm); }

/* -- 15. Library search --------------------------------------------------- */
.lib-hit mark{ background:var(--order); color:var(--void); padding:0 2px; border-radius:3px; }
.lib-snippet{ font-size:11.5px; color:var(--ink-dim); line-height:1.5; margin-top:4px; max-height:120px; overflow:auto; }

/* -- 16. Battle screen ---------------------------------------------------- */
.battle-layout{ display:flex; flex-direction:column; gap:16px; margin-top:14px; }
.battle-sidebar{ display:flex; flex-direction:column; gap:16px; }
.battle-combatant-row{ display:flex; align-items:center; gap:10px; padding:9px 12px; background:var(--surface-2); border-radius:10px; margin-bottom:6px; cursor:pointer; transition:background .15s ease; }
.battle-combatant-row:hover{ background:var(--surface-3); }
.battle-combatant-row input[type="checkbox"]{ width:18px; height:18px; accent-color:var(--fury); flex-shrink:0; }
.grid-size-input{ width:56px; background:var(--surface-2); border:1px solid var(--line); border-radius:8px; color:var(--ink); padding:6px; font-family:'JetBrains Mono',monospace; font-size:12px; text-align:center; }
.grid-size-label{ display:flex; align-items:center; gap:6px; font-size:11px; color:var(--ink-dim); white-space:nowrap; }

/* -- 17. Dice roller + theme toggle (fixed, global) ----------------------- */
/* These sit above every screen regardless of which page/screen is active. */
#dice-roller-btn{
  position:fixed; bottom:20px; right:20px; z-index:9999;
  width:52px; height:52px; border-radius:50%; background:var(--chaos); color:var(--void);
  display:flex; align-items:center; justify-content:center; font-size:24px; border:none;
  box-shadow:0 4px 14px rgba(0,0,0,.45);
}
#theme-toggle-btn{
  position:fixed; bottom:20px; right:82px; z-index:9999;
  width:52px; height:52px; border-radius:50%; background:var(--surface-3); color:var(--ink);
  display:flex; align-items:center; justify-content:center; font-size:22px; border:1px solid var(--field-border);
  box-shadow:0 4px 14px rgba(0,0,0,.35);
}
#dice-roller-panel{
  position:fixed; bottom:82px; right:20px; z-index:9999; width:260px; max-width:calc(100vw - 40px);
  background:var(--surface); border:1px solid var(--field-border); border-radius:16px; padding:14px;
  box-shadow:0 10px 28px rgba(0,0,0,.5);
}
.dice-type-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:6px; margin:10px 0; }
.dice-type-btn{ padding:10px 4px; border-radius:8px; border:1px solid var(--field-border); background:var(--surface-2); color:var(--ink); font-weight:700; font-size:12px; }
.dice-pool-row{ display:flex; justify-content:space-between; align-items:center; padding:4px 0; font-size:12px; }
#dice-result{ margin-top:10px; }

.slot-level-row{ display:flex; align-items:center; gap:8px; margin-bottom:6px; }
.slot-level-label{ font-size:11px; color:var(--ink-dim); min-width:58px; }
.slot-pips{ display:flex; gap:5px; flex-wrap:wrap; }
.slot-pip{ width:22px; height:22px; border-radius:50%; border:1px solid var(--field-border); background:var(--surface-2); cursor:pointer; padding:0; }
.slot-pip.used{ background:var(--fury); border-color:var(--fury); }

/* -- 18. Spell browser / entry modals ------------------------------------- */
#spell-browser-modal{ position:fixed; inset:0; z-index:10000; display:flex; align-items:center; justify-content:center; padding:20px; }
#entry-desc-modal{ position:fixed; inset:0; z-index:10001; display:flex; align-items:center; justify-content:center; padding:20px; }
#entry-desc-modal.hidden{ display:none; }
#entry-desc-backdrop{ position:absolute; inset:0; background:rgba(0,0,0,.6); }
#entry-desc-box{ position:relative; background:var(--surface); border:1px solid var(--field-border); border-radius:16px; padding:18px 20px; max-width:540px; width:100%; max-height:80vh; overflow-y:auto; }
.entry-link{ cursor:pointer; text-decoration:underline dotted; text-underline-offset:2px; }
.entry-link:hover{ color:var(--mind); }
#spell-browser-backdrop{ position:absolute; inset:0; background:rgba(0,0,0,.65); }
#spell-browser-panel{ position:relative; background:var(--surface); border:1px solid var(--field-border); border-radius:16px; padding:16px; width:min(560px, 100%); max-height:82vh; overflow-y:auto; box-shadow:0 12px 40px rgba(0,0,0,.6); }
.spell-browse-item{ background:var(--surface-2); border-radius:10px; padding:10px 12px; margin-bottom:8px; }
.spell-browse-header{ display:flex; justify-content:space-between; align-items:center; gap:8px; cursor:pointer; }
.spell-browse-desc{ font-size:12px; color:var(--ink-dim); margin-top:0; line-height:1.5; display:none; }
.spell-browse-desc.open{ display:block; margin-top:8px; }
.spell-level-group-label{ font-size:10px; text-transform:uppercase; letter-spacing:.05em; color:var(--ink-faint); margin:10px 0 6px; }

/* -- 19. General interaction polish + responsive breakpoints -------------- */
/* Consistent, responsive feedback across every button style. */
button{ cursor:pointer; transition:background-color .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease, transform .08s ease; }
button:active{ transform:scale(0.97); }
button:disabled{ opacity:.5; cursor:not-allowed; transform:none; }
.reset-btn:hover{ border-color:var(--chaos); }
.icon-btn:hover{ border-color:var(--fury); color:var(--fury); }
.small-btn:hover{ background:var(--surface-2); border-color:var(--chaos); }
.pill-toggle:hover{ border-color:var(--calm); }
.sub-tab:hover:not(.active){ background:var(--surface-2); color:var(--ink); }
.game-tab:hover:not(.active){ background:var(--surface-2); }
.game-select-card:active{ transform:scale(0.98); }
.result-item:hover{ background:var(--surface-3); }
input, textarea, select{ transition:border-color .15s ease; }
input:focus, textarea:focus, select:focus{ outline:none; border-color:var(--chaos); }
/* Every fillable field needs a boundary you can actually see, filled or empty */
input[type="text"], input[type="number"], input[type="file"], textarea, select,
.wide-input, .char-form-grid input, .grid-size-input, .init-roll-input, .init-hp-input{
  border-color: var(--field-border);
}
.stat-grid div{ border:1px solid var(--field-border); }
/* Fillable number boxes, no native up/down spinner clutter */
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button{ -webkit-appearance:none; margin:0; }
input[type="number"]{ -moz-appearance:textfield; }

@media (max-width: 700px){
  body{ overflow-x:hidden; }
  .wrap{ padding:0 12px; }
  .game-tabs{ flex-wrap:nowrap; overflow-x:auto; overflow-y:hidden; -webkit-overflow-scrolling:touch; scroll-snap-type:x proximity; margin-left:-12px; margin-right:-12px; padding-left:12px; padding-right:12px; padding-bottom:4px; }
  .game-tabs::-webkit-scrollbar{ display:none; }
  .game-tab, .sub-tab{ flex:0 0 auto; scroll-snap-align:start; white-space:nowrap; }
  .sub-tab{ min-width:100px; padding:11px 16px; }
  .game-tab{ min-width:112px; }
  .card{ border-radius:14px; }
  input, textarea, select{ font-size:16px; }
  .reset-btn{ min-height:46px; }
}
@media (min-width: 900px){
  .wrap{ max-width:1400px; padding:0 40px; }
  .game-select-grid{ display:grid; grid-template-columns:repeat(3,1fr); }
  #dnd-panel-init, #dnd-panel-chars, #dnd-panel-notes{
    display:grid; grid-template-columns:1fr 1fr; gap:20px; align-items:start;
  }
  #dnd-panel-maps{ grid-template-columns:1fr 2fr; }
  #dnd-panel-creatures .card, #dnd-panel-init .card, #dnd-panel-maps .card,
  #dnd-panel-chars .card, #dnd-panel-lib .card, #dnd-panel-notes .card{ margin-top:0; }
  .players-grid{ grid-template-columns:repeat(4,1fr); }
  .duo{ max-width:520px; margin:0 auto; }
  .battle-layout{ display:grid; grid-template-columns:2fr 1fr; align-items:start; }
}
/* Large monitors: stop wasting the extra width, give maps and the battle screen real room */
@media (min-width: 1600px){
  .wrap{ max-width:1900px; padding:0 56px; }
  #dnd-panel-maps{ grid-template-columns:1fr 3fr; }
  .battle-layout{ grid-template-columns:3fr 1fr; }
  #dnd-panel-init, #dnd-panel-chars, #dnd-panel-notes{
    grid-template-columns:1fr 1.4fr;
  }
}
