/* ═══════════════════════════════════════════════════════════════
   MILLIONAIRE RACE 2.5D — Wealth & Asset Tycoon Studio
   Stylesheet · luxury fintech / board-game hybrid
   ═══════════════════════════════════════════════════════════════ */

/* ───────────── Design tokens ───────────── */
:root {
  --bg: #06080c;
  --bg-2: #0a0f16;
  --panel: rgba(14, 20, 29, 0.82);
  --panel-solid: #0e141d;
  --panel-2: rgba(21, 29, 41, 0.72);
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #e9eef6;
  --text-dim: #a4b1c4;
  --muted: #7686a0;
  --gold: #f2c53d;
  --gold-2: #ffe08a;
  --gold-deep: #a97c10;
  --green: #3ddc97;
  --red: #ff6b6b;
  --blue: #5b9dff;
  --purple: #b088ff;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.6);
  --font: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.45;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select { font-family: inherit; }
button { touch-action: manipulation; }
::selection { background: rgba(242, 197, 61, 0.28); color: #fff; }

/* ───────────── Ambient background ───────────── */
.bg-aurora {
  position: fixed;
  inset: -20%;
  z-index: -2;
  background:
    radial-gradient(48% 42% at 18% 8%, rgba(242, 197, 61, 0.13), transparent 62%),
    radial-gradient(46% 46% at 88% 12%, rgba(64, 118, 255, 0.15), transparent 65%),
    radial-gradient(60% 52% at 50% 108%, rgba(24, 130, 94, 0.14), transparent 68%),
    linear-gradient(180deg, #070b11 0%, #05070a 100%);
  filter: saturate(1.1);
  animation: auroraDrift 26s ease-in-out infinite alternate;
}
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(80% 70% at 50% 40%, #000 25%, transparent 100%);
  -webkit-mask-image: radial-gradient(80% 70% at 50% 40%, #000 25%, transparent 100%);
  pointer-events: none;
}

@keyframes auroraDrift {
  0% { transform: translate3d(-1.5%, -1%, 0) scale(1); }
  100% { transform: translate3d(1.5%, 1.5%, 0) scale(1.06); }
}

/* ───────────── Top bar ───────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 26px 14px;
  position: relative;
  z-index: 5;
  max-width: 1276px;
  margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark {
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-size: 1.5625rem;
  border-radius: 15px;
  background:
    linear-gradient(155deg, rgba(242, 197, 61, 0.22), rgba(242, 197, 61, 0.04)),
    linear-gradient(180deg, #121a25, #0a0f16);
  border: 1px solid rgba(242, 197, 61, 0.34);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 10px 26px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: -40% -60%;
  background: linear-gradient(100deg, transparent 40%, rgba(255, 255, 255, 0.18) 50%, transparent 60%);
  animation: sheen 6.5s ease-in-out infinite;
}
@keyframes sheen { 0%, 62% { transform: translateX(-70%); } 100% { transform: translateX(70%); } }

.brand-copy h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.25rem, 1.75vw, 1.6875rem);
  letter-spacing: 0.2px;
  line-height: 1.05;
  color: #fdfaf0;
  white-space: nowrap;
}
.brand-copy h1 em {
  font-style: italic;
  background: linear-gradient(100deg, var(--gold-2), var(--gold) 55%, #fff3c4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-right: 2px;
}
.brand-copy p {
  margin: 4px 0 0;
  font-size: 0.6562rem;
  font-weight: 500;
  letter-spacing: 2.12px;
  text-transform: uppercase;
  color: var(--muted);
}

.topbar-stats {
  display: flex;
  gap: 10px;
  margin-left: auto;
}
.stat {
  min-width: 92px;
  padding: 8px 12px;
  border-radius: 13px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018));
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.stat span {
  font-size: 0.5938rem;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.stat strong {
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat-target strong {
  background: linear-gradient(100deg, var(--gold-2), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.topbar-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }

.ghost-btn, .icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-dim);
  border-radius: 11px;
  padding: 9px 11px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s, background 0.18s, transform 0.18s;
  white-space: nowrap;
}
.ghost-btn:hover, .icon-btn:hover {
  border-color: rgba(242, 197, 61, 0.4);
  color: #fff;
  background: rgba(242, 197, 61, 0.08);
  transform: translateY(-1px);
}
.ghost-btn.danger:hover {
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.09);
  color: #ffc7c7;
}
.icon-btn { font-size: 0.9375rem; padding: 8px 10px; line-height: 1; }
#rulesBtn { font-size: 0; padding: 8px 10px; }
#rulesBtn::first-letter { font-size: 1rem; }
#fullscreenBtn[aria-pressed="true"] {
  color: var(--gold-2);
  border-color: rgba(242, 197, 61, 0.4);
  background: rgba(242, 197, 61, 0.1);
}

/* ───────────── Layout ───────────── */
.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 356px;
  gap: 20px;
  padding: 2px 26px 24px;
  align-items: start;
  max-width: 1276px;
  margin: 0 auto;
}

.board-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.board-frame {
  position: relative;
  width: 100%;
  max-width: min(calc(100vh - 232px), 960px);
  aspect-ratio: 1 / 1;
  border-radius: 28px;
  background: #0a0f15;
  box-shadow:
    0 0 0 1px rgba(242, 197, 61, 0.18),
    0 0 0 8px rgba(255, 255, 255, 0.018),
    0 32px 90px rgba(0, 0, 0, 0.72),
    0 0 90px rgba(242, 197, 61, 0.06);
  isolation: isolate;
}
.board-frame::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 29px;
  padding: 1px;
  background: linear-gradient(150deg, rgba(255, 226, 143, 0.55), rgba(242, 197, 61, 0.08) 32%, transparent 55%, rgba(90, 140, 255, 0.22));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 2;
}
#board {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 28px;
  cursor: default;
}
.board-vignette {
  position: absolute;
  inset: 0;
  border-radius: 28px;
  pointer-events: none;
  box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.55);
  z-index: 1;
}

/* ───────────── Control dock ───────────── */
@keyframes dotPulse { 50% { opacity: 0.45; transform: scale(0.8); } }

.dock {
  width: 100%;
  max-width: min(calc(100vh - 232px), 960px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-radius: 17px;
  background: linear-gradient(180deg, rgba(20, 28, 40, 0.92), rgba(11, 16, 23, 0.94));
  border: 1px solid var(--line);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  min-height: 68px;
  position: relative;
  overflow: hidden;
}
.dock::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--gold-2), transparent);
  opacity: 0.6;
}
.dock-status { min-width: 0; }
.dock-player {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dock-player .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 10px currentColor;
  flex: 0 0 auto;
}
.dock-hint {
  margin: 3px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60ch;
}
.dock-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; flex: 0 0 auto; }

/* ───────────── Buttons ───────────── */
.btn {
  appearance: none;
  border: 0;
  border-radius: 11px;
  padding: 11px 17px;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.25px;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease, background 0.16s;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  color: #f5f8fc;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:focus-visible, .ghost-btn:focus-visible, .icon-btn:focus-visible, .mini-btn:focus-visible,
.swatch:focus-visible, .segmented button:focus-visible, .lobby-type button:focus-visible, .text-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.4); }

.btn-primary {
  background: linear-gradient(180deg, #2b3a51, #1a2534);
  border: 1px solid rgba(140, 175, 230, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 8px 20px rgba(0, 0, 0, 0.34);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #354866, #1e2b3d);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 10px 26px rgba(48, 90, 160, 0.35);
  transform: translateY(-1px);
}
.btn-gold {
  background: linear-gradient(180deg, #ffe08a 0%, #f2c53d 42%, #d8a51c 100%);
  color: #241a02;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), inset 0 -2px 4px rgba(120, 78, 0, 0.35), 0 10px 28px rgba(242, 197, 61, 0.24);
}
.btn-gold::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.45) 50%, transparent 65%);
  transform: translateX(-120%);
  transition: transform 0.6s ease;
}
.btn-gold:hover:not(:disabled) { filter: brightness(1.06); transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 14px 34px rgba(242, 197, 61, 0.34); }
.btn-gold:hover:not(:disabled)::after { transform: translateX(120%); }
.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-strong);
  color: var(--text-dim);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.09); color: #fff; border-color: rgba(255, 255, 255, 0.26); }
.btn-lg { padding: 14px 22px; font-size: 0.875rem; border-radius: 13px; }

.mini-btn {
  appearance: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.6562rem;
  font-weight: 600;
  padding: 4px 9px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.mini-btn:hover { color: #fff; border-color: rgba(242, 197, 61, 0.4); background: rgba(242, 197, 61, 0.08); }

.text-btn {
  appearance: none;
  background: none;
  border: 0;
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(242, 197, 61, 0.4);
}
.text-btn:hover { color: var(--gold-2); }

/* ───────────── Sidebar panels ───────────── */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 13px;
  height: calc(100vh - 104px);
  max-height: calc(100vh - 104px);
  position: sticky;
  top: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 99px; }
.leaderboard-panel { flex: 0 0 auto; }
.panel {
  background: linear-gradient(180deg, rgba(18, 25, 36, 0.9), rgba(10, 15, 22, 0.92));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.045);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 15px 9px;
}
.panel-head h2 {
  margin: 0;
  font-size: 0.6562rem;
  font-weight: 700;
  letter-spacing: 1.7px;
  text-transform: uppercase;
  color: var(--text-dim);
}
.panel-head-meta { display: flex; align-items: center; gap: 8px; }
.ledger-round {
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.7px;
  color: var(--gold-2);
  background: rgba(242, 197, 61, 0.09);
  border: 1px solid rgba(242, 197, 61, 0.24);
  padding: 2px 7px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.pill {
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--green);
  background: rgba(61, 220, 151, 0.1);
  border: 1px solid rgba(61, 220, 151, 0.26);
  padding: 3px 8px;
  border-radius: 999px;
}
.pill::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 5px;
  vertical-align: 1px;
  animation: dotPulse 1.8s infinite;
}

.empty-note { color: var(--muted); font-size: 0.75rem; margin: 4px 15px 14px; }

/* Leaderboard */
.leaderboard { padding: 0 10px 10px; display: flex; flex-direction: column; gap: 7px; }
.lb-row {
  display: grid;
  grid-template-columns: 5px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.024);
  border: 1px solid transparent;
  position: relative;
  transition: background 0.25s, border-color 0.25s;
}
.lb-row.is-turn {
  background: linear-gradient(100deg, rgba(242, 197, 61, 0.09), rgba(242, 197, 61, 0.025));
  border-color: rgba(242, 197, 61, 0.3);
}
.lb-row.is-turn::after {
  content: "TURN";
  position: absolute;
  top: -6px;
  right: 10px;
  font-size: 0.5rem;
  letter-spacing: 1px;
  font-weight: 800;
  color: #241a02;
  background: var(--gold);
  padding: 1px 6px;
  border-radius: 4px;
}
.lb-row.bankrupt { opacity: 0.42; filter: grayscale(0.6); }
.lb-color {
  width: 4px;
  height: 34px;
  border-radius: 99px;
  background: var(--pc, #888);
  box-shadow: 0 0 10px var(--pc, #888);
}
.lb-main { min-width: 0; }
.lb-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7812rem;
  font-weight: 700;
  letter-spacing: 0.15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-name .tag {
  font-size: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 1px 4px;
  flex: 0 0 auto;
}
.lb-name .tag.ai { color: #9db4d8; border-color: rgba(120, 160, 220, 0.3); }
.lb-sub {
  display: flex;
  gap: 9px;
  font-size: 0.6562rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}
.lb-bar {
  grid-column: 1 / -1;
  height: 3px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  margin-top: 1px;
}
.lb-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pc, #888), color-mix(in srgb, var(--pc, #888) 45%, #fff));
  box-shadow: 0 0 8px var(--pc, #888);
  transition: width 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.lb-value { text-align: right; }
.lb-value strong {
  display: block;
  font-size: 0.7812rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.1px;
}
.lb-value span { font-size: 0.5938rem; color: var(--muted); }

/* Log */
.log-panel { display: flex; flex-direction: column; flex: 1 1 0; min-height: 150px; max-height: 280px; }
.log {
  overflow-y: auto;
  padding: 0 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 auto;
  max-height: none;
  min-height: 80px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}
.log::-webkit-scrollbar { width: 6px; }
.log::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 99px; }
.log-entry {
  font-size: 0.7188rem;
  line-height: 1.45;
  color: var(--text-dim);
  padding: 4px 7px;
  border-radius: 7px;
  border-left: 2px solid transparent;
  animation: logIn 0.28s ease;
  overflow-wrap: anywhere;
}
@keyframes logIn { from { opacity: 0; transform: translateY(-3px); } }
.log-entry .t { color: #52617a; font-variant-numeric: tabular-nums; margin-right: 5px; font-size: 0.625rem; }
.log-entry.good { border-left-color: rgba(61, 220, 151, 0.5); background: rgba(61, 220, 151, 0.055); color: #b9ecd6; }
.log-entry.bad { border-left-color: rgba(255, 107, 107, 0.5); background: rgba(255, 107, 107, 0.055); color: #ffc3c3; }
.log-entry.warn { border-left-color: rgba(242, 197, 61, 0.5); background: rgba(242, 197, 61, 0.05); color: #f4dfa2; }
.log-entry.special { border-left-color: rgba(176, 136, 255, 0.55); background: rgba(176, 136, 255, 0.06); color: #d9c9ff; }
.log-entry.info { border-left-color: rgba(91, 157, 255, 0.35); }

/* Legend */
.legend-panel { flex: 0 0 auto; }
.legend { list-style: none; margin: 0; padding: 0 15px 14px; display: flex; flex-direction: column; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 0.6562rem; color: var(--muted); }
.legend b { color: var(--text-dim); font-weight: 600; }
.swatch-dot { width: 7px; height: 7px; border-radius: 2px; flex: 0 0 auto; }
.swatch-dot.go { background: var(--gold); box-shadow: 0 0 6px rgba(242, 197, 61, 0.6); }
.swatch-dot.asset { background: #6ea8ff; }
.swatch-dot.chance { background: #ffb347; }
.swatch-dot.tax { background: #ff6b6b; }

/* ───────────── Modals ───────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(3, 5, 9, 0.76);
  backdrop-filter: blur(14px) saturate(0.9);
  -webkit-backdrop-filter: blur(14px) saturate(0.9);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s ease, visibility 0.28s;
}
.modal-overlay.show { opacity: 1; visibility: visible; pointer-events: auto; }
.modal-overlay:not(.show) {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.modal {
  width: 100%;
  max-height: calc(100vh - 44px);
  overflow-y: auto;
  background: linear-gradient(180deg, #111925 0%, #0a0f16 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.09);
  transform: translateY(14px) scale(0.985);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.25, 1.05), opacity 0.28s ease;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}
.modal-overlay.show .modal { transform: none; opacity: 1; }
.modal::-webkit-scrollbar { width: 8px; }
.modal::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 99px; }

.eyebrow {
  margin: 0 0 3px;
  font-size: 0.5938rem;
  letter-spacing: 2.1px;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}

/* Lobby */
.lobby-modal { max-width: 790px; border-color: rgba(242, 197, 61, 0.2); }
.lobby-hero {
  text-align: center;
  padding: 34px 36px 22px;
  background:
    radial-gradient(70% 120% at 50% -20%, rgba(242, 197, 61, 0.18), transparent 62%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent);
  border-bottom: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.lobby-hero::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -1px;
  width: 220px;
  height: 1px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.7;
}
.hero-badge {
  display: inline-block;
  font-size: 0.5625rem;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--gold);
  border: 1px solid rgba(242, 197, 61, 0.34);
  background: rgba(242, 197, 61, 0.07);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 13px;
}
.lobby-hero h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.125rem, 5vw, 3.25rem);
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1;
  background: linear-gradient(180deg, #fffdf4 0%, #f4dda0 55%, #d8ab34 110%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 10px 40px rgba(242, 197, 61, 0.18);
}
.lobby-sub {
  margin: 7px 0 0;
  font-size: 0.6562rem;
  letter-spacing: 3.6px;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
}
.lobby-lede {
  max-width: 54ch;
  margin: 14px auto 0;
  font-size: 0.7812rem;
  line-height: 1.6;
  color: var(--muted);
}
.lobby-lede b { color: var(--gold-2); font-weight: 700; }

.lobby-config { padding: 20px 26px 6px; }
.player-count-row,
.match-length-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 2px 15px;
}
.player-count-row .label,
.match-length-row .label {
  font-size: 0.625rem;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.lobby-note { font-size: 0.6562rem; color: #5f6e86; margin-left: auto; }
.round-stepper {
  display: inline-flex;
  align-items: stretch;
  height: 34px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
}
.round-stepper button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  width: 30px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.round-stepper button:hover { background: rgba(242, 197, 61, 0.1); color: var(--gold-2); }
.round-stepper input {
  width: 52px;
  border: 0;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--gold-2);
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  outline: none;
  -moz-appearance: textfield;
}
.round-stepper input::-webkit-outer-spin-button,
.round-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.round-stepper input:focus-visible { box-shadow: inset 0 0 0 2px rgba(242, 197, 61, 0.45); }

.segmented {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}
.segmented button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.7188rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.17s, color 0.17s;
}
.segmented button:hover { color: var(--text); }
.segmented button.active {
  background: linear-gradient(180deg, rgba(242, 197, 61, 0.22), rgba(242, 197, 61, 0.09));
  color: var(--gold-2);
  box-shadow: inset 0 0 0 1px rgba(242, 197, 61, 0.28);
}

.lobby-players { display: flex; flex-direction: column; gap: 7px; }
.lobby-player {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.024);
  border: 1px solid var(--line);
  transition: border-color 0.2s, background 0.2s;
}
.lobby-player:focus-within { border-color: rgba(242, 197, 61, 0.32); background: rgba(242, 197, 61, 0.035); }
.lp-index {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 0.6875rem;
  font-weight: 800;
  color: var(--pc, #fff);
  background: color-mix(in srgb, var(--pc, #888) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--pc, #888) 40%, transparent);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.lp-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.lp-name {
  flex: 1 1 auto;
  min-width: 90px;
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 8px 11px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.lp-name::placeholder { color: #55637a; font-weight: 500; }
.lp-name:focus { border-color: rgba(242, 197, 61, 0.5); box-shadow: 0 0 0 3px rgba(242, 197, 61, 0.1); }
.lp-colors { display: flex; gap: 5px; flex: 0 0 auto; }
.swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--c);
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.28), inset 0 1px 1px rgba(255, 255, 255, 0.4);
}
.swatch:hover { transform: scale(1.16); }
.swatch.active { border-color: #fff; box-shadow: 0 0 0 2px var(--c), 0 0 12px var(--c); }
.swatch.taken { opacity: 0.22; cursor: not-allowed; }
.swatch.taken:hover { transform: none; }

.lp-type { display: inline-flex; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); border-radius: 8px; padding: 2px; gap: 1px; }
.lobby-type button, .lp-type button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.6562rem;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
  white-space: nowrap;
}
.lobby-type button.active, .lp-type button.active { background: rgba(91, 157, 255, 0.16); color: #bfd8ff; box-shadow: inset 0 0 0 1px rgba(91, 157, 255, 0.28); }
.lobby-type button[data-type="human"].active, .lp-type button[data-type="human"].active { background: rgba(61, 220, 151, 0.14); color: #b5f1d6; box-shadow: inset 0 0 0 1px rgba(61, 220, 151, 0.28); }

.lobby-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 26px 22px;
  flex-wrap: wrap;
}
.lobby-footer-left { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.lobby-footer-actions { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.save-hint {
  font-size: 0.6562rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.save-hint::before { content: "●"; color: var(--green); font-size: 0.5rem; animation: dotPulse 2s infinite; }

/* Dice modal */
.dice-modal { max-width: 690px; padding: 20px 22px 18px; }
.dice-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 2px 4px 10px; }
.dice-head h2 { margin: 0; font-family: var(--serif); font-size: 1.5625rem; font-weight: 600; letter-spacing: -0.2px; }
.dice-stage {
  position: relative;
  width: 100%;
  height: clamp(240px, 38vh, 340px);
  border-radius: 17px;
  overflow: hidden;
  background:
    radial-gradient(70% 90% at 50% 8%, rgba(242, 197, 61, 0.1), transparent 60%),
    linear-gradient(180deg, #0d1713 0%, #07100c 60%, #050b08 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.65);
}
.dice-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.55);
}
.dice-stage canvas { display: block; width: 100% !important; height: 100% !important; }
.dice-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.7188rem;
  letter-spacing: 0.6px;
  z-index: 1;
}
.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(242, 197, 61, 0.18);
  border-top-color: var(--gold);
  animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.dice-readout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 0 4px;
}
.die-chip {
  min-width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.3125rem;
  font-weight: 800;
  color: #1b1607;
  background: linear-gradient(160deg, #fffdf6, #f2e3b6);
  box-shadow: inset 0 2px 0 #fff, inset 0 -3px 6px rgba(150, 120, 40, 0.28), 0 6px 18px rgba(0, 0, 0, 0.35);
  font-variant-numeric: tabular-nums;
}
.dice-readout .plus, .dice-readout .equals { color: var(--muted); font-size: 0.875rem; font-weight: 600; }
.die-total {
  min-width: 58px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.375rem;
  font-weight: 800;
  color: #241a02;
  background: linear-gradient(160deg, #ffe08a, #e7b52c);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6), 0 8px 22px rgba(242, 197, 61, 0.22);
  font-variant-numeric: tabular-nums;
}
.dice-caption { text-align: center; margin: 0 0 2px; font-size: 0.6562rem; color: var(--muted); letter-spacing: 0.4px; }

/* Compact floating dice tray — keeps the board visible during the roll */
#diceModal {
  background: rgba(3, 5, 9, 0.14);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  padding: 0;
  align-items: flex-start;
  justify-content: flex-start;
}
#diceModal .dice-modal {
  position: fixed;
  left: var(--dice-left, 50vw);
  top: var(--dice-top, 50vh);
  width: min(470px, calc(100vw - 24px));
  max-width: 470px;
  padding: 12px 14px 10px;
  border-radius: 18px;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.97);
  transition: transform 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.2), opacity 0.2s ease;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
#diceModal.show .dice-modal {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
#diceModal .dice-head { padding: 0 2px 8px; }
#diceModal .dice-head h2 { font-size: 1.25rem; }
#diceModal .dice-head .eyebrow { font-size: 0.5rem; letter-spacing: 1.7px; }
#diceModal .dice-head .mini-btn { font-size: 0.55rem; padding: 3px 7px; }
#diceModal .dice-stage { height: 190px; border-radius: 13px; }
#diceModal .dice-readout { padding: 9px 0 2px; gap: 8px; }
#diceModal .die-chip { min-width: 36px; height: 36px; font-size: 1rem; border-radius: 9px; }
#diceModal .die-total { min-width: 44px; height: 36px; font-size: 1.1rem; border-radius: 9px; }
#diceModal .dice-readout .plus,
#diceModal .dice-readout .equals { font-size: 0.75rem; }
#diceModal .dice-caption { font-size: 0.6rem; margin-bottom: 0; }
.dice-readout-total { gap: 10px; padding: 9px 0 3px; }
.total-label {
  font-size: 0.5625rem;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}
#diceModal .dice-readout-total { gap: 8px; padding: 8px 0 2px; }
#diceModal .dice-readout-total .die-total { min-width: 56px; height: 42px; font-size: 1.4rem; }

/* Card modal */
.card-modal { max-width: 465px; text-align: center; padding: 30px 30px 26px; overflow: hidden; border-color: rgba(176, 136, 255, 0.24); }
.card-glow {
  position: absolute;
  top: -40%;
  left: 50%;
  width: 420px;
  height: 420px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(176, 136, 255, 0.22), transparent 62%);
  pointer-events: none;
}
.card-modal[data-kind="chance"] { border-color: rgba(255, 179, 71, 0.26); }
.card-modal[data-kind="chance"] .card-glow { background: radial-gradient(circle, rgba(255, 179, 71, 0.22), transparent 62%); }
.card-modal[data-kind="chance"] .eyebrow { color: #ffb347; }
.card-icon {
  font-size: 2.875rem;
  line-height: 1;
  margin: 8px 0 12px;
  filter: drop-shadow(0 8px 18px rgba(176, 136, 255, 0.4));
  animation: cardFloat 3.4s ease-in-out infinite;
}
.card-modal[data-kind="chance"] .card-icon { filter: drop-shadow(0 8px 18px rgba(255, 179, 71, 0.4)); }
@keyframes cardFloat { 50% { transform: translateY(-6px) rotate(-2deg); } }
.card-modal h2 { margin: 0 0 8px; font-family: var(--serif); font-size: 1.8125rem; font-weight: 700; letter-spacing: -0.3px; }
.card-text { margin: 0 auto; max-width: 34ch; font-size: 0.8125rem; color: var(--text-dim); line-height: 1.55; }
.card-effect {
  display: block;
  width: fit-content;
  margin: 17px auto 20px;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  padding: 8px 20px;
  border-radius: 11px;
  background: rgba(61, 220, 151, 0.09);
  border: 1px solid rgba(61, 220, 151, 0.28);
  color: var(--green);
  font-variant-numeric: tabular-nums;
}
#cardContinueBtn { display: block; margin: 0 auto; }
.card-effect.bad { background: rgba(255, 107, 107, 0.09); border-color: rgba(255, 107, 107, 0.3); color: #ff9c9c; }
.card-effect.neutral { background: rgba(242, 197, 61, 0.09); border-color: rgba(242, 197, 61, 0.28); color: var(--gold-2); }

/* Win modal */
.win-modal { max-width: 580px; text-align: center; padding: 34px 34px 28px; border-color: rgba(242, 197, 61, 0.3); overflow: hidden; }
.win-modal::before {
  content: "";
  position: absolute;
  inset: -30% -10% auto;
  height: 70%;
  background: radial-gradient(ellipse at center, rgba(242, 197, 61, 0.2), transparent 62%);
  pointer-events: none;
}
.trophy { font-size: 3.875rem; line-height: 1; filter: drop-shadow(0 14px 30px rgba(242, 197, 61, 0.4)); animation: trophyPop 0.8s cubic-bezier(0.2, 1.3, 0.4, 1); }
@keyframes trophyPop { 0% { transform: scale(0.4) rotate(-12deg); opacity: 0; } 70% { transform: scale(1.08) rotate(3deg); } }
.win-modal h2 {
  margin: 4px 0 6px;
  font-family: var(--serif);
  font-size: 2.375rem;
  font-weight: 700;
  letter-spacing: -0.4px;
  background: linear-gradient(180deg, #fffdf2, #f2c53d 80%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.win-reason { margin: 0 auto; max-width: 40ch; font-size: 0.7812rem; color: var(--muted); line-height: 1.55; }
.win-stats {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 20px 0 22px;
  text-align: left;
}
.win-stat-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  font-size: 0.7812rem;
}
.win-stat-row .wc { width: 8px; height: 8px; border-radius: 50%; background: var(--pc); box-shadow: 0 0 8px var(--pc); }
.win-stat-row b { font-weight: 700; }
.win-stat-row span { color: var(--muted); font-size: 0.6875rem; font-variant-numeric: tabular-nums; }
.win-stat-row.winner { border-color: rgba(242, 197, 61, 0.35); background: rgba(242, 197, 61, 0.07); }
.win-actions { display: flex; gap: 9px; justify-content: center; flex-wrap: wrap; }

/* Rules modal */
.rules-modal { max-width: 840px; padding: 24px 26px 22px; }
.rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; margin-top: 6px; }
.rule-card {
  padding: 14px 15px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.026);
  border: 1px solid var(--line);
}
.rule-card h3 { margin: 0 0 6px; font-size: 0.7812rem; font-weight: 700; letter-spacing: 0.2px; color: var(--text); }
.rule-card p { margin: 0; font-size: 0.7188rem; line-height: 1.55; color: var(--muted); }
.rule-card b { color: var(--gold-2); font-weight: 700; }
.rules-foot { margin-top: 14px; font-size: 0.6562rem; color: #5f6e86; text-align: center; }
kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.06);
  font-family: inherit;
  font-size: 0.625rem;
  color: var(--text-dim);
}

/* Confetti */
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i {
  position: absolute;
  top: -20px;
  left: var(--x);
  width: 7px;
  height: 11px;
  border-radius: 1px;
  background: var(--c);
  opacity: 0;
  animation: confettiFall var(--d) cubic-bezier(0.2, 0.55, 0.45, 1) var(--delay) forwards;
}
@keyframes confettiFall {
  0% { opacity: 1; transform: translate3d(0, -20px, 0) rotate(0deg); }
  100% { opacity: 0.9; transform: translate3d(var(--dx), 560px, 0) rotate(var(--rot)); }
}

/* ───────────── Toasts ───────────── */
.toast-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 44px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(13, 19, 27, 0.96);
  border: 1px solid var(--line-strong);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
  animation: toastIn 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  max-width: 100%;
  backdrop-filter: blur(10px);
}
.toast.out { animation: toastOut 0.3s ease forwards; }
.toast .ti { flex: 0 0 auto; font-size: 0.875rem; line-height: 1.2; }
.toast.good { border-color: rgba(61, 220, 151, 0.3); }
.toast.bad { border-color: rgba(255, 107, 107, 0.3); }
.toast.warn { border-color: rgba(242, 197, 61, 0.34); }
.toast.special { border-color: rgba(176, 136, 255, 0.34); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(0.97); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px) scale(0.98); } }

/* ───────────── Font & pacing controls ───────────── */
.font-control .font-label { display: none; }
.font-control {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}
.font-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.6875rem;
  font-weight: 800;
  padding: 5px 6px;
  border-radius: 7px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.font-btn:hover { color: #fff; background: rgba(242, 197, 61, 0.1); }
.font-label {
  font-size: 0.5625rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 32px;
  text-align: center;
  letter-spacing: 0.3px;
  font-variant-numeric: tabular-nums;
}

.dock-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dock-chip {
  flex: 0 0 auto;
  margin-top: 2px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 3px 8px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.dock-chip:hover {
  border-color: rgba(242, 197, 61, 0.4);
  color: var(--gold-2);
  background: rgba(242, 197, 61, 0.07);
}

#continueTurnBtn {
  animation: continuePulse 2.2s ease-in-out infinite;
}
@keyframes continuePulse {
  50% {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 0 0 4px rgba(242, 197, 61, 0.07), 0 10px 28px rgba(242, 197, 61, 0.3);
  }
}

.lb-row.is-review {
  background: linear-gradient(100deg, rgba(91, 157, 255, 0.09), rgba(91, 157, 255, 0.02));
  border-color: rgba(91, 157, 255, 0.3);
}
.lb-row.is-review::after {
  content: "REVIEW";
  position: absolute;
  top: -6px;
  right: 10px;
  font-size: 0.5rem;
  letter-spacing: 1px;
  font-weight: 800;
  color: #07111f;
  background: #8fc0ff;
  padding: 1px 6px;
  border-radius: 4px;
}

.swatch-dot.info { background: #8fc0ff; }

/* ───────────── Settings modal ───────────── */
.settings-modal { max-width: 660px; padding: 24px 26px 20px; }
.settings-body { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 14px 15px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.026);
  border: 1px solid var(--line);
}
.setting-row h3 { margin: 0; font-size: 0.875rem; font-weight: 700; letter-spacing: 0.1px; }
.setting-row p {
  margin: 4px 0 0;
  font-size: 0.7188rem;
  line-height: 1.5;
  color: var(--muted);
  max-width: 60ch;
}
.speed-picker { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.speed-picker button {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.24);
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 6px 9px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.speed-picker button:hover { color: var(--text); border-color: var(--line-strong); }
.speed-picker button.active {
  background: linear-gradient(180deg, rgba(242, 197, 61, 0.22), rgba(242, 197, 61, 0.09));
  color: var(--gold-2);
  border-color: rgba(242, 197, 61, 0.35);
}
.step-control { display: flex; align-items: center; gap: 10px; }
.step-control input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 170px;
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--gold) 0 var(--fill, 11%), rgba(255, 255, 255, 0.12) var(--fill, 11%) 100%);
  outline: none;
  cursor: pointer;
}
.step-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffe08a, #d8a51c);
  border: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 10px rgba(242, 197, 61, 0.45);
  cursor: pointer;
}
.step-control input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-radius: 50%;
  background: #f2c53d;
  cursor: pointer;
}
.step-control input[type="range"]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 5px;
}
#stepValue {
  min-width: 62px;
  text-align: right;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--gold-2);
  font-variant-numeric: tabular-nums;
}
.font-stepper { display: flex; align-items: center; gap: 8px; }
.font-stepper button {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.24);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 800;
  width: 38px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
}
.font-stepper button:hover { color: #fff; border-color: rgba(242, 197, 61, 0.4); }
.font-stepper strong {
  min-width: 52px;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--gold-2);
  font-variant-numeric: tabular-nums;
}
.settings-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.settings-tip {
  margin: 0;
  font-size: 0.7188rem;
  line-height: 1.5;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ───────────── Tile detail modal ───────────── */
.tile-modal { max-width: 545px; padding: 24px 26px 22px; }
.tile-modal-head { display: flex; align-items: flex-start; gap: 14px; }
.tile-modal-icon {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 2rem;
  background:
    linear-gradient(155deg, color-mix(in srgb, var(--tc, #6ea8ff) 30%, transparent), rgba(0, 0, 0, 0.24)),
    rgba(255, 255, 255, 0.03);
  border: 1px solid color-mix(in srgb, var(--tc, #6ea8ff) 40%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 24px rgba(0, 0, 0, 0.28);
}
.tile-modal-head h2 {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.2px;
}
.tile-modal-head .mini-btn { margin-left: auto; flex: 0 0 auto; }
.tile-owner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 14px 0 0; }
.owner-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--pc, #a4b1c4);
  background: color-mix(in srgb, var(--pc, #7686a0) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--pc, #7686a0) 36%, transparent);
}
.owner-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pc, #7686a0);
  box-shadow: 0 0 8px var(--pc, #7686a0);
}
.owner-chip.unowned {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
}
.owner-chip.unowned::before { background: var(--muted); box-shadow: none; }
.owner-meta { font-size: 0.6875rem; color: var(--muted); font-weight: 500; }
.tile-desc { margin: 14px 0 0; font-size: 0.7812rem; line-height: 1.6; color: var(--text-dim); }
.tile-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0 0; }
.tile-fact {
  padding: 10px 12px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.026);
  border: 1px solid var(--line);
}
.tile-fact span {
  display: block;
  font-size: 0.5625rem;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.tile-fact strong {
  display: block;
  margin-top: 3px;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.tile-fact strong.good { color: var(--green); }
.tile-fact strong.warn { color: #ffb3b3; }
.tile-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(242, 197, 61, 0.06);
  border: 1px solid rgba(242, 197, 61, 0.18);
  font-size: 0.7188rem;
  line-height: 1.5;
  color: #f0dfaa;
}
.tile-modal-actions { display: flex; justify-content: flex-end; margin-top: 18px; }

/* Larger text sizes collapse the header action labels to their icons so the
   top bar keeps a single row and the board keeps its space. */
html[data-font="125"] .legend-panel,
html[data-font="140"] .legend-panel { display: none; }

html[data-font="125"] .ghost-btn,
html[data-font="140"] .ghost-btn {
  font-size: 0;
  padding: 8px 9px;
}
html[data-font="125"] .ghost-btn::first-letter,
html[data-font="140"] .ghost-btn::first-letter {
  font-size: 1rem;
}

/* ───────────── Responsive ───────────── */
@media (max-width: 1240px) {
  .game-shell { grid-template-columns: minmax(0, 1fr) 326px; }
  .brand-copy p { display: none; }
  .topbar-stats .stat-target { display: none; }
  .ghost-btn { padding: 8px 10px; font-size: 0.7188rem; }
}

@media (max-width: 1040px) {
  body { overflow-y: auto; }
  .topbar { flex-wrap: wrap; gap: 12px; }
  .topbar-stats { order: 3; width: 100%; margin-left: 0; }
  .topbar-stats .stat { flex: 1; min-width: 0; }
  .topbar-stats .stat-target { display: flex; }
  .topbar-actions { margin-left: auto; }
  .game-shell { grid-template-columns: 1fr; padding: 0 16px 20px; }
  .board-frame, .dock { max-width: min(100%, 820px); }
  .sidebar { position: static; height: auto; max-height: none; overflow: visible; padding-right: 0; display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .log-panel { grid-row: span 2; }
  .legend-panel { display: none; }
}

@media (max-width: 720px) {
  .topbar { padding: 12px 14px 10px; }
  .brand-mark { width: 42px; height: 42px; font-size: 1.3125rem; border-radius: 12px; }
  .brand-copy h1 { font-size: 1.1875rem; white-space: normal; }
  .ghost-btn { font-size: 0; padding: 8px 9px; }
  .ghost-btn::first-letter { font-size: 0.875rem; }
  .topbar-actions { gap: 5px; }
  .board-frame { border-radius: 20px; }
  #board { border-radius: 20px; }
  .dock { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px; }
  .dock-hint { white-space: normal; }
  .dock-actions { justify-content: stretch; }
  .dock-actions .btn { flex: 1 1 auto; text-align: center; }
  .font-label { display: none; }
  .setting-row { grid-template-columns: 1fr; gap: 10px; }
  .speed-picker { justify-content: flex-start; }
  .step-control { width: 100%; }
  .step-control input[type="range"] { flex: 1 1 auto; width: auto; }
  .tile-facts { grid-template-columns: 1fr; }
  .tile-modal-head { gap: 10px; }
  .tile-modal-icon { width: 54px; height: 54px; font-size: 1.6rem; }
  .settings-modal, .tile-modal { padding: 18px; }
  .sidebar { grid-template-columns: 1fr; }
  .log-panel { grid-row: auto; }
  .modal-overlay { padding: 12px; }
  .modal { max-height: calc(100vh - 24px); border-radius: 18px; }
  .lobby-hero { padding: 26px 20px 18px; }
  .lobby-config { padding: 16px 15px 4px; }
  .lobby-player { grid-template-columns: 24px minmax(0, 1fr); }
  .lp-type { grid-column: 1 / -1; justify-self: stretch; display: grid; grid-template-columns: 1fr 1fr; }
  .lobby-footer { padding: 14px 16px 18px; }
  .lobby-footer-actions { margin-left: 0; width: 100%; justify-content: space-between; }
  .lobby-note { display: none; }
  .dice-modal, .rules-modal { padding: 16px; }
  #diceModal .dice-modal { width: min(360px, calc(100vw - 20px)); padding: 10px 11px 8px; }
  #diceModal .dice-stage { height: 150px; }
  #diceModal .dice-head h2 { font-size: 1.1rem; }
  .card-modal { padding: 24px 20px 20px; }
  .win-modal { padding: 26px 20px 22px; }
  .toast-stack { right: 12px; bottom: 12px; }
}

@media (max-height: 760px) and (min-width: 1041px) {
  .board-frame, .dock { max-width: min(calc(100vh - 208px), 860px); }
  .sidebar { height: calc(100vh - 92px); max-height: calc(100vh - 92px); }
  .legend-panel { display: none; }
}

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

/* Screen-reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Clean screenshot / demo mode (used for docs and automated captures) */
.clean-shot .modal-overlay { display: none !important; }

