:root, [data-theme="midnight"] {
  --bg:        #15131f;
  --surface:   #1b182a;
  --surface-2: #1c1930;
  --surface-3: #241f3a;
  --line:      #2c2740;
  --line-2:    #3a3358;
  --text:      #e8e6f0;
  --muted:     #8a83a8;
  --accent:    #7c63d8;
  --accent-2:  #5b3fa8;
  --accent-light: #b9a3ff;
  --amber:     #d8af52;
  --amber-bg:  #211c14;
  --font:      ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gap:       12px;
}

/* Deathmatch Island — stark black + signature orange-red (#ff4600),
   bold Helvetica. See https://www.deathmatchis.land/ */
[data-theme="deathmatch"] {
  --bg:        #0b0b0b;
  --surface:   #151515;
  --surface-2: #121212;
  --surface-3: #1f1f1f;
  --line:      #262626;
  --line-2:    #3a3a3a;
  --text:      #fffffd;
  --muted:     #8f8f8f;
  --accent:    #ff4600;
  --accent-2:  #c23300;
  --accent-light: #ff8a4d;
  --amber:     #ffae57;
  --amber-bg:  #2a1505;
  --font:      "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
/* Force the built-in [hidden] semantics to win over any class-level
   display rule. Without !important, a sibling `display:flex/grid` rule
   beats the UA stylesheet's `[hidden] { display: none }`. */
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  transition: background-color .2s ease, color .2s ease; }
body { min-height: 100dvh; }

/* ---- Landing ---- */
body.landing { display: grid; place-items: center; padding: 24px; min-height: 100dvh; }
.landing-card { max-width: 420px; text-align: center; }
.brand { font-size: 36px; letter-spacing: -0.5px; margin: 0; }
.brand .dot { color: var(--accent); }
.tagline { color: var(--muted); margin: 6px 0 20px; }

/* Landing vanity counters. */
.stats {
  list-style: none; margin: 28px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 14px 18px; max-width: 360px; margin-inline: auto;
}
.stats li {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 8px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface);
}
.stats strong {
  font-size: 24px; font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--accent-light);   /* solid + light so it reads on the dark card */
}
.stats span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.stats li.live strong { position: relative; }
.stats li.live span::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: #4ad97a; margin-right: 5px; vertical-align: middle;
  box-shadow: 0 0 6px #4ad97a;
}
.cta {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: none; padding: 14px 22px; border-radius: 12px;
  font-weight: 800; font-size: 16px; cursor: pointer;
}
.cta:active { transform: translateY(1px); }
.err { color: #ffb4a3; margin-top: 12px; font-size: 13px; }

/* ===========================================================
   ROOM
   Single column: topbar (auto) / feed (1fr, scrolls) / tray (auto).
   The feed is the sole results area — a chat-style log of roll cards.
   =========================================================== */
body.room {
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "topbar"
    "feed"
    "tray";
  height: 100dvh;
  overflow: hidden;            /* no page scroll — the feed scrolls instead */
}
.topbar { grid-area: topbar; }
.feed   { grid-area: feed; }
.tray   { grid-area: tray; }
#dice-audio { display: none; }

/* ---- Topbar (centered avatar row + invite "+" button) ---- */
.topbar {
  position: relative;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
}
.topbar-actions {
  position: absolute; top: 50%; right: 14px; transform: translateY(-50%);
  display: flex; gap: 8px;
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  background: transparent; border: 1px solid var(--line-2);
  color: var(--text); font-size: 18px; line-height: 1;
  display: grid; place-items: center; cursor: pointer;
  transition: border-color .15s, opacity .15s, transform .1s;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn:active { transform: scale(.94); }
.sound-btn[aria-pressed="false"] { opacity: .55; }

/* Left-hand topbar group: heart (always) + Rolls toggle (phones only). */
.topbar-left {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  display: flex; gap: 8px; align-items: center;
}
.heart-btn { text-decoration: none; font-size: 17px; }
.heart-btn:hover { border-color: #ff6b81; }

.avatar-stack {
  display: flex; justify-content: center; align-items: center;
  gap: 10px; flex-wrap: wrap;
}
.topbar .av {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700; color: var(--bg);
  position: relative;
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.topbar .av.offline { outline-color: var(--line-2); opacity: 0.5; }
.topbar .av .online {
  position: absolute; top: -2px; right: -2px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #4ad97a; outline: 2px solid var(--surface-2);
}
.invite-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: transparent;
  border: 2px dashed var(--line-2);
  color: var(--muted);
  display: grid; place-items: center;
  cursor: pointer;
  font-size: 22px; line-height: 1; padding-bottom: 2px;
  transition: color .15s, border-color .15s;
}
.invite-btn:hover { color: var(--accent); border-color: var(--accent); }
.invite-btn:active { transform: translateY(1px); }

/* ---- Feed: the single central column of roll cards ----
   The sole results area. Scrolls vertically; cards are bottom-anchored
   (newest at the bottom, older pushed up) so it reads like a chat log. */
.feed {
  position: relative;
  overflow-y: auto;
  min-width: 0;                /* allow the column to shrink, not overflow */
  display: flex; flex-direction: column;
}
.feed-empty {
  margin: auto; text-align: center;
  color: var(--muted); font-size: 15px;
}
.feed-empty p { margin: 0; }
.feed-list {
  margin-top: auto;            /* anchor to the bottom when the list is short */
  width: 100%; max-width: 680px; margin-left: auto; margin-right: auto;
  display: flex; flex-direction: column; gap: 14px;
  padding: 20px 16px;
}

/* Roll card — a boxed result: who/when header, formula + total, dice rows. */
.rcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 12px;
  animation: cardIn .25s ease both;
}
.rcard.me { border-color: var(--accent-2); }
.rcard.hidden-roll { border-style: dashed; border-color: var(--amber); background: var(--amber-bg); }
.rcard-h { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.rcard-h .av {
  width: 36px; height: 36px; border-radius: 50%; flex: 0 0 36px;
  display: grid; place-items: center;
  font-size: 16px; font-weight: 700; color: var(--bg);
}
.rcard-h .name { font-weight: 700; font-size: 19px; color: var(--text); flex: 0 0 auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.rcard-h .lock { color: var(--amber); font-size: 12px; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rcard-h .time {
  margin-left: auto; flex: 0 0 auto; padding-left: 6px;
  color: var(--muted); font-size: 12px; cursor: help; white-space: nowrap;
}
.rcard-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 18px;
}
.rcard-formula {
  font-size: 18px; font-weight: 600; letter-spacing: .3px;
  color: var(--muted); flex: 1; min-width: 0; line-height: 1.3;
}
.rcard-total {
  font-size: 44px; font-weight: 800; line-height: 1; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.rcard-rows { display: flex; flex-direction: column; gap: 7px; }
/* "Together" layout: all dice flow in one wrapping row, no per-type rows. */
.rcard-rows.together { flex-direction: row; flex-wrap: wrap; gap: 8px; }
.rcard-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rcard-again, .rcard-reroll {
  background: transparent; border: 1px solid var(--line-2);
  color: var(--muted); border-radius: 8px;
  padding: 7px 14px; font-size: 12px; font-weight: 700; cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.rcard-again:hover, .rcard-reroll:hover { color: var(--accent); border-color: var(--accent); }
.rcard-again:active, .rcard-reroll:active { transform: translateY(1px); }
.rcard-again[disabled], .rcard-reroll[disabled] { opacity: .5; cursor: default; }
/* Reroll is the primary action when dice are selected — fill it in. */
.rcard-reroll { background: var(--accent); border-color: var(--accent); color: #fff; }
.rcard-reroll:hover { background: var(--accent-light); border-color: var(--accent-light); color: #1a1430; }

/* ---- Dice rows (shared rich rendering, used inside each card) ---- */
.stage-rows { display: flex; flex-direction: column; gap: 7px; }
.stage-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 5px 12px;
}
.stage-row .row-icon { width: 30px; height: 30px; flex: 0 0 30px; }
.stage-row .row-icon svg { width: 30px; height: 30px; }
.stage-row .row-label { font-size: 14px; color: var(--muted); width: 48px; }
.stage-row .row-faces { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.stage-face {
  position: relative; display: grid; place-items: center;
  width: 56px; height: 56px;
  /* Each die slides up into place when a fresh result renders. The per-die
     animation-delay is set inline in JS for a staggered cascade. */
  animation: dieIn .3s cubic-bezier(.2,.9,.3,1.2) both;
}
.stage-face svg { position: absolute; inset: 0; }
.stage-face .face {
  position: relative; z-index: 1;
  font-weight: 800; color: #fff; font-size: 19px;
  text-shadow: 0 1px 2px rgba(0,0,0,.7);
}

@keyframes dieIn {
  from { opacity: 0; transform: translateY(22px) scale(.7); }
  to   { opacity: 1; transform: none; }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* Highlight outline — the .high class is added by the renderer only when the
   room highlight mode marks that die (Off / Highest N / Per type). Stacked
   drop-shadows follow the SVG's alpha edge, so the outline traces the actual
   die silhouette rather than boxing the cell. */
.stage-face.high svg {
  filter:
    drop-shadow( 1.5px 0 0 #fff)
    drop-shadow(-1.5px 0 0 #fff)
    drop-shadow( 0  1.5px 0 #fff)
    drop-shadow( 0 -1.5px 0 #fff)
    drop-shadow( 0  0 3px rgba(255,255,255,.5));   /* faint glow to lift it off the gems */
}
/* Deathmatch — no glow (doesn't match the stark look). The outline colour flips
   by layout so it always contrasts with what's BEHIND the die:
     • By type  → dice sit in dark rows → orange (accent) outline.
     • Together → dice sit on the orange card → black outline.
   Only the silhouette is traced; the die itself is never tinted. */
[data-theme="deathmatch"] .stage-face.high svg {
  filter:
    drop-shadow( 2px 0 0 var(--accent))
    drop-shadow(-2px 0 0 var(--accent))
    drop-shadow( 0  2px 0 var(--accent))
    drop-shadow( 0 -2px 0 var(--accent));
}
[data-theme="deathmatch"] .rcard-rows.together .stage-face.high svg {
  filter:
    drop-shadow( 2px 0 0 #0b0b0b)
    drop-shadow(-2px 0 0 #0b0b0b)
    drop-shadow( 0  2px 0 #0b0b0b)
    drop-shadow( 0 -2px 0 #0b0b0b);
}

/* ---- Build preview — the pool YOU are assembling, over the darkened feed.
       Occupies the same grid cell as the feed (so the tray stays tappable),
       laying a dark scrim over the results. Each die type shows its shape above
       the NdX label; the modifier trails as a ± segment. ---- */
.build-overlay {
  grid-area: feed; z-index: 5;
  background: rgba(8, 6, 16, .82);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; overflow: auto;
  animation: cardIn .15s ease both;
}
[data-theme="deathmatch"] .build-overlay { background: rgba(0, 0, 0, .85); }
.build-inner {
  display: flex; align-items: flex-end; justify-content: center;
  flex-wrap: wrap; gap: 14px 16px; max-width: 840px;
}
.build-seg { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.build-seg svg { width: 60px; height: 60px; }
.build-seg .ico {
  width: 60px; height: 60px; display: grid; place-items: center;
  font-size: 46px; font-weight: 300; color: var(--muted); line-height: 1;
}
.build-seg .label { font-size: 34px; font-weight: 800; letter-spacing: .5px; color: var(--text); }
/* "Mod" caption sits below the modifier segment without affecting its height,
   so the dice/labels stay aligned. */
.build-seg .pill {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  margin-top: 8px; font-size: 11px; font-weight: 700; letter-spacing: .5px;
  color: var(--muted); background: var(--surface-3); border-radius: 999px; padding: 2px 10px; white-space: nowrap;
}
.build-plus { font-size: 36px; font-weight: 300; color: var(--muted); padding-bottom: 6px; }
[data-theme="deathmatch"] .build-seg { color: #f2f2f2; }   /* mono dice render white */

/* Selective reroll. On your own cards the dice are tappable to select; selected
   dice get a solid ring + lift; a die that was just rerolled wears a small
   corner pip so you can see what changed. */
.rcard.selectable .stage-face { cursor: pointer; }
.rcard.selectable .stage-face:hover { transform: translateY(-2px); }
.stage-face.selected { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.stage-face.rerolled::after {
  content: "↻"; position: absolute; top: -7px; right: -7px; z-index: 3;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 800; line-height: 16px; text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}

/* ---- Deathmatch: roll cards become orange boxes with black text (the brand
       look), with the inner dice trays kept dark so the white dice read. ---- */
[data-theme="deathmatch"] .rcard {
  background: var(--accent); border-color: #ff6a33; color: #0b0b0b;
}
[data-theme="deathmatch"] .rcard.me { border-color: #0b0b0b; }
[data-theme="deathmatch"] .rcard.hidden-roll {
  background: #d63c00; border-style: dashed; border-color: #0b0b0b;
}
[data-theme="deathmatch"] .rcard-h .name { color: #0b0b0b; }
[data-theme="deathmatch"] .rcard-formula { color: rgba(0,0,0,.72); }
[data-theme="deathmatch"] .rcard-total {
  background: none; -webkit-background-clip: border-box; background-clip: border-box;
  color: #0b0b0b;
}
[data-theme="deathmatch"] .rcard-h .time,
[data-theme="deathmatch"] .rcard-h .lock { color: rgba(0,0,0,.65); }
[data-theme="deathmatch"] .rcard-h .av { box-shadow: 0 0 0 1px rgba(0,0,0,.35); }
[data-theme="deathmatch"] .rcard-again {
  border-color: rgba(0,0,0,.35); color: rgba(0,0,0,.7);
}
[data-theme="deathmatch"] .rcard-again:hover {
  background: #0b0b0b; color: var(--accent); border-color: #0b0b0b;
}
/* On the orange card the filled reroll reads as black-on-orange-card. */
[data-theme="deathmatch"] .rcard-reroll {
  background: #0b0b0b; border-color: #0b0b0b; color: var(--accent);
}
[data-theme="deathmatch"] .rcard-reroll:hover { background: #1a1a1a; color: #fff; }
[data-theme="deathmatch"] .stage-face.selected { outline-color: #0b0b0b; }
/* Selected recipient chip picks up the orange too. */
[data-theme="deathmatch"] .send-to-chip.on { background: #3a1505; }

/* Deathmatch dice: the monochrome set rendered as stark white (the "black &
   white" dice), with dark numbers. `color` drives the fill. */
[data-theme="deathmatch"] .dbtn,
[data-theme="deathmatch"] .stage-row .row-icon,
[data-theme="deathmatch"] .stage-face { color: #f2f2f2; }
/* Dark digit with a white halo so it reads on any facet of the light die. */
[data-theme="deathmatch"] .stage-face .face {
  color: #111; font-weight: 900;
  text-shadow: 0 0 3px #fff, 0 0 2px #fff;
}

/* ---- Tray (send-to + dice row + roll button) ---- */
.tray {
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  padding: 10px 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px;
}
.send-to { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.send-to-label {
  font-size: 11px; color: var(--muted); flex: 0 0 auto;
  text-transform: uppercase; letter-spacing: .6px;
}
.send-to-chips { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.send-to-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 12px 4px 4px;
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  user-select: none; white-space: nowrap;
  transition: color .12s, background .12s, border-color .12s, opacity .12s;
}
.send-to-chip.everyone { padding: 5px 14px; }
.send-to-chip .av {
  width: 22px; height: 22px; border-radius: 50%;
  font-size: 10px; font-weight: 700; color: var(--bg);
  display: grid; place-items: center;
}
/* Selected = this person will see the (now private) roll. */
.send-to-chip.on {
  background: #322c58; border-color: var(--accent); color: var(--text);
}
.send-to-chip.away { opacity: .55; }

.tray-dice {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
}
.dbtn {
  width: 64px; padding: 8px 4px 6px;
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  color: var(--accent);
  cursor: pointer;
  position: relative;
}
.dbtn:active { transform: translateY(1px); }
.dbtn svg { width: 38px; height: 38px; display: block; margin: 0 auto; }
.dbtn .label {
  display: block; margin-top: 2px;
  font-size: 10px; font-weight: 700;
  color: var(--muted); letter-spacing: .5px;
  text-align: center;
}
.dbtn .pip {
  position: absolute; top: 4px; right: 6px;
  background: var(--accent-2); color: #fff;
  font-size: 10px; font-weight: 800;
  padding: 1px 6px; border-radius: 10px;
}

/* Modifier row: a label, the +/- preset buttons, and a running-total chip. */
.mod-row {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; flex-wrap: wrap; margin-top: 2px;
}
.mod-title {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px;
}
.mod-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.mod-btns button {
  min-width: 40px; padding: 7px 10px;
  background: var(--surface-3); border: 1px solid var(--line-2);
  color: var(--text); border-radius: 9px;
  font-size: 13px; font-weight: 800; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.mod-btns button:hover { border-color: var(--accent); }
.mod-btns button:active { transform: translateY(1px); }
/* The ± toggle reveals/hides the whole modifier row. */
.mod-toggle { font-size: 20px; font-weight: 800; line-height: 1; }
.mod-toggle.on { border-color: var(--accent); color: var(--accent); background: var(--surface-3); }

.tray-actions {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; margin-top: 4px;
}
.clear-btn {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--muted);
  padding: 16px 22px;
  border-radius: 14px;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.clear-btn:hover { color: var(--text); border-color: var(--muted); }
.clear-btn:active { transform: translateY(1px); }

.roll-btn {
  padding: 18px 60px;
  min-width: 280px; max-width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none; border-radius: 14px;
  font-size: 18px; font-weight: 800; letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(124, 99, 216, 0.25);
}
.roll-btn:active { transform: translateY(1px); }
.roll-btn[disabled] {
  opacity: .35; cursor: not-allowed; box-shadow: none;
  background: var(--surface-3);
}

/* ---- Overlays ---- */
.overlay {
  position: fixed; inset: 0; background: rgba(10,8,18,.85);
  display: grid; place-items: center; z-index: 50; padding: 20px;
}
.name-card {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px; width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 12px;
}
.name-card h2 { margin: 0; font-size: 18px; }
.name-card input {
  background: var(--bg); border: 1px solid var(--line-2);
  color: var(--text); padding: 12px; border-radius: 10px; font-size: 16px;
}

/* ---- Theme picker modal ---- */
.theme-card {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 20px; width: 100%; max-width: 380px;
  display: flex; flex-direction: column; gap: 14px;
}
.theme-card h2 { margin: 0; font-size: 18px; }
.theme-options { display: flex; flex-direction: column; gap: 10px; }
.theme-opt {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 2px solid var(--line);
  border-radius: 12px; padding: 10px 12px; cursor: pointer;
  color: var(--text); font-size: 15px; font-weight: 600; text-align: left;
  transition: border-color .15s;
}
.theme-opt:hover { border-color: var(--line-2); }
.theme-opt.active { border-color: var(--accent); }
.theme-opt .check { margin-left: auto; color: var(--accent); font-weight: 800; opacity: 0; }
.theme-opt.active .check { opacity: 1; }
.theme-swatch {
  width: 46px; height: 46px; border-radius: 10px; flex: 0 0 46px;
  display: grid; grid-template-columns: 1fr 1fr; overflow: hidden;
  border: 1px solid rgba(255,255,255,.12);
}
.theme-swatch span { display: block; }
.swatch-midnight   .bg { background: #15131f; } .swatch-midnight   .ac { background: #7c63d8; }
.swatch-deathmatch .bg { background: #0b0b0b; } .swatch-deathmatch .ac { background: #ff4600; }
.theme-opt .label small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.theme-done {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: none; padding: 12px; border-radius: 10px;
  font-weight: 800; font-size: 15px; cursor: pointer;
}

/* ---- Settings ---- */
.settings-card { max-width: 420px; max-height: 86vh; overflow-y: auto; }
.settings-note { margin: -4px 0 4px; color: var(--muted); font-size: 12.5px; }
.settings-group-label {
  margin: 6px 0 -2px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .7px; color: var(--muted);
}
.setting-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; cursor: pointer;
}
.setting-row.col { flex-direction: column; align-items: stretch; gap: 10px; cursor: default; }
.setting-label { font-size: 15px; font-weight: 600; }

/* Segmented control (highlight mode, dice layout). */
.seg { display: flex; flex-wrap: wrap; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button {
  flex: 1 1 auto; min-width: 64px; border: 0; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 13px; font-weight: 700; white-space: nowrap;
  padding: 8px 6px; border-radius: 7px; transition: background .12s, color .12s;
}
.seg button.on { background: var(--accent); color: #fff; }
.seg button:not(.on):hover { color: var(--text); }
[data-theme="deathmatch"] .seg button.on { color: #0b0b0b; }

/* Number stepper (highest-N). */
.stepper { display: flex; align-items: center; gap: 12px; align-self: flex-start; }
.stepper button {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--surface-3); border: 1px solid var(--line-2); color: var(--text);
  font-size: 18px; font-weight: 800; cursor: pointer; line-height: 1;
}
.stepper button:hover { border-color: var(--accent); }
.stepper span { min-width: 20px; text-align: center; font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Native select, themed. */
.select {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; font-weight: 600; cursor: pointer;
}

.setting-label small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; }
.switch {
  appearance: none; -webkit-appearance: none;
  margin-left: auto; flex: 0 0 46px;
  width: 46px; height: 26px; border-radius: 999px;
  background: var(--line-2); position: relative; cursor: pointer;
  transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }

/* Room setting: hide roll totals when the room has them off. */
body.no-total .rcard-total { display: none; }

/* ---- Toast (for share clipboard) ---- */
.toast {
  position: fixed; bottom: 20%; left: 50%;
  transform: translateX(-50%);
  background: #2a2440; color: #fff;
  padding: 10px 16px; border-radius: 8px;
  font-size: 13px; z-index: 100;
}

/* ---- Phone: the feed already IS the single focus, so it just narrows. All 7
       dice fit on one row (no horizontal scroll). ---- */
@media (max-width: 720px) {
  /* Avatars: a single scrollable row, clear of the corner buttons. */
  .avatar-stack {
    justify-content: flex-start; flex-wrap: nowrap;
    overflow-x: auto; padding: 0 144px 0 56px;
    scrollbar-width: none;
  }
  .avatar-stack::-webkit-scrollbar { display: none; }
  .topbar .av { width: 32px; height: 32px; font-size: 12px; flex: 0 0 auto; }
  .invite-btn { width: 32px; height: 32px; font-size: 18px; flex: 0 0 auto; }

  .feed-list { padding: 14px 12px; }
  .rcard { padding: 14px; }
  .rcard-formula { font-size: 16px; }
  .rcard-total { font-size: 36px; }
  .stage-row { gap: 12px; padding: 10px 12px; }
  .stage-row .row-icon { width: 38px; height: 38px; flex: 0 0 38px; }
  .stage-row .row-icon svg { width: 38px; height: 38px; }
  .stage-face { width: 46px; height: 46px; }
  .stage-face .face { font-size: 16px; }

  /* Dice: a 7-column grid so every die (incl. d100) fits with no scroll. */
  .tray-dice {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px;
  }
  .dbtn { width: auto; padding: 7px 2px 5px; }
  .dbtn svg { width: 28px; height: 28px; }
  .dbtn .label { font-size: 9px; letter-spacing: 0; }
  .dbtn .pip { top: 2px; right: 3px; padding: 0 4px; font-size: 9px; }

  /* Recipient chips scroll sideways rather than stacking tall. */
  .send-to { flex-wrap: nowrap; align-items: center; }
  .send-to-label { flex: 0 0 auto; }
  .send-to-chips {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .send-to-chips::-webkit-scrollbar { display: none; }
  .send-to-chip { flex: 0 0 auto; }

  .tray-actions { gap: 8px; }
  .roll-btn { min-width: 0; flex: 1; padding: 15px; letter-spacing: 1px; }
  .clear-btn { padding: 15px 16px; }
}
