/* ===================================================================
   components.css — Embers tabletop UI
   =================================================================== */

#root, .app { height: 100%; }
.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ---------------- Top bar ---------------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 16px; min-height: 60px;
  border-bottom: 2px solid var(--leather-dark);
  box-shadow: 0 4px 18px rgba(0,0,0,.45); z-index: 30;
  color: var(--parchment-light);
}
.tb-left { display: flex; align-items: center; gap: 12px; position: relative; }
.tb-title { display: flex; flex-direction: column; position: relative; }
.campaign { font-size: 17px; color: var(--gold-bright); line-height: 1.1; letter-spacing: .03em; }
.map-switch { background: none; border: 0; color: var(--parchment-dark); font-family: var(--font-body);
  font-size: 13px; padding: 1px 0; text-align: left; display: flex; gap: 5px; align-items: center; }
.map-switch:hover { color: var(--gold-bright); }
.caret { font-size: 9px; }
.map-menu { position: absolute; top: 46px; left: 0; width: 280px; padding: 6px; border-radius: 9px;
  z-index: 60; box-shadow: var(--shadow-deep); }
.map-item { display: flex; justify-content: space-between; align-items: center; width: 100%;
  background: none; border: 0; border-radius: 6px; padding: 9px 10px; text-align: left; color: var(--ink); }
.map-item:hover { background: rgba(0,0,0,.06); }
.map-item.on { background: rgba(193,147,63,.18); }
.mi-name { font-family: var(--font-display); font-size: 14px; }
.mi-sub { font-size: 12px; color: var(--ink-faint); }
.mi-here { font-size: 10px; color: var(--gold-deep); font-family: var(--font-display); letter-spacing: .1em; text-transform: uppercase; }
.mi-tag { font-size: 9px; color: var(--arcane); font-family: var(--font-display); letter-spacing: .1em; text-transform: uppercase; background: color-mix(in srgb, var(--arcane) 16%, transparent); padding: 1px 5px; border-radius: 4px; }
.map-add { width: 100%; margin-top: 4px; background: none; border: 1px dashed var(--parchment-edge);
  border-radius: 6px; padding: 8px; color: var(--ink-soft); font-family: var(--font-body); }
.map-add:hover { background: rgba(0,0,0,.05); }

.tb-presence { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.pres { position: relative; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--leather-dark); border: 2px solid var(--ring); box-shadow: 0 0 0 1px rgba(0,0,0,.5); }
.pres-sprite { font-size: 17px; line-height: 1; }
.pres-ping { position: absolute; bottom: -1px; right: -1px; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--leather); }
.kick { position: absolute; top: -7px; right: -7px; width: 17px; height: 17px; border-radius: 50%;
  background: var(--wine); color: #fff; border: 0; font-size: 10px; line-height: 1; opacity: 0; transition: opacity .15s; }
.pres:hover .kick { opacity: 1; }
.pres-lock { font-size: 14px; opacity: .7; margin-left: 2px; }

.tb-right { display: flex; align-items: center; gap: 12px; }
.view-toggle { display: flex; background: var(--leather-dark); border-radius: 8px; padding: 3px; border: 1px solid #000; }
.view-toggle button { background: none; border: 0; color: var(--parchment-dark); font-family: var(--font-display);
  font-size: 12px; letter-spacing: .08em; text-transform: uppercase; padding: 6px 16px; border-radius: 6px; }
.view-toggle button.on { background: linear-gradient(180deg,var(--gold-bright),var(--gold-deep)); color: #2a1c08; box-shadow: 0 1px 4px rgba(0,0,0,.4); }

/* ---------------- Stage layout ---------------- */
.stage { flex: 1; display: grid; grid-template-columns: auto 1fr auto; min-height: 0; }
.layout-left .rail-left { order: 3; } .layout-left .rail-right { order: 1; } .layout-left .map-area { order: 2; }
.rail-left { position: relative; width: 252px; padding: 12px; overflow-y: auto;
  transition: width var(--duration-normal, 300ms) cubic-bezier(.16,1,.3,1); }
.layout-left .rail-left { width: 340px; }
.map-area { position: relative; min-width: 0; min-height: 0; }
.rail-right { position: relative; width: 340px; display: flex; flex-direction: column;
  border-left: 2px solid var(--leather-dark); min-height: 0;
  transition: width var(--duration-normal, 300ms) cubic-bezier(.16,1,.3,1); }
.layout-left .rail-right { width: 252px; border-left: 0; border-right: 2px solid var(--leather-dark); }

/* Collapsed rails close fully — the toggle lives on the map edge, not in a spine */
.rail-left.collapsed, .rail-right.collapsed { width: 0; padding: 0; overflow: hidden; border: 0; }
/* Toggles sit just inside the map area, on the edge facing each panel, so they never cover panel text */
.rail-toggle { position: absolute; top: 10px; z-index: 6; width: 26px; height: 38px;
  display: grid; place-items: center; cursor: pointer; font-size: 15px; line-height: 1;
  color: var(--gold-bright); background: var(--leather-dark);
  border: 1px solid rgba(0,0,0,.45); border-radius: 7px;
  box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.rail-toggle:hover { background: var(--leather); }
.rail-toggle:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.toggle-l { left: 6px; }
.toggle-r { right: 6px; }
.layout-left .toggle-l { left: auto; right: 6px; }
.layout-left .toggle-r { right: auto; left: 6px; }
@media (prefers-reduced-motion: reduce) { .rail-left, .rail-right { transition: none; } }

/* ---------------- Encounter tray / player card ---------------- */
.tray { border-radius: 10px; padding: 12px; color: var(--parchment-light); }
.tray-hd { margin-bottom: 4px; }
.tray-note { font-size: 12px; color: var(--parchment-dark); font-style: italic; opacity: .8; margin-bottom: 10px; }
.tray-list { display: flex; flex-direction: column; gap: 7px; }
.tray-row { display: flex; align-items: center; gap: 9px; background: rgba(0,0,0,.22); border-radius: 8px; padding: 7px 8px; border: 1px solid rgba(0,0,0,.4); }
.tray-row.hidden { opacity: .72; }
.tray-row.shown { box-shadow: inset 0 0 0 1px var(--gold-deep); }
.tray-sprite, .pc-sprite, .init-sprite, .cr-sprite, .sheet-portrait, .pres-sprite, .hp-sprite {
  display: grid; place-items: center; border-radius: 50%; background: var(--leather-dark);
  box-shadow: 0 0 0 2px var(--ring), inset 0 1px 3px rgba(0,0,0,.5); }
.tray-sprite { width: 32px; height: 32px; font-size: 17px; }
.tray-body { flex: 1; min-width: 0; }
.tray-name { font-size: 13px; font-family: var(--font-display); color: var(--parchment-light); }
.tray-meta { display: flex; gap: 8px; font-size: 11px; color: var(--parchment-dark); }
.reveal-pill { background: rgba(193,147,63,.18); color: var(--gold-bright); padding: 0 6px; border-radius: 4px; text-transform: capitalize; }
.eye-btn { width: 30px; height: 30px; border-radius: 7px; border: 1px solid rgba(0,0,0,.4); background: rgba(0,0,0,.3); font-size: 15px; }
.eye-btn.on { background: rgba(193,147,63,.25); box-shadow: 0 0 10px rgba(232,195,114,.4); }

.pc-card { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.pc-sprite { width: 60px; height: 60px; font-size: 30px; margin-top: 4px; }
.pc-name { font-size: 17px; color: var(--gold-bright); }
.pc-sub { font-size: 12px; color: var(--parchment-dark); margin-bottom: 6px; }
.pc-hp { width: 100%; }
.pc-hp .hp-bar { height: 9px; }
.pc-hp span { font-size: 11px; color: var(--parchment-dark); }
.pc-stats { display: flex; gap: 10px; font-size: 12px; color: var(--parchment-light); margin: 8px 0; font-family: var(--font-display); }
/* Ghost button sits on the dark leather player card — force legible light text */
.pc-card .btn.ghost { color: var(--parchment-light); border-color: var(--leather-stitch);
  background: rgba(0,0,0,.22); }
.pc-card .btn.ghost:hover { background: rgba(193,147,63,.2); border-color: var(--gold); color: #fff; }
.hp-bar { background: rgba(0,0,0,.5); border-radius: 5px; overflow: hidden; border: 1px solid rgba(0,0,0,.6); }
.hp-bar i { display: block; height: 100%; border-radius: 5px; transition: width .3s; }

/* ---------------- Map ---------------- */
.map-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; }
.map-scroll { flex: 1; overflow: auto; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(0,0,0,.28), transparent 60%),
    repeating-linear-gradient(135deg, rgba(0,0,0,.15) 0 3px, transparent 3px 8px), var(--table-bg); }
.board { position: relative; transform-origin: center center; border-radius: 6px;
  box-shadow: 0 0 0 10px var(--leather-dark), 0 0 0 13px var(--leather-light), 0 26px 60px rgba(0,0,0,.7);
  background: #d9c49b; }
.board-fit { position: relative; flex: none; }
.dungeon { position: absolute; inset: 0; display: block; }
.map-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; user-select: none; -webkit-user-drag: none; }
.grid-layer { position: absolute; inset: 0; pointer-events: none; }
.grid-layer line { stroke: rgba(42,32,23,.22); stroke-width: 1; }
.fog-canvas, .draw-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.fog-canvas { mix-blend-mode: multiply; }

/* toolbar */
.map-toolbar { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 20;
  display: flex; gap: 3px; padding: 6px; border-radius: 10px; }
.mtool { width: 36px; height: 36px; border-radius: 7px; border: 1px solid rgba(0,0,0,.4);
  background: rgba(0,0,0,.25); color: var(--parchment-light); font-size: 16px; display: grid; place-items: center; }
.mtool:hover { background: rgba(193,147,63,.2); }
.mtool.on { background: linear-gradient(180deg,var(--gold-bright),var(--gold-deep)); color: #2a1c08; box-shadow: 0 0 10px rgba(232,195,114,.4); }
.mtool.dm.on { background: linear-gradient(180deg,var(--wine-br),var(--wine)); color: #f6e9d0; }
.mtool-sep { width: 1px; background: rgba(255,255,255,.15); margin: 4px 2px; }
.ink-swatches { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); z-index: 20;
  display: flex; gap: 5px; padding: 6px; border-radius: 9px; }
.ink-sw { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(0,0,0,.5); }
.ink-sw.on { box-shadow: 0 0 0 2px var(--gold-bright); }

/* notes & measure */
.map-note { position: absolute; transform: translate(-50%, -50%); z-index: 15;
  background: none; border: 0; padding: 0; cursor: pointer; line-height: 1; }
.map-note-pin { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50% 50% 50% 2px;
  color: #fff; font-size: 13px; transform: rotate(-2deg);
  box-shadow: 0 2px 4px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.4), 0 0 0 2px rgba(255,255,255,.65);
  transition: transform .12s ease; }
.map-note:hover .map-note-pin, .map-note:focus .map-note-pin { transform: rotate(-2deg) scale(1.15); }
.map-note-bubble { position: absolute; left: 18px; bottom: 18px; z-index: 30; width: max-content; max-width: 190px;
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  font-family: var(--font-hand); font-size: 17px; font-weight: 700; line-height: 1.12; color: var(--ink);
  background: var(--parchment-light); border: 1px solid var(--nc); border-left: 4px solid var(--nc);
  border-radius: 4px 9px 9px 9px; padding: 7px 10px; box-shadow: 0 6px 18px rgba(0,0,0,.45);
  opacity: 0; transform: translateY(3px) scale(.96); transform-origin: bottom left;
  transition: opacity .12s ease, transform .12s ease; pointer-events: none; }
.map-note.flip .map-note-bubble { left: auto; right: 18px; border-radius: 9px 4px 9px 9px; transform-origin: bottom right; }
.map-note:hover .map-note-bubble, .map-note:focus .map-note-bubble { opacity: 1; transform: translateY(0) scale(1); }
.mnb-by { font-family: var(--font-display); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--nc); }
.measure-layer { position: absolute; inset: 0; pointer-events: none; z-index: 16; }
.measure-text { fill: #fff; font-family: var(--font-display); font-size: 18px; font-weight: 700; paint-order: stroke; stroke: #2a1a10; stroke-width: 4px; }

.map-caption { display: flex; align-items: center; gap: 12px; padding: 9px 18px;
  background: var(--leather); border-top: 1px solid rgba(0,0,0,.5); color: var(--parchment-dark); }
.map-caption .display { color: var(--gold-bright); font-size: 15px; }
.map-caption em { font-size: 12px; }
.fog-tag { margin-left: auto; font-family: var(--font-display); font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--gold-bright); background: rgba(193,147,63,.15); padding: 3px 9px; border-radius: 5px; }

/* ---------------- Tokens ---------------- */
.token { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: left .14s ease, top .14s ease; }
.token.drag { transition: none; cursor: grabbing; filter: drop-shadow(0 8px 10px rgba(0,0,0,.6)); }
.token.veiled { opacity: .8; }
.token.veiled .tk-disc, .token.veiled .tk-pixel, .token.veiled .tk-mini { filter: grayscale(.4) brightness(.85); border-style: dashed !important; }
.token.dead { filter: grayscale(1) brightness(.6); }
.tk-disc { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 28%, #f3ead2, #cdb589 70%, #a98f63);
  border: 3px solid var(--ring); box-shadow: 0 3px 6px rgba(0,0,0,.45), inset 0 0 6px rgba(0,0,0,.25); cursor: grab; }
.tk-pixel { width: 100%; height: 100%; display: grid; place-items: center; image-rendering: pixelated;
  background: var(--ring); border: 3px solid #1a120c; box-shadow: 4px 4px 0 rgba(0,0,0,.4); cursor: grab;
  clip-path: polygon(0 12%,12% 12%,12% 0,88% 0,88% 12%,100% 12%,100% 88%,88% 88%,88% 100%,12% 100%,12% 88%,0 88%); }
.tk-mini { width: 100%; height: 100%; position: relative; display: grid; place-items: end center; cursor: grab; }
.tk-mini-base { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 78%; height: 26%;
  border-radius: 50%; background: radial-gradient(circle, var(--ring), rgba(0,0,0,.4)); box-shadow: 0 2px 4px rgba(0,0,0,.5); }
.tk-mini .tk-emoji { position: relative; z-index: 2; filter: drop-shadow(0 3px 2px rgba(0,0,0,.5)); transform: translateY(2px); }
.tk-emoji { line-height: 1; }
.veil-badge { position: absolute; top: -6px; left: -6px; font-size: 14px; background: var(--wine); border-radius: 50%;
  width: 20px; height: 20px; display: grid; place-items: center; color: #f6e9d0; box-shadow: 0 1px 3px rgba(0,0,0,.5); }
.tk-hp { position: absolute; bottom: -7px; left: 8%; width: 84%; height: 5px; background: rgba(0,0,0,.6);
  border-radius: 3px; overflow: hidden; border: 1px solid rgba(0,0,0,.7); }
.tk-hp i { display: block; height: 100%; }
.tk-name { position: absolute; bottom: -25px; font-family: var(--font-display); color: #f3ead2;
  text-shadow: 0 1px 2px #000, 0 0 3px #000; white-space: nowrap; font-weight: 600; }

/* ---------------- Right rail tabs ---------------- */
.rail-tabs { display: flex; background: var(--leather-dark); border-top: 1px solid #000; border-bottom: 1px solid #000; }
.rt { flex: 1; background: none; border: 0; color: var(--parchment-dark); font-family: var(--font-display);
  font-size: 11px; letter-spacing: .05em; padding: 9px 2px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.rt-icon { font-size: 16px; }
.rt:hover { color: var(--gold-bright); }
.rt.on { color: var(--ink); background: var(--parchment); box-shadow: inset 0 3px 0 var(--gold); }
.rt.on .rt-icon { color: var(--gold-deep); }
[data-theme="ember"] .rt.on { color: var(--gold-bright); }
.rail-content { flex: 1; overflow-y: auto; min-height: 0; }
.panel-pad { padding: 14px; }

/* ---------------- Dice ---------------- */
.dice-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.die-btn { position: relative; aspect-ratio: 1; border-radius: 9px; border: 2px solid var(--dc);
  background: linear-gradient(160deg, color-mix(in srgb, var(--dc) 25%, #f3ead2), #e9dcbf);
  display: grid; place-items: center; color: var(--ink); box-shadow: 0 2px 4px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.5); }
.die-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0,0,0,.3); }
.die-face { font-family: var(--font-display); font-size: 16px; font-weight: 700; }
.die-count { position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px; padding: 0 4px; border-radius: 10px;
  background: var(--dc); color: #fff; font-style: normal; font-size: 11px; font-weight: 700; display: grid; place-items: center; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.dice-builder { margin-top: 12px; }
.mod-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.stepper { display: flex; align-items: center; gap: 8px; background: var(--parchment-dark); border-radius: 7px; padding: 3px; }
.stepper button { width: 26px; height: 26px; border: 0; border-radius: 5px; background: var(--parchment-light); font-size: 15px; }
.stepper b { min-width: 28px; text-align: center; font-family: var(--font-display); }
.builder-actions { display: flex; gap: 8px; }
.roll-result { margin-top: 14px; display: flex; align-items: center; gap: 14px; padding: 12px;
  background: linear-gradient(180deg, #2a1a10, #1a120c); border-radius: 10px; color: var(--parchment-light); box-shadow: inset 0 0 0 1px var(--gold-deep); }
.rr-total { font-size: 42px; color: var(--gold-bright); line-height: 1; min-width: 56px; text-align: center; text-shadow: 0 0 16px rgba(232,195,114,.5); }
.roll-result.rolling .rr-total { animation: tumble .5s ease; }
@keyframes tumble { 0%{transform:rotate(-25deg) scale(.6);opacity:.3} 60%{transform:rotate(15deg) scale(1.15)} 100%{transform:none;opacity:1} }
.rr-label { font-size: 13px; color: var(--parchment-dark); }
.rr-dice { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.rr-die { min-width: 24px; height: 24px; padding: 0 5px; border-radius: 5px; background: var(--parchment); color: var(--ink);
  display: grid; place-items: center; font-family: var(--font-display); font-size: 13px; font-weight: 700; }
.rr-die.crit { background: var(--gold-bright); box-shadow: 0 0 10px rgba(232,195,114,.7); }
.rr-die.fumble { background: var(--wine); color: #fff; }
.saved-rolls { margin-bottom: 4px; }
.saved-roll { display: flex; align-items: center; gap: 8px; width: 100%; background: var(--parchment-light);
  border: 1px solid var(--parchment-edge); border-radius: 7px; padding: 8px 10px; margin-bottom: 6px; color: var(--ink); }
.saved-roll:hover { background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.sr-dot { width: 9px; height: 9px; border-radius: 50%; }
.sr-label { font-family: var(--font-display); font-size: 13px; flex: 1; text-align: left; }
.sr-formula { font-size: 12px; color: var(--ink-faint); }

/* ---------------- Party / turn order ---------------- */
.party-panel { padding: 12px; border-bottom: 2px solid var(--leather-dark); background: linear-gradient(180deg, rgba(0,0,0,.15), transparent); }
.party-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; color: var(--parchment-light); }
.party-head .eyebrow { display: block; }
.round-num { font-size: 26px; color: var(--gold-bright); line-height: .9; }
.turn-controls { display: flex; align-items: center; gap: 6px; }
.init-roll-btn { width: 100%; margin-bottom: 9px; padding: 9px; border-radius: 8px; font-family: var(--font-display);
  font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: #f6e9d0;
  background: linear-gradient(180deg, var(--wine-br), var(--wine) 60%, #5c1822); border: 1px solid #4a131c;
  box-shadow: 0 2px 0 rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.18); }
.init-roll-btn:hover { filter: brightness(1.08); box-shadow: 0 0 14px rgba(162,54,68,.5), 0 2px 0 rgba(0,0,0,.35); }
.init-roll-btn:active { transform: translateY(1px); }
.init-mod { font-style: normal; opacity: .7; font-size: 11px; margin-left: 4px; }
.mini-btn { width: 30px; height: 30px; border-radius: 7px; border: 1px solid rgba(0,0,0,.4); background: rgba(0,0,0,.25); color: var(--parchment-light); font-size: 15px; }
.mini-btn:hover { background: rgba(193,147,63,.2); }
.initiative-list { display: flex; flex-direction: column; gap: 5px; max-height: 230px; overflow-y: auto; }
.init-row { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 8px; background: rgba(0,0,0,.18); border: 1px solid transparent; }
.init-row.active { background: rgba(193,147,63,.22); border-color: var(--gold); box-shadow: 0 0 12px rgba(193,147,63,.3); }
.init-row.mon { background: rgba(125,35,48,.18); }
.init-badge { width: 28px; height: 28px; flex: none; border-radius: 7px; border: 2px solid; background: var(--leather-dark);
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; color: var(--parchment-light); font-size: 13px; padding: 0; }
.init-badge.rollable { cursor: pointer; }
.init-badge.rollable:hover { background: var(--wine); box-shadow: 0 0 10px rgba(162,54,68,.55); }
.init-badge.pop { animation: initpop .55s ease; }
@keyframes initpop { 0%{ transform: scale(.4) rotate(-40deg); background: var(--gold); color:#2a1c08; }
  55%{ transform: scale(1.25) rotate(8deg); background: var(--gold-bright); color:#2a1c08; box-shadow:0 0 16px rgba(232,195,114,.8); }
  100%{ transform: none; } }
.init-sprite { width: 30px; height: 30px; flex: none; font-size: 16px; }
.init-body { flex: 1; min-width: 0; }
.init-name { font-family: var(--font-display); font-size: 13px; color: var(--parchment-light); display: flex; gap: 6px; align-items: center; }
.mon-tag { font-size: 9px; text-transform: uppercase; letter-spacing: .08em; color: var(--wine-br); background: rgba(125,35,48,.3); padding: 1px 5px; border-radius: 4px; }
.init-hp { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.init-hp .hp-bar { flex: 1; height: 7px; }
.hp-edit { display: flex; align-items: center; gap: 4px; }
.hp-edit button { width: 18px; height: 18px; border: 0; border-radius: 4px; background: rgba(0,0,0,.4); color: var(--parchment-light); font-size: 12px; line-height: 1; }
.hp-edit span { font-size: 11px; color: var(--parchment-dark); min-width: 42px; text-align: center; font-variant-numeric: tabular-nums; }
.hp-text { font-size: 11px; color: var(--parchment-dark); }
.ac-shield { flex: none; width: 26px; height: 28px; display: grid; place-items: center; font-family: var(--font-display);
  font-size: 12px; font-weight: 700; color: var(--parchment-light); background: var(--leather-light);
  clip-path: polygon(0 0,100% 0,100% 70%,50% 100%,0 70%); }
.hp-edit.big button { width: 26px; height: 26px; font-size: 15px; }
.hp-edit.big b { font-size: 18px; font-family: var(--font-display); }
.hp-edit.big b i { font-style: normal; font-size: 13px; color: var(--ink-faint); }

/* ---------------- Chat ---------------- */
.chat-panel { display: flex; flex-direction: column; height: 100%; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 9px; }
.chat-msg { font-size: 14px; line-height: 1.35; }
.chat-msg .cm-who { font-family: var(--font-display); font-size: 12px; margin-right: 6px; }
.chat-msg.narrate { font-style: italic; color: var(--ink-soft); background: rgba(193,147,63,.12);
  border-left: 3px solid var(--gold); padding: 7px 10px; border-radius: 0 6px 6px 0; }
.narrate-mark { color: var(--gold-deep); margin-right: 6px; }
.chat-msg.whisper { background: rgba(91,75,138,.14); border-radius: 6px; padding: 6px 9px; }
.chat-msg.whisper .cm-who { color: var(--arcane) !important; }
.chat-roll { display: flex; gap: 9px; align-items: center; background: linear-gradient(180deg,#2a1a10,#1a120c);
  color: var(--parchment-light); padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.chat-roll .cr-sprite { width: 28px; height: 28px; font-size: 15px; flex: none; }
.cr-formula { color: var(--parchment-dark); font-size: 12px; }
.cr-total { float: right; margin-left: 8px; font-family: var(--font-display); font-size: 18px; color: var(--gold-bright); }
.chat-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--parchment-edge); background: var(--parchment-light); }
.chat-input input, .lobby-input, .suggest-input input, .chat-input input { flex: 1; }
input { font-family: var(--font-body); font-size: 14px; padding: 9px 11px; border-radius: 7px;
  border: 1px solid var(--parchment-edge); background: var(--parchment-light); color: var(--ink); }
input:focus { outline: 2px solid var(--gold); outline-offset: -1px; }

/* ---------------- Poll ---------------- */
.poll-card { border-radius: 11px; padding: 14px; margin-bottom: 14px; }
.poll-card.closed { opacity: .92; }
.poll-top { display: flex; gap: 10px; align-items: flex-start; }
.poll-top > div { flex: 1; }
.poll-title { font-size: 16px; line-height: 1.15; color: var(--ink); }
.poll-by { font-size: 12px; color: var(--ink-faint); }
.poll-live { font-size: 10px; color: var(--forest); font-family: var(--font-display); letter-spacing: .1em; }
.poll-desc { font-size: 13px; color: var(--ink-soft); margin: 9px 0 11px; line-height: 1.4; }
.poll-options { display: flex; flex-direction: column; gap: 7px; }
.poll-opt { position: relative; overflow: hidden; display: flex; justify-content: space-between; align-items: center;
  border: 1px solid var(--parchment-edge); background: var(--parchment-light); border-radius: 8px; padding: 9px 11px; color: var(--ink); text-align: left; }
.poll-opt:not(:disabled):hover { border-color: var(--gold); }
.poll-opt.mine { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.poll-opt.win { border-color: var(--forest); box-shadow: inset 0 0 0 1px var(--forest); }
.po-fill { position: absolute; inset: 0 auto 0 0; background: rgba(193,147,63,.22); transition: width .4s; }
.poll-opt.win .po-fill { background: rgba(63,93,66,.25); }
.po-label { position: relative; font-size: 13.5px; }
.po-tally { position: relative; display: flex; align-items: center; gap: 5px; }
.po-voter { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 1.5px var(--parchment-light); }
.po-tally b { font-family: var(--font-display); font-size: 13px; }
.poll-close { width: 100%; margin-top: 11px; }
.poll-result { margin-top: 11px; font-size: 13px; color: var(--forest); background: rgba(63,93,66,.14); padding: 8px 10px; border-radius: 7px; }
.suggest-input { display: flex; gap: 8px; margin: 8px 0 12px; }
.suggest-list { display: flex; flex-direction: column; gap: 6px; }
.suggest-row { display: flex; align-items: center; gap: 8px; background: var(--parchment-light); border: 1px solid var(--parchment-edge); border-radius: 7px; padding: 7px 9px; }
.up-btn { background: var(--parchment-dark); border: 0; border-radius: 5px; padding: 4px 8px; font-family: var(--font-display); font-size: 12px; color: var(--ink); }
.up-btn:hover { background: var(--gold-bright); }
.sg-text { flex: 1; font-size: 13px; }
.sg-by { font-size: 11px; font-family: var(--font-display); }

/* ---------------- 5e sheet ---------------- */
.sheet-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.sheet-tab { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--ring); background: var(--parchment-light);
  font-size: 19px; display: grid; place-items: center; opacity: .6; }
.sheet-tab.on { opacity: 1; box-shadow: 0 0 0 2px var(--ring), 0 2px 6px rgba(0,0,0,.2); }
.sheet-card { border-radius: 11px; padding: 14px; }
.sheet-hd { display: flex; gap: 11px; align-items: center; }
.sheet-portrait { width: 46px; height: 46px; font-size: 24px; flex: none; }
.sheet-name { font-size: 17px; color: var(--ink); line-height: 1.05; }
.sheet-id { flex: 1; min-width: 0; }
.sheet-name { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; border-radius: 5px; }
.sheet-name:hover .rename-pen { opacity: 1; }
.rename-pen, .portrait-pen { opacity: 0; font-size: 12px; color: var(--gold-deep); transition: opacity .15s; }
.name-input { font-family: var(--font-display); font-size: 17px; color: var(--ink); padding: 3px 8px; width: 100%;
  border: 1px solid var(--gold); border-radius: 6px; background: var(--parchment-light); }
.edit-portrait { position: relative; border: 2px solid var(--ring); cursor: pointer; padding: 0; }
.edit-portrait:hover .portrait-pen { opacity: 1; }
.portrait-pen { position: absolute; bottom: -2px; right: -2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--leather); color: var(--parchment-light); display: grid; place-items: center; opacity: .85; font-size: 10px; }
.edit-row { display: flex; gap: 8px; align-items: flex-end; margin: 12px 0 2px; padding: 10px; background: rgba(0,0,0,.04); border-radius: 9px; }
.edit-row label { flex: 1; display: flex; flex-direction: column; gap: 3px; font-family: var(--font-display);
  font-size: 9px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); }
.edit-row select { font-family: var(--font-body); font-size: 13px; padding: 7px 6px; border-radius: 6px;
  border: 1px solid var(--parchment-edge); background: var(--parchment-light); color: var(--ink); }
.done-edit { padding: 7px 12px; font-size: 12px; }
.sheet-sub { font-size: 12px; color: var(--ink-faint); }
.import-chip { margin-left: auto; align-self: flex-start; background: var(--leather); color: var(--parchment-light);
  border: 0; border-radius: 6px; padding: 6px 9px; font-size: 11px; font-family: var(--font-display); }
.import-chip:hover { background: var(--leather-light); }
.vitals { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 8px; margin: 14px 0; text-align: center; }
.vital { background: var(--parchment-light); border: 1px solid var(--parchment-edge); border-radius: 9px; padding: 9px 6px; }
.vital b { display: block; font-size: 22px; color: var(--ink); }
.vital b i { font-style: normal; font-size: 11px; color: var(--ink-faint); }
.sync-link { background: none; border: 0; color: var(--gold-deep); font-size: 11px; font-family: var(--font-body); margin-top: 3px; }
.sync-link:hover { text-decoration: underline; }
.abil-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.abil { position: relative; background: var(--parchment-light); border: 1px solid var(--parchment-edge); border-radius: 9px;
  padding: 9px 4px 8px; display: flex; flex-direction: column; align-items: center; gap: 1px; color: var(--ink); overflow: hidden; }
.abil:hover { border-color: var(--gold); box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.abil-name { font-family: var(--font-display); font-size: 11px; letter-spacing: .08em; color: var(--ink-faint); }
.abil-mod { font-size: 22px; color: var(--ink); }
.abil-score { font-size: 11px; color: var(--ink-faint); }
.abil-roll { position: absolute; bottom: -16px; font-size: 10px; color: var(--gold-deep); font-family: var(--font-display); transition: bottom .15s; }
.abil:hover .abil-roll { bottom: 3px; }
.abil:hover .abil-score { opacity: 0; }
.sheet-actions { display: flex; gap: 8px; margin-top: 14px; }
.sheet-actions .btn { flex: 1; }
.companion-note { font-size: 12px; color: var(--ink-soft); text-align: center; margin-top: 12px; font-style: italic; }

/* ---------------- Lobby ---------------- */
.lobby-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(130% 90% at 50% 0%, color-mix(in srgb, var(--gold) 18%, transparent), transparent 55%), var(--leather-dark); overflow: auto; }
.lobby-card { width: min(460px, 94vw); border-radius: 16px; padding: 30px 30px 26px; position: relative; text-align: left; }
.lobby-crest { display: flex; justify-content: center; margin-bottom: 12px; }
.seal.big { width: 56px; height: 56px; font-size: 24px; }
.lobby-title { font-size: 28px; text-align: center; color: var(--ink); margin: 4px 0 10px; line-height: 1.05; }
.lobby-blurb { font-size: 14px; color: var(--ink-soft); text-align: center; line-height: 1.5; margin: 0 0 18px; }
.lobby-room { display: flex; align-items: center; gap: 12px; background: var(--parchment-light); border: 1px dashed var(--parchment-edge);
  border-radius: 10px; padding: 11px 14px; margin-bottom: 18px; }
.lobby-room .lock { font-size: 20px; }
.lobby-room > div { flex: 1; } .lobby-room b { font-size: 18px; color: var(--ink); letter-spacing: .08em; }
.lobby-label { font-family: var(--font-display); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); display: block; margin: 0 0 6px; }
.lobby-input { width: 100%; margin-bottom: 16px; }
.lobby-heroes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 22px; }
.sprite-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.tk-portrait { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.tk-pixel .tk-portrait { border-radius: 0; }
.tk-mini .tk-portrait { width: 78%; height: 78%; position: relative; z-index: 2; border-radius: 50%; }
.pres-sprite .sprite-img, .init-sprite .sprite-img, .pc-sprite .sprite-img, .sheet-portrait .sprite-img, .sheet-tab .sprite-img, .portrait-drop img { border-radius: 50%; }

/* ---- Lobby mode tabs ---- */
.lobby-modetabs { display: flex; gap: 6px; background: var(--parchment-dark); border-radius: 9px; padding: 4px; margin: 4px 0 16px; }
.lobby-modetabs button { flex: 1; background: none; border: 0; border-radius: 6px; padding: 9px; font-family: var(--font-display);
  font-size: 12px; letter-spacing: .04em; color: var(--ink-soft); }
.lobby-modetabs button.on { background: var(--parchment-light); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.seats-left { font-size: 11px; color: var(--ink-faint); font-style: italic; }

/* ---- Character creator ---- */
.creator { margin-bottom: 20px; }
.creator-top { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.portrait-drop { position: relative; width: 84px; height: 84px; flex: none; border-radius: 50%; border: 3px solid var(--ring);
  background: var(--parchment-light); display: grid; place-items: center; overflow: hidden; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.portrait-drop img { width: 100%; height: 100%; object-fit: cover; }
.pd-emoji { font-size: 38px; }
.pd-badge { position: absolute; bottom: 0; right: 0; width: 26px; height: 26px; border-radius: 50% 0 50% 50%;
  background: var(--leather); color: var(--parchment-light); display: grid; place-items: center; font-size: 13px; }
.creator-fields { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.creator-fields .lobby-input { margin-bottom: 0; }
.select-row { display: flex; gap: 8px; }
.select-row label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-family: var(--font-display);
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); }
.select-row select { font-family: var(--font-body); font-size: 14px; padding: 9px 8px; border-radius: 7px;
  border: 1px solid var(--parchment-edge); background: var(--parchment-light); color: var(--ink); }
.select-row select:focus { outline: 2px solid var(--gold); outline-offset: -1px; }
.color-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.color-swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.csw { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(0,0,0,.25); }
.csw.on { box-shadow: 0 0 0 2px var(--gold-bright); transform: scale(1.1); }
.creator-hint { font-size: 12px; color: var(--ink-soft); font-style: italic; line-height: 1.45; margin: 0; }
.hero-pick.taken { opacity: .45; cursor: not-allowed; }
.hero-pick { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border-radius: 10px;
  border: 2px solid var(--parchment-edge); background: var(--parchment-light); color: var(--ink); }
.hero-pick.on { border-color: var(--ring); box-shadow: 0 0 0 1px var(--ring), 0 3px 8px rgba(0,0,0,.18); }
.hp-sprite { font-size: 26px; line-height: 1; } .hp-name { font-family: var(--font-display); font-size: 12px; } .hp-cls { font-size: 10px; color: var(--ink-faint); }
.hp-portrait { width: 44px; height: 44px; object-fit: cover; object-position: top center; border-radius: 50%;
  border: 2px solid var(--ring, var(--parchment-edge)); background: rgba(0,0,0,.06); display: block; }
.lobby-actions { display: flex; gap: 10px; }

/* ---- Save / recall by code ---- */
.tb-save { background: var(--leather-dark); border: 1px solid #000; border-radius: 8px; color: var(--gold-bright);
  font-size: 15px; line-height: 1; padding: 7px 9px; cursor: pointer; }
.tb-save:hover { background: rgba(193,147,63,.22); }
.tb-save:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.save-card { width: min(420px, 94vw); }
.save-x { position: absolute; top: 12px; right: 14px; background: none; border: 0; font-size: 16px; color: var(--ink-faint); cursor: pointer; }
.save-x:hover { color: var(--ink); }
.save-card h2 { margin: 0 0 16px; font-size: 24px; color: var(--ink); }
.save-block { margin-bottom: 18px; }
.save-code-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 12px;
  background: var(--parchment-light); border: 1px dashed var(--parchment-edge); border-radius: 9px; }
.save-code-label { font-family: var(--font-display); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); }
.save-code { flex: 1; font-family: var(--font-body); font-size: 18px; font-weight: 700; letter-spacing: .1em; color: var(--ink); }
.save-copy { padding: 6px 12px; }
.save-actions { display: flex; gap: 10px; }
.save-actions .btn { flex: 1; }
.save-danger { color: var(--wine, #a23644); }
.save-note { font-size: 12px; color: var(--ink-soft); font-style: italic; line-height: 1.45; margin: 4px 0 0; }
.save-note.err { color: #b3261e; font-style: normal; font-weight: 600; }

/* Buttons that stay focusable while unavailable use aria-disabled (not the
   `disabled` attribute) so async state changes never strip keyboard focus.
   Style them to read as unavailable, and neutralize hover affordances. */
.btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn[aria-disabled="true"]:hover { filter: none;
  box-shadow: 0 2px 0 rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.5); }

/* Accessible alternative to the Ctrl+Alt+\ owner-reveal chord. */
.linklike { background: none; border: 0; padding: 4px 2px; font: inherit; font-size: 12px;
  color: var(--ink-soft); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.linklike:hover { color: var(--ink); }
.linklike:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 3px; }
.owner-reveal { display: block; margin: 10px auto 0; }

/* First-time owner setup disclosure. */
.admin-setup { margin-top: 12px; }
.admin-setup > summary { cursor: pointer; font-size: 12px; color: var(--ink-soft); }
.admin-setup > summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 3px; }
.admin-setup[open] > summary { margin-bottom: 8px; }

/* ---- Supporter (image uploads) + admin grants ---- */
.tb-support.is-paid { color: #e8c879; }
.tb-support.is-admin { background: rgba(193,147,63,.22); border-color: var(--gold-bright); }
.support-card { width: min(440px, 94vw); }
.support-card h2 { margin: 0 0 12px; font-size: 24px; color: var(--ink); }
.tier-pill { display: inline-block; margin: 0 0 16px; padding: 6px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.tier-pill.free { background: var(--parchment-light); border: 1px dashed var(--parchment-edge); color: var(--ink-soft); }
.tier-pill.paid { background: rgba(63,125,74,.16); border: 1px solid rgba(63,125,74,.5); color: #2f6b3a; }
.admin-block { border-top: 1px solid var(--parchment-edge); padding-top: 14px; }
.admin-block .eyebrow { margin-bottom: 8px; }
.code-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px;
  max-height: 168px; overflow-y: auto; }
.code-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--parchment-light); border: 1px dashed var(--parchment-edge); border-radius: 8px; }
.code-list .save-code { font-size: 15px; }
.code-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.code-for { font-size: 11px; color: var(--ink-soft); }
.code-for b { color: var(--ink); }

/* Supporter identity + badge */
.supporter-id { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; padding: 9px 12px;
  background: rgba(193,147,63,.14); border: 1px solid rgba(193,147,63,.45); border-radius: 9px;
  font-size: 13px; color: var(--ink); }
.supporter-badge { font-size: 15px; line-height: 1; }
.pres-supporter { position: absolute; top: -6px; right: -6px; z-index: 3; font-size: 12px; line-height: 1;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.5)); pointer-events: none; }

/* Locked upload affordances (free tier) */
.portrait-drop.locked { cursor: pointer; opacity: .92; border-style: dashed; }
.portrait-drop.locked .pd-badge { background: var(--leather-dark); }
.map-add.locked { color: var(--ink-soft); }
.hint-lock { color: var(--ink); font-style: normal; }
.sheet-portrait .portrait-pen { font-size: 11px; }

/* ---------------- Toast ---------------- */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 120;
  background: var(--leather); color: var(--parchment-light); padding: 12px 22px; border-radius: 10px;
  font-size: 14px; box-shadow: var(--shadow-deep); animation: toastIn .3s ease; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------------- House-rule announcement (big red banner) ---------------- */
.rule-alert { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 130;
  display: flex; align-items: center; gap: 14px; max-width: min(680px, 92vw);
  padding: 14px 16px 14px 18px; border-radius: 12px; color: #fff;
  background: linear-gradient(180deg, #b3261e, #8c1410);
  border: 1px solid rgba(0,0,0,.4); box-shadow: 0 10px 30px rgba(140,20,16,.5), inset 0 1px 0 rgba(255,255,255,.18);
  animation: ra-in .32s cubic-bezier(.16,1,.3,1); }
.ra-bell { font-size: 26px; line-height: 1; animation: ra-swing 1.6s ease-in-out infinite; transform-origin: top center; }
.ra-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ra-body b { font-family: var(--font-display); font-size: 15px; letter-spacing: .02em; }
.ra-text { font-size: 13px; color: rgba(255,255,255,.9); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ra-go { margin-left: auto; flex: none; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: #8c1410; background: #ffe9b0;
  border: 1px solid rgba(0,0,0,.2); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.ra-go:hover { background: #fff2cf; }
.ra-x { flex: none; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 14px;
  color: #fff; background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.25); }
.ra-x:hover { background: rgba(0,0,0,.38); }
.ra-go:focus-visible, .ra-x:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@keyframes ra-in { from { opacity: 0; transform: translate(-50%, -14px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes ra-swing { 0%,100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg); } }
@media (prefers-reduced-motion: reduce) {
  .rule-alert { animation: none; } .ra-bell { animation: none; } }

/* ---------------- House-rule list (left panel, under player card) ---------------- */
.rule-alerts { margin-top: 12px; border: 1px solid var(--wine, #6e1414); }
.rule-list { display: flex; flex-direction: column; gap: 7px; margin-top: 6px; }
.rule-row { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; cursor: pointer;
  padding: 8px 10px; border-radius: 8px; color: var(--parchment-light);
  background: rgba(0,0,0,.22); border: 1px solid rgba(0,0,0,.4); }
.rule-row:hover { background: rgba(0,0,0,.34); }
.rule-row:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.rule-row.live { border-color: #b3261e; box-shadow: inset 0 0 0 1px rgba(179,38,30,.6); }
.rule-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #e2473d;
  box-shadow: 0 0 0 0 rgba(226,71,61,.6); animation: rule-pulse 1.8s ease-out infinite; }
.rule-text { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rule-cta { flex: none; font-size: 12px; font-weight: 600; color: var(--gold-bright); }
.rule-up { flex: none; font-size: 12px; color: var(--parchment-dark); }
@keyframes rule-pulse { 0% { box-shadow: 0 0 0 0 rgba(226,71,61,.55); } 100% { box-shadow: 0 0 0 7px rgba(226,71,61,0); } }
@media (prefers-reduced-motion: reduce) { .rule-dot { animation: none; } }

/* ---------------- Responsive ---------------- */
@media (max-width: 1100px) {
  .stage, .layout-left .stage { grid-template-columns: 1fr 320px; }
  .rail-left { display: none; }
}
@media (max-width: 760px) {
  .stage, .layout-left .stage { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .rail-right { border-left: 0; border-top: 2px solid var(--leather-dark); max-height: 44vh; }
  .topbar { flex-wrap: wrap; }
}

/* ---------------- Presence status + manage menu ---------------- */
.pres.has-status { border-color: #c1933f; }
.pres.status-timeout { border-color: var(--wine, #8c1410); }
.pres.status-waiting { border-color: #5b7fb0; }
.pres-status { position: absolute; top: -7px; left: -7px; width: 17px; height: 17px; border-radius: 50%;
  display: grid; place-items: center; font-size: 9px; line-height: 1;
  background: var(--leather-dark); border: 1.5px solid var(--leather); box-shadow: 0 1px 2px rgba(0,0,0,.5); }
.pres-manage { position: absolute; top: -7px; right: -7px; }
.pres-menu-btn { width: 17px; height: 17px; border-radius: 50%; cursor: pointer; padding: 0;
  background: var(--leather); color: var(--parchment-light); border: 1px solid rgba(0,0,0,.5);
  font-size: 11px; line-height: 1; opacity: 0; transition: opacity .15s; display: grid; place-items: center; }
.pres:hover .pres-menu-btn, .pres-menu-btn:focus-visible { opacity: 1; }
.pres-menu-btn:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.pres-menu { position: absolute; top: 22px; right: 0; z-index: 140; min-width: 184px;
  display: flex; flex-direction: column; gap: 3px; padding: 7px; border-radius: 10px;
  box-shadow: var(--shadow-deep); animation: toastIn .16s ease; }
.pm-head { font-family: var(--font-display); font-size: 12px; letter-spacing: .03em;
  color: var(--ink); opacity: .75; padding: 3px 8px 5px; border-bottom: 1px solid var(--parchment-edge); margin-bottom: 2px; }
.pres-menu button { display: flex; align-items: center; gap: 7px; width: 100%; text-align: left; cursor: pointer;
  padding: 8px 10px; border-radius: 7px; font-size: 13px; color: var(--ink);
  background: var(--parchment-light); border: 1px solid var(--parchment-edge); }
.pres-menu button:hover { background: #fff2cf; }
.pres-menu button:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 1px; }
.pres-menu .pm-danger { color: var(--wine, #8c1410); border-color: rgba(140,20,16,.4); }
.pres-menu .pm-danger:hover { background: rgba(179,38,30,.12); }

/* ---------------- Timeout screen (jail bars + rickroll) ---------------- */
.timeout-screen { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, rgba(20,10,8,.82), rgba(8,4,3,.96)); }
.jail-bars { position: absolute; inset: 0; display: flex; justify-content: space-between;
  padding: 0 4%; pointer-events: none; }
.jail-bars span { width: 26px; height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, #2c2c30, #6b6b72 35%, #9a9aa2 50%, #6b6b72 65%, #2c2c30);
  box-shadow: 0 0 14px rgba(0,0,0,.6), inset 0 0 6px rgba(255,255,255,.15);
  animation: jail-drop .5s cubic-bezier(.16,1,.3,1) both; }
.jail-bars span:nth-child(2) { animation-delay: .04s; }
.jail-bars span:nth-child(3) { animation-delay: .08s; }
.jail-bars span:nth-child(4) { animation-delay: .12s; }
.jail-bars span:nth-child(5) { animation-delay: .16s; }
.jail-bars span:nth-child(6) { animation-delay: .2s; }
.jail-bars span:nth-child(7) { animation-delay: .24s; }
@keyframes jail-drop { from { transform: translateY(-100%); } to { transform: translateY(0); } }
.timeout-card { position: relative; z-index: 1; text-align: center; max-width: min(420px, 84vw);
  padding: 26px 30px; color: var(--parchment-light); }
.timeout-icon { font-size: 44px; line-height: 1; display: block; margin-bottom: 8px; }
.timeout-card h2 { font-family: var(--font-display); font-size: 26px; margin: 0 0 8px; }
.timeout-card p { font-size: 14px; color: rgba(255,255,255,.82); margin: 0; line-height: 1.5; }

/* ---------------- Waiting room (fantasy music) ---------------- */
.waiting-room { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 35%, rgba(40,30,70,.78), rgba(12,8,24,.96)); }
.waiting-card { position: relative; text-align: center; max-width: min(440px, 84vw);
  padding: 28px 32px; color: var(--parchment-light); animation: toastIn .3s ease; }
.waiting-icon { font-size: 46px; line-height: 1; display: block; margin-bottom: 8px;
  animation: wait-float 3s ease-in-out infinite; }
.waiting-card h2 { font-family: var(--font-display); font-size: 27px; margin: 0 0 8px; }
.waiting-card p { font-size: 14px; color: rgba(255,255,255,.85); margin: 0 0 14px; line-height: 1.5; }
.waiting-embers { display: flex; justify-content: center; gap: 14px; }
.waiting-embers span { width: 7px; height: 7px; border-radius: 50%;
  background: radial-gradient(circle, #ffcf7a, #d8862f); box-shadow: 0 0 8px #e8a24a;
  animation: ember-rise 2.4s ease-in-out infinite; }
.waiting-embers span:nth-child(2) { animation-delay: .4s; }
.waiting-embers span:nth-child(3) { animation-delay: .8s; }
.waiting-embers span:nth-child(4) { animation-delay: 1.2s; }
.waiting-embers span:nth-child(5) { animation-delay: 1.6s; }
@keyframes wait-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes ember-rise { 0%,100% { transform: translateY(0); opacity: .5; } 50% { transform: translateY(-7px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .jail-bars span { animation: none; }
  .waiting-icon, .waiting-embers span, .waiting-card { animation: none; }
}

/* ---------------- Elements / Power (DM palette) ---------------- */
.elements-panel { color: var(--ink); }
.el-sub { font-size: 12.5px; color: var(--ink-soft); margin: 2px 0 10px; }

/* target picker */
.el-targets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.el-target { display: flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 4px 8px 4px 4px; border-radius: 999px; font-family: var(--font-body); font-size: 12.5px; color: var(--ink);
  background: var(--parchment-light); border: 1.5px solid var(--parchment-edge); transition: border-color .12s, box-shadow .12s; }
.el-target:hover { border-color: var(--ring, var(--gold)); }
.el-target.on { border-color: var(--ring, var(--gold)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring, var(--gold)) 35%, transparent), 0 2px 6px rgba(0,0,0,.18); }
.el-target:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.el-tg-sprite { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; line-height: 1;
  background: var(--leather-dark); border: 1.5px solid var(--ring, var(--parchment-edge)); overflow: hidden; flex: none; }
.el-tg-sprite img { width: 100%; height: 100%; object-fit: cover; }
.el-tg-name { font-weight: 600; }
.el-tg-hp { font-size: 11px; color: var(--ink-faint); }
.el-empty { font-size: 12.5px; color: var(--ink-faint); font-style: italic; padding: 4px 2px; }

/* "unleashing on" stage + cast flash */
.el-stage { position: relative; display: flex; align-items: baseline; gap: 6px; min-height: 22px;
  padding: 6px 2px; border-top: 1px solid var(--parchment-edge); }
.el-stage-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); }
.el-stage-name { font-family: var(--font-display); font-size: 15px; }
.el-cast-flash { position: absolute; right: 8px; top: -2px; font-size: 20px; opacity: 0; pointer-events: none; }
.el-cast-flash.go { animation: el-flash .9s cubic-bezier(.16,1,.3,1); }
@keyframes el-flash {
  0%   { opacity: 0; transform: translateY(6px) scale(.5); }
  25%  { opacity: 1; transform: translateY(0) scale(1.5); }
  100% { opacity: 0; transform: translateY(-26px) scale(1.1); }
}

/* active conditions on the selected target */
.el-active { margin: 6px 0 4px; }
.el-badges, .init-conds { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.el-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--ink);
  padding: 2px 4px 2px 7px; border-radius: 999px; line-height: 1.4; text-transform: capitalize;
  background: color-mix(in srgb, var(--c) 16%, var(--parchment-light));
  border: 1px solid color-mix(in srgb, var(--c) 55%, var(--parchment-edge)); }
.el-badge .elb-glyph { font-size: 12px; }
.el-badge button { width: 15px; height: 15px; border-radius: 50%; cursor: pointer; padding: 0; font-size: 9px; line-height: 1;
  display: grid; place-items: center; color: var(--ink-soft); background: rgba(0,0,0,.08); border: 0; }
.el-badge button:hover { background: var(--wine); color: #fff; }

/* tier sections */
.el-tier { margin-top: 12px; }
.el-tier-hd { font-family: var(--font-display); font-size: 13px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-soft); padding-bottom: 6px; margin-bottom: 8px; border-bottom: 1.5px solid var(--parchment-edge);
  display: flex; align-items: center; gap: 8px; }
.el-tier-hd::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--parchment-edge), transparent); }
.tier-legendary .el-tier-hd { color: var(--gold-deep); }

/* the orb grid */
.el-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 8px 6px; }
.el-orb { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer;
  padding: 6px 2px 4px; border-radius: 10px; background: none; border: 1px solid transparent; transition: background .12s, border-color .12s, transform .1s; }
.el-orb:hover { background: rgba(0,0,0,.05); border-color: var(--parchment-edge); }
.el-orb:active { transform: translateY(1px); }
.el-orb:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 1px; }
.el-orb:disabled { opacity: .4; cursor: not-allowed; }
.el-glyph { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; line-height: 1;
  background:
    radial-gradient(circle at 36% 28%, rgba(255,255,255,.55), rgba(255,255,255,0) 42%),
    radial-gradient(circle at 50% 120%, rgba(0,0,0,.45), rgba(0,0,0,0) 60%),
    var(--c);
  border: 2px solid color-mix(in srgb, var(--c) 60%, black);
  box-shadow: inset 0 1px 2px rgba(255,255,255,.35), 0 2px 5px rgba(0,0,0,.3);
  text-shadow: 0 1px 2px rgba(0,0,0,.45); transition: transform .12s, box-shadow .12s; }
.el-orb:hover .el-glyph { transform: scale(1.08); box-shadow: inset 0 1px 2px rgba(255,255,255,.4), 0 4px 12px color-mix(in srgb, var(--c) 50%, transparent); }
.el-name { font-family: var(--font-display); font-size: 10.5px; letter-spacing: .02em; color: var(--ink); text-align: center; line-height: 1.05; }
.el-eff { font-size: 9.5px; color: var(--ink-faint); text-align: center; line-height: 1; }
/* kind accent dot on each orb */
.el-orb .el-glyph::after { content: ''; position: absolute; top: 4px; right: 8px; width: 8px; height: 8px; border-radius: 50%;
  border: 1.5px solid var(--parchment-light); box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.el-orb.k-damage  .el-glyph::after { background: #c2402f; }
.el-orb.k-heal    .el-glyph::after { background: #3f9e5a; }
.el-orb.k-control .el-glyph::after { background: #7a4f8a; }
.el-orb.k-buff    .el-glyph::after { background: var(--gold); }

/* condition chips in the initiative list */
.init-conds { margin-top: 3px; }
.cond-chip { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; line-height: 1.3; text-transform: capitalize;
  padding: 1px 6px 1px 4px; border-radius: 999px; color: var(--parchment-light);
  background: color-mix(in srgb, var(--c) 50%, var(--leather-dark));
  border: 1px solid color-mix(in srgb, var(--c) 70%, black); }

@media (prefers-reduced-motion: reduce) {
  .el-cast-flash.go { animation: none; }
}
