/* =====================================================================
   PATH OF PATHOS — multiplayer client styles
   ===================================================================== */
:root {
  --parchment: #dccba0;
  --parchment-deep: #c9b07c;
  --paper: #efe3c4;
  --ink: #2a1c0f;
  --ink-soft: #5a4630;
  --rule: #8a6d43;
  --crimson: #8e1b1b;
  --ochre: #b0801f;
  --lapis: #1f4a8a;
  --forest: #1f5f35;
  --gilt: #d4a93a;
  --hp: #b8322a;
  --hp-back: #4a1410;
  --mana: #2e6fd0;
  --poison: #4f8a1f;
  --shadow: rgba(42, 28, 15, 0.35);
  --backdrop: rgba(30, 20, 10, 0.6);
  --panel-bg: #f3e9cf;
  --button-bg: #2a1c0f;
  --button-ink: #efe3c4;
  --good: #2f7d32;
  --bad: #a3261f;
  --stage: #1c1410;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --parchment: #221a13;
    --parchment-deep: #17110c;
    --paper: #2e241a;
    --ink: #eadcb8;
    --ink-soft: #b9a67f;
    --rule: #6c5638;
    --shadow: rgba(0, 0, 0, 0.6);
    --backdrop: rgba(0, 0, 0, 0.7);
    --panel-bg: #2b2118;
    --button-bg: #d4a93a;
    --button-ink: #1b140d;
    --good: #6cc070;
    --bad: #ff7a6a;
  }
}

:root[data-theme="dark"] {
  --parchment: #221a13;
  --parchment-deep: #17110c;
  --paper: #2e241a;
  --ink: #eadcb8;
  --ink-soft: #b9a67f;
  --rule: #6c5638;
  --shadow: rgba(0, 0, 0, 0.6);
  --backdrop: rgba(0, 0, 0, 0.7);
  --panel-bg: #2b2118;
  --button-bg: #d4a93a;
  --button-ink: #1b140d;
  --good: #6cc070;
  --bad: #ff7a6a;
}

*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(ellipse at 50% 20%, var(--parchment) 0%, var(--parchment-deep) 100%) fixed;
  background-color: var(--parchment);
  color: var(--ink);
  font-family: "Alegreya", Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.4;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow-x: hidden;
}

h1, h2, h3, .logo, .kicker {
  font-family: "IM Fell English SC", "IM Fell English", Georgia, serif;
  font-weight: 400;
  line-height: 1.1;
  margin: 0;
}

.kicker {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

button {
  font: inherit;
  cursor: pointer;
  border: 1.5px solid var(--ink);
  background: var(--button-bg);
  color: var(--button-ink);
  padding: 0.45em 0.9em;
  border-radius: 4px;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}
@media (hover: hover) {
  button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 3px 8px var(--shadow); }
}
/* No double-tap zoom or grey flash on buttons and cards. */
button, [role="button"], .card, label { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
button.quiet { background: transparent; color: var(--ink); }
button.small { font-size: 0.85rem; padding: 0.25em 0.65em; }
button.big { font-size: 1.15rem; padding: 0.6em 1.3em; font-family: "IM Fell English SC", Georgia, serif; }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.link { background: none; border: none; padding: 0; color: inherit; text-decoration: underline; font-size: inherit; }
button.link:hover { box-shadow: none; transform: none; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--gilt); outline-offset: 2px; }

button.glow { animation: glow-pulse 1.8s ease-in-out infinite; }
@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 169, 58, 0.7); }
  50% { box-shadow: 0 0 0 8px rgba(212, 169, 58, 0); }
}

input[type="text"], input[type="password"] {
  font: inherit;
  background: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--rule);
  padding: 0.4em 0.6em;
  border-radius: 4px;
  width: 100%;
}

#app {
  max-width: 1360px;
  margin: 0 auto;
  padding: 12px 16px 40px;
}

.muted { color: var(--ink-soft); }
.small { font-size: 0.85rem; }
.hint { color: var(--ink-soft); font-style: italic; }
.connecting { text-align: center; padding: 30vh 0; font-family: "IM Fell English SC", Georgia, serif; font-size: 1.6rem; color: var(--ink-soft); }

.dots { display: inline-flex; gap: 3px; margin: 0 6px 0 2px; vertical-align: middle; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: dot 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

.waiting { color: var(--ink-soft); font-style: italic; margin: 8px 0 0; }

/* =====================================================================
   PORTRAITS, BARS, BADGES
   ===================================================================== */
.portrait {
  position: relative;
  flex: none;
  width: 56px;
  aspect-ratio: 1;
  border-radius: 22%;
  border: 2px solid #2a1c0f;
  background: radial-gradient(circle at 50% 35%, var(--cls-light), var(--cls));
  box-shadow: inset 0 -6px 12px rgba(0, 0, 0, 0.25);
}
.portrait { align-self: flex-start; }
.portrait.tiny .crown { display: none; }
.portrait .portrait-svg { width: 100%; height: 100%; display: block; border-radius: 20%; }
.portrait.tiny { width: 22px; border-width: 1.5px; }
.portrait.small { width: 38px; }
.portrait.medium { width: 60px; }
.portrait.large { width: 108px; border-width: 3px; }
.portrait.dead { filter: grayscale(1) brightness(0.7); }
.portrait.dead::after {
  content: "✕";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #ff5a4a;
  font-size: 180%;
  font-weight: 700;
  text-shadow: 0 0 4px #000;
}
.portrait.tiny.dead::after { font-size: 16px; }
.portrait .crown {
  position: absolute;
  top: -12px;
  left: -6px;
  font-size: 18px;
  color: #ffd54a;
  text-shadow: 0 1px 0 #6b4f25, 0 0 6px rgba(255, 200, 60, 0.8);
  transform: rotate(-18deg);
}
.portrait.large .crown { font-size: 30px; top: -18px; }
.portrait .away {
  position: absolute;
  bottom: -6px;
  right: -6px;
  background: #b0801f;
  color: #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 11px;
  display: grid;
  place-items: center;
  border: 1.5px solid #2a1c0f;
}

.cls-warrior { --cls: #7e1d15; --cls-light: #d06a4f; }
.cls-ranger { --cls: #1f5f35; --cls-light: #7fb870; }
.cls-mage { --cls: #3d2466; --cls-light: #9a7ad0; }
.cls-priest { --cls: #9a7420; --cls-light: #f3dc8f; }

.hpbar {
  position: relative;
  height: 16px;
  background: var(--hp-back);
  border: 1.5px solid #2a1c0f;
  border-radius: 8px;
  overflow: hidden;
  margin: 3px 0;
}
.hpbar > i {
  display: block;
  height: 100%;
  background: linear-gradient(180deg, #ef6a55, var(--hp) 60%, #8a1f18);
  transition: width 0.45s cubic-bezier(.3, .8, .3, 1);
}
.hpbar > span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
  letter-spacing: 0.02em;
}
.hpbar.big { height: 22px; border-radius: 11px; }
.hpbar.big > span { font-size: 0.9rem; }

.pips { display: flex; gap: 4px; margin: 4px 0; flex-wrap: wrap; align-items: center; }
.pips i {
  width: 14px;
  height: 14px;
  transform: rotate(45deg) scale(0.8);
  border: 1.5px solid #173a6e;
  background: rgba(46, 111, 208, 0.18);
  border-radius: 2px;
  transition: background 0.3s;
}
.pips i.full { background: radial-gradient(circle at 35% 30%, #bfe0ff, #2e6fd0 60%); box-shadow: 0 0 6px rgba(80, 150, 255, 0.7); }
.pips.health-note { font-size: 0.78rem; color: var(--hp); font-weight: 700; }

.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.74rem;
  line-height: 1;
  padding: 3px 7px 3px 5px;
  border-radius: 10px;
  background: #3a2a1a;
  color: #f6e7bd;
  border: 1px solid rgba(0, 0, 0, 0.3);
  cursor: help;
}
.badge b { font-weight: 400; font-size: 0.9rem; }
.badge.tone-block { background: #4f5968; }
.badge.tone-poison { background: #3f6a18; }
.badge.tone-stun { background: #8a6d10; }
.badge.tone-buff { background: #9a5a12; }
.badge.tone-mana { background: #1f4a8a; }
.badge.tone-ward { background: #5b3a8a; }
.badge.tone-bad { background: #8e1b1b; }

/* =====================================================================
   CARDS
   ===================================================================== */
.card {
  --cw: 170px;
  position: relative;
  flex: none;
  width: var(--cw);
  aspect-ratio: 874 / 1240;
  container-type: inline-size;
  color: var(--card-ink);
  user-select: none;
  transition: transform 0.18s cubic-bezier(.3, .8, .3, 1), filter 0.18s, box-shadow 0.18s;
}
.card.size-mini { --cw: 40px; }
.card.size-small { --cw: 104px; }
.card.size-hand { --cw: 146px; }
.card.size-zoom { --cw: 240px; }
.card.size-fly { --cw: 190px; }

/* Each kind has its own printed frame (public/artwork/cards), with "cost" and an
   empty circle in it. The art, the number and the words sit on top. */
.kind-skill { --card-ink: #4c2e4e; --frame: url("/artwork/cards/frame-skill.webp"); --back: url("/artwork/cards/back-skill.webp"); --gem-x: 86.3%; --gem-y: 11.5%; --gem-size: 10.2cqw; }
.kind-item { --card-ink: #2e394d; --frame: url("/artwork/cards/frame-item.webp"); --back: url("/artwork/cards/back-item.webp"); --gem-x: 87.4%; --gem-y: 10.7%; --gem-size: 8.9cqw; }
.kind-equipment { --card-ink: #4f4d2f; --frame: url("/artwork/cards/frame-equipment.webp"); --back: url("/artwork/cards/back-equipment.webp"); --gem-x: 15.5%; --gem-y: 13.3%; --gem-size: 10.2cqw; }

.card-frame {
  position: absolute;
  inset: 0;
  border-radius: 4cqw;
  background: #ecd2ab var(--frame) center / 100% 100% no-repeat;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

/* The art is cut from the top of the printed card, so it lands where it was printed. */
.card-art {
  position: absolute;
  inset: 0 0 auto;
  height: 72.34%;
  display: grid;
  place-items: center;
}
.card-art .art-svg { width: 100%; height: 100%; display: block; }
.card-art svg.art-svg { box-sizing: border-box; padding: 20cqw 16cqw 6cqw; overflow: visible; }

.card-gem {
  position: absolute;
  left: var(--gem-x);
  top: var(--gem-y);
  transform: translate(-50%, -50%);
  font-family: "Tinos", "Times New Roman", Georgia, serif;
  font-weight: 700;
  font-size: var(--gem-size);
  line-height: 1;
  z-index: 2;
}
.card-gem.cheaper { color: #1c7a2c; }

.card-words {
  position: absolute;
  inset: 70.4% 13.5% 2.2%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6cqw;
  font-family: "Tinos", "Times New Roman", Georgia, serif;
  font-weight: 700;
  text-align: center;
  z-index: 1;
}
.card-name { font-size: 7.4cqw; line-height: 1.1; white-space: nowrap; }
.card-name.medium { font-size: 6.6cqw; }
.card-name.long { font-size: 5.9cqw; }
.card-limit { font-size: 4.8cqw; line-height: 1; font-style: italic; font-weight: 400; }
.card-text { font-size: 6cqw; line-height: 1.12; }
.card-text.medium { font-size: 5.6cqw; }
.card-text.long { font-size: 5.1cqw; }

/* ---------- 2.5D ----------
   The frame leans towards the pointer (--rx/--ry, set by client.js), a glare
   follows it (--gx/--gy), the art slides the other way behind the frame
   (--px/--py) and the shadow falls away from the light (--sx/--sy). */
.card { perspective: 520px; }
.card-frame { transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform 0.45s cubic-bezier(.2, .8, .3, 1), box-shadow 0.3s; }
.card.tilting { z-index: 6; }
.card.tilting .card-frame {
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) scale(1.04);
  transition: transform 0.08s linear, box-shadow 0.15s;
  box-shadow: var(--sx, 0px) var(--sy, 8px) 22px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.3);
}
.card-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 0%), rgba(255, 252, 240, 0.7), rgba(255, 252, 240, 0.18) 32%, transparent 62%);
  mix-blend-mode: overlay;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 3;
}
.card.tilting .card-frame::after { opacity: 1; }
.card-art > .art-svg { transition: transform 0.45s cubic-bezier(.2, .8, .3, 1); }
.card.tilting .card-art > .art-svg { transform: translate(var(--px, 0px), var(--py, 0px)) scale(1.1); transition: transform 0.08s linear; }
/* A card held up to read turns slowly, so it reads as a thing and not a picture. */
.zoom .card:not(.tilting) .card-frame { animation: card-sway 7s ease-in-out infinite; }
@keyframes card-sway {
  0%, 100% { transform: rotateY(-9deg) rotateX(4deg); }
  50% { transform: rotateY(9deg) rotateX(-2deg); }
}

/* Real artwork (shared/artwork.json) fills the same boxes as the drawings. */
img.art-img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* ---------- Performance mode: flat cards, no decorative motion ---------- */
.performance .card-frame,
.performance .card.tilting .card-frame { transform: none; transition: none; }
.performance .card-frame::after { display: none; }
.performance .card-art > .art-svg { transform: none !important; }
.performance .zoom .card .card-frame,
.performance .enemy-frame,
.performance button.glow,
.performance .board-svg .tile.current,
.performance .board-svg .tile.reachable,
.performance .splash-rays,
.performance .fx-flycard.glowing .card-frame { animation: none; }
.performance .backdrop { backdrop-filter: none; }

/* Small cards show the picture and name; hold or tap for the full text. */
.card.size-small .card-text { display: none; }
.card.size-small .card-words { justify-content: center; inset: 70.4% 11% 5%; }
.card.size-small .card-name, .card.size-small .card-name.medium, .card.size-small .card-name.long { font-size: 10.5cqw; white-space: normal; line-height: 1; }
.card.size-small .card-limit { font-size: 7.5cqw; }
/* Mini cards are just the picture, moved down to the middle of the card. */
.card.size-mini .card-words { display: none; }
.card.size-mini .card-art { top: 14%; }

.card.clickable { cursor: pointer; }
@media (hover: hover) {
  .card.clickable:hover { transform: translateY(-6px); filter: brightness(1.05); }
}
/* Holding a card zooms it; don't also pop up the phone's copy/save menu. */
.card { -webkit-touch-callout: none; -webkit-user-select: none; }
.card.selected { transform: translateY(-12px) scale(1.04); }
.card.selected .card-frame { box-shadow: 0 0 0 3px #ffd54a, 0 0 22px 4px rgba(255, 213, 74, 0.8); }
.card.blocked .card-frame { filter: grayscale(0.7) brightness(0.8); }
.card-reason {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 8%;
  background: rgba(20, 10, 5, 0.85);
  color: #ffb4a8;
  font-size: 0.72rem;
  text-align: center;
  padding: 3px 4px;
  border-radius: 4px;
  z-index: 3;
  line-height: 1.15;
}
.size-small .card-reason { font-size: 0.64rem; bottom: 16%; }
.card.nope { animation: nope 0.4s; }
@keyframes nope {
  20% { transform: translateX(-6px) rotate(-2deg); }
  40% { transform: translateX(6px) rotate(2deg); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

.card-back-face .card-frame {
  background-image: var(--back);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 6cqw;
  color: #fff8e6;
  text-shadow: 0 1px 3px #000, 0 0 6px #000;
}
.back-label { font-family: "IM Fell English SC", Georgia, serif; font-size: 11.5cqw; white-space: nowrap; }
.back-count { font-size: 10cqw; }
.card-back {
  width: 70px;
  aspect-ratio: 5 / 7;
  border-radius: 8px;
  border: 3px solid #b0801f;
  background: repeating-linear-gradient(45deg, #3a2412 0 6px, #2a1a0c 6px 12px);
}

.card-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 6px 0 10px; }
.card-row.compact { gap: 8px; }

/* =====================================================================
   TOP BAR
   ===================================================================== */
.top-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.logo { font-size: 1.6rem; white-space: nowrap; }
.logo img { display: block; height: 38px; width: auto; filter: drop-shadow(0 1px 0 rgba(42, 28, 16, 0.45)); }
.top-bar .tools { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.party-strip { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.party-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border: 1.5px solid var(--rule);
  border-radius: 10px;
  padding: 5px 10px 5px 6px;
  min-width: 150px;
  flex: 0 1 190px;
}
.party-chip.me { border-color: var(--gilt); box-shadow: 0 0 0 2px rgba(212, 169, 58, 0.35); }
.party-chip.leader { background: linear-gradient(180deg, var(--paper), color-mix(in srgb, var(--gilt) 25%, var(--paper))); }
.party-chip .chip-body { flex: 1; min-width: 0; }
.chip-name { font-weight: 700; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-name em { font-weight: 400; font-style: normal; font-size: 0.72rem; background: var(--gilt); color: #2a1c0f; border-radius: 6px; padding: 0 5px; }
.party-chip .hpbar { height: 13px; }
.party-chip .hpbar > span { font-size: 0.66rem; }

.targetable { cursor: pointer; animation: target-pulse 1.1s ease-in-out infinite; }
@keyframes target-pulse {
  0%, 100% { box-shadow: 0 0 0 2px #ffd54a, 0 0 8px 2px rgba(255, 213, 74, 0.6); }
  50% { box-shadow: 0 0 0 4px #ffd54a, 0 0 22px 8px rgba(255, 213, 74, 0.45); }
}

/* =====================================================================
   LOBBY
   ===================================================================== */
.lobby { max-width: 1060px; margin: 0 auto; }
.lobby-hero { text-align: center; padding: 4vh 0 1rem; }
.lobby-hero h1 { font-size: clamp(2.8rem, 8vw, 5.5rem); }
/* The official logo: red and gold, with a thin shadow so the gold holds up on parchment. */
.title-logo { margin: 0; line-height: 0; }
.title-logo img { width: min(560px, 92%); height: auto; filter: drop-shadow(0 2px 0 rgba(42, 28, 16, 0.4)); }
.tagline { font-style: italic; color: var(--ink-soft); margin: 0.4rem auto 0; max-width: 46ch; }
.join-urls { text-align: center; margin: 0 auto 18px; padding: 8px 12px; background: var(--paper); border: 1.5px dashed var(--rule); border-radius: 8px; max-width: 640px; }
.join-urls code { background: var(--ink); color: var(--paper); padding: 1px 6px; border-radius: 4px; font-size: 0.95rem; user-select: all; overflow-wrap: anywhere; }
.lobby-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 18px; align-items: start; }
.lobby-form, .lobby-seats {
  background: var(--paper);
  border: 2px solid var(--rule);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 6px 18px var(--shadow);
}
.lobby-form h2, .lobby-seats h2 { font-size: 1.6rem; margin-bottom: 10px; }
.name-field { display: block; font-weight: 700; margin-bottom: 12px; }
.class-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.class-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: transparent;
  color: var(--ink);
  border: 2px solid var(--rule);
  border-radius: 10px;
  padding: 8px 6px 10px;
}
.class-card.chosen { border-color: var(--gilt); background: color-mix(in srgb, var(--gilt) 18%, transparent); box-shadow: 0 0 0 3px rgba(212, 169, 58, 0.45); }
.class-portrait {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 2px solid #2a1c0f;
  background: radial-gradient(circle at 50% 35%, var(--cls-light), var(--cls));
  overflow: hidden;
}
.class-card .class-portrait { background: radial-gradient(circle at 50% 35%, var(--cls-light), var(--cls)); }
.class-card.cls-warrior, .class-card.cls-ranger, .class-card.cls-mage, .class-card.cls-priest { --x: 0; }
.class-portrait svg { width: 100%; height: 100%; display: block; }
.class-name { font-family: "IM Fell English SC", Georgia, serif; font-size: 1.15rem; }
.class-stats { display: flex; gap: 8px; font-size: 0.8rem; font-weight: 700; }
.stat-hp { color: var(--hp); }
.stat-mana { color: var(--mana); }
.class-note { color: var(--ink-soft); font-style: italic; margin: 10px 0 0; }
.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seat { border: 1.5px solid var(--rule); border-radius: 10px; padding: 10px; text-align: center; }
.seat.me { border-color: var(--gilt); box-shadow: 0 0 0 2px rgba(212, 169, 58, 0.4); }
.seat.empty { border-style: dashed; opacity: 0.6; }
.seat-portrait { width: 72px; aspect-ratio: 1; margin: 0 auto 6px; border-radius: 14px; border: 2px solid #2a1c0f; background: radial-gradient(circle at 50% 35%, var(--cls-light, #b9a67f), var(--cls, #6c5638)); overflow: hidden; }
.seat.empty .seat-portrait { border-style: dashed; background: transparent; }
.seat-portrait svg { width: 100%; height: 100%; display: block; }
.seat-name { font-weight: 700; }
.seat-class { font-size: 0.85rem; color: var(--ink-soft); }
.host-tag { font-size: 0.7rem; background: var(--ink); color: var(--paper); border-radius: 6px; padding: 0 5px; vertical-align: 2px; font-weight: 400; }
.lobby-action { margin-top: 16px; text-align: center; }
.seat.enter { animation: pop-in 0.45s cubic-bezier(.3, 1.6, .5, 1); }

/* =====================================================================
   MAP
   ===================================================================== */
.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr);
  gap: 18px;
  align-items: start;
}
.board-wrap {
  background: var(--paper);
  border: 2px solid var(--rule);
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 6px 18px var(--shadow);
}
.board-svg { width: 100%; height: auto; display: block; }
.board-svg .tile.visited { filter: saturate(0.55) brightness(0.85); }
.board-svg .tile.current { animation: tile-glow 1.6s ease-in-out infinite; }
@keyframes tile-glow { 50% { filter: brightness(1.35); } }
.board-svg .tile.tile-step { animation: tile-step 0.6s; }
@keyframes tile-step { 0% { filter: brightness(2.2); } 100% { filter: none; } }
.board-caption { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 0.9rem; color: var(--ink-soft); }
.legend span::before {
  content: "";
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-right: 0.3em;
  vertical-align: -0.05em;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: var(--swatch);
}
.party-token { transition: transform 0.28s cubic-bezier(.4, 1.6, .5, 1); filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.5)); }

.sidebar { display: flex; flex-direction: column; gap: 14px; }
.roll-box {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--paper);
  border: 2px solid var(--rule);
  padding: 12px;
  border-radius: 10px;
  flex-wrap: wrap;
}
.roll-box.mine { border-color: var(--gilt); box-shadow: 0 0 0 3px rgba(212, 169, 58, 0.35); }
.roll-box .roll-text { flex: 1; min-width: 140px; color: var(--ink-soft); font-size: 0.92rem; }
.roll-box .roll-text strong { display: block; color: var(--ink); font-size: 1.1rem; font-family: "IM Fell English SC", Georgia, serif; font-weight: 400; }
.d4-face {
  width: 58px;
  height: 52px;
  display: grid;
  place-items: center;
  font-family: "IM Fell English SC", Georgia, serif;
  font-size: 1.6rem;
  background: linear-gradient(180deg, #e9bb42, #a87b1c);
  color: #2a1c0f;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  padding-top: 16px;
  flex: none;
}

.pack {
  background: var(--paper);
  border: 2px solid var(--rule);
  border-radius: 10px;
  padding: 12px;
}
.pack-head { display: flex; align-items: center; gap: 10px; }
.pack-head h3 { font-size: 1.35rem; }
.pack-head > button { margin-left: auto; }
.pack-sub { font-size: 0.88rem; color: var(--ink-soft); }
.pack-hint { font-size: 0.85rem; color: var(--ink-soft); margin: 8px 0 2px; }
.pack-label { font-weight: 700; margin: 10px 0 4px; font-size: 0.95rem; }
.pack-label span { font-weight: 400; color: var(--ink-soft); font-size: 0.85rem; }
.pack-row { display: flex; gap: 10px; flex-wrap: wrap; }
.pack-slot { position: relative; }
.empty-slot {
  width: 104px;
  aspect-ratio: 874 / 1240;
  border: 2px dashed var(--rule);
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  font-size: 0.8rem;
  opacity: 0.55;
}
.discard-x {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  font-size: 0.75rem;
  z-index: 4;
  opacity: 0;
  transition: opacity 0.15s;
}
.pack-slot:hover .discard-x, .discard-x:focus-visible { opacity: 1; }
@media (hover: none) { .discard-x { opacity: 0.85; } }
/* Items have their cost in the top right corner. */
.kind-item + .discard-x { right: auto; left: -8px; }

/* =====================================================================
   PANELS (event popups)
   ===================================================================== */
.backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 20;
  overflow-y: auto;
  backdrop-filter: blur(2px);
}
.panel {
  background: var(--panel-bg);
  color: var(--ink);
  border: 2px solid var(--rule);
  border-top: 6px solid var(--band, var(--ink));
  border-radius: 12px;
  width: min(680px, 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overscroll-behavior: contain;
  overflow-y: auto;
  overflow-x: hidden;
}
.panel.wide { width: min(980px, 100%); }
.panel.enter { animation: panel-in 0.5s cubic-bezier(.2, 1.2, .4, 1); }
.encounter-panel.enter { animation: encounter-flip 0.7s cubic-bezier(.2, 1, .4, 1); }
@keyframes panel-in {
  from { opacity: 0; transform: translateY(30px) scale(0.92); }
  to { opacity: 1; transform: none; }
}
@keyframes encounter-flip {
  0% { opacity: 0; transform: perspective(900px) rotateY(80deg) scale(0.8); }
  60% { opacity: 1; transform: perspective(900px) rotateY(-8deg); }
  100% { transform: none; }
}
.panel-body { padding: 16px 20px 20px; }
.panel-scene { position: relative; aspect-ratio: 16 / 6; max-height: 30vh; max-height: 30dvh; width: 100%; overflow: hidden; background: #2a1c0f; }
.panel-scene .scene-svg { width: 100%; height: 100%; display: block; }
/* The encounter cards' art is wide and painted on parchment: show all of it
   and carry the parchment out to the strip's edges. */
.panel-scene img.scene-svg { object-fit: contain; object-position: center top; background: #ecd0ac; }
.scene-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 26px 20px 10px;
  background: linear-gradient(180deg, transparent, rgba(15, 8, 3, 0.88));
  color: #f6e7bd;
}
.scene-caption .kicker { color: #e8cf8a; }
.scene-caption h2 { font-size: 2rem; text-shadow: 0 2px 4px #000; }
.flavor { font-style: italic; margin: 0 0 12px; max-width: 64ch; }
.panel .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.vote-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.vote-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  text-align: left;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--rule);
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 60px;
}
.vote-option:hover:not(:disabled) { border-color: var(--gilt); }
.vote-option.mine { border-color: var(--gilt); background: color-mix(in srgb, var(--gilt) 22%, var(--paper)); box-shadow: 0 0 0 3px rgba(212, 169, 58, 0.4); }
.vote-label { font-weight: 700; flex: 1; min-width: 100px; }
.voters { display: flex; gap: 3px; }
.voter {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1.5px solid #2a1c0f;
  background: radial-gradient(circle at 50% 35%, var(--cls-light, #b9a67f), var(--cls, #6c5638));
  overflow: hidden;
  animation: pop-in 0.35s cubic-bezier(.3, 1.6, .5, 1);
}
.voter svg { width: 100%; height: 100%; display: block; }
.your-vote { position: absolute; top: -9px; right: 10px; font-size: 0.7rem; background: var(--gilt); color: #2a1c0f; padding: 1px 7px; border-radius: 6px; }
.vote-status { font-size: 0.88rem; color: var(--ink-soft); margin: 10px 0 0; }

.roll-call {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px;
  border: 2px dashed var(--gilt);
  border-radius: 10px;
  background: color-mix(in srgb, var(--gilt) 10%, transparent);
}
.roll-call.enter { animation: pop-in 0.45s cubic-bezier(.3, 1.6, .5, 1); }
.roll-call-text { flex: 1; min-width: 160px; }
.roll-call .need { font-size: 1.1rem; font-weight: 700; }
.roll-call .waiting { margin: 0; }

.roll-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-radius: 10px;
  margin-bottom: 10px;
  border: 2px solid;
}
.roll-summary.good { border-color: var(--good); }
.roll-summary.bad { border-color: var(--bad); }
.mini-dice { display: flex; gap: 4px; }
.mini-dice b { width: 30px; height: 30px; display: grid; place-items: center; background: #fff8e6; color: #2a1c0f; border: 2px solid #2a1c0f; border-radius: 6px; }
.stamp { margin-left: auto; font-family: "IM Fell English SC", Georgia, serif; font-size: 1.2rem; padding: 0 10px; border: 2px solid; border-radius: 6px; transform: rotate(-4deg); }
.roll-summary.good .stamp { color: var(--good); }
.roll-summary.bad .stamp { color: var(--bad); }

.outcome { font-family: "IM Fell English SC", Georgia, serif; font-size: 1.45rem; margin: 6px 0; }
.outcome.tone-good { color: var(--good); }
.outcome.tone-bad { color: var(--bad); }
.outcome.enter { animation: pop-in 0.5s cubic-bezier(.3, 1.6, .5, 1); }
.foe-preview { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 10px; background: #2a1410; color: #f6e7bd; margin: 8px 0; }
.foe-preview .portrait-svg { width: 76px; height: 76px; border-radius: 10px; background: radial-gradient(circle, #7a3a2a, #2a0a06); border: 2px solid #b0801f; flex: none; }
.foe-preview .kicker { color: #e8cf8a; }
.foe-preview.big .portrait-svg { width: 110px; height: 110px; }
.door-offer { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--rule); }

.loot-row { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; }
.loot-card { display: flex; flex-direction: column; align-items: center; }
.loot-card.enter { animation: deal-in 0.6s cubic-bezier(.2, 1.2, .4, 1) both; }
.loot-card .card { --cw: 180px; margin-bottom: 8px; }
.loot-card { width: 200px; }
.give-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.give-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  padding: 3px 8px 3px 4px;
  background: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--rule);
  border-radius: 14px;
}
.give-btn:hover { border-color: var(--gilt); }
.give-btn.full { opacity: 0.6; }
.give-btn.discard { padding-left: 8px; }
.give-to { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 10px; border-radius: 10px; background: var(--ink); color: var(--paper); margin: 8px 0; }
.give-to .give-btn { background: var(--paper); }
.done-bar .give-to { flex-basis: 100%; margin: 0; }

.deck-row { display: flex; gap: 20px; justify-content: center; margin: 10px 0; }
.deck-pick.clickable .card { cursor: pointer; }
@media (hover: hover) {
  .deck-pick.clickable .card:hover { transform: translateY(-8px) rotate(-2deg); }
}
.deck-pick:not(.clickable) { opacity: 0.7; }

.sold-out { color: var(--ink-soft); font-style: italic; }
.buy-btn { position: absolute; left: 8%; right: 8%; bottom: -30px; font-size: 0.8rem; padding: 4px 6px; z-index: 3; }
.panel .card-row .card.kind-skill, .panel .card-row .card.kind-item, .panel .card-row .card.kind-equipment { margin-bottom: 32px; }
.done-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; border-top: 1px dashed var(--rule); padding: 12px 0 8px; margin-top: 8px; }
/* Long shop and trade lists: "Done" stays in reach while scrolling. */
.panel .done-bar { position: sticky; bottom: -20px; padding-bottom: 20px; background: var(--panel-bg); z-index: 4; }
.done-list { display: flex; gap: 6px; flex-wrap: wrap; }
.done-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 0.85rem; padding: 3px 9px 3px 4px; border-radius: 14px; border: 1.5px solid var(--rule); }
.done-chip.done { border-color: var(--good); color: var(--good); font-weight: 700; }
.done-chip.away { opacity: 0.5; }

.lair-panel .panel-body { background: linear-gradient(180deg, transparent, rgba(120, 20, 10, 0.12)); }

/* =====================================================================
   BATTLE
   ===================================================================== */
.battle { display: flex; flex-direction: column; gap: 14px; }
.battle.enter { animation: fade-in 0.5s; }
.battlefield { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.enemy-stage {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  padding: 16px;
  border-radius: 14px;
  color: #f6e7bd;
  background:
    radial-gradient(ellipse at 25% 40%, rgba(255, 140, 60, 0.18), transparent 60%),
    linear-gradient(180deg, #2b1d14, #120b07);
  border: 2px solid #6b4f25;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6), 0 8px 20px var(--shadow);
}
.enemy-stage.boss { background: radial-gradient(ellipse at 25% 40%, rgba(255, 80, 30, 0.3), transparent 60%), linear-gradient(180deg, #3a0f08, #120404); border-color: #b0401f; }
.enemy-frame {
  width: 190px;
  aspect-ratio: 1;
  border-radius: 20px;
  border: 3px solid #b0801f;
  background: radial-gradient(circle at 50% 40%, #7a3a2a, #2a0a06 75%);
  box-shadow: 0 0 30px rgba(255, 120, 50, 0.25), inset 0 0 20px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  animation: enemy-idle 3.2s ease-in-out infinite;
}
.enemy-portrait .portrait-svg { width: 100%; height: 100%; display: block; }
@keyframes enemy-idle { 50% { transform: translateY(-4px) scale(1.01); } }
.enemy-info h2 { font-size: 2.2rem; margin: 2px 0 6px; }
.enemy-info .kicker { color: #e8cf8a; }
.enemy-info .hpbar { max-width: 420px; }
.moves { margin-top: 10px; font-size: 0.82rem; display: grid; gap: 3px; }
.moves-title { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: #cdb988; }
.move { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.move b { color: #fff4dc; font-weight: 700; }
.move span:last-child { color: #cdb988; }
.faces { display: inline-flex; gap: 2px; }
.faces i { font-style: normal; width: 18px; height: 18px; display: grid; place-items: center; background: #f6e7bd; color: #2a1c0f; border-radius: 4px; font-size: 0.72rem; font-weight: 700; }

.allies { display: grid; gap: 10px; }
.ally {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: var(--paper);
  border: 1.5px solid var(--rule);
  border-radius: 12px;
  transition: opacity 0.3s;
}
.ally.dead { opacity: 0.6; }
.ally-body { flex: 1; min-width: 0; }
.ally-name { font-weight: 700; display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.ally-state { font-weight: 400; font-size: 0.78rem; padding: 1px 8px; border-radius: 8px; background: var(--ink); color: var(--paper); }
.ally-state.ready { background: var(--good); color: #fff; }
.ally-state.ko, .ally-state.stun { background: var(--bad); color: #fff; }
.ally-state.away { background: #b0801f; color: #fff; }
.ally-meta { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin-top: 5px; }
.hand-count { font-size: 0.85rem; margin-right: 4px; }

.my-area {
  background: var(--paper);
  border: 2px solid var(--rule);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 8px 20px var(--shadow);
}
.my-area.spectator { text-align: center; color: var(--ink-soft); }
.select-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: #2a1c0f;
  color: #ffe9a8;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 10px;
  animation: pop-in 0.3s;
}
.select-banner button { background: #f6e7bd; color: #2a1c0f; }
.my-grid { display: grid; grid-template-columns: 250px minmax(0, 1fr) 190px; gap: 16px; align-items: center; }
.my-hero { display: flex; gap: 12px; align-items: flex-start; padding: 6px; border-radius: 12px; }
.my-hero.dead .portrait { filter: grayscale(1); }
.my-stats { flex: 1; min-width: 0; }
.my-name { font-weight: 700; font-size: 1.05rem; }
.pile-info { display: flex; gap: 10px; font-size: 0.8rem; color: var(--ink-soft); margin-top: 4px; }

.hand-wrap { min-width: 0; }
.hand {
  display: flex;
  justify-content: safe center;
  align-items: flex-end;
  padding: 40px 28px 22px;
  min-height: 250px;
  overflow-x: auto;
  overflow-y: hidden;
}
/* Earlier cards lie on top: a skill's cost is in its top right corner, and this keeps every one in view. */
.hand-slot { transform: rotate(var(--rot)); transform-origin: 50% 120%; transition: transform 0.2s; position: relative; z-index: var(--z); }
.hand-slot:has(.card.selected) { z-index: 99; }
.hand-slot + .hand-slot { margin-left: calc(-1 * var(--overlap, 0px) + 6px); }
@media (hover: hover) {
  .hand-slot:hover { z-index: 99; transform: rotate(0deg) translateY(-14px); }
  .hand-slot:hover .card { transform: scale(1.1); }
}
.hand-slot .card.selected { transform: translateY(-20px) scale(1.08); }
.hand-slot.deal .card { animation: hand-deal-in 0.55s cubic-bezier(.2, 1.1, .4, 1) both; animation-delay: calc(var(--i) * 110ms); }
/* Short path, so dealing never overflows the scrollable hand row. */
@keyframes hand-deal-in {
  from { opacity: 0; transform: translateY(-30px) rotate(6deg) scale(0.7); }
  to { opacity: 1; transform: none; }
}
@keyframes deal-in {
  from { opacity: 0; transform: translate(260px, -160px) rotate(25deg) scale(0.4); }
  to { opacity: 1; transform: none; }
}
.empty-hand { color: var(--ink-soft); font-style: italic; text-align: center; }
.overcharge { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 0.9rem; }
.overcharge b { min-width: 1.4em; text-align: center; font-size: 1.1rem; color: var(--mana); }

.turn-control { display: flex; flex-direction: column; align-items: stretch; gap: 8px; text-align: center; }
.turn-control .end-turn { font-size: 1.35rem; padding: 0.8em 0.6em; }
.turn-state { font-family: "IM Fell English SC", Georgia, serif; font-size: 1.3rem; padding: 10px; border-radius: 10px; border: 2px solid; }
.turn-state.ready { color: var(--good); border-color: var(--good); }
.turn-state.ko, .turn-state.stun { color: var(--bad); border-color: var(--bad); }

.kit { display: grid; grid-template-columns: 1fr 1.4fr; gap: 14px; border-top: 1px dashed var(--rule); margin-top: 8px; padding-top: 6px; }
.kit-divider { width: 2px; align-self: stretch; background: var(--rule); opacity: 0.4; margin: 0 4px; }
.gear-slot {
  width: 104px;
  aspect-ratio: 874 / 1240;
  border: 2px dashed var(--rule);
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  font-size: 0.8rem;
  opacity: 0.6;
}
.card.worn .card-frame { box-shadow: 0 0 0 3px #7fd07f, 0 3px 8px rgba(0, 0, 0, 0.35); }
.worn-tag { position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%); background: #2f7d32; color: #fff; font-size: 0.68rem; padding: 0 8px; border-radius: 8px; z-index: 3; }

/* =====================================================================
   MODALS, END SCREEN, RULES
   ===================================================================== */
.modal-layer { z-index: 30; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.modal-head h2 { font-size: 1.8rem; }
.modal .card { margin: 4px auto 10px; }
.zoom .card { animation: pop-in 0.3s cubic-bezier(.3, 1.4, .5, 1); cursor: zoom-out; }
.chronicle { max-height: 60vh; overflow-y: auto; font-size: 0.92rem; }
.chronicle p { margin: 0 0 4px; padding-bottom: 4px; border-bottom: 1px solid color-mix(in srgb, var(--rule) 30%, transparent); }
.rules { font-size: 0.95rem; }
.rules h3 { font-size: 1.3rem; margin-top: 0.8rem; }
.rules ul { padding-left: 1.2em; margin: 0.3rem 0; }

.end-screen { text-align: center; padding: 6vh 0; max-width: 760px; margin: 0 auto; }
.end-screen h1 { font-size: clamp(2.4rem, 7vw, 4.6rem); }
.end-screen p { max-width: 56ch; margin: 1rem auto; }
.end-art svg { width: 150px; height: 150px; border-radius: 24px; border: 3px solid #b0801f; background: radial-gradient(circle, #7a3a2a, #2a0a06); }
.end-screen.won .end-art svg { filter: grayscale(0.8) brightness(0.8); transform: rotate(-8deg); }
.end-party { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; margin: 14px 0; }
.end-hero { display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 700; }

/* =====================================================================
   FX LAYER
   ===================================================================== */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
#preview {
  position: fixed;
  z-index: 70;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 0.12s, transform 0.12s;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
}
#preview.show { opacity: 1; transform: none; }
@media (hover: none) { #preview { display: none; } }

#toasts { position: fixed; left: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 6px; max-width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  background: #2a1c0f;
  color: #f6e7bd;
  padding: 8px 14px;
  border-radius: 8px;
  border-left: 4px solid var(--gilt);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.3s cubic-bezier(.3, 1.4, .5, 1);
  font-size: 0.92rem;
}
.toast.tone-bad { border-left-color: #ff6a55; }
.toast.leaving { opacity: 0; transform: translateX(-20px); transition: all 0.35s; }
@keyframes toast-in { from { opacity: 0; transform: translateX(-30px); } }

#offline-banner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 90;
  background: #8e1b1b;
  color: #fff;
  text-align: center;
  padding: 6px;
  font-weight: 700;
}
body.offline #offline-banner { display: block; }

.fx-float {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: "IM Fell English SC", Georgia, serif;
  font-size: 26px;
  font-weight: 700;
  white-space: nowrap;
  color: #fff;
  -webkit-text-stroke: 1px rgba(0, 0, 0, 0.7);
  text-shadow: 0 2px 0 #000, 0 0 10px rgba(0, 0, 0, 0.7);
  animation: float-up 1.4s cubic-bezier(.2, .8, .3, 1) forwards;
}
.fx-float.big { font-size: 40px; }
.fx-float.tone-damage { color: #ff5a4a; }
.fx-float.tone-heal { color: #7df07a; }
.fx-float.tone-poison { color: #b6ef6a; }
.fx-float.tone-mana { color: #8cc0ff; font-size: 20px; }
.fx-float.tone-block { color: #dbe3ee; font-size: 22px; }
.fx-float.tone-stun { color: #ffe066; }
.fx-float.tone-buff { color: #ffcf5a; font-size: 21px; }
.fx-float.tone-bad { color: #ff8a7a; font-size: 21px; }
.fx-float.tone-ward { color: #dcc2ff; font-size: 21px; }
.fx-float.tone-gold { color: #ffd76a; }
.fx-float.tone-thorns { color: #ffa24a; }
.fx-float.tone-neutral { color: #f6e7bd; font-size: 19px; }
.fx-float.tone-ko { color: #ff3b30; }
@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.5); }
  15% { opacity: 1; transform: translate(-50%, -60%) scale(1.25); }
  30% { transform: translate(-50%, -70%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(0.95); }
}

.fx-center {
  position: fixed;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  animation: center-in 0.35s cubic-bezier(.3, 1.5, .5, 1);
}
.fx-center.leaving { animation: center-out 0.26s forwards; }
@keyframes center-in { from { opacity: 0; transform: translate(-50%, -50%) scale(0.6); } }
@keyframes center-out { to { opacity: 0; transform: translate(-50%, -50%) scale(0.9); } }

.dice-card, .coin-card, .banner-card {
  background: linear-gradient(180deg, rgba(42, 28, 15, 0.96), rgba(20, 12, 6, 0.96));
  color: #f6e7bd;
  border: 2px solid #d4a93a;
  border-radius: 16px;
  padding: 14px 26px 16px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 6px rgba(212, 169, 58, 0.15);
  min-width: 260px;
  position: relative;
}
.dice-card.enemy { border-color: #d0452a; }
.dice-label { font-family: "IM Fell English SC", Georgia, serif; font-size: 1.15rem; color: #ffe39a; margin-bottom: 10px; }
.dice-row { display: flex; justify-content: center; gap: 14px; }
.dice-total { font-family: "IM Fell English SC", Georgia, serif; font-size: 1.6rem; line-height: 1.2; margin-top: 2px; min-height: 0.5em; color: #fff4dc; }
.dice-card { min-width: 300px; padding-bottom: 18px; }
.dice-card.enemy { background: linear-gradient(180deg, rgba(48, 12, 8, 0.96), rgba(18, 6, 4, 0.96)); }

/* The number to beat, in a gilded crest above the dice. */
.dice-dc { display: inline-flex; flex-direction: column; align-items: center; margin: -2px auto 4px; padding: 4px 18px 6px; border: 2px solid #d4a93a; border-radius: 10px 10px 50% 50% / 10px 10px 30% 30%; background: radial-gradient(circle at 50% 30%, rgba(212, 169, 58, 0.25), rgba(0, 0, 0, 0.35)); }
.dice-dc span { font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase; color: #cdb988; }
.dice-dc b { font-family: "IM Fell English SC", Georgia, serif; font-size: 2rem; line-height: 1; color: #ffe39a; font-weight: 400; }

.die3d { width: 150px; height: 150px; display: block; transition: opacity 0.3s, filter 0.3s, transform 0.3s; }
.die3d.solo { width: 210px; height: 210px; margin: -10px 0 -14px; }
.die3d.dropped { opacity: 0.35; filter: grayscale(1); transform: scale(0.85); }

.dice-natural { font-family: "IM Fell English SC", Georgia, serif; font-size: 1.5rem; letter-spacing: 0.06em; animation: natural-in 0.5s cubic-bezier(.3, 1.8, .5, 1); }
.natural-high .dice-natural { color: #ffd76a; text-shadow: 0 0 14px rgba(255, 200, 80, 0.9); }
.natural-low .dice-natural { color: #ff7a6a; text-shadow: 0 0 12px rgba(255, 60, 40, 0.8); }
.dice-card.natural-high { border-color: #ffd76a; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 40px 6px rgba(255, 200, 80, 0.45); }
.dice-card.natural-low { border-color: #ff5a40; }
@keyframes natural-in { from { opacity: 0; transform: scale(2); } }

/* "Success" / "Failure", big across the bottom once the dice land. */
.dice-verdict { min-height: 0; font-family: "IM Fell English SC", Georgia, serif; font-size: 0; letter-spacing: 0.14em; text-transform: uppercase; }
.dice-verdict.show { font-size: 2.1rem; line-height: 1.1; margin-top: 2px; animation: verdict-in 0.45s cubic-bezier(.2, 1.4, .4, 1); }
.dice-verdict.good { color: #ffe39a; text-shadow: 0 0 18px rgba(255, 210, 90, 0.75), 0 2px 0 #3a2608; }
.dice-verdict.bad { color: #ff7a6a; text-shadow: 0 0 16px rgba(255, 70, 50, 0.6), 0 2px 0 #3a0a06; }
@keyframes verdict-in { from { opacity: 0; letter-spacing: 0.6em; transform: scale(1.3); } }

.coin-stage { perspective: 600px; height: 110px; display: grid; place-items: center; }
.coin { width: 90px; height: 90px; position: relative; transform-style: preserve-3d; }
.coin .face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 44px;
  backface-visibility: hidden;
  background: radial-gradient(circle at 35% 30%, #fff2b0, #e9bb42 45%, #9a6f16);
  border: 4px solid #6b4f10;
  color: #5a3a08;
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.25);
}
.coin .tails { transform: rotateY(180deg); background: radial-gradient(circle at 35% 30%, #f0f0f0, #b8b8c0 45%, #6a6a78); border-color: #3a3a44; color: #2a2a34; }
.coin.flip-heads { animation: flip-heads 1.1s cubic-bezier(.2, .7, .3, 1) forwards; }
.coin.flip-tails { animation: flip-tails 1.1s cubic-bezier(.2, .7, .3, 1) forwards; }
@keyframes flip-heads {
  0% { transform: translateY(0) rotateY(0); }
  40% { transform: translateY(-60px) rotateY(900deg); }
  100% { transform: translateY(0) rotateY(1800deg); }
}
@keyframes flip-tails {
  0% { transform: translateY(0) rotateY(0); }
  40% { transform: translateY(-60px) rotateY(900deg); }
  100% { transform: translateY(0) rotateY(1980deg); }
}
.coin-result { font-family: "IM Fell English SC", Georgia, serif; font-size: 1.6rem; min-height: 1.4em; }
.coin-result.heads { color: #ffd76a; animation: pop-in 0.3s; }
.coin-result.tails { color: #cfd3de; animation: pop-in 0.3s; }

.fx-flycard { position: fixed; transform: translate(-50%, -50%); z-index: 2; }
.fx-flycard .card { --cw: 190px; }
.fx-flycard.glowing .card-frame { animation: card-glow 0.5s ease-in-out infinite alternate; }
.fx-flycard.flip-in { animation: flip-in 0.45s cubic-bezier(.2, 1.2, .4, 1); }
@keyframes flip-in { from { transform: translate(-50%, -50%) perspective(700px) rotateY(90deg); } }
@keyframes card-glow {
  from { box-shadow: 0 0 0 3px #ffd54a, 0 0 18px 6px rgba(255, 213, 74, 0.6); }
  to { box-shadow: 0 0 0 3px #fff4c2, 0 0 40px 14px rgba(255, 213, 74, 0.8); }
}
.fly-ribbon {
  position: absolute;
  left: 50%;
  top: -16px;
  transform: translateX(-50%);
  white-space: nowrap;
  background: #7b4bb3;
  color: #fff;
  font-family: "IM Fell English SC", Georgia, serif;
  padding: 2px 12px;
  border-radius: 10px;
  border: 2px solid #2a1c0f;
}

.fx-burst {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: burst 0.6s ease-out forwards;
  border: 6px solid var(--burst);
  box-shadow: 0 0 30px 10px var(--burst);
}
.fx-burst.tone-attack { --burst: rgba(255, 110, 60, 0.9); }
.fx-burst.tone-heal { --burst: rgba(120, 240, 120, 0.9); }
.fx-burst.tone-magic { --burst: rgba(190, 150, 255, 0.9); }
.fx-burst.tone-item { --burst: rgba(120, 180, 255, 0.9); }
@keyframes burst {
  from { opacity: 1; width: 20px; height: 20px; }
  to { opacity: 0; width: 220px; height: 220px; border-width: 1px; }
}

.banner-card { min-width: min(320px, 92vw); max-width: min(520px, 92vw); padding-top: 12px; }
.banner-title { font-family: "IM Fell English SC", Georgia, serif; font-size: 2.1rem; color: #ffe39a; line-height: 1.1; }
.banner-text { font-size: 1.05rem; margin-top: 4px; }
.banner-text.small { font-size: 0.85rem; opacity: 0.8; }
.banner-face { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; color: #cdb988; margin-top: 4px; }
/* A tile's scene sits on top of the card, edge to edge, above the title. */
.banner-art { margin: -12px -26px 10px; border-radius: 14px 14px 0 0; overflow: hidden; border-bottom: 2px solid rgba(212, 169, 58, 0.5); }
.banner-art svg { width: 100%; height: 120px; display: block; }
.banner-card.tone-danger { border-color: #d0452a; }
.banner-card.tone-danger .banner-title { color: #ff8a6a; }
.banner-card.tone-lapis { border-color: #5b8ad0; }
.banner-card.tone-forest { border-color: #5fa050; }
.banner-card.tone-magic { border-color: #a07ad8; }
.banner-card.tone-vote { border-color: #d4a93a; }
.tally-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.tally { font-size: 0.85rem; padding: 2px 10px; border-radius: 10px; border: 1px solid rgba(246, 231, 189, 0.4); opacity: 0.7; }
.tally.won { opacity: 1; border-color: #ffd76a; background: rgba(212, 169, 58, 0.25); }

.fx-splash {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle, rgba(30, 10, 5, 0.75), rgba(0, 0, 0, 0.92));
  animation: fade-in 0.3s;
}
.fx-splash.leaving { animation: fade-out 0.5s forwards; }
.splash-inner { text-align: center; color: #f6e7bd; position: relative; animation: splash-zoom 0.6s cubic-bezier(.2, 1.4, .4, 1); }
.splash-kicker { font-family: "IM Fell English SC", Georgia, serif; font-size: 1.4rem; letter-spacing: 0.2em; text-transform: uppercase; color: #ff8a6a; }
.splash-title { font-family: "IM Fell English SC", Georgia, serif; font-size: clamp(2.6rem, 9vw, 5.5rem); color: #ffe39a; text-shadow: 0 4px 0 #000, 0 0 30px rgba(255, 180, 60, 0.5); position: relative; }
.splash-sub { font-size: 1.3rem; position: relative; }
.splash-portrait { width: 220px; height: 220px; margin: 10px auto; border-radius: 28px; border: 4px solid #d4a93a; overflow: hidden; background: radial-gradient(circle at 50% 40%, #7a3a2a, #2a0a06 75%); box-shadow: 0 0 60px rgba(255, 110, 40, 0.5); animation: splash-shake 0.5s 0.4s; }
.splash-portrait svg { width: 100%; height: 100%; display: block; }
.fx-splash.boss .splash-portrait { width: 280px; height: 280px; border-color: #ff5a2a; }
.fx-splash.boss { background: radial-gradient(circle, rgba(90, 10, 0, 0.8), rgba(0, 0, 0, 0.95)); }
.fx-splash.victory { background: radial-gradient(circle, rgba(90, 70, 10, 0.75), rgba(0, 0, 0, 0.9)); }
.fx-splash.defeat { background: radial-gradient(circle, rgba(40, 40, 50, 0.85), rgba(0, 0, 0, 0.95)); }
.fx-splash.defeat .splash-title { color: #c8c8d0; text-shadow: 0 4px 0 #000; }
.fx-splash.fled { background: radial-gradient(circle, rgba(60, 30, 100, 0.8), rgba(0, 0, 0, 0.9)); }
.splash-rays {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 900px;
  height: 900px;
  transform: translate(-50%, -50%);
  background: repeating-conic-gradient(rgba(255, 215, 106, 0.18) 0 10deg, transparent 10deg 20deg);
  border-radius: 50%;
  mask-image: radial-gradient(circle, #000 20%, transparent 65%);
  -webkit-mask-image: radial-gradient(circle, #000 20%, transparent 65%);
  animation: spin 12s linear infinite;
}
.fx-splash.defeat .splash-rays, .fx-splash.fled .splash-rays { display: none; }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes splash-zoom { from { transform: scale(0.3); opacity: 0; } }
@keyframes splash-shake {
  20% { transform: translate(-8px, 4px) rotate(-2deg); }
  40% { transform: translate(8px, -4px) rotate(2deg); }
  60% { transform: translate(-5px, 2px); }
  80% { transform: translate(4px, -2px); }
}

.fx-shake { animation: shake 0.45s; }
@keyframes shake {
  20% { transform: translateX(-8px) rotate(-1.5deg); }
  40% { transform: translateX(7px) rotate(1.5deg); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}
.fx-hurt { filter: brightness(1.2) sepia(1) saturate(6) hue-rotate(-40deg); transition: filter 0.1s; }
.fx-healed { box-shadow: 0 0 0 3px #7df07a, 0 0 30px 8px rgba(125, 240, 122, 0.6) !important; transition: box-shadow 0.2s; }
.fx-glow { box-shadow: 0 0 0 3px #ffd54a, 0 0 30px 8px rgba(255, 213, 74, 0.6) !important; }
.fx-ko { animation: ko 1.1s; }
@keyframes ko {
  0% { filter: none; }
  20% { filter: brightness(2.5); transform: scale(1.05); }
  100% { filter: grayscale(1) brightness(0.6); transform: rotate(-3deg); }
}
.fx-revive { animation: revive 1.1s; }
@keyframes revive {
  0% { filter: grayscale(1) brightness(0.6); }
  40% { filter: brightness(2.5) sepia(0.6); box-shadow: 0 0 60px 20px rgba(255, 220, 120, 0.8); }
  100% { filter: none; }
}
.fx-lunge { animation: lunge 0.65s cubic-bezier(.4, 0, .2, 1); }
@keyframes lunge {
  30% { transform: translateY(-10px) scale(0.95); }
  55% { transform: translateY(26px) scale(1.14); filter: brightness(1.5); }
  100% { transform: none; }
}
.fx-dizzy { animation: dizzy 1s; }
@keyframes dizzy { 25% { transform: rotate(-8deg); } 50% { transform: rotate(7deg); } 75% { transform: rotate(-5deg); } }
.fx-targeted { outline: 3px solid #ff4a30; outline-offset: 3px; animation: targeted 0.5s ease-in-out infinite alternate; }
@keyframes targeted { to { outline-color: rgba(255, 74, 48, 0.3); outline-offset: 7px; } }
body.fx-screenshake #app { animation: shake 0.4s; }

@keyframes pop-in { from { opacity: 0; transform: scale(0.6); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
/* ---------- Rooms, home screen & small UX helpers ---------- */
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; max-width: 820px; margin: 0 auto; }
.home .lobby-form { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.home .name-field { width: 100%; }
#room-code { text-transform: uppercase; letter-spacing: 0.2em; font-size: 1.3rem; }
.join-urls.invite { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.room-code { font-family: "IM Fell English SC", Georgia, serif; font-size: 1.7rem; letter-spacing: 0.18em; color: var(--crimson); }
.room-chip { background: var(--paper); color: var(--ink); border: 1.5px dashed var(--rule); }
.room-chip b { letter-spacing: 0.12em; }
button.on { background: var(--button-bg); color: var(--button-ink); }

/* A request is on its way: show it, and don't invite a second click. */
.is-busy { opacity: 0.6; pointer-events: none; cursor: progress; }
button.is-busy::after { content: " …"; }

.board-svg .tile.reachable { stroke: #fff4c2; stroke-width: 3; stroke-dasharray: 5 3; animation: tile-reach 1.4s ease-in-out infinite; }
@keyframes tile-reach { 50% { filter: brightness(1.25); } }

.last-move { margin: 8px 0 0; font-size: 0.85rem; color: #e8dcc0; max-width: 520px; }
.last-move .moves-title { margin-right: 6px; }

.key-hint {
  position: absolute; top: -8px; left: 50%; transform: translateX(-50%); z-index: 2;
  min-width: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--ink); color: var(--paper); font-size: 0.72rem; line-height: 18px; text-align: center;
  pointer-events: none;
}
.kbd-hint { font-size: 0.78rem; color: var(--ink-soft); margin: 4px 0 0; }
@media (hover: none) { .key-hint, .kbd-hint { display: none; } }

/* ---------- Accounts, home screen, menu ---------- */
.home-top { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.home-top .spacer { flex: 1; }
.account-chip { max-width: 14em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-card { max-width: 440px; margin: 0 auto; }
.auth-card .flavor { margin-bottom: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 4px; align-self: stretch; }
.auth-form .name-field { margin-bottom: 10px; }
.auth-form input { margin-top: 4px; font-size: 1.05rem; padding: 0.55em 0.7em; }
.auth-form button[type="submit"] { align-self: stretch; margin-top: 4px; }
.auth-form .hint { margin: -4px 0 8px; }
.auth-tabs { display: flex; gap: 0; margin-bottom: 14px; border: 1.5px solid var(--rule); border-radius: 8px; overflow: hidden; }
.auth-tabs button { flex: 1; border: none; border-radius: 0; background: transparent; color: var(--ink); padding: 0.55em 0.5em; }
.auth-tabs button.on { background: var(--button-bg); color: var(--button-ink); }
.auth-tabs button:hover { transform: none; box-shadow: none; }
.form-error { color: var(--bad); font-weight: 700; margin: 0 0 8px; }
.guest-line { align-self: center; text-align: center; margin: 14px 0 0; color: var(--ink-soft); }
.guest-nudge { font-size: 0.88rem; color: var(--ink-soft); text-align: center; margin: 12px 0 0; }
.home .lobby-hero { padding-top: 2vh; }

.recent-rooms { max-width: 820px; margin: 18px auto 0; }
.recent-rooms h2 { font-size: 1.4rem; }
.room-list { display: flex; flex-direction: column; gap: 8px; }
.room-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--rule);
  border-radius: 10px;
  padding: 10px 14px;
}
.room-row .room-code { font-size: 1.3rem; }
.room-row .room-status { flex: 1; color: var(--ink-soft); font-size: 0.92rem; }
.room-row .room-go { font-size: 1.3rem; }
@media (hover: hover) { .room-row:hover { border-color: var(--gilt); } }
.open-rooms { margin-top: 18px; }
.open-rooms .room-list { align-self: stretch; }
.open-room { padding: 10px 12px; gap: 10px; }
.open-room .room-status { min-width: 0; }
.open-room .room-status { display: flex; flex-direction: column; min-width: 0; color: var(--ink); }
.open-room .room-status b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.open-room .room-status small { color: var(--ink-soft); font-size: 0.85rem; }
.open-room .room-go { font-size: 1rem; font-weight: 700; color: var(--crimson); white-space: nowrap; }
.open-faces { display: flex; flex: none; }
.open-face { width: 34px; height: 34px; border-radius: 9px; border: 2px solid #2a1c0f; overflow: hidden; background: radial-gradient(circle at 50% 35%, var(--cls-light, #b9a67f), var(--cls, #6c5638)); }
.open-face + .open-face { margin-left: -10px; }
.open-face svg { width: 100%; height: 100%; display: block; }

/* Private / Public, on the home screen and in the lobby */
.visibility { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 100%; max-width: 420px; padding: 4px; border-radius: 12px; border: 1.5px solid var(--rule); }
.visibility button { display: flex; flex-direction: column; align-items: center; gap: 1px; background: transparent; color: var(--ink); border: 0; border-radius: 9px; padding: 7px 8px; min-height: 44px; box-shadow: none; }
.visibility button:hover { transform: none; box-shadow: none; }
.visibility button small { font-size: 0.74rem; color: var(--ink-soft); font-weight: 400; }
.visibility button.on { background: var(--ink); color: var(--paper); }
.visibility button.on small { color: color-mix(in srgb, var(--paper) 75%, transparent); }
.join-urls .visibility { margin: 4px auto 0; }
.visibility-note { font-size: 0.88rem; color: var(--ink-soft); }
.seat { position: relative; }
@media (max-width: 700px) { .seat:has(.seat-remove) { padding-right: 40px; } }
.seat-remove { position: absolute; top: 4px; right: 4px; min-width: 32px; min-height: 32px; padding: 0; border-radius: 50%; line-height: 1; }

.danger-row { color: var(--bad); }
.lobby-leave { text-align: center; margin: 12px 0 0; font-size: 0.9rem; }
.lobby-leave .link { color: var(--bad); }
.app-version { text-align: center; color: var(--ink-soft); font-size: 0.8rem; margin: 14px 0 0; }
.volume-row input { margin-left: auto; width: min(180px, 45%); accent-color: var(--gilt); }

/* ---------- Leaderboard ---------- */
.leaderboard-card { max-width: 820px; margin: 18px auto 0; }
.leaderboard-card h2 { font-size: 1.4rem; }
.leaderboard { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; align-self: stretch; }
.leaderboard-card .my-record, .leaderboard-card .guest-nudge { align-self: stretch; }
.leader-row {
  display: grid;
  grid-template-columns: 2.2em minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid color-mix(in srgb, var(--rule) 55%, transparent);
}
.leader-row.me { border-color: var(--gilt); background: color-mix(in srgb, var(--gilt) 16%, transparent); }
.leader-rank {
  width: 2em;
  height: 2em;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: "IM Fell English SC", Georgia, serif;
  border: 1.5px solid var(--rule);
}
.leader-rank.medal-1 { background: radial-gradient(circle at 35% 30%, #fff2b0, #e9bb42 50%, #9a6f16); border-color: #6b4f10; color: #3a2608; }
.leader-rank.medal-2 { background: radial-gradient(circle at 35% 30%, #ffffff, #c8ccd4 50%, #7a7f8a); border-color: #4a4d55; color: #24262b; }
.leader-rank.medal-3 { background: radial-gradient(circle at 35% 30%, #ffd9b0, #c07a3a 50%, #7a4519); border-color: #4f2a0c; color: #2a1405; }
.leader-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-wins b { font-size: 1.15rem; }
.leader-runs { color: var(--ink-soft); font-size: 0.85rem; }
.my-record { margin: 10px 0 0; text-align: center; color: var(--ink-soft); }
.end-record { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }

.touch-hint { text-align: center; font-size: 0.8rem; color: var(--ink-soft); margin: 2px 0 0; }
.invite-link { overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  .my-grid { grid-template-columns: 1fr; }
  .turn-control { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; }
  .turn-control .end-turn { flex: 1; max-width: 360px; }
  .kit { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .map-layout, .battlefield, .lobby-grid, .home-grid { grid-template-columns: 1fr; }
  .enemy-frame { width: 130px; }
  .card.size-hand { --cw: 124px; }
  .hand { justify-content: flex-start; min-height: 200px; }
}

/* =====================================================================
   PHONES: one column, compact panels, and the main action docked at the
   bottom of the screen where a thumb can reach it.
   ===================================================================== */
@media (max-width: 700px) {
  body { font-size: 16px; }
  #app { padding: 8px 12px 24px; }
  .wide-only { display: none; }

  /* Buttons big enough to hit with a thumb. */
  button.small { min-height: 36px; padding: 0.3em 0.75em; }
  .give-btn { min-height: 38px; padding: 4px 10px 4px 5px; }
  .discard-x { width: 30px; height: 30px; opacity: 0.9; }

  /* Top bar: tools on one row, the party strip under them. */
  .top-bar { gap: 8px; margin-bottom: 10px; }
  .logo { display: none; }
  .top-bar .tools { margin-left: 0; width: 100%; flex-wrap: nowrap; }
  .top-bar .tools .room-chip { margin-right: auto; }
  .party-strip { order: 2; flex-basis: 100%; flex-wrap: nowrap; gap: 6px; }
  .party-chip { min-width: 0; flex: 1 1 0; padding: 4px 6px 4px 4px; gap: 5px; }
  .party-chip .portrait.small { width: 28px; }

  /* Toasts at the top, out of the way of the action dock. */
  #toasts { left: 12px; right: 12px; bottom: auto; top: calc(8px + env(safe-area-inset-top, 0px)); max-width: none; align-items: center; }
  .toast { width: 100%; max-width: 440px; }

  /* Popups become bottom sheets. */
  .backdrop { place-items: end center; padding: 0; }
  .backdrop.zoom { place-items: center; padding: 16px; }
  .panel { width: 100%; border-radius: 16px 16px 0 0; max-height: 94vh; max-height: 94dvh; border-bottom: none; }
  .panel.wide { width: 100%; }
  .panel-body { padding: 12px 14px calc(18px + env(safe-area-inset-bottom, 0px)); }
  /* Short scene art, so the text and choices start high on the sheet. */
  .panel-scene { aspect-ratio: auto; height: clamp(72px, 14vh, 116px); height: clamp(72px, 14dvh, 116px); }
  .scene-caption { padding: 16px 14px 6px; }
  .scene-caption h2 { font-size: 1.3rem; }
  .flavor { font-size: 0.95rem; margin-bottom: 10px; }
  .vote-options { grid-template-columns: 1fr; gap: 8px; }
  .vote-option { min-height: 48px; padding: 8px 12px; }
  .vote-status { font-size: 0.82rem; margin-top: 8px; }
  .panel .actions .big { flex: 1; }
  .outcome { font-size: 1.15rem; }
  .roll-summary { padding: 6px 10px; gap: 8px; }
  .roll-summary .stamp { font-size: 1rem; }
  .roll-call { padding: 10px; gap: 10px; }
  .roll-call .big { flex: 1; }
  .foe-preview .portrait-svg { width: 60px; height: 60px; }
  .foe-preview.big .portrait-svg { width: 80px; height: 80px; }
  .door-offer { margin-top: 10px; padding-top: 10px; }
  .door-offer .quiet { flex: 1; }
  .modal-head h2 { font-size: 1.5rem; }
  .modal .card.size-normal { --cw: 200px; }
  .chronicle { max-height: none; }
  .card.size-normal { --cw: min(150px, calc(50vw - 22px)); }
  .panel .card-row { gap: 10px; }
  .panel .card-row { justify-content: center; }
  .loot-row { gap: 12px; }
  .loot-card { width: calc(50% - 6px); }
  .loot-card .card { --cw: min(150px, 100%); }
  /* The leader's view: each card in a row with who to give it to beside it. */
  .loot-row:has(.give-row) { flex-direction: column; flex-wrap: nowrap; }
  .loot-card:has(.give-row) { width: 100%; flex-direction: row; align-items: flex-start; gap: 10px; }
  .loot-card:has(.give-row) .card { --cw: min(116px, 36vw); margin: 0; }
  .loot-card .give-row { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .give-btn { min-width: 0; }
  .give-btn > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .deck-row { gap: 12px; flex-wrap: wrap; }
  .done-bar .big { flex: 1; }
  .done-name { display: none; }
  .panel .done-bar { bottom: calc(-18px - env(safe-area-inset-bottom, 0px)); padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
  .fx-flycard .card, .card.size-fly { --cw: 160px; }
  .dice-card { min-width: 0; width: calc(100vw - 24px); max-width: 380px; padding-left: 14px; padding-right: 14px; }
  .die3d { width: 128px; height: 128px; }
  .die3d.solo { width: 190px; height: 190px; }

  /* Home and lobby */
  .lobby-hero { padding: 2vh 0 0.8rem; }
  .lobby-hero h1 { font-size: clamp(2.4rem, 12vw, 3.4rem); }
  .lobby-form, .lobby-seats { padding: 14px; }
  .lobby-form h2, .lobby-seats h2 { font-size: 1.4rem; }
  .home-grid, .lobby-grid { gap: 12px; }
  .home .lobby-form .big { align-self: stretch; }
  .home .lobby-form .flavor { margin-bottom: 0; }
  .class-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .class-card { display: grid; grid-template-columns: 48px 1fr; grid-template-rows: auto auto; column-gap: 8px; row-gap: 0; align-items: center; justify-items: start; text-align: left; padding: 6px 8px; }
  .class-card .class-portrait { grid-row: span 2; border-radius: 10px; }
  .class-name { font-size: 1.05rem; }
  .class-stats { gap: 6px; font-size: 0.75rem; }
  .seats { gap: 8px; }
  .seat { display: grid; grid-template-columns: 44px 1fr; column-gap: 8px; align-items: center; text-align: left; padding: 8px; }
  .seat-portrait { width: 44px; margin: 0; grid-row: span 2; border-radius: 10px; }
  .seat-name { display: flex; align-items: center; gap: 4px; min-width: 0; white-space: nowrap; }
  .seat-name > span:first-child { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .seat-name .host-tag { flex: none; }
  .join-urls { padding: 8px 10px; }
  .room-code { font-size: 1.4rem; }

  /* Map: three pack cards to a row, and the leader's roll docked. */
  .board-wrap { padding: 6px; }
  .legend { font-size: 0.82rem; gap: 8px; }
  .pack { padding: 10px; }
  .pack-head h3 { font-size: 1.2rem; }
  .pack-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .pack-row .card.size-small, .pack-row .empty-slot { --cw: 100%; width: 100%; }

  .roll-box.mine {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    z-index: 15;
    flex-wrap: nowrap;
    padding: 8px 10px;
    gap: 10px;
    background: var(--paper);
    box-shadow: 0 0 0 3px rgba(212, 169, 58, 0.35), 0 10px 30px var(--shadow);
  }
  .roll-box.mine .d4-face { width: 44px; height: 40px; padding-top: 12px; font-size: 1.2rem; }
  .roll-box.mine .roll-text { min-width: 0; font-size: 0.8rem; line-height: 1.2; }
  .roll-box.mine .roll-text strong { font-size: 1rem; }
  .roll-box.mine .big { padding: 0.6em 0.9em; white-space: nowrap; }

  /* Lobby: joining or setting out is docked too. */
  .lobby-action:has(> .big) {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    z-index: 15;
    margin: 0;
  }
  .lobby-action > .big { width: 100%; box-shadow: 0 10px 30px var(--shadow); }

  /* Battle: enemy, then your hand, then the rest of the party. */
  .battle { gap: 10px; }
  .battlefield { display: contents; }
  .enemy-stage { order: 1; }
  .my-area { order: 2; }
  .allies { order: 3; }

  .enemy-stage { grid-template-columns: 72px minmax(0, 1fr); gap: 4px 12px; padding: 10px; justify-items: stretch; text-align: left; }
  .enemy-frame { width: 72px; border-radius: 12px; border-width: 2px; grid-row: 1 / span 4; align-self: start; }
  .enemy-info h2 { font-size: 1.3rem; margin: 0 0 2px; }
  .moves { gap: 2px; }
  .faces i { width: 16px; height: 16px; font-size: 0.66rem; }
  .enemy-info .hpbar { margin: 3px 0; }
  .moves { grid-column: 1 / -1; margin-top: 2px; font-size: 0.76rem; }
  .enemy-info { display: contents; }
  .enemy-info > :not(.moves) { grid-column: 2; }
  .enemy-info > .kicker { align-self: end; }
  .last-move { grid-column: 1 / -1 !important; margin-top: 0; font-size: 0.8rem; }

  .allies { grid-template-columns: 1fr; gap: 8px; }
  .ally { padding: 8px; gap: 8px; }
  .ally .portrait.medium { width: 44px; }
  .ally .card.size-mini { --cw: 30px; }

  .my-area { padding: 10px; }
  .my-grid { gap: 6px; }
  .my-hero { padding: 2px; gap: 10px; }
  .my-hero .portrait.large { width: 52px; border-width: 2px; }
  .my-hero .portrait.large .crown { font-size: 22px; top: -14px; }
  .my-name { font-size: 1rem; }

  /* The hand scrolls sideways, flat and snapping, cards side by side. */
  .hand { --overlap: 0px !important; padding: 20px 4px 6px; min-height: 0; gap: 8px; scroll-snap-type: x proximity; scroll-padding: 0 4px; }
  .hand-slot { transform: none; scroll-snap-align: start; }
  .hand-slot + .hand-slot { margin-left: 0; }
  .hand-slot .card.selected { transform: translateY(-16px) scale(1.04); }
  .card.size-hand { --cw: 124px; }
  .key-hint { display: none; }

  .turn-control {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    z-index: 15;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    padding: 8px;
    border-radius: 14px;
    background: var(--paper);
    border: 2px solid var(--rule);
    box-shadow: 0 10px 30px var(--shadow);
  }
  .turn-control .waiting, .turn-control > .muted { order: -1; flex-basis: 100%; margin: 0; font-size: 0.8rem; text-align: center; }
  .turn-control .end-turn { flex: 1; max-width: none; font-size: 1.2rem; padding: 0.55em; }
  .turn-control .turn-state { flex: 1; font-size: 1.05rem; padding: 6px; }
  .turn-control .kbd-hint { display: none; }

  .select-banner {
    position: fixed;
    left: 8px;
    right: 8px;
    top: calc(8px + env(safe-area-inset-top, 0px));
    z-index: 16;
    margin: 0;
    flex-wrap: nowrap;
    font-size: 0.9rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  }
  .select-banner button { flex: none; }

  .kit { gap: 4px; }
  .kit .card.size-small, .kit .gear-slot { --cw: 88px; width: 88px; }

  /* Room for the docked action under the last thing on the page. */
  #app:has(.roll-box.mine), #app:has(.turn-control), #app:has(.lobby-action > .big) { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 380px) {
  .class-grid { grid-template-columns: 1fr; }
  .party-chip { display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: center; gap: 3px 4px; padding: 4px 5px; }
  .party-chip .chip-body { display: contents; }
  .party-chip .portrait.small { width: 24px; border-width: 1.5px; }
  .party-chip .hpbar { grid-column: 1 / -1; }
  .party-chip .chip-name { font-size: 0.8rem; }
  .party-chip .chip-name em { display: none; }
  .party-chip .portrait .crown { font-size: 13px; top: -9px; }
  .roll-box.mine .roll-text span { display: none; }
}

/* While you pick who gets a potion, the party bar stays in view. */
.top-bar.selecting {
  position: sticky;
  top: 0;
  z-index: 16;
  margin: -8px -12px 10px;
  padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  background: var(--parchment);
  box-shadow: 0 8px 20px var(--shadow);
}

/* =====================================================================
   PHONES ON THEIR SIDE: little height, so everything gets shorter and the
   party bar fits on one row.
   ===================================================================== */
@media (max-height: 500px) and (orientation: landscape) {
  #app { padding-top: 8px; }
  .logo, .top-bar .wide-only { display: none; }
  .top-bar { flex-wrap: nowrap; gap: 8px; margin-bottom: 8px; }
  .top-bar .tools { flex-wrap: nowrap; }
  .party-strip { flex-wrap: nowrap; gap: 6px; }
  .party-chip { min-width: 0; flex: 1 1 0; padding: 3px 6px 3px 4px; gap: 6px; }
  .party-chip .portrait.small { width: 30px; }

  /* Popups use the whole height, with a thin strip of scene art. */
  .backdrop { padding: 8px; }
  .panel { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
  .panel-scene { aspect-ratio: auto; height: 64px; }
  .scene-caption { padding: 8px 16px 6px; }
  .scene-caption .kicker { display: none; }
  .scene-caption h2 { font-size: 1.3rem; }
  .panel-body { padding: 10px 16px 14px; }
  .flavor { margin-bottom: 8px; }
  .vote-options { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
  .vote-option { min-height: 44px; padding: 8px 12px; }
  .outcome { font-size: 1.2rem; }
  .loot-card { width: 170px; }
  .loot-card .card { --cw: 150px; }
  .loot-card:has(.give-row) { width: calc(50% - 9px); flex-direction: row; align-items: flex-start; gap: 10px; }
  .loot-card:has(.give-row) .card { --cw: 110px; margin: 0; }
  .loot-card .give-row { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .give-btn { min-width: 0; min-height: 34px; }
  .give-btn > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .panel .done-bar { padding-top: 8px; }

  /* The board beside the pack instead of above it. */
  .map-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
  .board-svg { max-height: calc(100vh - 120px); max-height: calc(100dvh - 120px); }

  /* Battle: enemy, your hand, then the party, as on a phone held upright. */
  .battle { gap: 10px; }
  .battlefield { display: contents; }
  .enemy-stage { order: 1; padding: 10px 14px; gap: 14px; }
  .my-area { order: 2; padding: 10px 12px; }
  .allies { order: 3; grid-template-columns: 1fr 1fr; gap: 8px; }
  .ally { padding: 8px; }
  .ally .portrait.medium { width: 44px; }
  .enemy-frame { width: 96px; }
  .enemy-info h2 { font-size: 1.6rem; }
  .my-hero .portrait.large { width: 64px; }
  .hand { min-height: 0; padding-top: 24px; }
  .card.size-hand { --cw: 116px; }

  .lobby-hero { padding: 1vh 0 0.6rem; }
  .lobby-hero h1 { font-size: 2.6rem; }

  /* Dice, banners and splash screens fit the height. */
  .die3d { width: 110px; height: 110px; }
  .die3d.solo { width: 150px; height: 150px; margin: -8px 0 -10px; }
  .dice-card { padding-top: 10px; padding-bottom: 12px; }
  .dice-label { margin-bottom: 4px; }
  .dice-dc { flex-direction: row; gap: 8px; padding: 2px 14px; }
  .dice-dc b { font-size: 1.4rem; }
  .banner-art svg { height: 64px; }
  .splash-portrait, .fx-splash.boss .splash-portrait { width: 38vh; height: 38vh; margin: 4px auto; }
  .splash-title { font-size: 2.4rem; }
  .splash-kicker { font-size: 1rem; }
  .splash-sub { font-size: 1rem; }
  .end-screen { padding: 2vh 0; }
  .end-art svg { width: 90px; height: 90px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* =====================================================================
   HOME: the tavern stage, live tables, the Hall of Legends, the heroes
   In the printed board's colours: raspberry, ochre, steel blue, teal,
   charcoal and cream.
   ===================================================================== */
.tavern-home {
  --board-raspberry: #ac4866;
  --board-ochre: #bf8d40;
  --board-blue: #2c6da2;
  --board-teal: #278b6d;
  --board-charcoal: #2b2622;
  --board-cream: #f8dfc5;
  max-width: 1180px;
}
.tavern-home .home-top { flex-wrap: wrap; }

.live-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 11px; border-radius: 99px; font-size: 0.85rem;
  background: var(--panel-bg); border: 1.5px solid var(--rule); color: var(--ink-soft);
}
.live-pill b { color: var(--ink); }
.live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: #3fbf8a; box-shadow: 0 0 0 0 rgba(63, 191, 138, 0.6);
  animation: live-pulse 2s ease-out infinite;
}
@keyframes live-pulse { 70%, 100% { box-shadow: 0 0 0 7px rgba(63, 191, 138, 0); } }

/* ---------- The stage ---------- */
.home-stage {
  position: relative; isolation: isolate; overflow: hidden;
  margin: 10px 0 22px; border-radius: 18px;
  color: #f3e5d8;
  background:
    radial-gradient(ellipse 60% 55% at 50% 30%, rgba(172, 72, 102, 0.3), transparent 70%),
    radial-gradient(ellipse 80% 60% at 50% 110%, rgba(44, 109, 162, 0.22), transparent 70%),
    var(--board-charcoal);
  border: 2px solid #1a1613;
  box-shadow: 0 24px 50px -24px rgba(0, 0, 0, 0.6), inset 0 0 0 4px var(--board-charcoal), inset 0 0 0 5px rgba(248, 223, 197, 0.2);
}
/* The board turns slowly behind everything, fading out towards the edges. */
.stage-board {
  position: absolute; z-index: -1; left: 50%; top: 50%;
  width: min(1100px, 150%); aspect-ratio: 1; translate: -50% -50%;
  opacity: 0.17;
  -webkit-mask-image: radial-gradient(circle, #000 30%, transparent 66%);
          mask-image: radial-gradient(circle, #000 30%, transparent 66%);
  animation: stage-turn 240s linear infinite;
}
.stage-board img, .stage-board svg { width: 100%; height: 100%; display: block; object-fit: contain; }
@keyframes stage-turn { to { rotate: 360deg; } }
.stage-inner { position: relative; padding: clamp(22px, 4vw, 42px) clamp(14px, 4vw, 44px) clamp(18px, 3.5vw, 36px); text-align: center; }
.home-stage .title-logo img { width: min(620px, 94%); filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.55)); }
.home-stage .tagline { color: #e6d6c6; margin-top: 6px; }

.live-ticker { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 16px 0 24px; padding: 0; }
.live-ticker li {
  padding: 5px 13px; border-radius: 99px; font-size: 0.92rem; color: #e6d6c6;
  background: rgba(248, 223, 197, 0.08); border: 1px solid rgba(248, 223, 197, 0.2);
}
.live-ticker b { color: #fff6ee; font-size: 1.08rem; margin-right: 2px; }

/* The two ways in: cream cards on the dark stage, the same in either theme. */
.stage-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 880px; margin: 0 auto; text-align: left; }
.action-card {
  --ink: #403933; --ink-soft: #6b5d52; --paper: #fff6ee; --panel-bg: #fff6ee; --rule: #a39281;
  --button-bg: #403933; --button-ink: #fff6ee;
  position: relative; display: flex; flex-direction: column; gap: 10px;
  padding: 18px 20px 20px; border-radius: 14px;
  background: var(--paper); color: var(--ink);
  border: 2px solid #1a1613; box-shadow: 0 6px 0 #1a1613;
}
/* A board tile in the corner: raspberry to start, blue to join. */
.action-card::after {
  content: ""; position: absolute; top: 16px; right: 18px; width: 30px; height: 26px;
  background: var(--tile); clip-path: polygon(50% 0, 100% 100%, 0 100%);
  box-shadow: inset 0 0 0 2px var(--board-cream);
}
.action-start { --tile: var(--board-raspberry); }
.action-join { --tile: var(--board-blue); }
.action-kicker { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--tile); }
.action-card h2 { margin: 0; font-size: 1.75rem; color: var(--ink); }
.action-card p { margin: 0; color: var(--ink-soft); }
.action-card .big { align-self: stretch; margin-top: auto; border-color: #1a1613; background: var(--tile); color: #fff6ee; }
.action-card .visibility { align-self: stretch; }
.action-join #room-code {
  width: 100%; text-align: center; font-size: 1.6rem; letter-spacing: 0.32em; padding: 0.35em 0.5em;
  background: #fff; color: var(--ink); border: 2px dashed var(--rule); border-radius: 10px;
}
.action-join #room-code:focus { border-style: solid; border-color: var(--board-blue); outline: none; }

/* ---------- Live panels ---------- */
.home-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; align-items: start; }
.home-panel {
  position: relative; padding: 20px 18px 18px; border-radius: 14px;
  background: var(--panel-bg); border: 1.5px solid var(--rule);
  box-shadow: 0 12px 26px -18px var(--shadow);
}
.home-panel::before {
  content: ""; position: absolute; left: 18px; right: 18px; top: -1.5px; height: 5px;
  border-radius: 0 0 5px 5px; background: var(--band);
}
.tables-panel { --band: var(--board-raspberry); }
.legends-panel { --band: var(--board-ochre); }
.adventures-panel { --band: var(--board-blue); }
.home-panel > h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0; font-size: 1.45rem; }
.home-panel > .flavor { margin: 2px 0 12px; }
.live-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--board-teal); }

.table-row, .adventure-row { background: var(--paper); padding: 9px 12px; }
@media (hover: hover) {
  .table-row:hover { border-color: var(--board-raspberry); }
  .adventure-row:hover { border-color: var(--board-blue); }
}
.table-seats { display: flex; gap: 4px; flex: none; }
.table-seat {
  width: 32px; height: 32px; border-radius: 8px; overflow: hidden; flex: none;
  background: radial-gradient(circle at 50% 35%, var(--cls-light, #b9a67f), var(--cls, #6c5638));
  border: 1.5px solid #2a1c0f;
}
/* Small seats show the hero's face, not the whole portrait. */
.table-seat svg, .table-seat img { width: 100%; height: 100%; display: block; transform: scale(1.7) translateY(10%); }
.empty-table .table-seat svg { transform: none; }
.table-seat.empty { display: grid; place-items: center; background: transparent; border: 1.5px dashed var(--rule); color: var(--ink-soft); font-size: 1rem; }
.table-info { flex: 1; min-width: 0; display: flex; flex-direction: column; color: var(--ink); }
.table-info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-info small { color: var(--ink-soft); font-size: 0.85rem; }
.table-join { font-weight: 700; color: var(--board-raspberry); white-space: nowrap; }
.adventure-icon { font-size: 1.5rem; width: 36px; text-align: center; flex: none; }
.empty-table { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 6px 4px 2px; }
.empty-table .table-seat { width: 46px; height: 46px; border-radius: 12px; }
.empty-table p { margin: 0; color: var(--ink-soft); max-width: 32ch; }
.empty-table button { background: var(--board-raspberry); border-color: #1a1613; color: #fff6ee; }

/* The Hall of Legends: a podium, then the next names. */
.podium { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-areas: "second first third"; align-items: end; gap: 8px; margin: 6px 0 12px; }
.podium-step { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; text-align: center; }
.podium-step.rank-1 { grid-area: first; }
.podium-step.rank-2 { grid-area: second; }
.podium-step.rank-3 { grid-area: third; }
.podium-step b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-step small { color: var(--ink-soft); }
.podium-step.me b { color: var(--board-raspberry); }
.podium-medal {
  display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 4px; border-radius: 50%;
  font-weight: 700; color: #2a1c0f; border: 2px solid #2a1c0f;
}
.rank-1 .podium-medal { width: 42px; height: 42px; font-size: 1.2rem; background: radial-gradient(circle at 35% 30%, #fff1b0, #d9b230 60%, #9c7317); }
.rank-2 .podium-medal { background: radial-gradient(circle at 35% 30%, #ffffff, #c9c9c9 60%, #8a8a8a); }
.rank-3 .podium-medal { background: radial-gradient(circle at 35% 30%, #ffd9b0, #c98a52 60%, #8a5426); }
.podium-block { width: 100%; margin-top: 6px; border-radius: 8px 8px 0 0; border: 1.5px solid #2a1c0f; border-bottom: none; }
.rank-1 .podium-block { height: 64px; background: linear-gradient(var(--board-ochre), #8f6526); }
.rank-2 .podium-block { height: 44px; background: linear-gradient(var(--board-blue), #1d4a73); }
.rank-3 .podium-block { height: 30px; background: linear-gradient(var(--board-raspberry), #7a2f47); }
.legends-panel .leaderboard { margin-top: 0; }
.empty-podium { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 8px 4px; }
.empty-podium span { font-size: 2.4rem; filter: grayscale(0.4); }
.empty-podium p { margin: 0; color: var(--ink-soft); max-width: 32ch; }
.see-all { text-align: center; margin: 8px 0 0; font-size: 0.92rem; }

/* ---------- The heroes ---------- */
.hero-roster { margin: 30px 0 6px; text-align: center; }
.hero-roster h2 { margin: 0; font-size: 1.6rem; }
.hero-roster .flavor { margin: 2px auto 14px; }
.roster { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; text-align: left; }
.roster-card {
  display: flex; gap: 12px; align-items: center; padding: 12px;
  background: var(--panel-bg); border: 1.5px solid var(--rule); border-radius: 14px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
@media (hover: hover) { .roster-card:hover { transform: translateY(-4px); box-shadow: 0 14px 24px -16px var(--shadow); } }
.roster-portrait {
  width: 76px; aspect-ratio: 1; flex: none; overflow: hidden; border-radius: 16px;
  background: radial-gradient(circle at 50% 35%, var(--cls-light), var(--cls)); border: 2px solid #2a1c0f;
}
.roster-portrait svg, .roster-portrait img { width: 100%; height: 100%; display: block; }
.roster-text { min-width: 0; }
.roster-card h3 { margin: 0 0 4px; font-size: 1.25rem; }
.roster-stats { display: flex; gap: 12px; margin: 0; }
.roster-stats div { display: flex; flex-direction: column; }
.roster-stats dt { font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.roster-stats dd { margin: 0; font-weight: 700; white-space: nowrap; }

@media (max-width: 960px) {
  .roster { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .stage-actions { grid-template-columns: 1fr; }
  .home-stage { margin-inline: -4px; border-radius: 14px; }
  .action-card h2 { font-size: 1.5rem; }
}
@media (max-width: 460px) {
  .roster { grid-template-columns: 1fr; }
  .home-panels { grid-template-columns: 1fr; }
  .live-ticker li { font-size: 0.82rem; padding: 4px 10px; }
}
.performance .stage-board, .performance .live-dot { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .stage-board, .live-dot { animation: none; }
}


/* =====================================================================
   PAGES, WINDOWS AND SETTINGS
   Each page and window takes a colour from the printed board, so they
   match without looking alike: Play raspberry, Legends ochre, How to play
   teal, Account steel blue; windows the same, and Settings in ochre.
   ===================================================================== */
.tone-plain, .tone-settings, .tone-legends, .page-leaderboard { --tone: #bf8d40; }
.tone-party, .tone-danger, .tone-play, .page-play { --tone: #ac4866; }
.tone-rules, .page-rules { --tone: #278b6d; }
.tone-auth, .tone-account, .page-account { --tone: #2c6da2; }

/* ---------- The navigation bar ---------- */
.site-nav {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 6px 14px; margin-top: 4px;
  background: #2b2622; color: #f3e5d8;
  border: 2px solid #1a1613; border-radius: 14px;
  box-shadow: 0 10px 24px -16px rgba(0, 0, 0, 0.6);
}
.nav-logo { display: block; flex: none; }
.nav-logo img { display: block; height: 34px; width: auto; }
.nav-tabs { display: flex; gap: 4px; margin-left: 8px; }
.nav-tab {
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 10px;
  color: #e6d6c6; text-decoration: none; white-space: nowrap;
  font-family: "IM Fell English SC", Georgia, serif; font-size: 1.02rem;
  transition: background 0.15s, color 0.15s;
}
.nav-tab.tab-play { --tab: #ac4866; }
.nav-tab.tab-leaderboard { --tab: #bf8d40; }
.nav-tab.tab-rules { --tab: #278b6d; }
.nav-tab.tab-account { --tab: #2c6da2; }
.nav-tab:hover { background: rgba(248, 223, 197, 0.08); color: #fff6ee; }
.nav-tab.on { background: rgba(248, 223, 197, 0.12); color: #fff6ee; }
/* The open page's tab carries a small board tile in its colour. */
.nav-tab.on::after {
  content: ""; position: absolute; left: 50%; bottom: -1px; width: 14px; height: 7px; translate: -50% 0;
  background: var(--tab); clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.nav-icon { font-size: 1rem; }
.tab-account .nav-label { max-width: 10em; overflow: hidden; text-overflow: ellipsis; }
.nav-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.site-nav .live-pill { background: rgba(248, 223, 197, 0.08); border-color: rgba(248, 223, 197, 0.2); color: #e6d6c6; }
.site-nav .live-pill b { color: #fff6ee; }

/* The gear. */
.icon-btn {
  display: grid; place-items: center; flex: none;
  width: 38px; height: 38px; padding: 0; border-radius: 50%;
  background: transparent; color: var(--ink); border: 1.5px solid var(--rule);
}
.icon-btn svg { width: 22px; height: 22px; transition: rotate 0.4s ease; }
@media (hover: hover) { .icon-btn:hover svg { rotate: 60deg; } }
.site-nav .icon-btn { color: #f3e5d8; border-color: rgba(248, 223, 197, 0.3); }
.top-bar .icon-btn, .room-top .icon-btn { width: 34px; height: 34px; }
.top-bar .icon-btn svg, .room-top .icon-btn svg { width: 19px; height: 19px; }
.party-btn { white-space: nowrap; }

/* ---------- Page headings and cards ---------- */
.page-main { min-height: 50vh; }
.page-head { text-align: center; max-width: 720px; margin: clamp(22px, 4vw, 40px) auto clamp(16px, 3vw, 24px); }
.page-kicker {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--tone);
}
.page-tile { display: inline-block; width: 16px; height: 14px; background: var(--tone); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.page-head h1 { font-size: clamp(2.1rem, 5.5vw, 3.2rem); margin: 4px 0 6px; overflow-wrap: anywhere; }
.page-head .tagline { margin-top: 0; }
.page-card {
  background: var(--panel-bg); border: 1.5px solid var(--rule); border-top: 5px solid var(--tone, var(--rule));
  border-radius: 16px; padding: clamp(16px, 3vw, 26px);
  box-shadow: 0 14px 30px -20px var(--shadow);
}
.page-card > h2 { font-size: 1.4rem; margin: 0 0 12px; }
.legends-page { max-width: 760px; margin: 0 auto; }
.legends-page .podium { margin: 4px auto 18px; max-width: 520px; }
.legends-page .rank-1 .podium-block { height: 84px; }
.legends-page .rank-2 .podium-block { height: 58px; }
.legends-page .rank-3 .podium-block { height: 38px; }
.rules-page { max-width: 820px; margin: 0 auto; }
.rules-page .rules h3 { color: var(--tone); margin-top: 18px; }
.rules-page .rules > p:first-child { font-size: 1.1rem; }
.page-cta { text-align: center; margin: 22px 0 0; }
.cta-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0.6em 1.4em; border-radius: 10px; text-decoration: none;
  font-family: "IM Fell English SC", Georgia, serif; font-size: 1.15rem;
  background: #ac4866; color: #fff6ee; border: 1.5px solid #1a1613; box-shadow: 0 4px 0 #1a1613;
}
.cta-btn:hover { filter: brightness(1.08); }
.link-arrow { color: var(--tone, var(--ink)); font-weight: 700; text-decoration: none; }
.link-arrow:hover { text-decoration: underline; }
.legends-panel { --tone: #bf8d40; }

/* ---------- Account ---------- */
.account-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 18px; max-width: 920px; margin: 0 auto; align-items: start; }
.account-perks { padding: 8px 6px; }
.account-perks h2 { font-size: 1.35rem; margin: 0 0 12px; }
.account-perks ul { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 14px; }
.account-perks li { display: flex; gap: 12px; align-items: flex-start; }
.account-perks li b { display: block; }
.account-perks li span { color: var(--ink-soft); }
.account-perks li b { color: var(--ink); }
.perk-tile { flex: none; width: 24px; height: 21px; margin-top: 2px; background: var(--tile); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.avatar {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: #2b2622; color: #f8dfc5; border: 2px solid var(--tone, #bf8d40);
  font-family: "IM Fell English SC", Georgia, serif; font-size: 1.2rem;
}
.avatar.big { width: 74px; height: 74px; font-size: 2.2rem; border-width: 3px; }
.avatar.guest { background: transparent; color: var(--ink-soft); border-style: dashed; border-color: var(--rule); }
.profile-top { display: flex; align-items: center; gap: 14px; }
.profile-top h2 { margin: 0; font-size: 1.6rem; overflow-wrap: anywhere; }
.profile-top small { color: var(--ink-soft); }
.profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 18px 0; padding: 12px 0; border-block: 1.5px solid var(--rule); }
.profile-stats div { text-align: center; }
.profile-stats dt { font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft); }
.profile-stats dd { margin: 0; font-size: 1.9rem; font-weight: 700; font-family: "IM Fell English SC", Georgia, serif; }

/* ---------- The sign-in form: steel blue, the account's colour ---------- */
.auth-form { --tone: #2c6da2; }
.auth-tabs { gap: 3px; padding: 3px; border-radius: 12px; }
.auth-tabs button { border-radius: 9px; font-family: "IM Fell English SC", Georgia, serif; font-size: 1rem; }
.auth-tabs button.on { background: var(--tone); color: #fff6ee; }
.auth-form input { border-radius: 10px; border: 1.5px solid var(--rule); background: var(--paper); color: var(--ink); }
.auth-form input:focus { outline: none; border-color: var(--tone); box-shadow: 0 0 0 3px rgba(44, 109, 162, 0.25); }
.auth-form button[type="submit"] { background: var(--tone); color: #fff6ee; border-color: #1a1613; border-radius: 10px; box-shadow: 0 4px 0 #1a1613; }
.auth-card .auth-form { max-width: none; }

/* ---------- Windows ---------- */
.modal.window { padding: 0; border: 2px solid #1a1613; border-radius: 16px; box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.65); }
.window-head {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px 12px 18px;
  background: #2b2622; color: #f8dfc5;
  border-bottom: 4px solid var(--tone);
}
.window-head h2 { margin: 0; flex: 1; min-width: 0; font-size: 1.4rem; color: #f8dfc5; }
.window-tile { flex: none; width: 18px; height: 16px; background: var(--tone); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.window-close {
  display: grid; place-items: center; flex: none; width: 34px; height: 34px; padding: 0; border-radius: 50%;
  background: rgba(248, 223, 197, 0.1); color: #f8dfc5; border: 1px solid rgba(248, 223, 197, 0.3); font-size: 0.95rem;
}
.window-close:hover { background: rgba(248, 223, 197, 0.2); }
.window-body { padding: 16px 18px 18px; }
.window-body > .flavor:first-child { margin-top: 0; }

/* ---------- Settings and the party window ---------- */
.settings-group { margin: 0 0 16px; }
.settings-group:last-of-type { margin-bottom: 6px; }
.settings-group h3 {
  margin: 0 0 6px 2px; font-family: inherit; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-soft);
}
.setting-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; margin-bottom: 6px;
  padding: 9px 12px; text-align: left; font-weight: 400;
  background: var(--paper); color: var(--ink); border: 1.5px solid var(--rule); border-radius: 12px;
}
button.setting-row:hover { transform: none; box-shadow: none; border-color: var(--tone); }
.setting-icon { flex: none; width: 1.6em; text-align: center; font-size: 1.1rem; }
.setting-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.setting-text small { color: var(--ink-soft); font-size: 0.8rem; }
.row-go { color: var(--ink-soft); font-size: 1.4rem; line-height: 1; }
.danger-row .setting-text, .danger-row .setting-icon { color: var(--bad); }
button.danger-row:hover { border-color: var(--bad); }
.switch {
  position: relative; flex: none; width: 46px; height: 27px; border-radius: 99px;
  background: color-mix(in srgb, var(--ink) 18%, transparent); border: 1.5px solid var(--rule);
  transition: background 0.2s, border-color 0.2s;
}
.switch span {
  position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); transition: transform 0.2s;
}
.switch.on { background: #278b6d; border-color: #1d6b54; }
.switch.on span { transform: translateX(19px); }
.volume-row input[type="range"] { flex: 1.3; min-width: 90px; accent-color: var(--tone); }
.volume-row output { width: 3.2em; text-align: right; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; border: 1.5px solid var(--rule); }
.segmented button { padding: 0.3em 0.8em; border: 0; border-radius: 7px; background: transparent; color: var(--ink); box-shadow: none; }
.segmented button:hover { transform: none; box-shadow: none; }
.segmented button.on { background: #2b2622; color: #f8dfc5; }
.settings-account { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--tone) 12%, transparent); }
.settings-account > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.settings-account small { display: block; font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); }
.window-body .app-version { margin: 4px 0 0; }

/* ---------- The lobby, in the same family as the home page ---------- */
.lobby-form, .lobby-seats { position: relative; border-radius: 14px; }
.lobby-form::before, .lobby-seats::before {
  content: ""; position: absolute; left: 18px; right: 18px; top: -1.5px; height: 5px;
  border-radius: 0 0 5px 5px; background: var(--band-top, #ac4866);
}
.lobby-seats { --band-top: #278b6d; }
.join-urls { border-radius: 14px; border-width: 2px; }
.join-urls .room-code { color: #ac4866; }

/* ---------- Phones: the pages become a tab bar along the bottom ---------- */
@media (max-width: 720px) {
  .site-nav { padding: 6px 8px 6px 12px; }
  .nav-logo img { height: 28px; }
  .nav-tabs {
    position: fixed; z-index: 19; left: 0; right: 0; bottom: 0; margin: 0;
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    background: #2b2622; border-top: 2px solid #1a1613;
    box-shadow: 0 -8px 20px -12px rgba(0, 0, 0, 0.6);
  }
  .nav-tab { flex-direction: column; gap: 1px; padding: 6px 2px 7px; font-size: 0.78rem; min-width: 0; }
  .nav-icon { font-size: 1.25rem; }
  .nav-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .nav-tab.on::after { bottom: auto; top: -8px; rotate: 180deg; }
  body[data-page]:not([data-page=""]) .tavern-home { padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px)); }
  .account-grid { grid-template-columns: 1fr; }
  .window-head { padding: 10px 10px 10px 14px; }
  .window-head h2 { font-size: 1.25rem; }
  .window-body { padding: 14px 14px calc(18px + env(safe-area-inset-bottom, 0px)); }
  .theme-row { flex-wrap: wrap; }
  .theme-row .segmented { margin-left: auto; }
}
.page-card.auth-card { max-width: none; margin: 0; }
