@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;600;700&family=Knewave&family=Permanent+Marker&display=swap');

:root {
  --bg:        #0E0A24;          /* slightly deeper purple-black, from preview */
  --panel:     #1f1a2e;
  --panel-2:   #261f3a;
  --ink:       #f3eefb;
  --muted:     #9c93b3;
  --accent:    #ff3ea5;          /* hot pink */
  --accent-2:  #6ee7ff;          /* cyan */
  --accent-3:  #ffb800;          /* amber */
  --good:      #7cff5a;
  --warn:      #ff6a3d;
  --border:    #3a2f55;
  /* logo gradient + magenta press-button (preview palette) */
  --c-magenta: #EC008C;
  --c-magenta-deep: #8c0055;
  --font-display: 'Knewave', 'Fredoka', sans-serif;
  --font-marker:  'Permanent Marker', 'Knewave', cursive;
  --font-hand:    'Caveat', cursive;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}
/* Atmospheric glow blobs — layered radial gradients with grain on top.
   All on body's background-image stack so we don't fight any z-index in the
   room layout. */
body {
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 70% 55% at 15% 85%, rgba(109,77,159,.50) 0%, transparent 65%),
    radial-gradient(ellipse 50% 45% at 85% 15%, rgba(0,174,239,.18)  0%, transparent 65%),
    radial-gradient(ellipse 45% 40% at 70% 90%, rgba(236,0,140,.15)  0%, transparent 55%),
    radial-gradient(ellipse 60% 60% at 50% 50%, rgba(30,21,64,0)     0%, rgba(30,21,64,.80) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  background-attachment: fixed;
  background-size: auto, auto, auto, auto, 300px 300px;
}

/* ============ Landing ============ */
body.landing {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
}
.landing-card {
  text-align: center;
  background: rgba(109, 77, 159, 0.12);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 22px;
  padding: 60px 30px;
  max-width: 520px; width: 100%;
  /* No backdrop-filter — it creates a stacking context that silently breaks
     background-clip:text on the descendant .logo in Chromium + Firefox. */
}
/* Verbatim port of the preview's logo treatment — Knewave swapped in for
   Fredoka. The previous override-heavy version (display:inline-block,
   explicit bg-size, text-shadow) was the cause of the failed clip; preview
   uses none of that and renders correctly. */
.logo {
  font-family: var(--font-display);
  font-size: clamp(44px, 10vw, 66px);   /* sized to fit the 460px inner card */
  font-weight: 400;
  line-height: 0.92;
  letter-spacing: 1px;
  background: linear-gradient(150deg, #ffffff 0%, #F175AD 55%, #EC008C 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 32px rgba(236, 0, 140, 0.45));
  margin: 0 0 8px;
  user-select: none;
}
.tagline { color: var(--muted); margin: 0 0 32px; font-size: 14px; }
.cta {
  background: var(--accent); color: #1a0814;
  border: none; border-radius: 12px;
  padding: 16px 32px; font-size: 16px; font-weight: 800;
  cursor: pointer;
}
.paste-row { margin-top: 22px; color: var(--muted); font-size: 13px; }
.paste-row input {
  margin-left: 8px;
  background: rgba(0,0,0,0.4); border: 1px solid var(--border);
  color: var(--ink); padding: 6px 10px; border-radius: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px;
  width: 260px;
}

/* ============ Top bar ============ */
.topbar {
  background: #1a1525;
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 5;
}
.room-id { font-family: ui-monospace, monospace; font-size: 13px; color: var(--accent); font-weight: 700; }
.room-id .label { color: var(--muted); font-weight: 400; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.gm-toggle {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 10px 4px 12px;
  font-size: 12px; cursor: pointer; color: var(--muted);
  user-select: none;
}
.gm-toggle .switch {
  width: 28px; height: 16px; border-radius: 10px;
  background: var(--border); position: relative;
  transition: background 0.15s;
}
.gm-toggle .switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--ink); transition: left 0.15s;
}
.gm-toggle.on { color: var(--accent-2); border-color: var(--accent-2); }
.gm-toggle.on .switch { background: var(--accent-2); }
.gm-toggle.on .switch::after { left: 14px; background: #001a22; }

.you-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 30px; padding: 4px 14px 4px 4px;
  cursor: pointer;
}
.you-card .avatar { width: 28px; height: 28px; border-radius: 50%; overflow: hidden; border: 2px solid var(--accent); }
.you-card .avatar img { width: 100%; height: 100%; object-fit: cover; }
.you-card .name { font-size: 13px; font-weight: 700; }
.you-card .arch-pill {
  font-size: 9px; padding: 1px 6px; border-radius: 4px;
  background: rgba(255,62,165,0.18); color: var(--accent);
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  margin-left: 4px;
}
.you-card .cog { color: var(--muted); font-size: 12px; }

/* ============ Main grid ============ */
.app-grid {
  display: grid; grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 49px);
}

/* Left panel */
.roll-panel {
  background: #1a1525;
  border-right: 1px solid var(--border);
  padding: 16px 14px 32px;
  overflow-y: auto;
}
.panel-title {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.1em;
  margin: 0 0 14px;
}
.rgroup {
  margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; background: var(--panel);
}
.rgroup-head {
  padding: 10px 14px 8px; background: var(--panel-2);
  font-family: var(--font-marker);
  font-size: 20px; letter-spacing: 1px;
  font-weight: 400; color: var(--accent);
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; user-select: none;
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
}
.rgroup-head .chev { color: var(--muted); font-size: 10px; }
.rgroup.gm .rgroup-head { color: var(--accent-2); }
.rgroup.table .rgroup-head { color: var(--accent-3); }
.rgroup.gen .rgroup-head { color: var(--good); }
.rgroup.loner .rgroup-head { color: var(--warn); }
.rgroup.util .rgroup-head { color: var(--muted); }
.rgroup.collapsed .rgroup-body { display: none; }
.rgroup-body { padding: 8px 10px 12px; }
.rbtn {
  display: block; width: 100%;
  background: transparent; border: 1px solid var(--border); color: var(--ink);
  border-radius: 8px; padding: 8px 10px; margin-bottom: 6px;
  text-align: left; font-size: 13px; font-weight: 600; cursor: pointer;
}
.rbtn:hover { border-color: var(--accent); background: rgba(255,62,165,0.08); }
.rbtn .sub { display: block; font-size: 10px; color: var(--muted); font-weight: 400; margin-top: 2px; }

/* Feed */
.feed-area { padding: 24px 20px 80px; overflow-y: auto; }
.feed-inner { max-width: 680px; margin: 0 auto; }

.bite-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border); border-top: 3px solid var(--accent-2);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 24px;
}
.bite-card .blabel {
  position: absolute; top: 6px; left: 14px;
  font-family: var(--font-marker);
  font-size: 14px; letter-spacing: 1px;
  color: var(--accent-2); font-weight: 400;
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
  pointer-events: none;
}
/* Bite row: [−]  pips  [+]. For non-GMs, the buttons hide, and the pips are
   centered via .viewer-only override. */
.bite-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bite-row.viewer-only { justify-content: center; }
.bite-pips { display: flex; gap: 4px; flex: 1; justify-content: center; align-items: center; min-height: 56px; }
/* Tooth icons — each pip gets an inline transform: rotate(±10deg) per spawn. */
.bite-pip {
  height: 56px; width: auto;
  filter: drop-shadow(0 0 6px rgba(110,231,255,0.45));
  transform-origin: 50% 60%;
}
.bite-empty { color: var(--muted); font-size: 14px; opacity: 0.5; }
.bite-btn {
  width: 28px; height: 28px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--ink); cursor: pointer;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.bite-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* Share button — small icon next to the room code in the topbar. */
.room-id { display: inline-flex; align-items: center; gap: 6px; position: relative; }
.share-btn {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; padding: 4px 6px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .15s, border-color .15s;
}
.share-btn:hover { color: var(--accent-2); border-color: var(--accent-2); }
.share-toast {
  position: absolute; left: 100%; margin-left: 10px;
  background: var(--accent-2); color: #001a22;
  font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 12px;
  opacity: 0; transform: translateY(2px); pointer-events: none;
  transition: opacity .2s, transform .2s;
  white-space: nowrap;
}
.share-toast.show { opacity: 1; transform: none; }
.share-toast.share-toast-error { background: var(--warn); color: #1a0f00; }

/* Custom clocks — GM-managed progress tracks under the bite card. */
.clocks-panel {
  background: var(--panel);
  border: 1px solid var(--border); border-top: 3px solid var(--accent-3);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 24px;
}
/* Up to 3 clocks per row. Each card is capped at a third of the row, so a full
   row of 3 fills the width; a partial row (1 or 2) is centred. Cards never
   shrink below 180px, dropping to 2 then 1 per row as the panel narrows. */
.clocks-list {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 8px;
}
.clocks-list:empty + .clock-add { margin-top: 0; }
.clock-card {
  flex: 1 1 calc((100% - 16px) / 3); min-width: 180px;
  max-width: calc((100% - 16px) / 3);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center;
  justify-content: space-between; gap: 8px; text-align: center;
  min-height: 140px; padding: 10px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px;
}
.clock-card.complete { border-color: var(--good); }
.clock-card.complete .clock-name { color: var(--good); }
/* The pie face fills the card as a large dimmed backdrop; name + controls
   layer over it. */
.clock-face {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 116px; height: 116px; opacity: 0.8;
  z-index: 0; pointer-events: none;
}
.clock-face .seg.empty  { fill: rgba(255,255,255,0.06); stroke: var(--border); stroke-width: 1; }
.clock-face .seg.filled { fill: var(--accent-3); stroke: rgba(0,0,0,0.4); stroke-width: 1; }
.clock-card.complete .clock-face .seg.filled { fill: var(--good); }
.clock-controls { position: relative; z-index: 1; }
.clock-meta {
  position: relative; z-index: 1;
  background: rgba(8, 5, 20, 0.45);
  padding: 2px 7px; border-radius: 8px;
}
.clock-name { font-weight: 700; font-size: 14px; }
.clock-progress { font-size: 11px; color: var(--ink); margin-top: 2px; }
.clock-controls { display: flex; gap: 4px; }
.clock-btn {
  width: 26px; height: 26px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; color: var(--ink); cursor: pointer;
  font-size: 13px; font-weight: 700;
}
.clock-btn:hover { border-color: var(--accent); }
.clock-btn.clock-del { color: var(--warn); }
.clock-btn.clock-del:hover { border-color: var(--warn); }
.clock-add {
  margin-top: 10px;
  width: 100%;
  background: transparent; border: 1px dashed var(--border); color: var(--muted);
  padding: 8px; border-radius: 8px; cursor: pointer;
  font-size: 12px; font-weight: 600;
  transition: color .15s, border-color .15s;
}
.clock-add:hover { color: var(--accent-3); border-color: var(--accent-3); }

/* Site footer (landing + room) */
.site-footer {
  text-align: center; color: var(--muted); opacity: 0.75;
  font-size: 12px; line-height: 1.6;
  padding: 24px 16px 16px;
}
.site-footer a { color: var(--accent-2); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* Roll cards */
.roll-card {
  background: var(--panel);
  border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  display: grid; grid-template-columns: 56px 1fr; gap: 14px; align-items: center;
}
.roll-card.private { opacity: 0.85; }
.roll-card .avatar {
  width: 56px; height: 56px; border-radius: 50%;
  border: 2px solid var(--accent); overflow: hidden;
  background: #2a2438;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #1a0814;
}
.roll-card .avatar img { width: 100%; height: 100%; object-fit: cover; }
.roll-card .who { font-weight: 700; font-size: 14px; }
.roll-card .meta { color: var(--muted); font-size: 12px; margin-left: 6px; }
.badge {
  display: inline-block; font-size: 9px;
  padding: 1px 6px; border-radius: 8px;
  text-transform: uppercase; letter-spacing: 0.06em;
  background: rgba(255,184,0,0.18); color: var(--accent-3);
  margin-left: 4px; font-weight: 700; vertical-align: middle;
}
.badge.boost { background: rgba(110,231,255,0.18); color: var(--accent-2); }
.badge.kick  { background: rgba(255,106,61,0.20); color: var(--warn); }
.badge.private { background: rgba(156,147,179,0.20); color: var(--muted); }

.dice { display: flex; gap: 6px; margin-top: 8px; }
.die {
  width: 32px; height: 32px; border-radius: 6px;
  background: #fff; color: #000;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px;
  border: 1px solid rgba(0,0,0,0.2);
}
.die.dim { background: transparent; color: var(--muted); border: 1px dashed var(--border); }
.die.win { background: var(--accent-3); color: #1a0814; border-color: var(--accent-3); }
/* On outcome cards the marked (winning) dice take the outcome colour:
   success → green, partial → amber, fail → red. */
.roll-card.rc-out-success .die.win { background: var(--good);     border-color: var(--good);     }
.roll-card.rc-out-partial .die.win { background: var(--accent-3); border-color: var(--accent-3); }
.roll-card.rc-out-fail    .die.win { background: var(--warn);     border-color: var(--warn);     }

.result {
  margin-top: 10px; display: flex; align-items: center; gap: 8px;
  font-size: 14px;
}
.result.success { color: var(--good); }
.result.partial, .result.partial * { color: var(--accent-3); }
.result.fail, .result.fail * { color: var(--warn); }
.result .body { color: var(--ink); flex: 1; }
.result .body b { color: inherit; }

/* (i) tooltip */
.info {
  position: relative;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1px solid var(--muted); color: var(--muted);
  background: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; font-style: italic;
  cursor: help; font-family: Georgia, serif;
  flex-shrink: 0;
}
.info:hover { border-color: var(--accent-2); color: var(--accent-2); }
/* GM-only delete × — same footprint as the info (i), sits right beside it. */
.rc-del {
  flex: 0 0 auto;
  width: 18px; height: 18px; padding: 0;
  border-radius: 50%;
  border: 1px solid var(--warn); color: var(--warn);
  background: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1; cursor: pointer;
}
.rc-del:hover { background: var(--warn); color: #1a0814; border-color: var(--warn); }
/* Pin the (i) and × to the bottom-right of the result row so a tall text body
   drops them to the corner instead of floating them to the vertical centre. */
.result .info, .result .rc-del { align-self: flex-end; }
.info .tip {
  position: absolute; bottom: calc(100% + 4px); left: 50%;
  transform: translateX(-50%);
  width: 280px;
  background: #0d0a14; color: var(--ink);
  border: 1px solid var(--accent-2);
  border-radius: 8px; padding: 10px 12px;
  font-size: 12px; font-style: normal; font-weight: 400;
  line-height: 1.5; text-align: left;
  opacity: 0; visibility: hidden;
  transition: opacity 0.15s ease;
  z-index: 20; pointer-events: none;
}
.info:hover .tip, .info.open .tip { opacity: 1; visibility: visible; }
/* `?` variant used in the roll-form title — non-italic glyph, tip drops below
   the title so it doesn't clip above the form. Click toggles `.open` for
   touch devices where hover isn't available. */
.info-q {
  font-family: inherit; font-style: normal; cursor: pointer;
  margin-left: 6px; vertical-align: middle;
}
.info-q .tip {
  top: calc(100% + 6px); bottom: auto;
  left: 0; transform: none;
}
.info .tip .tip-head {
  color: var(--accent-2); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  font-size: 10px; margin-bottom: 4px;
}
.info .tip .tip-rule { margin-top: 5px; font-size: 11px; line-height: 1.45; color: var(--ink); }
.info .tip .tip-rule b { color: var(--accent-2); font-weight: 700; }
/* "Rolled on <time>" — light grey cursive footer under the rules. */
.info .tip .tip-rolled {
  margin-top: 8px; padding-top: 6px;
  border-top: 1px solid var(--border);
  font-family: var(--font-hand); font-size: 14px;
  color: var(--muted);
}

/* Attitude prompts */
.attitude-prompt {
  margin-top: 10px;
  background: linear-gradient(90deg, rgba(255,62,165,0.18), rgba(110,231,255,0.12));
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex; align-items: center; gap: 10px;
  font-size: 12px;
}
.attitude-prompt .arch-tag {
  background: var(--accent); color: #1a0814;
  font-weight: 800; font-size: 10px;
  padding: 2px 7px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.attitude-prompt .text { flex: 1; color: var(--ink); }
.attitude-prompt .dismiss {
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); border-radius: 6px;
  padding: 3px 8px; font-size: 11px; cursor: pointer;
}

/* ============ Join overlay ============ */
.join-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 17, 28, 0.92);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.join-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px; max-width: 480px; width: 100%;
}
.join-header { color: var(--muted); font-size: 13px; text-align: center; margin-bottom: 18px; }
.join-header .session-code { color: var(--accent); font-family: ui-monospace, monospace; font-weight: 700; }
.field { margin-bottom: 18px; }
.field > span, .label-text { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field > span em { color: var(--muted); font-style: normal; }
.field input[type="text"] {
  width: 100%; padding: 10px 12px;
  background: #0d0a14; border: 1px solid var(--border);
  border-radius: 8px; color: var(--ink); font-size: 14px;
}
.colors {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px;
}
.swatch {
  aspect-ratio: 1; border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.08);
  cursor: pointer; transition: transform 0.1s;
}
.swatch.sel { transform: scale(1.12); box-shadow: 0 0 0 3px var(--ink); border-color: var(--ink); }

.archetypes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.arch {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; background: #0d0a14; cursor: pointer; position: relative;
  display: flex; align-items: center; gap: 10px;
}
.arch:hover { border-color: var(--accent); }
.arch.sel { border-color: var(--accent); background: rgba(255,62,165,0.08); }
.arch .arch-ic {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover; background: #1a1525; border: 1px solid var(--border);
}
.arch .arch-text { min-width: 0; }
.arch .name { font-weight: 700; font-size: 12px; }
.arch .trig { font-size: 10px; color: var(--muted); margin-top: 2px; }
.arch.none { grid-column: span 2; justify-content: center; text-align: left; }
.arch .solo-tag {
  position: absolute; top: 6px; right: 6px;
  font-size: 8px; padding: 1px 5px; border-radius: 3px;
  background: rgba(110,231,255,0.18); color: var(--accent-2);
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
}

.presence-block .presence-list {
  display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px;
}
.pmem { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.pmem .avatar { width: 22px; height: 22px; border-width: 2px; border-radius: 50%; overflow: hidden; border: 2px solid var(--accent); display:flex; align-items:center; justify-content:center; font-weight:800; color:#1a0814; font-size:10px; }
.pmem .avatar img { width: 100%; height: 100%; object-fit: cover; }

.primary-btn {
  background: var(--accent); color: #1a0814;
  border: none; border-radius: 10px;
  padding: 12px 20px; font-size: 14px; font-weight: 800;
  cursor: pointer; width: 100%; margin-top: 4px;
}
.primary-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.error-line { color: var(--warn); font-size: 12px; margin-top: 8px; min-height: 16px; }

/* Profile edit popover */
.edit-popover {
  position: fixed; top: 60px; right: 20px;
  background: var(--panel); border: 2px solid var(--accent);
  border-radius: 12px; padding: 16px;
  max-width: 380px; width: 100%;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  z-index: 30;
}
.edit-popover .ph { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 12px; }

/* Roll-form modal (small dialog above the feed when a roll button is clicked) */
.roll-form {
  background: var(--panel-2); border: 1px solid var(--accent);
  border-radius: 10px; padding: 14px;
  margin-bottom: 12px;
}
/* Header row: title on the left, "Roll privately" pinned top-right. */
.roll-form .rf-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.roll-form .rf-title { font-weight: 700; color: var(--accent); }
.gen-headline { font-weight: 800; color: var(--accent); margin-bottom: 4px; }
.gen-list { margin: 4px 0 0 18px; padding: 0; font-size: 13px; line-height: 1.5; }
.gen-list li { margin-bottom: 2px; }
.opt { line-height: 1.4; }
.result .body .opt b { color: var(--accent); font-weight: 800; }
.opt-or {
  font-family: var(--font-hand, inherit);
  font-style: italic;
  text-align: center;
  opacity: 0.7;
  margin: 10px 0;
  font-size: 13px;
}
.roll-form label { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; font-size: 13px; }
.roll-form input[type="number"] {
  width: 56px; background: #0d0a14; border: 1px solid var(--border);
  color: var(--ink); border-radius: 6px; padding: 4px 8px; font-size: 13px;
}
.roll-form .rf-private { display: inline-flex; align-items: center; gap: 6px; margin-right: 0; font-size: 13px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
/* Trick row mirrors a Boosts/Kicks icon-strip: same label size, checkbox pushed
   to the right so it lands under the +/- column. */
.roll-form .trick-row {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 0 0;
  cursor: pointer;
}
.roll-form .trick-row .strip-label { min-width: 60px; font-weight: 600; font-size: 16px; }
/* Checkbox sized + framed to match the strip-btn circles, so the Trick row's
   right-edge control reads as part of the same control family. */
.roll-form .trick-row input[type="checkbox"] {
  margin-left: auto;
  appearance: none; -webkit-appearance: none;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--border); background: transparent;
  cursor: pointer; position: relative;
  transition: border-color 0.1s ease, background 0.1s ease;
}
.roll-form .trick-row input[type="checkbox"]:hover { border-color: var(--accent); }
.roll-form .trick-row input[type="checkbox"]:checked {
  background: var(--accent); border-color: var(--accent);
}
.roll-form .trick-row input[type="checkbox"]:checked::after {
  content: '✓'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #1a0814; font-weight: 800; font-size: 16px; line-height: 1;
}
/* Stacked checkbox list (Make-a-Person toggles, Opp/Chal bonuses) */
/* Multi-table picker (Problems): a button per sub-table, each rolls on click. */
.roll-form .rf-pickgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.roll-form .rf-pick {
  background: var(--panel); border: 1px solid var(--accent-2); color: var(--ink);
  border-radius: 8px; padding: 10px 12px; font-size: 13px; font-weight: 700;
  cursor: pointer; text-align: center;
}
.roll-form .rf-pick:hover { background: rgba(110,231,255,0.12); }
.roll-form .rf-checks { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 4px; }
.roll-form .rf-checks label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); }
.roll-form .rf-bonuses { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.roll-form .rf-bonuses label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); cursor: pointer; }
.roll-form .rf-block { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.roll-form .rf-block span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.roll-form select {
  background: #0d0a14; border: 1px solid var(--border); color: var(--ink);
  border-radius: 6px; padding: 6px 8px; font-size: 13px;
}
/* Actions row: Roll centered, Cancel pinned right. The spacer mirrors the
   Cancel button's width so the Roll button sits visually centred. */
.roll-form .rf-actions {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}
.roll-form .rf-actions .rf-actions-spacer { display: block; }
.roll-form .rf-actions .roll-btn { justify-self: center; }
.roll-form .rf-actions .cancel-btn { justify-self: end; }
/* Roll button — lifted from the preview design: lipped 3D press, magenta,
   uppercase Knewave-ish display font with a satin sheen overlay. */
.rf-actions .roll-btn {
  height: 44px;
  padding: 0 22px;
  border: none;
  border-radius: 12px;
  background: var(--c-magenta);
  color: #fff;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 0 var(--c-magenta-deep), 0 6px 18px rgba(236,0,140,0.45);
  transition: transform .1s, box-shadow .1s;
  user-select: none;
}
.rf-actions .roll-btn::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.16) 0%, transparent 55%);
  pointer-events: none;
}
.rf-actions .roll-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--c-magenta-deep), 0 10px 24px rgba(236,0,140,0.55);
}
.rf-actions .roll-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--c-magenta-deep), 0 3px 8px rgba(236,0,140,0.25);
}
/* Trick armed → "Check It!" in a zany marker font, slightly tilted. The
   hover/active variants re-include the rotation so the press keeps the tilt. */
.rf-actions .roll-btn.check-it {
  font-family: var(--font-marker);
  text-transform: none; letter-spacing: 1px;
  transform: rotate(-3deg);
}
.rf-actions .roll-btn.check-it:hover  { transform: rotate(-3deg) translateY(-2px); }
.rf-actions .roll-btn.check-it:active { transform: rotate(-3deg) translateY(3px); }
.rf-actions .cancel-btn { background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
.rf-actions .cancel-btn:hover { color: var(--ink); border-color: var(--muted); }

/* ============ Create-row extras (landing) ============ */
.create-row { display: flex; flex-direction: column; gap: 10px; max-width: 340px; margin: 0 auto; }
.create-row input[type="password"] {
  background: rgba(0,0,0,0.4); border: 1px solid var(--border);
  color: var(--ink); padding: 10px 12px; border-radius: 8px; font-size: 13px;
}
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.create-warn { font-size: 12px; color: var(--warn); text-align: left; }

/* Join-an-existing-room row: code field + Join button, under the create flow. */
.join-row { max-width: 340px; margin: 24px auto 0; }
.join-row .join-line { display: flex; gap: 8px; }
.join-row input {
  flex: 1; min-width: 0;
  background: rgba(0,0,0,0.4); border: 1px solid var(--border);
  color: var(--ink); padding: 10px 12px; border-radius: 8px; font-size: 13px;
}
.btn-join {
  flex-shrink: 0;
  background: var(--accent-2); color: #001a22; border: none;
  border-radius: 8px; padding: 10px 18px; font-size: 14px; font-weight: 800;
  cursor: pointer;
}
.btn-join:hover { filter: brightness(1.08); }
.join-row .create-warn { margin-top: 8px; }

.owner-key-panel {
  max-width: 340px; margin: 0 auto; text-align: center;
  background: rgba(110,231,255,0.07); border: 1px dashed var(--accent-2);
  border-radius: 12px; padding: 18px;
}
.owner-key-panel .ok-title { font-weight: 800; margin-bottom: 8px; }
.owner-key-panel .ok-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.owner-key-panel .ok-value {
  display: block; font-family: ui-monospace, monospace; font-size: 16px;
  color: var(--accent-2); background: rgba(0,0,0,0.35); padding: 8px;
  border-radius: 6px; margin-bottom: 14px; letter-spacing: 0.04em;
}

/* ============ Password gate page ============ */
body.gate-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.gate-card {
  text-align: center; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 40px 30px; max-width: 380px; width: 100%;
}
.gate-lock { font-size: 36px; margin-bottom: 8px; }
.gate-title { font-weight: 700; margin-bottom: 4px; }
.gate-code { font-family: ui-monospace, monospace; color: var(--accent); margin-bottom: 18px; }
.gate-card input[type="password"] {
  width: 100%; padding: 10px 12px; margin-bottom: 12px;
  background: #0d0a14; border: 1px solid var(--border);
  border-radius: 8px; color: var(--ink); font-size: 14px;
}

/* ============ Settings button + panel ============ */
.settings-btn {
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--accent-2); border-radius: 20px; padding: 4px 12px;
  font-size: 12px; font-weight: 700; cursor: pointer;
}
.settings-btn:hover { border-color: var(--accent-2); }
.settings-btn.gm-on { background: var(--accent); color: #1a1525; border-color: var(--accent); }
.settings-panel .check-row { margin-bottom: 12px; color: var(--ink); }
.settings-panel .gm-row em { color: var(--muted); font-style: normal; font-size: 11px; }
.settings-divider { font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.1em; border-top: 1px solid var(--border); margin: 6px 0 12px; padding-top: 12px; }
.settings-note { font-size: 12px; color: var(--muted); }

/* ============ Profile editor: divider, leave, claim ============ */
.popover-divider { border: none; border-top: 1px solid var(--border); margin: 16px 0 12px; }
.leave-btn {
  width: 100%; padding: 10px; background: transparent;
  border: 1px solid var(--warn); color: var(--warn);
  border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.leave-btn:hover { background: rgba(255,106,61,0.08); }
.claim-details { margin-top: 14px; font-size: 13px; color: var(--muted); }
.claim-details summary { cursor: pointer; }
.claim-details input[type="text"] {
  width: 100%; padding: 8px 10px; margin: 6px 0;
  background: #0d0a14; border: 1px solid var(--border);
  border-radius: 6px; color: var(--ink); font-family: ui-monospace, monospace;
}

/* ============ RUN / DOWNTIME mode switcher ============ */
.mode-switch {
  background: var(--panel-2); border: 1px solid var(--accent-3);
  color: var(--accent-3); border-radius: 20px; padding: 4px 12px;
  font-size: 12px; font-weight: 800; cursor: pointer;
  letter-spacing: 0.04em;
}
.mode-switch:hover { background: rgba(255,184,0,0.10); }
.mode-switch.downtime { border-color: var(--accent-2); color: var(--accent-2); }

/* ============================================================
   Boost / kick icon strips (action + group_action forms)
   Per .superpowers/specs/2026-06-09-boost-kick-icon-ui-design.md §3
   ============================================================ */

.action-hint {
  font-style: italic;
  opacity: 0.7;
  margin-bottom: 6px;
  font-size: 0.9em;
}

/* ===== Dare block (action / group action form) =====
   Sits as a normal inset row in the form — amber is reserved for the SELECTED
   state so a player who hasn't engaged with it sees a calm panel, not an alert. */
.dare-block {
  margin-top: 12px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: rgba(255,255,255,0.02);
}
.dare-head { font-weight: 700; font-size: 13px; color: var(--ink); margin-bottom: 8px; }
.dare-head::before { content: '⚡ '; color: var(--accent-3); }
.dare-sub { font-weight: 400; font-size: 11px; color: var(--muted); font-style: italic; margin-left: 4px; }
.dare-row { display: flex; flex-wrap: wrap; gap: 6px; }
.dare-opt {
  padding: 6px 11px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600;
  background: #120e1b; border: 1px solid var(--border); color: var(--ink);
  transition: border-color 0.1s ease, background 0.1s ease, color 0.1s ease;
}
.dare-opt:hover { border-color: var(--accent-3); }
.dare-opt.on { background: rgba(255,184,0,0.18); border-color: var(--accent-3); color: var(--accent-3); }
.dare-cost { margin-top: 10px; }
.dare-cost-label { font-size: 11px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.dare-problem {
  width: 100%; box-sizing: border-box; margin-top: 8px; padding: 7px 10px;
  border-radius: 6px; background: #120e1b; border: 1px solid var(--border);
  color: var(--ink); font-size: 12px;
}
.dare-problem:focus { outline: none; border-color: var(--accent-3); }

/* Dare badge on the roll card */
.rc-dare {
  display: inline-block; margin-top: 8px; padding: 3px 9px; border-radius: 6px;
  font-size: 11px; font-weight: 600;
  background: rgba(255,184,0,0.14); color: var(--accent-3);
}
.rc-dare b { font-weight: 800; }

.icon-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.icon-strip .strip-label {
  min-width: 60px;
  font-weight: 600;
}
.icon-strip .strip-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
  min-height: 32px;
  align-items: center;
  /* Cluster the dice next to the +/- buttons — otherwise the empty space
     between the label and the right-pinned buttons reads as a layout bug. */
  justify-content: flex-end;
}
.icon-strip .strip-icon {
  width: 28px;
  height: 28px;
  image-rendering: -webkit-optimize-contrast;
}
.icon-strip .strip-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.2em;
  line-height: 1;
}
.icon-strip .strip-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.badge-icon {
  width: 20px;
  height: 20px;
  vertical-align: middle;
  image-rendering: -webkit-optimize-contrast;
}

/* ============================================================
   Roll-card redesign — loud category-colored titles + decomposed
   action result. Per .superpowers/specs/2026-06-09-roll-card-redesign-design.md
   ============================================================ */

/* Roll-type title — Permanent Marker, colored per sidebar category */
.rc-title {
  font-family: var(--font-marker);
  font-size: 28px;
  letter-spacing: 1px;
  line-height: 1;
  font-weight: 400;
}
.rc-title-row { display: flex; align-items: flex-start; gap: 12px; }
.rc-title-row .meta-block { flex: 1; min-width: 0; }
.rc-title-row .dice { margin-left: auto; margin-top: 0; }

/* Category colors — mirror .rgroup.<key> .rgroup-head */
.roll-card.rc-cat-player .rc-title { color: var(--accent);   }
.roll-card.rc-cat-gm     .rc-title { color: var(--accent-2); }
.roll-card.rc-cat-table  .rc-title { color: var(--accent-3); }
.roll-card.rc-cat-gen    .rc-title { color: var(--good);     }
.roll-card.rc-cat-loner  .rc-title { color: var(--warn);     }
.roll-card.rc-cat-util   .rc-title { color: var(--muted);    }

/* Border + background carry MEANING, not category:
   - action / group_action / disaster: a uniform 2px outcome-colored outline
     all the way around + a whole-card background tinted toward that outcome
     color (green success / yellow mix / red fail), matching the headline.
   - everything else: neutral left border + plain panel, since those rolls
     have no success/mix/fail outcome. */
.roll-card { border-left-color: var(--border); }
.roll-card.rc-out-success {
  border: 2px solid var(--good);
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--good) 22%, var(--panel)),
    color-mix(in srgb, var(--good) 9%, var(--panel)));
}
.roll-card.rc-out-partial {
  border: 2px solid var(--accent-3);
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--accent-3) 22%, var(--panel)),
    color-mix(in srgb, var(--accent-3) 9%, var(--panel)));
}
.roll-card.rc-out-fail {
  border: 2px solid var(--warn);
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--warn) 22%, var(--panel)),
    color-mix(in srgb, var(--warn) 9%, var(--panel)));
}

/* Applied modifiers on the meta line (compact icon ×N) */
.rc-applied { display: inline-flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.rc-applied .badge-icon { width: 17px; height: 17px; }

/* Reward pills */
.rc-rewards { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.reward-pill {
  border-radius: 6px; padding: 3px 9px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.reward-pill.style  { background: rgba(124,255,90,0.16); color: var(--good); }
.reward-pill.impact { background: rgba(255,106,61,0.20); color: var(--warn); }

/* Outcome row */
.rc-outcome { margin-top: 9px; font-size: 15px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.rc-outcome-head { font-weight: 800; }
.rc-outcome-head.success { color: var(--good);     }
.rc-outcome-head.partial { color: var(--accent-3); }
.rc-outcome-head.fail    { color: var(--warn);     }
.rc-outcome-prose { color: var(--ink); font-weight: 400; }
.rc-outcome .info { margin-left: auto; }

/* ===== Top-level view switch ===== */
.view-switch { display: flex; gap: 2px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 20px; padding: 3px; }
.view-btn { background: transparent; border: 0; color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 700; padding: 5px 12px;
  border-radius: 16px; cursor: pointer; white-space: nowrap;
  text-decoration: none; display: inline-flex; align-items: center; }
.view-btn:hover { color: var(--ink); }
.view-btn.on { background: var(--accent); color: #1a1525; }
.view-ico { display: inline-flex; align-items: center; margin-right: 4px; }
.view-ico-img { width: 16px; height: 16px; border-radius: 50%;
  object-fit: cover; display: block; }

/* ===== Profile editor — clickable avatar tile ===== */
.player-avatar-row { display: flex; align-items: center; gap: 12px; }
.player-avatar {
  flex: 0 0 auto; width: 64px; height: 64px; border-radius: 50%;
  background: #241b33; border: 2px solid var(--border); padding: 0; overflow: hidden;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.player-avatar:hover { border-color: var(--accent); }
.player-avatar:active { transform: scale(0.96); }
.player-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.player-avatar span { width: 100%; height: 100%; display: flex !important;
  align-items: center; justify-content: center; font-weight: 700; font-size: 26px; }
.player-avatar-hint { font-size: 12px; color: var(--muted); line-height: 1.3; }

/* ===== Shared sheet-view shell ===== */
.sheet-view { padding: 22px; max-width: 920px; margin: 0 auto; }
.sheet-inner { display: flex; flex-direction: column; gap: 18px; }
.crew-coming-soon { text-align: center; color: var(--muted);
  font-family: var(--font-marker); font-size: 22px; padding: 80px 0; }

/* ===== Crew sheet cards ===== */
.crew-card { background: #1a1525; border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; }
.crew-card-title { font-family: var(--font-marker); font-size: 18px; margin-bottom: 10px; }
.crew-line { display: grid; grid-template-columns: 90px 1fr; align-items: center;
  gap: 12px; margin-bottom: 10px; }
.crew-line.col { grid-template-columns: 1fr; }
.crew-line > span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.crew-line input, .crew-line textarea { width: 100%; background: #0d0a14;
  border: 1px solid var(--border); border-radius: 8px; color: var(--ink);
  padding: 8px 10px; font: inherit; }
.crew-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.crew-chip { background: #0d0a14; border: 1px solid var(--border); color: var(--muted);
  border-radius: 14px; padding: 4px 10px; font-size: 12px; font-weight: 700; cursor: pointer; }
.crew-chip.on { background: var(--accent); color: #1a1525; border-color: var(--accent); }
.crew-pools { display: flex; gap: 28px; }
.crew-counter { display: grid; grid-template-columns: auto auto auto auto; align-items: center; gap: 10px; }
.cc-label { font-family: var(--font-marker); font-size: 16px; }
.cc-btn { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--ink); font-size: 16px; cursor: pointer; }
.cc-val { min-width: 1.5em; text-align: center; font-size: 18px; font-weight: 800; }

/* ===== Factions & NPCs — compact 2-column sheet layout ===== */
.fac-legend { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.fac-legend .pos { color: var(--good); font-weight: 700; }
.fac-legend .neg { color: var(--warn); font-weight: 700; }
.fac-legend b { color: var(--ink); }
.fac-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fac-group { padding: 12px 14px; }
.fac-group-title { font-family: var(--font-marker); font-size: 16px; margin-bottom: 6px; }

.fac-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px;
  align-items: start; padding: 3px 0; }
.fac-row.unstable { background: rgba(255,106,61,0.08); border-radius: 6px; }
.fac-text { font-size: 12px; line-height: 1.3; }
.fac-text b { font-weight: 800; }
/* Symbol-only status box, coloured by sign. */
.fac-status { width: 34px; text-align: center; background: #0d0a14;
  border: 1px solid var(--border); color: var(--ink); border-radius: 6px;
  padding: 3px 0; font: inherit; font-size: 12px; font-weight: 800; cursor: pointer;
  -webkit-appearance: none; appearance: none; }
.fac-status.pos { color: var(--good); border-color: var(--good); }
.fac-status.neg { color: var(--warn); border-color: var(--warn); }
.fac-ctl { display: flex; gap: 2px; align-items: center; }
.fac-unstable { background: transparent; border: 0; color: var(--border);
  font-weight: 800; font-size: 11px; cursor: pointer; padding: 0 2px; line-height: 1; }
.fac-unstable.on { color: var(--warn); }
.fac-del, .npc-del { background: transparent; border: 0; color: var(--muted);
  font-size: 16px; cursor: pointer; line-height: 1; padding: 0 2px; }
.fac-del:hover, .npc-del:hover { color: #ff5ed8; }

.fac-add { display: flex; gap: 6px; margin-top: 8px; }
.fac-add-name { flex: 1; min-width: 0; background: #0d0a14; border: 1px dashed var(--border);
  border-radius: 6px; color: var(--ink); padding: 4px 6px; font: inherit; font-size: 12px; }
.fac-add-btn { background: var(--panel-2); border: 1px solid var(--border); color: var(--ink);
  border-radius: 6px; padding: 4px 10px; font-weight: 700; font-size: 12px; cursor: pointer; }

/* NPCs — stacked cards (name on top, notes below), each a fixed third-width and
   centred so the row doesn't reflow as cards are added */
.npc-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.npc-card { flex: 0 0 calc(33.333% - 8px); display: flex; flex-direction: column; gap: 6px;
  background: #0d0a14; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
@media (max-width: 560px) { .npc-card { flex-basis: calc(50% - 6px); } }
.npc-card-head { display: flex; align-items: center; gap: 6px; }
.npc-name { flex: 1; min-width: 0; background: transparent; border: 0;
  border-bottom: 1px solid var(--border); color: var(--ink); font: inherit; font-weight: 700;
  padding: 2px 2px 4px; }
.npc-name:focus { outline: none; border-bottom-color: var(--accent); }
.npc-details { width: 100%; min-height: 46px; resize: vertical; background: transparent;
  border: 0; color: var(--muted); font: inherit; font-size: 12px; line-height: 1.45; padding: 2px; }
.npc-details:focus { outline: none; }

.npc-add { display: flex; flex-direction: column; gap: 8px; margin-top: 12px;
  border-top: 1px solid var(--border); padding-top: 12px; max-width: 320px; }
.npc-add-name, .npc-add-details { background: #0d0a14; border: 1px solid var(--border);
  border-radius: 8px; color: var(--ink); padding: 7px 9px; font: inherit; }
.npc-add-details { resize: vertical; min-height: 46px; line-height: 1.45; }
.npc-add-btn { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--border);
  color: var(--ink); border-radius: 8px; padding: 6px 12px; font-weight: 700; cursor: pointer; }

@media (max-width: 640px) { .fac-grid { grid-template-columns: 1fr; } }

/* ===== Crew sheet — redesigned Main & Fame ===== */
/* Identity header: clickable avatar + the crew name in the display font. */
.crew-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.crew-head .crew-name-input { margin-bottom: 0; }

.crew-avatar {
  --crew-avatar-size: 88px;   /* bump this to grow the avatar everywhere */
  flex: 0 0 auto; width: var(--crew-avatar-size); height: var(--crew-avatar-size);
  border-radius: 50%; padding: 0; cursor: pointer; overflow: hidden;
  border: 2px solid var(--border); background: #241b33;
  display: flex; align-items: center; justify-content: center; position: relative;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.crew-avatar:hover { border-color: var(--accent); }
.crew-avatar:active { transform: scale(0.96); }
.crew-avatar .cav-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.crew-avatar .cav-anim {
  width: 100%; height: 100%; display: block;
  background-size: 78%; background-position: center; background-repeat: no-repeat;
}
.crew-avatar .cav-anim.cav-ready { background-image: none !important; }
.crew-avatar .cav-anim svg { display: block; }
.crew-avatar .cav-empty { font-size: calc(var(--crew-avatar-size) * 0.5); line-height: 1;
  color: var(--muted); font-weight: 300; }

.crew-name-input {
  width: 100%; background: transparent; border: 0; border-bottom: 2px solid var(--border);
  color: var(--ink); font-family: var(--font-display); font-size: 30px; letter-spacing: 0.5px;
  padding: 4px 2px 8px; margin-bottom: 12px;
}
.crew-name-input::placeholder { color: var(--muted); opacity: 0.5; }
.crew-name-input:focus { outline: none; border-bottom-color: var(--accent); }

/* ===== Crew avatar picker ===== */
.cav-backdrop { position: fixed; inset: 0; z-index: 80; }
.cav-pop {
  position: fixed; z-index: 81; display: flex; flex-direction: column; gap: 8px;
  max-height: min(70vh, 520px); padding: 12px;
  background: #1a1525; border: 1px solid var(--accent); border-radius: 12px;
  box-shadow: 0 18px 48px rgba(0,0,0,0.55);
}
.cav-pop-head { display: flex; align-items: center; gap: 8px; }
.cav-tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.cav-tab {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; background: transparent; font-size: 18px; line-height: 1;
  opacity: 0.55; transition: opacity 0.1s ease, background 0.1s ease;
}
.cav-tab:hover { opacity: 0.9; background: #271d39; }
.cav-tab.on { opacity: 1; background: #2d2142; border-color: var(--accent); }
.cav-close { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: var(--muted); font-size: 14px; }
.cav-close:hover { color: var(--ink); border-color: var(--accent); }
.cav-search {
  width: 100%; padding: 7px 10px; border-radius: 8px; box-sizing: border-box;
  background: #120e1b; border: 1px solid var(--border); color: var(--ink); font-size: 14px;
}
.cav-search:focus { outline: none; border-color: var(--accent); }
.cav-grid {
  flex: 1; overflow-y: auto; display: grid; gap: 2px;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  align-content: start; min-height: 120px;
}
.cav-cell {
  aspect-ratio: 1; padding: 4px; border: 1px solid transparent; border-radius: 8px;
  background: transparent; cursor: pointer; transition: background 0.08s ease;
}
.cav-cell:hover { background: #2d2142; border-color: var(--accent); }
.cav-cell img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cav-loading { grid-column: 1 / -1; color: var(--muted); text-align: center; padding: 24px 0; }
.cav-url-row { display: flex; gap: 6px; }
.cav-url {
  flex: 1; padding: 7px 10px; border-radius: 8px; box-sizing: border-box;
  background: #120e1b; border: 1px solid var(--border); color: var(--ink); font-size: 13px;
}
.cav-url:focus { outline: none; border-color: var(--accent); }
.cav-url-use {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 8px; cursor: pointer;
  background: var(--accent); border: 0; color: #120e1b; font-weight: 700; font-size: 13px;
}
.cav-pop-foot { display: flex; align-items: center; gap: 10px; }
.cav-clear { background: transparent; border: 0; color: var(--muted); cursor: pointer;
  font-size: 12px; text-decoration: underline; padding: 0; }
.cav-clear:hover { color: var(--warn, #ff6b6b); }
.cav-err { color: var(--warn, #ff6b6b); font-size: 12px; }

.crew-brand-wrap { display: flex; flex-direction: column; gap: 8px; }
.crew-chip.disabled { opacity: 0.35; cursor: not-allowed; }
.brand-means { display: flex; flex-direction: column; gap: 3px; }
.brand-mean { font-size: 12px; color: var(--muted); }
.brand-mean b { color: var(--ink); }
.brand-hint { font-size: 12px; color: var(--muted); font-style: italic; }
.crew-unlocks { display: flex; flex-direction: column; gap: 4px; }
.unlock { font-size: 12px; color: var(--muted); line-height: 1.35;
  border-left: 2px solid var(--good); padding-left: 8px; }
.unlock b { color: var(--good); }

/* Boost / Kick pip trackers — larger, centred, label on top */
.crew-resources { display: flex; gap: 56px; flex-wrap: wrap; justify-content: center; padding: 6px 0; }
.pip-tracker { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pip-label { font-family: var(--font-marker); font-size: 20px; }
.pip-controls { display: flex; align-items: center; gap: 12px; }
.pip-lock { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--ink); font-size: 16px; cursor: pointer; }
.pip-lock:disabled { opacity: 0.35; cursor: default; }
.pip-row { display: flex; gap: 8px; }
/* Empty box you fill left-to-right (like Style): faint when off, lit when on. */
.cpip { width: 42px; height: 42px; padding: 0; border-radius: 9px; cursor: pointer;
  border: 2px solid var(--border); background-color: #0d0a14;
  background-image: var(--pip); background-size: 26px; background-repeat: no-repeat;
  background-position: center; opacity: 0.4; transition: opacity 0.12s, border-color 0.12s, background-color 0.12s; }
.cpip.on { opacity: 1; border-color: var(--accent-2); background-color: rgba(110,231,255,0.14); }

/* Style + Fractures share a row, wrapping to stacked when narrow */
.crew-style-frac { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px; align-items: start; }
.sf-col { min-width: 0; }

/* Style pool boxes — large, two rows of five */
.style-track { display: grid; grid-template-columns: repeat(5, 44px); gap: 8px; }
.style-box { width: 44px; height: 44px; border-radius: 8px; border: 2px solid var(--border);
  background: #0d0a14; cursor: pointer; }
.style-box.on { background: var(--accent-3); border-color: var(--accent-3); }
/* Fractures — two open text lines */
.frac-title { margin-top: 16px; }
.frac-field { width: 100%; background: #0d0a14; border: 1px solid var(--border);
  border-radius: 8px; color: var(--ink); padding: 7px 10px; font: inherit; margin-bottom: 6px; }

/* ===== Fame — neon progression rail + one focused tier ===== */
.fame-top { display: flex; align-items: baseline; gap: 6px 12px; flex-wrap: wrap; }
.fame-current { font-family: var(--font-marker); font-size: 14px; color: var(--accent); }
.fame-banked { font-size: 12px; color: var(--muted); margin-left: auto; }
.fame-banked b { color: var(--accent-3); font-size: 15px; }

.fame-rail { position: relative; display: flex; justify-content: space-between;
  align-items: flex-start; margin: 6px 0 20px; }
.fame-rail::before, .fame-rail::after { content: ''; position: absolute; top: 13px;
  height: 3px; border-radius: 3px; }
.fame-rail::before { left: 8%; right: 8%; background: var(--border); }
.fame-rail::after  { left: 8%; width: calc((100% - 16%) * var(--fillw, 0));
  background: var(--accent-3); box-shadow: 0 0 10px rgba(255,184,0,0.5); transition: width 0.35s ease; }
.fame-node { position: relative; z-index: 1; width: 16%; background: none; border: 0; padding: 0;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.fame-node-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: #0d0a14; border: 2px solid var(--border); color: var(--muted);
  font-weight: 800; font-size: 13px; transition: all 0.2s; }
.fame-node.reached .fame-node-dot { background: var(--accent-3); border-color: var(--accent-3); color: #1a1525; }
.fame-node.current .fame-node-dot { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255,62,165,0.25); }
.fame-node.active .fame-node-dot { outline: 2px solid var(--accent); outline-offset: 2px; }
.fame-node-name { font-size: 9.5px; line-height: 1.15; text-align: center; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.03em; max-width: 84px; }
.fame-node.active .fame-node-name { color: var(--ink); font-weight: 700; }

.fame-panel { display: none; }
.fame-panel.active { display: block; }
/* Fade only on an explicit tab switch (.fame-anim), never on a data re-render —
   otherwise every pip click visibly pops the whole panel back in. */
.fame-panel.fame-anim { animation: famefade 0.25s ease; }
@keyframes famefade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.fame-panel-head { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.fame-panel-title { display: flex; align-items: baseline; gap: 8px; }
.fame-tierno { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.fame-panel-name { font-family: var(--font-marker); font-size: 22px; color: var(--accent); }
.fame-advance { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }
.fame-advance-num { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.fame-pips { display: flex; gap: 5px; flex-wrap: wrap; }
.fame-pip { width: 24px; height: 24px; border-radius: 6px; border: 2px solid var(--border);
  background: #0d0a14; color: transparent; font-size: 15px; font-weight: 900; line-height: 1;
  display: grid; place-items: center; padding: 0; cursor: default; transition: all 0.12s; }
.fame-pip.filled { background: var(--accent-3); border-color: var(--accent-3); color: #1a1525; }
.fame-pip.next { border-color: var(--accent); border-style: dashed;
  box-shadow: 0 0 0 3px rgba(255,62,165,0.18); cursor: pointer; }
.fame-pip.next:hover { background: rgba(255,62,165,0.15); }
.fame-pip[data-fame] { cursor: pointer; }
.fame-pip.filled[data-fame="down"]:hover { filter: brightness(1.12); }
.fame-panel-blurb { color: var(--muted); font-size: 13px; font-style: italic;
  margin: 0 0 10px; line-height: 1.4; }
.fame-benefits { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.fame-benefit { font-size: 11px; background: rgba(124,255,90,0.12); color: var(--good);
  border: 1px solid rgba(124,255,90,0.3); border-radius: 12px; padding: 2px 9px; }
.fame-perks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.perk { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; align-items: center;
  background: #0d0a14; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font-size: 12px; cursor: pointer; }
.perk input { margin: 0; }
.perk-cost { width: 20px; height: 20px; border-radius: 50%; background: var(--accent-3);
  color: #1a1525; font-weight: 800; font-size: 11px; display: grid; place-items: center; }
.perk-body { display: flex; flex-direction: column; min-width: 0; }
.perk-name { font-weight: 700; }
.perk-effect { color: var(--muted); }
.perk.owned { border-color: var(--good); }
.perk.owned .perk-name { color: var(--good); }
.perk.owned .perk-cost { background: var(--good); }
.perk.locked { opacity: 0.5; cursor: not-allowed; }
.perk.tier-locked .perk-cost { background: var(--border); color: var(--muted); }

@media (max-width: 640px) {
  .fame-perks { grid-template-columns: 1fr; }
  .fame-node-name { font-size: 8px; }
}

/* ===== Collaborative edit locks ===== */
.locked-edit { opacity: 0.9; cursor: not-allowed; }
.edit-flag { font-size: 11px; font-weight: 700; margin: 2px 0 6px; }
.edit-flag::before { content: '✎ '; }

/* ============================================================
   Whiteboard view (v2 — vanilla canvas)
   ============================================================ */
/* On the World Map view, the page consumes the whole viewport edge-to-edge. */
body.view-world { overflow: hidden; margin: 0; padding: 0; }
body.view-world .site-footer { display: none; }
html.view-world, body.view-world { height: 100%; }

.whiteboard-view {
  /* Anchor to the viewport so nothing in normal flow can push the bottom edge
     off-screen. The 49px top offset is the sticky topbar's height. Break out
     of the shared .sheet-view shell (which adds 22px padding + 920px max). */
  position: fixed;
  top: 49px; left: 0; right: 0; bottom: 0;
  max-width: none !important;
  padding: 0 !important;
  margin: 0 !important;
  min-height: 0;
  overflow: hidden;
  z-index: 1;
}
/* Toolbar stack — floats above the canvas; its height changes don't move
   the map. The two rows are wrapped in a flex column so the second row
   automatically tracks the first row's height. */
.wb-toolbar-stack {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  flex-direction: column;
  z-index: 4;
  pointer-events: none;           /* per-row .wb-toolbar/.wb-tools-row re-enable */
}
.wb-toolbar, .wb-tools-row {
  display: flex;
  gap: 8px;
  /* A little extra top padding so the icons clear the topbar's bottom edge
     and don't feel like they're stuck to it. */
  padding: 14px 8px 8px;
  align-items: center;
  justify-content: center;          /* center the controls on the toolbar */
  background: rgba(20, 12, 28, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
  flex-wrap: wrap;
  pointer-events: auto;
}
/* The end-of-row spacer becomes a thin gap — everything centers as one cluster
   instead of being pinned to opposite edges. */
.wb-tools-row .wb-spacer { width: 18px; }
/* Single source of truth for the canvas wrap — see the merged rule below. */
.wb-toolbar .wb-spacer { flex: 1; }
.wb-toolbar button,
.wb-toolbar select,
.wb-tools-row button {
  background: rgba(255,255,255,0.08);
  color: var(--ink, #fff);
  border: 1px solid var(--border, rgba(255,255,255,0.16));
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.wb-toolbar button:hover,
.wb-tools-row button:hover { background: rgba(255,255,255,0.16); }

.wb-tool-group { display: inline-flex; gap: 4px; }
.wb-tool.active { background: var(--c-magenta, #c0398f); border-color: var(--c-magenta-deep, #9a2872); }

.wb-colors { display: inline-flex; gap: 6px; align-items: center; }
.wb-swatch {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  cursor: pointer;
  padding: 0;
}
.wb-swatch.active { border-color: var(--c-magenta, #c0398f); outline: 2px solid rgba(255,255,255,0.7); }

/* Custom-color picker styled as one more swatch — the <input type="color"> is
   invisible but covers the circle, so clicking opens the system picker. */
.wb-swatch-custom {
  position: relative;
  display: inline-block;
  background: conic-gradient(from 0deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  overflow: hidden;
}
.wb-swatch-custom input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  opacity: 0;
  cursor: pointer;
}

/* Icon toolbar buttons (compound selector beats the generic .wb-tools-row button padding) */
.wb-toolbar .wb-icon-btn,
.wb-tools-row .wb-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  box-sizing: border-box;
  width: 38px; height: 34px;
  padding: 0;
}
.wb-icon-btn svg {
  width: 20px; height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.wb-width-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; opacity: 0.8; }
.wb-width-label { display: inline-flex; align-items: center; gap: 6px; }

/* Shapes popover */
.wb-shapes-menu {
  display: flex; gap: 4px;
  padding: 6px;
  background: var(--panel-2, #1c1620);
  border: 1px solid var(--border, rgba(255,255,255,0.16));
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  z-index: 1200;
}
.wb-shape-pick {
  width: 38px; height: 34px;
  font-size: 20px; line-height: 1;
  color: var(--ink, #fff);
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border, rgba(255,255,255,0.16));
  border-radius: 6px;
  cursor: pointer;
}
.wb-shape-pick:hover { background: rgba(255,255,255,0.16); }

.wb-zorder { display: inline-flex; gap: 2px; align-items: center; }

.wb-fonts { display: inline-flex; gap: 4px; align-items: center; }
.wb-font-btn {
  min-width: 30px; height: 26px;
  padding: 0 6px;
  font-size: 15px; line-height: 1;
  color: var(--ink, #fff);
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border, rgba(255,255,255,0.16));
  border-radius: 6px;
  cursor: pointer;
}
.wb-font-btn.active { background: var(--c-magenta, #c0398f); border-color: var(--c-magenta-deep, #9a2872); }

.wb-width-label { display: inline-flex; align-items: center; gap: 6px; font-family: inherit; color: var(--ink, #fff); }
.wb-width { width: 120px; }

.wb-canvas-wrap {
  /* Fill the .whiteboard-view panel completely (the toolbar floats over it).
     The stage is positioned within it via inline left/top from wbApplyView. */
  position: absolute;
  inset: 0;
  background: transparent;        /* the map floats over the app gradient */
  overflow: hidden;
  touch-action: none;             /* we own wheel/pointer gestures */
}
.wb-stage {
  position: absolute;
  left: 0; top: 0;
  /* left/top/width/height set inline by wbApplyView */
}
.wb-bg {
  position: absolute;
  /* left/top/width/height set inline by wbApplyView (the map's centered sub-rect) */
  object-fit: fill;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}
.wb-canvas {
  position: absolute;
  inset: 0;
  touch-action: none;
  cursor: crosshair;
}
/* The foreground canvas is purely visual — pointer events always pass through
   to objects below it. The bg canvas is the pointer surface (in drawing mode)
   and is toggled by wbApplyToolMode. */
.wb-canvas-fg { pointer-events: none !important; }

/* Stroke-layer toggle button — blue arrow up = draw on top; magenta arrow down = draw under. */
.wb-stroke-layer.layer-up   { background: #1e88e5; border-color: #1565c0; color: #fff; }
.wb-stroke-layer.layer-down { background: var(--c-magenta, #c0398f); border-color: var(--c-magenta-deep, #9a2872); color: #fff; }
.wb-stroke-layer .wb-layer-svg { stroke: currentColor; }
.wb-objects { position: absolute; inset: 0; }
.wb-cursors { position: absolute; inset: 0; pointer-events: none; }

/* Brush-size preview circle (follows the pointer in pen/eraser modes). */
.wb-brush-preview {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5);
  z-index: 5;
}
/* Rotation handle — a small dot above the top edge, connected by a stem. */
.wb-obj-rot {
  position: absolute;
  left: 50%;
  top: -32px;
  width: 14px; height: 14px;
  margin-left: -7px;
  background: var(--c-magenta, #c0398f);
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: grab;
  pointer-events: auto;
}
.wb-obj-rot:active { cursor: grabbing; }
.wb-obj-rot-stem {
  position: absolute;
  left: 50%;
  top: -22px;
  width: 2px; height: 22px;
  margin-left: -1px;
  background: var(--c-magenta, #c0398f);
  pointer-events: none;
}

.wb-brush-preview[data-tool="eraser"] {
  background: rgba(255,255,255,0.08);
  border-style: dashed;
  border-color: rgba(255,255,255,0.85);
}

/* Pan cursors */
.wb-canvas-wrap.space-pan { cursor: grab; }
.wb-canvas-wrap.space-pan .wb-canvas,
.wb-canvas-wrap.space-pan .wb-objects { cursor: grab; pointer-events: none; }
.wb-canvas-wrap.panning,
.wb-canvas-wrap.panning .wb-canvas { cursor: grabbing; }
.wb-cursor {
  position: absolute;
  top: 0; left: 0;
  transform: translate(0, 0);
  display: flex; align-items: center; gap: 4px;
  pointer-events: none;
  font: 11px var(--font-hand, sans-serif);
  white-space: nowrap;
}
.wb-cursor-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}
.wb-cursor-label {
  padding: 1px 6px;
  border-radius: 3px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* Objects layer (emoji / image / text) */
.wb-obj {
  position: absolute;
  box-sizing: border-box;
  user-select: none;
}
.wb-obj.selected { outline: 2px solid var(--c-magenta, #c0398f); outline-offset: 2px; }
.wb-obj-text {
  width: 100%; height: 100%;
  display: flex; align-items: center;
  font-family: var(--font-hand, sans-serif);
  line-height: 1.1; white-space: pre-wrap; word-break: break-word;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.wb-obj svg, .wb-obj img { pointer-events: none; }
.wb-obj-handle {
  position: absolute;
  right: -7px; bottom: -7px;
  width: 14px; height: 14px;
  background: var(--c-magenta, #c0398f);
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: nwse-resize;
  pointer-events: auto;
}
.wb-obj-text[contenteditable="true"] {
  outline: 1px dashed rgba(255,255,255,0.6);
  cursor: text;
}
.wb-tool-select.active, .wb-tool-text.active { background: var(--c-magenta, #c0398f); border-color: var(--c-magenta-deep, #9a2872); }

/* ============================================================
   Roll-card entry animations.
   Anchor flair particles (sparkles / dust puffs) to the card.
   ============================================================ */
.roll-card { position: relative; }

/* Default pop-in with overshoot — every roll card uses this when freshly
   appended. The .rc-enter class is added at append time and self-removes after
   the animation ends so re-layouts (e.g. delete) don't replay it. */
@keyframes rcPop {
  0%   { opacity: 0; transform: scale(0.78) translateY(-10px); }
  60%  { opacity: 1; transform: scale(1.04) translateY(0); }
  100% { transform: scale(1); }
}
.roll-card.rc-enter { animation: rcPop 520ms cubic-bezier(.34, 1.56, .64, 1) both; }

/* Disaster roll type gets a heavier drop from above instead of the pop.
   Distance is kept under ~90px so .feed-area's overflow-y: auto (which
   implicitly clips overflow-x too per CSS spec) doesn't eat the off-screen
   portion. The accelerating ease + landing squash sell "falling object".  */
@keyframes rcDrop {
  0%   { opacity: 0; transform: translateY(-90px) rotate(-6deg) scaleY(0.95); }
  60%  { opacity: 1; transform: translateY(0)     rotate(2deg)  scaleY(1);    }
  72%  { transform: translateY(0) rotate(0) scale(1.04, 0.84);                }
  85%  { transform: translateY(0) rotate(0) scale(0.98, 1.06);                }
  100% { transform: translateY(0) rotate(0) scale(1);                          }
}
.roll-card.rc-enter-drop { animation: rcDrop 720ms cubic-bezier(.55, .02, .85, .55) both; }

/* Outcome flair layered on top of the entry animation. The pulse runs longer
   and brighter so it reads even against the already-green success background. */
@keyframes rcSuccessPulse {
  0%   { box-shadow: 0 0 0 0 rgba(124, 255, 90, 0); }
  20%  { box-shadow: 0 0 36px 10px rgba(124, 255, 90, 0.75); }
  100% { box-shadow: 0 0 0 0 rgba(124, 255, 90, 0); }
}
.roll-card.rc-enter.rc-out-success {
  animation: rcPop         520ms cubic-bezier(.34, 1.56, .64, 1) both,
             rcSuccessPulse 1300ms ease-out 200ms both;
}

/* Partial — no outcome-specific flair; it just uses the default rcPop pop-in
   (the amber pulse / old wobble read as noise on a mixed result). */

@keyframes rcFailShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-5px); }
  30% { transform: translateX(5px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  80% { transform: translateX(-2px); }
}
@keyframes rcFailFlash {
  0%   { box-shadow: 0 0 0 0 rgba(255, 106, 61, 0); }
  30%  { box-shadow: 0 0 0 6px rgba(255, 106, 61, 0.55); }
  100% { box-shadow: 0 0 0 0 rgba(255, 106, 61, 0); }
}
.roll-card.rc-enter.rc-out-fail .rc-body {
  animation: rcFailShake 360ms ease-out 380ms both;
}
.roll-card.rc-enter.rc-out-fail {
  animation: rcPop       520ms cubic-bezier(.34, 1.56, .64, 1) both,
             rcFailFlash 720ms ease-out 300ms both;
}
/* Drop + flash on disaster-type fails (so the drop isn't overwritten). */
.roll-card.rc-enter-drop.rc-out-fail {
  animation: rcDrop      720ms cubic-bezier(.55, .02, .85, .55) both,
             rcFailFlash 720ms ease-out 460ms both;
}
.roll-card.rc-enter-drop.rc-out-fail .rc-body {
  animation: rcFailShake 360ms ease-out 540ms both;
}

/* Particles — absolutely positioned inside .roll-card.
   --dx / --rot are set per-particle inline by JS so each one drifts
   at a different angle. */
.rc-flair {
  position: absolute;
  pointer-events: none;
  left: 50%; top: 50%;
  font-size: 20px;
  line-height: 1;
  z-index: 2;
  will-change: transform, opacity;
}
.rc-flair.sparkle {
  color: #fff;
  text-shadow: 0 0 10px rgba(124, 255, 90, 0.95),
               0 0 22px rgba(124, 255, 90, 0.6);
  animation: rcSparkleRise 1100ms cubic-bezier(.2, .7, .2, 1) forwards;
}
@keyframes rcSparkleRise {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(0deg); }
  20%  { opacity: 1; }
  100% { opacity: 0;
         transform: translate(calc(-50% + var(--dx, 0px)),
                              calc(-50% - 80px)) scale(1.1) rotate(var(--rot, 30deg)); }
}
.rc-flair.puff {
  font-size: 32px;
  animation: rcPuffOut 850ms ease-out forwards;
}
@keyframes rcPuffOut {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  25%  { opacity: 0.95; }
  100% { opacity: 0;
         transform: translate(calc(-50% + var(--dx, 0px)),
                              calc(-50% + var(--dy, -16px))) scale(1.8); }
}

/* Dice spin — JS swaps textContent through random faces while this class
   is on. The slight 3D flip sells the "still rolling" feel. */
@keyframes rcDieSpin {
  0%   { transform: rotateX(0)    scale(1); }
  50%  { transform: rotateX(180deg) scale(1.08); }
  100% { transform: rotateX(360deg) scale(1); }
}
.die.rc-spin { animation: rcDieSpin 140ms linear infinite; }
.die.rc-lock {
  animation: rcDieLock 220ms cubic-bezier(.34, 1.56, .64, 1) both;
}
@keyframes rcDieLock {
  0%   { transform: scale(1.25); }
  60%  { transform: scale(0.92); }
  100% { transform: scale(1); }
}

/* Respect reduced-motion: kill the showy stuff but keep a tiny fade so
   cards don't pop in jarringly. */
@media (prefers-reduced-motion: reduce) {
  .roll-card.rc-enter,
  .roll-card.rc-enter-drop,
  .roll-card.rc-enter.rc-out-success,
  .roll-card.rc-enter.rc-out-fail,
  .roll-card.rc-enter-drop.rc-out-fail {
    animation: rcReducedFade 160ms ease-out both;
  }
  .roll-card.rc-enter .rc-body,
  .roll-card.rc-enter-drop .rc-body { animation: none; }
  .rc-flair, .die.rc-spin, .die.rc-lock { animation: none; display: none; }
  @keyframes rcReducedFade { from { opacity: 0; } to { opacity: 1; } }
}
