:root {
  --bg: #16130f;
  --panel: #221d17;
  --panel-2: #2c261e;
  --line: #3b3328;
  --ink: #f3ecdc;
  --muted: #b3a891;
  --accent: #ba0c2f;
  --accent-2: #e0425f;
  --good: #3faa63;
  --warn: #e3a32a;
  --board: #efe6d0;
  --board-ink: #1d1a15;
  --board-line: #3a3226;
  --radius: 10px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100%; }
body { -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 14px; cursor: pointer; font-weight: 600; transition: background .12s, transform .05s;
}
button:hover:not(:disabled) { background: #3a3227; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--accent-2); }
button.good { background: var(--good); border-color: var(--good); color: #fff; }
button.danger { background: transparent; border-color: #8a2a2a; color: #ff8d8d; }
button.small { padding: 5px 9px; font-size: 13px; }
button.link { background: none; border: none; padding: 0; color: var(--muted); text-decoration: underline; font-weight: 500; }
input[type=text], input[type=password], input[type=number], select {
  background: #120f0c; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 1px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

/* ---------- auth / home ---------- */
.center-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth { width: min(400px, 100%); }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brand-mark { width: 42px; height: 42px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; font-weight: 900; color: #fff; font-size: 20px; }
.brand h1 { font-size: 26px; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.tabs { display: flex; gap: 4px; background: #120f0c; border-radius: 9px; padding: 4px; margin-bottom: 6px; }
.tabs button { flex: 1; background: none; border: none; }
.tabs button.on { background: var(--panel-2); }
.err { color: #ff8d8d; font-size: 14px; min-height: 20px; margin-top: 10px; }

.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.topbar .brand { margin: 0; }
.topbar .brand-mark { width: 32px; height: 32px; font-size: 16px; }
.topbar .brand h1 { font-size: 19px; }
@media (max-width: 600px) { .topbar { padding: 10px; gap: 8px; } .topbar .brand h1 { display: none; } .topbar .muted { display: none; } }
.page { max-width: 760px; margin: 0 auto; padding: 22px 16px 60px; display: grid; gap: 16px; }
.code-input { text-transform: uppercase; letter-spacing: .25em; font-weight: 700; }
.game-list { display: grid; gap: 8px; margin-top: 10px; }
.game-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel-2); border-radius: 8px; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #3b3328; color: var(--muted); font-weight: 600; }
.pill.live { background: #1f4a2e; color: #8fe3a9; }

/* ---------- lobby ---------- */
.big-code { font-size: 40px; font-weight: 900; letter-spacing: .2em; color: var(--ink); }
.player-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.player-row:last-child { border-bottom: none; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px rgba(0,0,0,.35); }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 3px solid transparent; padding: 0; }
.swatch.on { border-color: #fff; }
.swatch:disabled { opacity: .2; }
.toggle { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.toggle:last-child { border-bottom: none; }
.toggle .t-title { font-weight: 700; }
.toggle .t-desc { font-size: 13px; color: var(--muted); margin-top: 2px; }
.switch { position: relative; width: 46px; height: 26px; flex: none; margin-top: 2px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #4a4135; border-radius: 99px; transition: .15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::before { transform: translateX(20px); }
.switch input:disabled + span { cursor: default; opacity: .7; }

/* ---------- game layout ---------- */
.game { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; padding: 14px; max-width: 1400px; margin: 0 auto; align-items: start; }
@media (max-width: 960px) { .game { grid-template-columns: 1fr; padding: 8px; gap: 10px; } }
.side { display: grid; gap: 12px; }
.board-wrap { position: sticky; top: 10px; }
@media (max-width: 960px) { .board-wrap { position: static; } }

.board {
  container-type: inline-size;
  aspect-ratio: 1; width: 100%; max-height: calc(100vh - 90px); max-width: calc(100vh - 90px); margin: 0 auto;
  display: grid; grid-template-columns: 1.55fr repeat(9, 1fr) 1.55fr; grid-template-rows: 1.55fr repeat(9, 1fr) 1.55fr;
  background: var(--board-line); gap: 1px; border: 2px solid var(--board-line); border-radius: 8px; overflow: hidden;
  color: var(--board-ink);
}
.sp { background: var(--board); position: relative; display: flex; overflow: hidden; cursor: pointer; min-width: 0; min-height: 0; }
.sp:hover { filter: brightness(1.04); }
.sp.hl { box-shadow: inset 0 0 0 3px var(--accent); }
.sp .bar { flex: none; position: relative; display: flex; gap: 1px; align-items: center; justify-content: center; }
.sp .body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: space-between; text-align: center; padding: .4cqw .2cqw; min-width: 0; }
.sp .nm { font-size: 1.45cqw; line-height: 1.12; font-weight: 700; text-transform: uppercase; overflow-wrap: anywhere; }
.sp .nm.long { font-size: 1.12cqw; letter-spacing: -.02em; }
.sp.left .ic, .sp.right .ic { font-size: 2.3cqw; }
.sp.left .nm, .sp.right .nm { font-size: 1.35cqw; }
.sp .pr { font-size: 1.35cqw; font-weight: 600; opacity: .8; }
.sp .ic { font-size: 3.2cqw; line-height: 1; }
.sp.bottom { flex-direction: column; }  .sp.bottom .bar { height: 22%; width: 100%; }
.sp.top { flex-direction: column-reverse; } .sp.top .bar { height: 22%; width: 100%; }
.sp.left { flex-direction: row-reverse; } .sp.left .bar { width: 22%; height: 100%; flex-direction: column; }
.sp.right { flex-direction: row; } .sp.right .bar { width: 22%; height: 100%; flex-direction: column; }
.sp.left .body, .sp.right .body { justify-content: center; gap: .4cqw; }
.sp.corner .body { justify-content: center; gap: .6cqw; }
.sp.corner .nm { font-size: 1.7cqw; }
.sp.corner .ic { font-size: 4.6cqw; }
.owner-tag { position: absolute; width: 1.6cqw; height: 1.6cqw; border-radius: 50%; border: .25cqw solid #fff; bottom: .4cqw; right: .4cqw; box-shadow: 0 0 2px #000; }
.sp.mort .body { opacity: .4; }
.sp.mort::after { content: "MORTGAGED"; position: absolute; inset: auto 0 40% 0; text-align: center; font-size: 1.1cqw; font-weight: 900; color: var(--accent); transform: rotate(-20deg); }
.house { width: 1.5cqw; height: 1.5cqw; background: #1aa34a; border: 1px solid #0b4d22; border-radius: 1px; }
.hotel { width: 3.4cqw; height: 1.7cqw; background: #d4202f; border: 1px solid #6b0e16; border-radius: 1px; }
.sp.left .hotel, .sp.right .hotel { width: 1.7cqw; height: 3.4cqw; }
.tokens { position: absolute; inset: 0; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: .3cqw; pointer-events: none; padding: 1cqw; }
.token { width: 3.4cqw; height: 3.4cqw; border-radius: 50%; border: .3cqw solid #fff; box-shadow: 0 .2cqw .6cqw rgba(0,0,0,.55);
  display: grid; place-items: center; color: #fff; font-weight: 900; font-size: 1.9cqw; line-height: 1; text-shadow: 0 0 .4cqw rgba(0,0,0,.8); }
.token.jailed { border-color: #222; outline: .3cqw dashed #fff; }

.center {
  grid-column: 2 / 11; grid-row: 2 / 11; background: radial-gradient(circle at 50% 40%, #f6eedb, #e5d8b9);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.6cqw; padding: 3cqw; text-align: center;
}
.logo { font-size: 7.4cqw; font-weight: 900; letter-spacing: -.02em; color: var(--accent); transform: rotate(-8deg); line-height: .9; text-shadow: .3cqw .3cqw 0 rgba(0,0,0,.12); }
.logo small { display: block; font-size: 2.2cqw; letter-spacing: .5em; color: var(--board-ink); font-weight: 800; margin-top: .8cqw; }
.dice { display: flex; gap: 1.6cqw; }
.die { width: 6.4cqw; height: 6.4cqw; background: #fff; border-radius: 1.2cqw; box-shadow: 0 .4cqw 0 #bbb, 0 .6cqw 1.4cqw rgba(0,0,0,.25); display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: .8cqw; }
.die i { width: 1.25cqw; height: 1.25cqw; background: #1d1a15; border-radius: 50%; place-self: center; }
.die.roll { animation: tumble .45s ease-out; }
@keyframes tumble { 0% { transform: rotate(-30deg) scale(.7); } 60% { transform: rotate(12deg) scale(1.08); } 100% { transform: none; } }
.center-stats { display: flex; gap: 2.4cqw; font-size: 1.8cqw; font-weight: 700; flex-wrap: wrap; justify-content: center; }
.center-stats span { background: rgba(0,0,0,.07); padding: .5cqw 1.4cqw; border-radius: 99px; }
.pot { font-size: 2.6cqw; font-weight: 900; color: #0d6b32; }
.drawn { background: #fff; border-radius: 1.2cqw; padding: 1.6cqw 2.4cqw; max-width: 46cqw; font-size: 1.9cqw; box-shadow: 0 .5cqw 1.6cqw rgba(0,0,0,.2); border-top: 1cqw solid var(--warn); }
.drawn.chest { border-top-color: #2d6cdf; }
.drawn b { display: block; font-size: 1.5cqw; letter-spacing: .15em; text-transform: uppercase; margin-bottom: .5cqw; color: #6a5d48; }

/* ---------- side panels ---------- */
.turn-banner { display: flex; align-items: center; gap: 10px; }
.turn-banner .who { font-weight: 800; font-size: 18px; }
.actions { display: grid; gap: 8px; margin-top: 12px; }
.actions .row button { flex: 1; }
.notice { background: #2f2717; border: 1px solid #5a4620; color: #f2d48c; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.notice.red { background: #351a1a; border-color: #6d2a2a; color: #ffb3b3; }
.plist { display: grid; gap: 4px; }
.prow { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; }
.prow.cur { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }
.prow.out { opacity: .4; text-decoration: line-through; }
.prow .nm { font-weight: 700; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.prow .cash { font-variant-numeric: tabular-nums; font-weight: 800; }
.badge { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: #3b3328; color: var(--muted); }
.badge.jail { background: #4a2020; color: #ffb3b3; }
.online { width: 7px; height: 7px; border-radius: 50%; background: #666; }
.online.on { background: #4ade80; }
.chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.chip { width: 12px; height: 8px; border-radius: 2px; }
.chip.m { opacity: .35; }
.log { max-height: 260px; overflow-y: auto; font-size: 13px; line-height: 1.45; display: flex; flex-direction: column-reverse; }
.log div { padding: 3px 0; border-bottom: 1px dashed #2e2820; color: #d8ceb8; }
.log div.chat { color: #9fd3f0; }
.rules-mini { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.rules-mini span { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: #1f4a2e; color: #8fe3a9; font-weight: 700; }
.panel-title { font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.panel-title .grow { flex: 1; }
.auction-high { font-size: 28px; font-weight: 900; }
.trade-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 8px; font-size: 14px; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 14px; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: min(460px, 100%); max-height: calc(100vh - 28px); overflow-y: auto; padding: 18px; }
.modal.wide { width: min(780px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.modal-head h2 { flex: 1; font-size: 19px; }
.deed { background: var(--board); color: var(--board-ink); border-radius: 10px; overflow: hidden; }
.deed-head { padding: 14px; text-align: center; color: #fff; font-weight: 900; text-transform: uppercase; letter-spacing: .02em; }
.deed-head small { display: block; font-size: 11px; letter-spacing: .25em; opacity: .85; margin-bottom: 4px; }
.deed table { width: 100%; border-collapse: collapse; font-size: 14px; }
.deed td { padding: 5px 16px; }
.deed td:last-child { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.deed tr.now { background: rgba(186,12,47,.12); }
.deed .foot { padding: 10px 16px 14px; font-size: 13px; border-top: 1px solid #cbbd9c; }
.prop-list { display: grid; gap: 6px; }
.prop-item { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; background: var(--panel-2); border-radius: 8px; }
.prop-item .bar { width: 10px; align-self: stretch; border-radius: 3px; }
.prop-item .acts { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.trade-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .trade-cols { grid-template-columns: 1fr; } }
.check { display: flex; gap: 8px; align-items: center; padding: 5px 0; font-size: 14px; color: var(--ink); margin: 0; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; width: min(420px, calc(100% - 24px)); }
.toast { background: #3b1717; border: 1px solid #7a2c2c; color: #ffd0d0; padding: 10px 14px; border-radius: 9px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: rise .2s ease-out; }
.toast.ok { background: #183522; border-color: #2c6b40; color: #c9f2d5; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.conn { position: fixed; top: 0; left: 0; right: 0; background: var(--warn); color: #000; text-align: center; font-size: 13px; font-weight: 700; padding: 4px; z-index: 60; }
.winner { text-align: center; padding: 10px 0; }
.winner .big { font-size: 26px; font-weight: 900; margin: 6px 0; }

/* jail corner: in-jail box top-right, just-visiting strip along the edges */
.sp.jailcell { display: block; }
.jailcell .cell-box { position: absolute; top: 0; right: 0; width: 66%; height: 66%; background: #f4b942; border-left: 2px solid var(--board-line); border-bottom: 2px solid var(--board-line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4cqw;
  background-image: repeating-linear-gradient(90deg, transparent 0 18%, rgba(0,0,0,.35) 18% 22%); }
.jailcell .cell-box .nm { font-size: 1.4cqw; background: var(--board); padding: .1cqw .6cqw; border-radius: .4cqw; }
.jail-tokens, .visit-tokens { display: flex; flex-wrap: wrap; gap: .3cqw; justify-content: center; }
.visit-label { position: absolute; left: 0; bottom: 0; width: 100%; text-align: center; font-size: 1.2cqw; font-weight: 800; text-transform: uppercase; padding: .3cqw 0; }
.visit-tokens { position: absolute; left: .4cqw; top: .4cqw; bottom: 3cqw; width: 30%; flex-direction: column; justify-content: flex-start; align-items: center; flex-wrap: nowrap; overflow: hidden; }
.jailcell .visit-tokens .token { width: 2.8cqw; height: 2.8cqw; font-size: 1.5cqw; flex: none; }
.chip-lg { display: inline-block; width: 14px; height: 14px; border-radius: 3px; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
.check .chip-lg { margin-right: 2px; }
.prow[data-player] { cursor: pointer; }
.prow[data-player]:hover { background: var(--panel-2); }
.token-lg { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; color: #fff; border: 2px solid #fff; text-shadow: 0 0 3px rgba(0,0,0,.7); flex: none; }
.inv-group { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.inv-head { display: flex; gap: 8px; align-items: center; font-weight: 800; margin-bottom: 4px; }
.inv-item { display: flex; justify-content: space-between; padding: 4px 0 4px 22px; font-size: 14px; cursor: pointer; border-top: 1px dashed #2e2820; }
.inv-item:hover { color: #fff; }
