/* =====================================================================
   Deed & Dice — UI system
   Dark, low-noise surfaces · one warm accent · dark board · responsive
   ===================================================================== */

:root {
  /* --- surfaces (near-black neutral, slightly cool) --- */
  --bg:        #0a0c11;
  --bg-2:      #0e1118;
  --surface:   #131722;
  --surface-2: #1a1f2c;
  --surface-3: #222838;

  /* hairlines: translucent so they read correctly over any surface */
  --line:      rgba(255,255,255,.075);
  --line-2:    rgba(255,255,255,.14);
  --sheen:     rgba(255,255,255,.05);

  /* --- text --- */
  --tx:   #e9edf5;
  --tx-2: #98a2b6;
  --tx-3: #626c80;

  /* --- accents --- */
  --gold:    #f2b840;
  --gold-2:  #d0951d;
  --gold-dim: rgba(242,184,64,.14);
  --mint:    #3ddc97;
  --mint-dim: rgba(61,220,151,.14);
  --rose:    #ff6b6b;
  --rose-dim: rgba(255,107,107,.14);
  --sky:     #5b9dff;

  /* --- board (dark) --- */
  --board-bg:   #0b0e14;
  --board-felt: #101520;
  --tile:       #171d28;
  --tile-hi:    #202736;
  --tile-corner:#131924;
  --tile-line:  rgba(255,255,255,.085);
  --tile-tx:    #eaeff8;   /* labels must stay readable at ~9px */
  --tile-tx-2:  #aab4c8;

  /* --- motion --- */
  --ease:      cubic-bezier(.4, 0, .2, 1);
  --ease-out:  cubic-bezier(.2, .8, .3, 1);
  --ease-pop:  cubic-bezier(.2, 1, .3, 1);

  /* --- shape & depth --- */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --sh-1: 0 1px 2px rgba(0,0,0,.4);
  --sh-2: 0 10px 30px -12px rgba(0,0,0,.7);
  --sh-3: 0 30px 70px -20px rgba(0,0,0,.8);

  --f-display: "Fraunces", Georgia, serif;
  --f-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* layout metrics shared between the shell and the board sizing maths */
  --topbar-h: 56px;
  --board-pad: clamp(6px, 1.5vh, 20px);
  --dock-reserve: 168px;   /* height reserved for the mobile bottom bar */

  color-scheme: dark;
  accent-color: var(--gold);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--f-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--tx);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
body.page-game { overflow: hidden; width: 100%; max-width: 100vw; overscroll-behavior: none; }
h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 600; letter-spacing: -.2px; margin: 0; }
a { color: var(--sky); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--tx-2); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.mt8 { margin-top: 8px; }
[hidden] { display: none !important; }
::selection { background: rgba(242,184,64,.26); }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Money and other figures should never jitter as they change. */
.pc-cash, .big-bid, .code, .money-float, .v-stats b { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- buttons */
.btn {
  --b-bg: var(--surface-2);
  --b-tx: var(--tx);
  --b-bd: var(--line-2);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px;
  font: 600 14.5px/1 var(--f-ui);
  letter-spacing: .1px;
  color: var(--b-tx);
  background: var(--b-bg);
  border: 1px solid var(--b-bd);
  border-radius: var(--r);
  cursor: pointer;
  white-space: nowrap;
  transition: transform .1s var(--ease), background .16s var(--ease), border-color .16s var(--ease),
              box-shadow .16s var(--ease), opacity .16s var(--ease);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-3); border-color: rgba(255,255,255,.2); }
.btn:active { transform: translateY(1px); }
.btn:disabled {
  cursor: not-allowed; transform: none; opacity: 1;
  color: var(--tx-3);
  background: var(--surface-2);
  border-color: var(--line);
  box-shadow: none;
}
.btn:disabled:hover { background: var(--surface-2); border-color: var(--line); }

.btn-primary {
  --b-tx: #241a04;
  --b-bd: transparent;
  background: linear-gradient(180deg, #f8c95f, var(--gold));
  box-shadow: 0 1px 0 rgba(255,255,255,.35) inset, 0 8px 24px -10px rgba(242,184,64,.75);
}
.btn-primary:hover { background: linear-gradient(180deg, #ffd478, #f5c052); }

.btn-secondary {
  --b-tx: #04170e;
  --b-bd: transparent;
  background: linear-gradient(180deg, #5aebaf, var(--mint));
  box-shadow: 0 1px 0 rgba(255,255,255,.3) inset, 0 8px 24px -10px rgba(61,220,151,.6);
}
.btn-secondary:hover { background: linear-gradient(180deg, #6ff0bb, #48e2a1); }

.btn-danger { --b-tx: #ffb3b3; --b-bd: rgba(255,107,107,.3); background: rgba(255,107,107,.1); }
.btn-danger:hover { background: rgba(255,107,107,.18); border-color: rgba(255,107,107,.5); }

.btn-ghost { --b-bg: transparent; --b-tx: var(--tx-2); --b-bd: var(--line-2); }
.btn-ghost:hover { --b-tx: var(--tx); background: var(--surface-2); }

.btn-big { width: 100%; padding: 15px 22px; font-size: 15.5px; border-radius: var(--r-lg); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- inputs */
.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block; font-size: 11px; font-weight: 600;
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--tx-3); margin-bottom: 7px;
}
input[type=text], input[type=number], .field input, .settings-grid input {
  width: 100%; padding: 12px 13px; font: inherit; font-size: 15px;
  color: var(--tx); background: var(--bg-2);
  border: 1px solid var(--line-2); border-radius: var(--r);
  outline: none;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease);
}
input::placeholder { color: var(--tx-3); }
input:hover { border-color: rgba(255,255,255,.22); }
input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
  background: var(--surface);
}
.code-input {
  text-transform: uppercase; letter-spacing: .28em; text-align: center;
  font: 700 25px/1 var(--f-display); padding: 15px;
}

/* ---------------------------------------------------------------- toasts */
.toast-stack {
  position: fixed; right: 16px; bottom: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 9px; max-width: 340px;
  pointer-events: none;
}
.toast {
  padding: 12px 15px; font-size: 14px; font-weight: 500;
  background: var(--surface-2); color: var(--tx);
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--sky);
  border-radius: var(--r);
  box-shadow: var(--sh-2);
  animation: toastIn .24s var(--ease-pop);
}
.toast.err { border-left-color: var(--rose); }
.toast.ok  { border-left-color: var(--mint); }
.toast.fade { animation: toastOut .28s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* ---------------------------------------------------------------- confirm dialog */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(6, 8, 12, .62);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  opacity: 0; transition: opacity .14s var(--ease);
}
.modal-backdrop.open { opacity: 1; }
.modal-backdrop.closing { opacity: 0; }
.modal-card {
  width: min(400px, 100%);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line-2); border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  padding: 22px 22px 18px;
  transform: translateY(8px) scale(.98); opacity: 0;
  transition: transform .16s var(--ease-pop), opacity .16s var(--ease);
}
.modal-backdrop.open .modal-card { transform: none; opacity: 1; }
.modal-title { font-size: 18px; margin-bottom: 8px; }
.modal-body { color: var(--tx-2); font-size: 14px; line-height: 1.5; margin: 0; }
.modal-list {
  margin: 10px 0 0; padding: 10px 12px; list-style: none;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--tx); display: flex; flex-direction: column; gap: 4px;
  max-height: 168px; overflow-y: auto;
}
.modal-list li::before { content: "•"; color: var(--gold); margin-right: 8px; }
.modal-input {
  width: 100%; margin-top: 14px; padding: 12px 13px;
  font: inherit; font-size: 16px; color: var(--tx);
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r);
  outline: none;
}
.modal-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-dim); background: var(--surface); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
/* make the confirm button read as the primary action inside the dialog */
.modal-actions .btn-danger {
  --b-tx: #fff; --b-bd: transparent;
  background: linear-gradient(180deg, #ff7a7a, var(--rose));
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 8px 24px -10px rgba(255,107,107,.7);
}
.modal-actions .btn-danger:hover { background: linear-gradient(180deg, #ff8f8f, #ff5a5a); border-color: transparent; }

/* =====================================================================
   HOME
   ===================================================================== */
.page-home {
  min-height: 100vh; min-height: 100dvh; overflow-x: hidden;
  background:
    radial-gradient(1100px 600px at 50% -14%, rgba(242,184,64,.12), transparent 62%),
    radial-gradient(800px 560px at 92% 116%, rgba(61,220,151,.08), transparent 60%),
    var(--bg);
}
.home-bg { display: none; }
.home-wrap { max-width: 980px; margin: 0 auto; padding: min(10vh, 80px) 20px 56px; }

.brand { text-align: center; margin-bottom: 36px; }
.brand-mark { width: 78px; margin: 0 auto 16px; }
.brand-mark svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 10px 26px rgba(0,0,0,.55)); }
.brand-title {
  font-size: clamp(36px, 6.4vw, 60px); line-height: 1; letter-spacing: -.5px;
  background: linear-gradient(175deg, #fff 10%, #ffe2a5 48%, var(--gold-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-title span { -webkit-text-fill-color: var(--gold); font-style: italic; }
.brand-tag { color: var(--tx-2); margin-top: 14px; font-size: clamp(14px, 2.2vw, 17px); }

.home-cards { display: grid; grid-template-columns: 1.05fr .95fr; gap: 18px; align-items: start; }
@media (max-width: 760px) { .home-cards { grid-template-columns: 1fr; } }

.panel {
  position: relative;
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 26px;
  box-shadow: var(--sh-2), inset 0 1px 0 var(--sheen);
}
.panel h2 { font-size: 22px; }
.panel > .muted { margin: 3px 0 20px; font-size: 14px; }
.panel.invited {
  border-color: rgba(242,184,64,.45);
  box-shadow: var(--sh-2), 0 0 0 3px var(--gold-dim), inset 0 1px 0 var(--sheen);
}

.pawn-picker { display: flex; flex-wrap: wrap; gap: 9px; }
.pawn-chip {
  width: 54px; height: 54px; padding: 6px; flex: 0 0 auto;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r);
  cursor: pointer;
  transition: transform .14s var(--ease-pop), border-color .14s var(--ease), box-shadow .14s var(--ease), background .14s var(--ease);
}
.pawn-chip img { width: 100%; height: 100%; display: block; }
.pawn-chip:hover { transform: translateY(-3px); border-color: rgba(255,255,255,.28); }
.pawn-chip.selected {
  border-color: var(--gold);
  background: rgba(242,184,64,.1);
  box-shadow: 0 0 0 3px var(--gold-dim);
}
.pawn-chip.taken { opacity: .25; cursor: not-allowed; transform: none; }

.settings-fold {
  margin: 6px 0 18px; border: 1px solid var(--line);
  border-radius: var(--r); background: var(--bg-2); overflow: hidden;
}
.settings-fold summary {
  cursor: pointer; padding: 13px 15px; font-weight: 600; font-size: 14px;
  list-style: none; color: var(--tx-2);
}
.settings-fold summary:hover { color: var(--tx); }
.settings-fold summary::-webkit-details-marker { display: none; }
.settings-fold summary::before {
  content: "›"; color: var(--gold); margin-right: 10px; font-size: 17px;
  display: inline-block; transition: transform .18s var(--ease);
}
.settings-fold[open] summary::before { transform: rotate(90deg); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; padding: 4px 15px 17px; }
.settings-grid label { font-size: 12.5px; color: var(--tx-2); display: flex; flex-direction: column; gap: 6px; }
.settings-grid label.check { flex-direction: row; align-items: center; gap: 10px; grid-column: 1/-1; }
.settings-grid input[type=number] { padding: 9px 11px; font-size: 14px; }
.settings-grid input[type=checkbox] { width: 17px; height: 17px; flex: none; }
@media (max-width: 460px) { .settings-grid { grid-template-columns: 1fr; } }

/* open games directory */
.open-games { margin-top: 18px; }
.og-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.og-head h2 { font-size: 20px; }
.open-games > .muted { margin: 4px 0 16px; font-size: 13.5px; }
.og-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.og-item {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 11px 14px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: var(--r);
  transition: border-color .15s var(--ease);
}
.og-item:hover { border-color: var(--line-2); }
.og-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.og-code { font: 700 15px/1 var(--f-display); letter-spacing: .16em; color: var(--gold); display: inline-flex; align-items: center; gap: 7px; }
.og-lang {
  font: 700 9px/1 var(--f-ui); letter-spacing: .08em;
  padding: 2px 5px; border-radius: 4px; color: var(--tx-2);
  background: var(--surface-3); border: 1px solid var(--line-2);
}
.home-lang { display: flex; justify-content: center; margin-top: 16px; }
.og-meta { font-size: 12px; color: var(--tx-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.og-right { display: flex; align-items: center; gap: 12px; flex: none; }
.og-count { font: 700 13px/1 var(--f-ui); color: var(--tx-2); font-variant-numeric: tabular-nums; }
.og-count.hot { color: var(--gold); }
.og-empty { text-align: center; padding: 16px 0 2px; font-size: 13.5px; }
@media (max-width: 460px) {
  .og-item { flex-direction: column; align-items: stretch; }
  .og-right { justify-content: space-between; }
  .og-right .og-join { flex: 1; }
}

.home-foot { text-align: center; color: var(--tx-3); font-size: 12.5px; margin-top: 26px; }

/* =====================================================================
   LOBBY
   ===================================================================== */
.page-lobby {
  min-height: 100vh; min-height: 100dvh;
  background:
    radial-gradient(1000px 560px at 50% -10%, rgba(242,184,64,.10), transparent 62%),
    radial-gradient(700px 500px at 100% 100%, rgba(61,220,151,.05), transparent 60%),
    var(--bg);
}
/* the whole lobby aims to sit inside one viewport — column flex, chat absorbs slack */
.lobby-wrap {
  max-width: 1180px; margin: 0 auto; padding: 20px 20px 18px;
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
}

.lobby-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px; flex: none;
}
.lobby-top .brand-mini { display: flex; align-items: center; gap: 11px; }
.lobby-top .brand-mini svg { width: 32px; }
.lobby-top .brand-mini b { font: 600 18px/1 var(--f-display); letter-spacing: -.2px; }

/* the invite card is the one thing a host needs to hand to friends */
.invite {
  display: grid; grid-template-columns: auto auto; align-items: center;
  column-gap: 18px; row-gap: 1px;
  padding: 9px 14px;
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: inset 0 1px 0 var(--sheen), var(--sh-2);
}
.invite-label {
  grid-column: 1; font-size: 9.5px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: var(--tx-3);
}
.invite .code {
  grid-column: 1; grid-row: 2;
  font: 700 24px/1 var(--f-display); letter-spacing: .2em;
  color: var(--gold); text-shadow: 0 0 30px rgba(242,184,64,.3);
}
.invite-actions { grid-column: 2; grid-row: 1 / 3; display: flex; gap: 8px; }

.lobby-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 396px);
  gap: 20px; align-items: start;
}
@media (max-width: 1040px) { .lobby-grid { grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; } }
@media (max-width: 900px)  { .lobby-grid { grid-template-columns: minmax(0, 1fr); } }

.lobby-main { display: flex; flex-direction: column; gap: 12px; }
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin: 0 2px; flex: none;
}
.panel-head h2 { font-size: 17px; }

/* the "table" — a calm slab that only takes the room its seats need */
.table-felt {
  border-radius: var(--r-xl);
  padding: 16px;
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(61,220,151,.05), transparent 58%),
    linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 var(--sheen), var(--sh-2);
  flex: none;
}
.seat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 1180px) { .seat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px)  { .seat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } }

.seat-card {
  position: relative;
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-content: center;
  column-gap: 10px; row-gap: 4px;
  padding: 11px 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
  transition: border-color .18s var(--ease);
}
.seat-card:hover { border-color: var(--line-2); }
.seat-card.is-you { border-color: rgba(242,184,64,.5); box-shadow: 0 0 0 2px var(--gold-dim); }
.seat-card .pawn-badge {
  grid-row: 1 / 3; align-self: center;
  width: 40px; height: 40px; padding: 5px; margin: 0;
  background: var(--bg-2); border-radius: var(--r-sm); border: 1px solid var(--line);
}
.seat-card .pawn-badge img { width: 100%; height: 100%; }
.seat-card .pname { grid-column: 2; font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 7px; }
.seat-card .pname .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.seat-card .prow { grid-column: 2; display: flex; gap: 5px; flex-wrap: wrap; }
.tag {
  font-size: 9.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; background: var(--surface-3); color: var(--tx-2);
}
.tag.host { background: var(--gold-dim); color: var(--gold); }
.tag.ready { background: var(--mint-dim); color: var(--mint); }
.tag.wait { background: var(--surface-3); color: var(--tx-3); }
.tag.offline { background: var(--rose-dim); color: #ffb3b3; }
.seat-card.is-empty {
  display: flex; align-items: center; justify-content: center; min-height: 62px;
  border-style: dashed; border-color: var(--line-2);
  color: var(--tx-3); font-size: 12px; background: transparent;
}
.seat-card .kick {
  position: absolute; top: 8px; right: 8px;
  padding: 3px 8px; font: 700 10px/1 var(--f-ui);
  color: #ffb3b3; background: rgba(255,107,107,.1);
  border: 1px solid rgba(255,107,107,.3); border-radius: var(--r-sm);
  cursor: pointer; transition: background .15s var(--ease), border-color .15s var(--ease);
}
.seat-card .kick:hover { background: rgba(255,107,107,.2); border-color: rgba(255,107,107,.55); }

/* launch bar — full width under the table, host only */
.launch-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 13px 16px; flex: none;
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: inset 0 1px 0 var(--sheen), var(--sh-2);
}
.launch-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.launch-copy b { font: 600 14px/1.25 var(--f-display); letter-spacing: -.2px; }
.launch-copy .small { line-height: 1.4; }
.launch-actions { display: flex; gap: 9px; flex: none; }
.launch-actions .btn { padding: 11px 20px; }
@media (max-width: 560px) {
  .launch-bar { flex-direction: column; align-items: stretch; }
  .launch-actions .btn { flex: 1; }
}

/* right rail — stacked panels, compact */
.lobby-side { display: flex; flex-direction: column; gap: 14px; }
.lobby-side .panel { padding: 16px 18px; }
.lobby-side h3 { font-size: 14px; margin-bottom: 12px; }
.panel-sub { margin: -6px 0 14px; }
.lobby-side .field { margin-bottom: 12px; }
.lobby-side .field:last-of-type { margin-bottom: 14px; }
.lobby-side .field > span { margin-bottom: 6px; }
.pawn-picker.lobby .pawn-chip { width: 44px; height: 44px; padding: 5px; }

.host-note { margin: 10px 0 0; line-height: 1.45; }

/* EN / NL language switch (host, lobby) + home */
.lang-switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.lang-switch .seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; overflow: hidden; }
.lang-switch .seg button {
  border: 0; background: transparent; color: var(--tx-2);
  font: 700 11px/1 var(--f-ui); letter-spacing: .06em;
  padding: 6px 12px; cursor: pointer; transition: background .15s var(--ease), color .15s var(--ease);
}
.lang-switch .seg button + button { border-left: 1px solid var(--line-2); }
.lang-switch .seg button.on { background: var(--gold); color: #241a04; }
.lang-switch .seg button:not(.on):hover { background: var(--surface-2); color: var(--tx); }

/* public / private toggle under the table (host only) */
.visibility-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 16px; flex: none; cursor: pointer;
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: inset 0 1px 0 var(--sheen);
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
.visibility-row.is-on { border-color: rgba(61,220,151,.4); }
.vis-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.vis-text b { font: 600 13.5px/1.3 var(--f-display); letter-spacing: -.2px; }
.toggle { position: relative; flex: none; width: 44px; height: 26px; }
.toggle input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle-track {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--line-2);
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.toggle-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--tx-2);
  transition: transform .18s var(--ease-out), background .16s var(--ease);
}
.toggle input:checked + .toggle-track { background: var(--mint); border-color: transparent; }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); background: #04170e; }
.toggle input:focus-visible + .toggle-track { box-shadow: 0 0 0 3px var(--gold-dim); }

.pill-pub {
  display: inline-block; margin-left: 6px; padding: 2px 7px;
  background: var(--mint-dim); color: var(--mint);
  font: 700 9px/1.4 var(--f-ui); letter-spacing: .08em; text-transform: uppercase;
  border-radius: 999px; vertical-align: 1px;
}

/* host rules fold — collapsed by default so the rail stays short */
.rule-fold { border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2); overflow: hidden; }
.rule-fold > summary {
  cursor: pointer; list-style: none; padding: 12px 15px;
  font: 600 13px/1 var(--f-ui); color: var(--tx-2);
  display: flex; align-items: center; justify-content: space-between;
}
.rule-fold > summary::-webkit-details-marker { display: none; }
.rule-fold > summary::after { content: "›"; color: var(--gold); font-size: 16px; transition: transform .18s var(--ease); }
.rule-fold[open] > summary::after { transform: rotate(90deg); }
.rule-fold[open] > summary { border-bottom: 1px solid var(--line); }
.rule-fold .fold-body { padding: 14px 15px; }

.rule-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.rule-grid label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 11.5px; font-weight: 600; color: var(--tx-2);
}
.rule-grid .hint { font-weight: 400; font-size: 10.5px; color: var(--tx-3); margin-top: -3px; }
.rule-grid input[type=number] { padding: 8px 10px; font-size: 13.5px; }
@media (max-width: 420px) { .rule-grid { grid-template-columns: 1fr; } }

.rule-toggles { display: flex; flex-direction: column; gap: 1px; margin-bottom: 12px; }
.switch {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; margin: 0 -9px; border-radius: var(--r-sm);
  font-size: 12px; color: var(--tx-2); cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.switch:hover { background: var(--surface-2); color: var(--tx); }
.switch input { width: 16px; height: 16px; flex: none; margin: 0; cursor: pointer; }

/* chat panel — fixed, comfortable height; only its log scrolls */
.panel-chat { display: flex; flex-direction: column; }
.chatbox { display: flex; flex-direction: column; height: clamp(200px, 30vh, 320px); }
.chat-log {
  flex: 1; min-height: 0; overflow-y: auto; font-size: 13px;
  display: flex; flex-direction: column; gap: 6px; padding-right: 4px;
}
.chat-log:empty::before {
  content: "No messages yet — say hi while you wait."; color: var(--tx-3); font-size: 12.5px;
}
.chat-line { color: var(--tx-2); }
.chat-line b { font-weight: 700; }
.chat-input { display: flex; gap: 8px; margin-top: 10px; flex: none; }
.chat-input input { padding: 9px 11px; font-size: 13.5px; }

.lobby-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 4px 0; margin-top: auto;
}
.conn-line { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--tx-3); }

@media (max-width: 560px) {
  .lobby-wrap { padding: 3vh 14px 40px; }
  .lobby-top { gap: 14px; }
  .invite { width: 100%; grid-template-columns: 1fr; }
  .invite-actions { grid-column: 1; grid-row: 3; margin-top: 10px; }
  .invite-actions .btn { flex: 1; }
  .invite .code { font-size: 26px; }
  .seat-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .table-felt { padding: 14px; }
}

/* =====================================================================
   GAME SHELL
   ===================================================================== */
.page-game { height: 100vh; height: 100dvh; overflow: hidden; background: var(--bg); }

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 372px);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  grid-template-areas: "topbar topbar" "board side";
  height: 100vh; height: 100dvh;
  width: 100%; max-width: 100vw; overflow: hidden; min-height: 0;
}

/* ---- topbar ---- */
.topbar {
  grid-area: topbar;
  display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border-bottom: 1px solid var(--line);
  z-index: 30; overflow: hidden; min-width: 0;
}
.topbar .brand-mini {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  font: 600 15px/1 var(--f-display); letter-spacing: -.1px;
}
.topbar .brand-mini svg { width: 26px; }
.topbar .pill {
  flex: 0 0 auto; background: var(--surface-3); padding: 5px 11px; border-radius: 999px;
  font: 600 12px/1 var(--f-ui); letter-spacing: .18em; color: var(--tx-2);
}
.turn-status {
  flex: 1; min-width: 0; text-align: center; font-size: 14.5px; color: var(--tx-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.turn-status b { color: var(--gold); font-weight: 700; }
.turn-status.you b { color: var(--mint); }
.mini-actions { flex: 0 0 auto; display: flex; gap: 7px; align-items: center; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--surface-2);
  color: var(--tx-2); cursor: pointer; display: grid; place-items: center; font-size: 16px;
  transition: color .15s var(--ease), border-color .15s var(--ease), background .15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { color: var(--tx); border-color: rgba(255,255,255,.26); background: var(--surface-3); }
.side-toggle { display: none; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tx-3); flex: none; }
.conn-dot.live { background: var(--mint); box-shadow: 0 0 9px var(--mint); }
.conn-dot.poll { background: var(--gold); box-shadow: 0 0 9px var(--gold); }
.conn-dot.down { background: var(--rose); box-shadow: 0 0 9px var(--rose); }

/* =====================================================================
   BOARD — dark theme
   ===================================================================== */
.board-area {
  grid-area: board; position: relative;
  display: grid; place-items: center;
  padding: var(--board-pad);
  overflow: hidden;
  background:
    radial-gradient(70% 60% at 50% 42%, rgba(242,184,64,.05), transparent 70%),
    var(--bg);
}
.board-area.zoomed { cursor: grab; }
.board-area.grabbing { cursor: grabbing; }
/* The board is a square. Its size is limited by BOTH the width of the board
   column and the height left over after the topbar and this area's padding —
   sizing it off raw vh clipped the top and bottom rows. */
.board-viewport {
  position: relative;
  width: min(100%, calc(100dvh - var(--topbar-h) - 2 * var(--board-pad)), 1100px);
  aspect-ratio: 1 / 1;
  transform-origin: center center;
  transition: transform .16s var(--ease-pop);
  will-change: transform;
}

.board {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: 1.5fr repeat(9, 1fr) 1.5fr;
  grid-template-rows: 1.5fr repeat(9, 1fr) 1.5fr;
  gap: 1px;
  padding: 1px;
  container-type: inline-size;           /* tile type scales off the board width */
  background: var(--tile-line);          /* the gap colour draws the grid lines */
  border-radius: var(--r-lg);
  box-shadow:
    0 0 0 1px rgba(255,255,255,.10),
    0 0 0 9px var(--board-felt),
    0 0 0 10px rgba(255,255,255,.07),
    var(--sh-3);
  overflow: hidden;
}

.tile {
  position: relative;
  background: var(--tile);
  display: flex; flex-direction: column;
  color: var(--tile-tx);
  overflow: hidden; cursor: pointer; user-select: none;
  transition: background .18s var(--ease), box-shadow .18s var(--ease);
}
.tile:hover { background: var(--tile-hi); z-index: 5; }

/* Colour band, always facing the middle of the board (as on a real board):
   bottom row -> top edge, top row -> bottom edge, left col -> right edge,
   right col -> left edge. Achieved by flipping the tile's flex direction.  */
.tile.edge-bottom { flex-direction: column; }
.tile.edge-top    { flex-direction: column-reverse; }
.tile.edge-left   { flex-direction: row-reverse; }
.tile.edge-right  { flex-direction: row; }

.tile .band {
  position: relative; flex: 0 0 auto;
  height: 24%; min-height: 11px; width: auto;
}
.tile.edge-left .band, .tile.edge-right .band { height: auto; width: 18%; min-width: 11px; min-height: 0; }
.tile.edge-bottom .band { border-bottom: 1px solid rgba(0,0,0,.55); }
.tile.edge-top    .band { border-top: 1px solid rgba(0,0,0,.55); }
.tile.edge-left   .band { border-left: 1px solid rgba(0,0,0,.55); }
.tile.edge-right  .band { border-right: 1px solid rgba(0,0,0,.55); }
/* background:inherit picks up the inline group colour board.js sets */
.tile .band::after {
  content: ""; position: absolute; inset: -6px;
  background: inherit; filter: blur(8px); opacity: .55; pointer-events: none;
}
/* a printed-strip highlight so the band has some body to it */
.tile .band::before {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(180deg, rgba(255,255,255,.32), rgba(255,255,255,0) 55%, rgba(0,0,0,.24));
  pointer-events: none;
}
.tile.edge-left .band::before, .tile.edge-right .band::before {
  background: linear-gradient(90deg, rgba(255,255,255,.32), rgba(255,255,255,0) 55%, rgba(0,0,0,.24));
}
.tile .band-none { display: none; }

.tile .t-body {
  flex: 1 1 auto; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; justify-content: center;
  padding: 3px; gap: 0; position: relative; z-index: 1; overflow: hidden;
}
.tile .t-name {
  font-weight: 600; line-height: 1.06; letter-spacing: .005em;
  text-transform: uppercase;
  color: var(--tile-tx);
  /* wrap at spaces first; only hyphenate a word that cannot fit on its own line */
  overflow-wrap: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  /* Fallback for browsers without container queries … */
  font-size: clamp(7px, .78vw, 10px);
  /* … and the real rule: size against the board, so a big screen gets big
     labels instead of being capped at a fixed pixel size. */
  font-size: clamp(7.5px, 1.78cqw, 15px);
}
.tile .t-price {
  margin-top: 2px; font-weight: 600; color: var(--tile-tx-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
  font-size: clamp(6.5px, .74vw, 9px);
  font-size: clamp(6.5px, 1.4cqw, 12px);
}
.tile .t-ico {
  margin: 1px auto 0; opacity: .9; line-height: 1;
  font-size: clamp(11px, 1.5vw, 17px);
  font-size: clamp(11px, 2.5cqw, 22px);
}
/* Stations and utilities already show a name and a price — the emoji would
   overflow the tile, so keep those two text-only. */
.tile.t-rail:not(.corner) .t-ico,
.tile.t-utility:not(.corner) .t-ico,
.tile.t-tax:not(.corner) .t-ico { display: none; }
.tile.t-event .t-name, .tile.t-fund .t-name { opacity: .82; }
/* Top and bottom rows are the narrow ones (tile width = 1fr, the side columns
   get the wider corner track), so their labels run a little tighter to keep a
   long single word like CLEARWATER or JUNCTION on one line. */
.tile.edge-top .t-name, .tile.edge-bottom .t-name {
  letter-spacing: -.01em;
  font-size: clamp(6.5px, .7vw, 9px);
  font-size: clamp(7px, 1.62cqw, 13px);
}
.tile.edge-top .t-price, .tile.edge-bottom .t-price {
  font-size: clamp(6px, 1.22cqw, 10.5px);
}
.tile.corner {
  align-items: center; justify-content: center; text-align: center; gap: 4px; padding: 5px;
  background: var(--tile-corner);
}
.tile.corner .t-ico {
  margin: 0;
  font-size: clamp(17px, 2.8vw, 32px);
  font-size: clamp(17px, 4.4cqw, 40px);
}
.tile.corner .t-name {
  color: var(--tx); overflow-wrap: anywhere; letter-spacing: .03em;
  font-size: clamp(7.5px, 1.05vw, 11px);
  font-size: clamp(7.5px, 1.85cqw, 15px);
}

/* Ownership has to read at a glance: lit inner edge plus a soft wash. */
.tile.owned-me {
  background: linear-gradient(180deg, rgba(61,220,151,.17), rgba(61,220,151,.04) 60%), var(--tile);
  box-shadow: inset 0 0 0 1.5px rgba(61,220,151,.75), inset 0 0 18px rgba(61,220,151,.2);
}
.tile.owned-other {
  background: linear-gradient(180deg, rgba(255,107,107,.15), rgba(255,107,107,.03) 60%), var(--tile);
  box-shadow: inset 0 0 0 1.5px rgba(255,107,107,.6), inset 0 0 18px rgba(255,107,107,.15);
}
.tile.mortgaged { filter: grayscale(.9) brightness(.58); }
.tile.tile-active { animation: tilePulse 2s var(--ease) infinite; z-index: 6; }
@keyframes tilePulse {
  0%, 100% { box-shadow: inset 0 0 0 2px rgba(242,184,64,.7),  0 0 0 0 rgba(242,184,64,.32); }
  50%      { box-shadow: inset 0 0 0 2px rgba(242,184,64,1),   0 0 24px 2px rgba(242,184,64,.45); }
}

/* Buildings sit ON the colour strip, like a real board — which also keeps
   them from covering the property name on the left/right columns. */
.tile .houses {
  position: absolute; z-index: 4;
  display: flex; gap: .32cqw; justify-content: center; align-items: center;
  --hs: clamp(3.5px, .95cqw, 9px);
}
.tile.edge-bottom .houses { top: 1px; left: 0; right: 0; height: 22%; }
.tile.edge-top    .houses { bottom: 1px; left: 0; right: 0; height: 22%; }
.tile.edge-left   .houses { right: 1px; top: 0; bottom: 0; width: 17%; flex-direction: column; }
.tile.edge-right  .houses { left: 1px;  top: 0; bottom: 0; width: 17%; flex-direction: column; }

.tile .house {
  width: var(--hs); height: var(--hs); border-radius: 1.5px; flex: none;
  background: linear-gradient(180deg, #7df3c2, var(--mint));
  box-shadow: 0 0 0 1px rgba(0,0,0,.7), 0 0 6px rgba(61,220,151,.85);
}
.tile .house.hotel {
  width: calc(var(--hs) * 2.4); height: calc(var(--hs) * 1.05);
  background: linear-gradient(180deg, #ffa5a5, var(--rose));
  box-shadow: 0 0 0 1px rgba(0,0,0,.7), 0 0 8px rgba(255,107,107,.9);
}
.tile.edge-left .house.hotel, .tile.edge-right .house.hotel {
  width: calc(var(--hs) * 1.05); height: calc(var(--hs) * 2.4);
}

.tile .owner-dot {
  position: absolute; bottom: 2px; right: 2px; border-radius: 50%;
  width: clamp(4px, 1cqw, 10px); height: clamp(4px, 1cqw, 10px);
  box-shadow: 0 0 0 1.5px rgba(0,0,0,.8), 0 0 8px currentColor;
}
/* on the side columns the strip is on the inner edge, so tuck the dot away
   from it to keep the label clear */
.tile.edge-left .owner-dot  { right: auto; left: 2px; }
.tile.edge-right .owner-dot { right: 2px; left: auto; }

/* board centre */
.board-centre {
  grid-column: 2 / 11; grid-row: 2 / 11; position: relative;
  display: grid; place-items: center;
  background:
    radial-gradient(70% 60% at 50% 42%, rgba(242,184,64,.06), transparent 72%),
    linear-gradient(160deg, #141a28, var(--board-felt) 55%, #0d1219);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05), inset 0 16px 44px -24px rgba(0,0,0,.9);
}
/* faint weave so the middle reads as a surface rather than a hole */
.board-centre::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .55;
  background: repeating-linear-gradient(45deg,
    rgba(255,255,255,.015) 0 2px, transparent 2px 7px);
}
.board-centre .centre-inner { position: absolute; top: 12%; left: 50%; transform: translateX(-50%); text-align: center; }
.board-centre .logo-big { width: 66px; margin: 0 auto 8px; opacity: .3; }
.board-centre .logo-big svg { width: 100%; height: auto; }
.board-centre .brand-word {
  font: 600 clamp(11px, 1.7vw, 18px)/1 var(--f-display);
  letter-spacing: .42em; color: var(--tx-3); opacity: .8; text-indent: .42em;
}

.deck-stack {
  position: absolute; width: 19%; aspect-ratio: 3/2; border-radius: var(--r);
  display: grid; place-items: center; text-align: center;
  font: 700 clamp(8px, 1.05vw, 11px)/1.2 var(--f-ui); text-transform: uppercase; letter-spacing: .1em;
  border: 1px solid var(--line-2);
  box-shadow: var(--sh-2), inset 0 1px 0 rgba(255,255,255,.09);
}
.deck-stack.events {
  top: 15%; right: 11%; transform: rotate(5deg);
  color: #a9f0cd; background: linear-gradient(160deg, #1d4e3b, #133527);
}
.deck-stack.fund {
  bottom: 15%; left: 11%; transform: rotate(-5deg);
  color: #ffdca8; background: linear-gradient(160deg, #5a4014, #3a2909);
}

.dice-tray {
  position: absolute; left: 50%; top: 51%; transform: translateX(-50%);
  display: flex; gap: 13px; perspective: 700px; pointer-events: none;
  opacity: 0; transition: opacity .22s var(--ease);
}
.dice-tray.has-dice { opacity: 1; }
.die {
  width: clamp(30px, 4.6vw, 46px); aspect-ratio: 1; border-radius: 22%;
  background: linear-gradient(155deg, #fdfdfd, #dfe3ea);
  box-shadow: 0 1px 0 rgba(255,255,255,.9) inset, 0 10px 22px -6px rgba(0,0,0,.7);
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  padding: 14%; gap: 6%;
}
.die .pip { border-radius: 50%; background: #1b1f28; align-self: center; justify-self: center; width: 100%; aspect-ratio: 1; opacity: 0; }
.die.rolling { animation: dieRoll .62s cubic-bezier(.3,1.2,.5,1); }
@keyframes dieRoll {
  0% { transform: rotate(0) translateY(-34px) scale(.88); }
  55% { transform: rotate(372deg) translateY(5px) scale(1.05); }
  100% { transform: rotate(360deg) translateY(0) scale(1); }
}

/* pawns */
.pawn {
  position: absolute; z-index: 20;
  width: var(--pawn, 30px); height: var(--pawn, 30px);
  /* duration is overridden per step by board.js so the walk stays in sync */
  transition: left .16s var(--ease), top .16s var(--ease);
  filter: drop-shadow(0 6px 8px rgba(0,0,0,.8));
  pointer-events: none;
  will-change: left, top, transform;
}
.pawn img { width: 100%; height: 100%; display: block; }
.pawn .ring {
  position: absolute; inset: -4px -4px auto -4px; height: calc(100% + 8px);
  border-radius: 50%; border: 2.5px solid var(--ring, var(--gold)); opacity: .85;
}
.pawn.hop { animation: pawnHop .16s ease; }
@keyframes pawnHop { 50% { transform: translateY(-11px) scale(1.06); } }
.pawn.active-pawn { z-index: 25; }
.pawn.active-pawn .ring { animation: ringPulse 1.7s ease-in-out infinite; box-shadow: 0 0 14px var(--ring, var(--gold)); }
@keyframes ringPulse { 0%, 100% { transform: scale(1); opacity: .95; } 50% { transform: scale(1.18); opacity: .3; } }

/* the big roll button, centred on the board */
.board-roll {
  position: absolute; left: 50%; bottom: 25%; transform: translateX(-50%);
  z-index: 40; cursor: pointer;
  font: 700 clamp(13px, 1.5vw, 17px)/1 var(--f-ui); letter-spacing: .03em;
  color: #241a04; padding: 16px 34px; border: none; border-radius: var(--r-lg);
  background: linear-gradient(180deg, #f8c95f, var(--gold));
  box-shadow: 0 1px 0 rgba(255,255,255,.4) inset,
              0 14px 34px -10px rgba(242,184,64,.75),
              0 0 0 0 rgba(242,184,64,.4);
  transition: transform .1s var(--ease), box-shadow .2s var(--ease), filter .15s var(--ease);
  animation: brPulse 2.4s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}
.board-roll:hover { filter: brightness(1.05); }
.board-roll:active { transform: translateX(-50%) translateY(2px); }
@keyframes brPulse {
  0%, 100% { box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 14px 34px -10px rgba(242,184,64,.7), 0 0 0 0 rgba(242,184,64,.34); }
  50%      { box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 14px 34px -10px rgba(242,184,64,.7), 0 0 0 12px rgba(242,184,64,0); }
}

.zoom-controls { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 7px; z-index: 15; }

/* =====================================================================
   SIDE COLUMN
   ===================================================================== */
.game-side {
  grid-area: side; display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  background: var(--bg-2); border-left: 1px solid var(--line);
}
.side-tabs { display: flex; border-bottom: 1px solid var(--line); flex: 0 0 auto; background: var(--surface); }
.side-tabs button {
  flex: 1; padding: 14px 4px; background: none; border: none;
  border-bottom: 2px solid transparent; color: var(--tx-3);
  font: 600 12.5px/1 var(--f-ui); letter-spacing: .02em; cursor: pointer;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.side-tabs button:hover { color: var(--tx-2); }
.side-tabs button.active { color: var(--gold); border-bottom-color: var(--gold); }
.side-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px; padding-bottom: 200px; }
.side-pane { display: none; }
.side-pane.active { display: block; }
#pane-chat.active { display: flex; flex-direction: column; }
#pane-chat .chat-log { height: min(52vh, 420px); min-height: 170px; overflow-y: auto; margin-bottom: 10px; }

.player-card {
  position: relative;
  display: grid; grid-template-columns: 44px 1fr auto; gap: 11px; align-items: center;
  padding: 12px; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
}
.player-card.turn {
  border-color: var(--pc, var(--gold));
  background: linear-gradient(180deg, color-mix(in srgb, var(--pc, var(--gold)) 9%, var(--surface)), var(--surface));
  box-shadow: 0 0 0 1px var(--pc, var(--gold)), 0 8px 26px -14px var(--pc, var(--gold));
}
.player-card.bankrupt { opacity: .42; }
.player-card .pc-pawn { width: 44px; height: 44px; padding: 5px; background: var(--bg-2); border-radius: var(--r-sm); }
.player-card .pc-pawn img { width: 100%; height: 100%; }
.player-card .pc-name { font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.player-card .pc-sub { font-size: 12px; color: var(--tx-3); margin-top: 2px; }
.player-card .pc-cash { font: 700 17px/1 var(--f-display); color: var(--gold); white-space: nowrap; }
.player-card .setline { display: flex; gap: 5px; margin-top: 7px; flex-wrap: wrap; }
.setpip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px 2px 5px; border-radius: 999px;
  font: 700 10.5px/1 var(--f-ui); font-variant-numeric: tabular-nums;
  color: var(--tx-2); background: var(--surface-3);
  border: 1px solid var(--line-2);
}
.setpip .sp-dot { width: 8px; height: 8px; border-radius: 3px; background: var(--sc, #888); flex: none; }
.setpip .sp-b { font-size: 9px; letter-spacing: -1px; }
.setpip.full {
  color: var(--sc, var(--gold));
  border-color: color-mix(in srgb, var(--sc, #fff) 55%, transparent);
  background: color-mix(in srgb, var(--sc, #fff) 16%, var(--surface-2));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--sc, #fff) 35%, transparent);
}
.setpip.mortg { opacity: .5; }
.player-card .pc-actions { grid-column: 1/-1; display: flex; gap: 7px; margin-top: 4px; }
.player-card .pc-actions .btn { flex: 1; }

.badge-mini {
  font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 5px;
  background: var(--surface-3); color: var(--tx-2);
  text-transform: uppercase; letter-spacing: .06em;
}
.badge-mini.jail { background: var(--rose-dim); color: #ffb3b3; }
.badge-mini.off { background: var(--gold-dim); color: var(--gold); }

.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; background: var(--surface-3); font-size: 11px; color: var(--tx-2); }
.pill.wide { display: block; text-align: center; padding: 10px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); margin-top: 8px; }

.log-line { font-size: 12.5px; padding: 7px 9px; border-radius: var(--r-sm); color: var(--tx-2); animation: logIn .3s ease; }
.log-line:nth-child(odd) { background: rgba(255,255,255,.025); }
.log-line b { color: var(--tx); font-weight: 600; }
@keyframes logIn { from { opacity: 0; transform: translateX(-7px); } }

/* ---- action dock ---------------------------------------------------
   Desktop: occupies the bottom of the SIDE grid cell (so its width always
   matches the sidebar, whatever that column resolves to).
   Mobile:  a full-width bar pinned to the bottom of the viewport.       */
.turn-dock {
  grid-area: side; align-self: end; z-index: 65;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border-top: 1px solid var(--line-2);
  border-left: 1px solid var(--line);
  padding: 15px 16px calc(15px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -20px 40px -18px rgba(0,0,0,.85);
}
/* always-visible cash strip — never hidden behind a menu, especially on mobile */
.dock-me {
  display: flex; align-items: center; gap: 10px;
  margin: -2px 0 10px; padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.dock-me .dm-name {
  font-weight: 700; font-size: 13px; color: var(--tx-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%;
}
.dock-me .dm-cash {
  font: 700 18px/1 var(--f-display); color: var(--gold);
  font-variant-numeric: tabular-nums; letter-spacing: .01em;
}
.dock-me .dm-props {
  margin-left: auto; flex: none;
  display: inline-flex; align-items: center; gap: 2px;
  padding: 6px 11px; font: 700 12.5px/1 var(--f-ui);
  color: var(--tx); background: var(--surface-3);
  border: 1px solid var(--line-2); border-radius: 999px; cursor: pointer;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.dock-me .dm-props:hover { background: var(--surface-2); border-color: rgba(255,255,255,.2); }
.turn-dock .dock-eyebrow { font-size: 10.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--tx-3); margin-bottom: 4px; }
.turn-dock .dock-headline { font: 600 16px/1.3 var(--f-display); margin-bottom: 12px; color: var(--tx); }
.turn-dock .dock-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.turn-dock .dock-actions .btn { flex: 1 1 auto; min-width: 118px; padding: 12px 14px; }
.turn-dock .dock-actions .btn-primary { flex-basis: 100%; }

/* =====================================================================
   MODALS / OVERLAYS
   ===================================================================== */
.overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(5,7,11,.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 18px;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: min(450px, 100%); max-height: 90vh; overflow-y: auto;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  color: var(--tx);
  border: 1px solid var(--line-2); border-radius: var(--r-xl); padding: 24px;
  box-shadow: var(--sh-3), inset 0 1px 0 var(--sheen);
  animation: modalIn .26s var(--ease-pop);
}
.modal.wide { width: min(600px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(22px) scale(.97); } }
.modal h3 { font-size: 22px; }
.modal .sub { color: var(--tx-2); font-size: 13.5px; margin: 4px 0 18px; }
.modal .m-buttons { display: flex; gap: 9px; margin-top: 20px; }
.modal .m-buttons .btn { flex: 1; }
.modal .field input, .modal input[type=number] { background: var(--bg-2); }

.deed { border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--line-2); background: var(--bg-2); }
.deed-band { padding: 13px; text-align: center; color: #fff; font: 700 15px/1 var(--f-display); letter-spacing: .04em; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.deed-body { padding: 13px 15px; font-size: 13px; }
.deed-body.deed-plain { background: var(--bg-2); border-radius: var(--r); }
.deed-row { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.deed-row:last-child { border-bottom: none; }
.deed-row.head { font-weight: 700; }

.cardflip-wrap {
  perspective: 1100px;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.cardflip-wrap .card-ok { min-width: 190px; }
.cardflip { width: 288px; height: 194px; position: relative; transform-style: preserve-3d; animation: cardFlip 1s ease forwards; }
@keyframes cardFlip { 0% { transform: rotateY(180deg) translateY(-26px) scale(.82); } 70% { transform: rotateY(0) scale(1.04); } 100% { transform: rotateY(0) scale(1); } }
.cardflip .face { position: absolute; inset: 0; border-radius: var(--r-lg); backface-visibility: hidden; padding: 20px; display: flex; flex-direction: column; gap: 9px; box-shadow: var(--sh-3); }
.cardflip .front { background: linear-gradient(165deg, #f7f4ec, #e6e0d2); color: #1b1f28; }
.cardflip .front .deck-name { font: 700 11px/1 var(--f-ui); text-transform: uppercase; letter-spacing: .16em; color: #9a7526; }
.cardflip .front .card-text {
  font-size: 16px; line-height: 1.45; flex: 1;
  display: flex; align-items: center;
}
.cardflip .front .card-foot { font-size: 11px; color: #6a6f7c; text-align: right; }
.cardflip .back { background: linear-gradient(160deg, #1d4e3b, #133527); transform: rotateY(180deg); }

.auction-panel { width: min(470px, 100%); text-align: center; }
.auction-panel .big-bid { font: 700 44px/1 var(--f-display); color: var(--gold); margin: 10px 0; transition: transform .2s var(--ease-pop); text-shadow: 0 0 34px rgba(242,184,64,.4); }
.auction-panel .big-bid.bump { transform: scale(1.16); }
.auction-panel .bid-who { font-size: 13.5px; color: var(--tx-2); min-height: 20px; }
.auction-panel .auction-timer { height: 6px; background: var(--bg-2); border-radius: 999px; overflow: hidden; margin: 16px 0; }
.auction-panel .auction-timer i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--rose)); width: 100%; transition: width .2s linear; }
.auction-panel .bid-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.auction-panel .bid-feed { margin-top: 14px; font-size: 12px; color: var(--tx-3); max-height: 90px; overflow-y: auto; }

.money-float { position: fixed; z-index: 300; font: 700 23px/1 var(--f-display); pointer-events: none; animation: moneyFloat 1.4s ease forwards; text-shadow: 0 2px 10px rgba(0,0,0,.8); }
.money-float.plus { color: #5fe8ad; }
.money-float.minus { color: #ff8f8f; }
@keyframes moneyFloat {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(.8); }
  20% { opacity: 1; transform: translate(-50%, -4px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -48px) scale(1); }
}

.trade-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .trade-cols { grid-template-columns: 1fr; } }
.trade-col { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); padding: 13px; }
.trade-col h4 { margin: 0 0 9px; font: 600 11px/1 var(--f-ui); text-transform: uppercase; letter-spacing: .1em; color: var(--tx-3); }
.trade-col label { font-size: 12.5px; display: block; margin-bottom: 7px; color: var(--tx-2); }
.trade-col input[type=number] { padding: 8px 10px; }
/* NB: must out-specify `.trade-col label` above, which sets display:block. */
.trade-col .prop-check, .prop-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; padding: 5px 0; margin: 0;
  color: var(--tx-2); cursor: pointer;
}
.prop-check:hover { color: var(--tx); }
.prop-check .swatch { width: 9px; height: 9px; border-radius: 2px; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,.5); }
.prop-check .pc-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prop-check .pc-val { flex: 0 0 auto; color: var(--tx-3); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.trade-list { max-height: 170px; overflow-y: auto; }
.trade-list.tall { max-height: 54vh; }

.manage-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line); }
.manage-row:last-child { border-bottom: none; }
.manage-row .mr-name { flex: 1; min-width: 150px; font-size: 13px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.manage-row .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.manage-row .mr-acts { display: flex; gap: 6px; flex-wrap: wrap; }

.victory {
  position: fixed; inset: 0; z-index: 500; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 36%, rgba(26,20,8,.95), rgba(5,7,11,.99));
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.victory { overflow-y: auto; padding: 20px 0; }
.victory .v-card { text-align: center; padding: 20px; position: relative; z-index: 2; }
.victory .v-pawn { width: 122px; margin: 0 auto 12px; animation: vpawn 2.2s ease-in-out infinite; filter: drop-shadow(0 20px 30px rgba(0,0,0,.75)); }
@keyframes vpawn { 50% { transform: translateY(-13px) rotate(3deg); } }
.victory h1 {
  font-size: clamp(34px, 6.5vw, 52px);
  background: linear-gradient(175deg, #fff, #ffe2a5 50%, var(--gold-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.victory .v-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px 24px; margin: 22px auto; max-width: 380px; font-size: 14px; color: var(--tx-2); }
.victory .v-stats span { text-align: left; }
.victory .v-stats b { text-align: right; color: var(--gold); }
.confetti { position: fixed; width: 9px; height: 13px; top: -20px; z-index: 501; will-change: transform; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }
::-webkit-scrollbar-track { background: transparent; }

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 1024px) {
  .game-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--topbar-h) minmax(0, 1fr);
    grid-template-areas: "topbar" "board";
  }
  .game-side {
    position: fixed; top: var(--topbar-h); right: 0; bottom: 0;
    width: min(372px, 92vw);
    transform: translateX(100%);
    transition: transform .28s var(--ease-pop);
    z-index: 60;
    box-shadow: -30px 0 70px -14px rgba(0,0,0,.8);
  }
  .game-side.open { transform: translateX(0); }
  .side-body { padding-bottom: 210px; }
  .side-toggle { display: inline-flex !important; }

  /* Centre the board in the space that is actually left above the docked
     bottom bar, so there is no dead area under it. */
  .board-area {
    --board-pad: 8px;
    padding: 10px var(--board-pad) var(--dock-reserve);
    align-content: center;
  }
  .board-viewport {
    width: min(100%, calc(100dvh - var(--topbar-h) - var(--dock-reserve) - 10px));
  }
  .board-roll { bottom: calc(var(--dock-reserve) + 12px); top: auto; padding: 14px 30px; }

  /* full-width bottom bar — reserve a little extra for the cash strip */
  :root { --dock-reserve: 196px; }
  .turn-dock {
    position: fixed; left: 0; right: 0; bottom: 0; width: auto;
    align-self: auto; border-left: none;
  }
  .dock-me { margin-top: 0; }
  .dock-me .dm-cash { font-size: 17px; }
  .zoom-controls { bottom: calc(var(--dock-reserve) + 8px); right: 10px; }

  .topbar .brand-mini span:not(.pill) { display: none; }
  .turn-status { font-size: 13px; }
}

@media (max-width: 560px) {
  body { font-size: 14px; }

  /* The topbar has to hold six controls on a 375px screen: drop the wordmark,
     tighten the room-code pill and shrink the icon buttons so nothing clips. */
  .topbar { gap: 8px; padding: 0 8px; }
  .topbar .brand-mini svg { width: 22px; }
  .topbar .pill { padding: 4px 8px; font-size: 11px; letter-spacing: .12em; }
  .mini-actions { gap: 5px; }
  .icon-btn { width: 32px; height: 32px; font-size: 14px; border-radius: 7px; }
  .turn-status { font-size: 12px; }
  .home-wrap, .lobby-wrap { padding-left: 14px; padding-right: 14px; }
  .panel { padding: 20px; border-radius: var(--r-lg); }
  .tile .t-body { padding: 2px; }
  .tile .band { min-height: 6px; }
  .tile.edge-left .band, .tile.edge-right .band { min-width: 6px; }
  .tile:not(.corner) .t-price { display: none; }
  .tile:not(.corner) .t-ico { font-size: 11px; }
  .board-roll { font-size: 13px; padding: 12px 22px; }
  .turn-dock { padding: 12px 13px calc(12px + env(safe-area-inset-bottom, 0px)); }
  .turn-dock .dock-headline { font-size: 14.5px; margin-bottom: 10px; }
  .turn-dock .dock-actions .btn { min-width: 104px; padding: 11px 12px; font-size: 13.5px; }
  .lobby-top .brand-mini b { font-size: 17px; }
  .code-box .code { font-size: 22px; }
  .modal { padding: 20px; border-radius: var(--r-lg); }
  .cardflip { width: min(288px, 78vw); }
  .victory .v-pawn { width: 92px; }
  .victory .v-stats { gap: 7px 14px; font-size: 13px; margin: 16px auto; }
  .manage-row { gap: 7px; }
  .manage-row .mr-name { min-width: 100%; }
  .manage-row .mr-acts { width: 100%; }
  .manage-row .mr-acts .btn { flex: 1; }
}

/* Respect users who ask for less motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
