/* Landlords - dark "deed office" theme: slate + brass, serif display, system UI. */
:root {
  --bg: #0e1215;
  --bg-2: #12181c;
  --panel: #171d22;
  --panel-2: #1f272e;
  --tile: #1a2228;
  --line: #2b363f;
  --line-2: #3a4854;
  --text: #e8eef2;
  --muted: #8f9ca7;
  --accent: #d9a441;      /* brass */
  --accent-2: #f2c76e;
  --accent-ink: #1b1405;
  --good: #5cc98a;
  --bad: #e5675f;
  --warn: #e8b04a;
  --houses: #4fbf6d;
  --hotel: #e5483f;
  --radius: 10px;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: Georgia, "Palatino Linotype", Palatino, "Book Antiqua", serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --shadow: 0 6px 20px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 700px at 50% -10%, #19222a 0%, var(--bg) 60%) fixed;
  color: var(--text);
  font: 14px/1.4 var(--font-ui);
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* ---------- view switching ---------- */
body.view-home #room, body.view-room #home { display: none; }
body.phase-lobby .only-game, body.phase-game .only-lobby { display: none !important; }
body:not(.is-host) .only-host { display: none !important; }

/* ---------- buttons / inputs ---------- */
.btn {
  appearance: none; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
  padding: 9px 14px; min-height: 40px; border-radius: 8px; cursor: pointer; font-weight: 600;
  transition: background .15s, transform .1s, border-color .15s;
}
.btn:hover:not(:disabled) { background: #28333c; border-color: #4b5b69; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.danger:hover:not(:disabled) { background: rgba(229, 103, 95, .14); border-color: var(--bad); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }

input[type=text], input[type=number], select, textarea {
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px;
  min-height: 38px; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(217, 164, 65, .2); }
label.field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }

/* ---------- panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.panel > h2, .panel > h3, .panel-title {
  margin: 0 0 8px; font: 700 11px/1 var(--font-ui); letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}

/* ---------- home ---------- */
#home { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.home-card { width: min(420px, 100%); text-align: center; display: grid; gap: 14px; }
.logo { font: 400 clamp(40px, 11vw, 64px)/1 var(--font-display); letter-spacing: .06em; margin: 0; color: var(--text); }
.logo b { color: var(--accent); font-weight: 400; font-style: italic; }
.logo-mark { display: inline-grid; grid-template-columns: repeat(3, 10px); gap: 3px; margin-bottom: 14px; }
.logo-mark i { width: 10px; height: 10px; border-radius: 2px; background: var(--line-2); }
.logo-mark i:nth-child(2n) { background: var(--accent); }
.tagline { color: var(--muted); margin: 0 0 6px; font-family: var(--font-display); font-style: italic; }
.home-card .panel { display: grid; gap: 12px; text-align: left; padding: 18px; }
.error-text { color: var(--bad); min-height: 1.2em; font-size: 13px; }

/* ---------- room layout ---------- */
#room { padding: 12px; min-height: 100%; }
.room-grid {
  display: grid; gap: 12px; align-items: start; margin: 0 auto; max-width: 1760px;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr) minmax(260px, 330px);
}
.col { display: grid; gap: 12px; min-width: 0; align-content: start; }
.col-left { height: calc(100vh - 24px); grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr); }
.col-left .panel { display: flex; flex-direction: column; min-height: 0; }
.col-center { justify-items: center; }
.room-title { display: flex; align-items: baseline; gap: 8px; }
.room-title .logo { font-size: 22px; }

.share { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.share input { font-family: var(--font-mono); font-size: 12px; }
.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; font-size: 13px; }
.list li { padding: 3px 0; overflow-wrap: anywhere; }
#chatList .who { font-weight: 700; }
#chatList .ts { color: var(--muted); font-size: 11px; margin-left: 4px; }
#logList li { color: #c3ced6; border-bottom: 1px dashed var(--line); }
#logList li.hot { color: var(--accent-2); }
#chatForm { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-top: 8px; }

/* ---------- players ---------- */
.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.player {
  display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; align-items: center;
  padding: 8px 10px; background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--pc, var(--line-2));
  border-radius: 8px;
}
.player.turn { border-color: var(--accent); background: #2a2616; box-shadow: 0 0 0 1px var(--accent) inset; }
.player.bankrupt { opacity: .45; text-decoration: line-through; }
.player.offline .pl-name::after { content: " (offline)"; color: var(--muted); font-weight: 400; font-size: 12px; }
.player.you .pl-name::before { content: "\2605 "; color: var(--accent-2); }
.pl-token { width: 26px; height: 26px; border-radius: 50%; background: var(--pc, #888); border: 2px solid rgba(255, 255, 255, .85); box-shadow: 0 1px 3px #000a; grid-row: span 2; }
.pl-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-cash { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--good); }
.pl-state { grid-column: 2 / 4; font-size: 12px; color: var(--muted); }
.player.turn .pl-state { color: var(--accent-2); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); margin-right: 4px; }
.player.offline .dot { background: var(--muted); }

/* ---------- settings ---------- */
.settings { display: grid; gap: 10px; }
.settings .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toggles { display: grid; gap: 2px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.toggle input { appearance: none; width: 38px; height: 22px; min-height: 0; padding: 0; border-radius: 99px; background: var(--line-2); position: relative; cursor: pointer; flex: none; border: 0; transition: background .15s; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(16px); background: var(--accent-ink); }
.toggle input:disabled { opacity: .5; cursor: not-allowed; }
.toggle small { color: var(--muted); display: block; font-size: 11px; }

/* ---------- tile card ---------- */
.tile-card { display: grid; gap: 8px; }
.tile-card .tc-band { height: 14px; border-radius: 4px; background: var(--band, var(--line-2)); }
.tile-card h3 { margin: 0; font: 400 20px/1.2 var(--font-display); text-transform: none; letter-spacing: 0; color: var(--text); }
.tile-card table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tile-card td { padding: 2px 0; border-bottom: 1px solid var(--line); }
.tile-card td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.tile-card tr.on td { color: var(--accent-2); font-weight: 700; }
.tile-card .owner-line { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.tile-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.muted { color: var(--muted); }

/* ---------- board ---------- */
.board {
  --N: 11;
  container-type: inline-size;
  display: grid; gap: 2px; padding: 2px;
  grid-template-columns: repeat(var(--N), minmax(0, 1fr));
  grid-template-rows: repeat(var(--N), minmax(0, 1fr));
  width: min(100%, calc(100vh - 24px)); aspect-ratio: 1;
  background: #0a0e11; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  user-select: none;
}
.tile {
  --band: transparent; --owner: transparent;
  position: relative; display: flex; flex-direction: column; align-items: center; min-width: 0; min-height: 0; overflow: hidden;
  background: var(--tile); border-radius: 3px; cursor: pointer;
  font-size: max(5.5px, calc(100cqw / var(--N) * .15));
  line-height: 1.1; text-align: center; color: var(--text);
}
.tile:hover { filter: brightness(1.25); z-index: 2; }
.tile:focus-visible { z-index: 3; }
.tile.sel { outline: 2px solid var(--accent-2); outline-offset: -2px; z-index: 2; }
.tile.owned { background: color-mix(in srgb, var(--owner) 20%, var(--tile)); box-shadow: inset 0 0 0 2px var(--owner); }
.tile .band { align-self: stretch; flex: 0 0 24%; background: var(--band); display: flex; align-items: center; justify-content: center; gap: 1px; padding: 0 2px; }
.tile:not(.t-property) .band { display: none; }
.tile .hs { display: flex; gap: 1px; align-items: center; justify-content: center; }
.tile .hs i { display: block; width: 1.1em; height: 1.1em; max-width: 22%; border-radius: 1px; background: var(--houses); box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); }
.tile .hs.hotel i { width: 2.6em; max-width: 60%; background: var(--hotel); }
.tile .ico { font-size: 1.9em; line-height: 1.15; margin-top: .15em; font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; }
.tile .nm { padding: 0 .2em; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; hyphens: auto; }
.tile .pr { margin-top: auto; padding-bottom: .25em; font-weight: 700; color: var(--accent-2); font-variant-numeric: tabular-nums; }
.tile .own { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--owner); }
.tile.corner { background: #222c34; justify-content: center; }
.tile.corner .ico { font-size: 3em; margin: 0; }
.tile.corner .nm { font-size: 1.1em; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.tile.t-start { background: linear-gradient(160deg, #3a3017, #221d10); }
.tile.t-gotoprison { background: linear-gradient(160deg, #3a1f1d, #221413); }
.tile.mortgaged { filter: grayscale(.85) brightness(.75); background-image: repeating-linear-gradient(135deg, transparent 0 5px, rgba(255, 255, 255, .07) 5px 8px); }
.tile.mortgaged::after { content: "M"; position: absolute; top: 1px; right: 2px; font-weight: 800; color: var(--bad); font-size: 1.2em; }
.tile.has-tok .nm, .tile.has-tok .pr { opacity: .4; }

.tokens { position: absolute; left: 0; right: 0; bottom: 0; top: 26%; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 1px; padding: 1px; pointer-events: none; }
.tile.corner .tokens { top: 0; }
.tk {
  --pc: #888; width: calc(100% / var(--cols) - 2px); max-width: 38%; aspect-ratio: 1; border-radius: 50%;
  background: var(--pc); border: max(1px, .15em) solid rgba(255, 255, 255, .9); box-shadow: 0 1px 3px #000c;
  display: grid; place-items: center; color: #101418; font-weight: 800; font-size: .95em; line-height: 1; overflow: hidden;
}
.tk.you { border-color: #fff; box-shadow: 0 0 0 2px var(--accent-2), 0 1px 3px #000c; }
.tk.turn { animation: pulse 1.2s ease-in-out infinite; }
.tk.jailed { border-style: dashed; }
@keyframes pulse { 50% { transform: scale(1.18); } }
@media (prefers-reduced-motion: reduce) { .tk.turn { animation: none; outline: 2px solid var(--accent-2); } }

/* small boards: drop the names, tiles are too narrow to read them */
@container (max-width: 480px) {
  .tile .nm { display: none; }
  .tile .ico { font-size: 2.2em; }
  .tile .pr { font-size: .95em; }
}

/* ---------- board centre / action area ---------- */
.board-center {
  grid-area: 2 / 2 / calc(var(--N) ) / calc(var(--N));
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 12px; min-width: 0; min-height: 0; overflow: hidden;
  background: radial-gradient(ellipse at center, #1c252c 0%, #12181c 100%); border-radius: 8px; text-align: center;
}
.center-title { font: 400 clamp(18px, 5cqw, 44px)/1 var(--font-display); letter-spacing: .12em; color: var(--line-2); text-transform: uppercase; margin: 0; }
#dice { display: flex; gap: 12px; min-height: 56px; align-items: center; }
.die { width: 52px; height: 52px; display: grid; place-items: center; font-size: 46px; line-height: 1; background: #f3ecdb; color: #1b1b1b; border-radius: 10px; box-shadow: 0 3px 0 #b8ae93, var(--shadow); font-family: "Segoe UI Symbol", "Apple Symbols", sans-serif; }
.die.rolling { animation: tumble .5s linear infinite; }
@keyframes tumble { to { transform: rotate(360deg); } }
#prompt { max-width: 34em; font-size: clamp(13px, 2.2cqw, 17px); color: var(--text); min-height: 2.4em; }
#prompt b { color: var(--accent-2); }
#timer { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; min-height: 1.2em; }
#timer.low { color: var(--bad); font-weight: 700; }
#actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
#actions .btn { min-width: 96px; }

/* ---------- dialogs ---------- */
dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line-2); border-radius: 14px; padding: 18px;
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(5, 8, 10, .7); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 12px; font: 400 22px/1.2 var(--font-display); }
dialog form.dlg { display: grid; gap: 12px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.color-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.swatch { aspect-ratio: 1; border-radius: 50%; border: 3px solid transparent; background: var(--c); cursor: pointer; padding: 0; min-height: 40px; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .35); }
.swatch:hover:not(:disabled) { transform: scale(1.08); }
.swatch[aria-pressed=true] { border-color: #fff; box-shadow: 0 0 0 3px var(--accent); }
.swatch:disabled { opacity: .2; cursor: not-allowed; }

.trade-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.trade-col { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 8px; align-content: start; }
.trade-col h3 { margin: 0; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.checklist { max-height: 220px; overflow-y: auto; display: grid; gap: 2px; }
.checklist label { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; cursor: pointer; border-left: 4px solid var(--band, transparent); }
.checklist label:hover { background: #28333c; }
.checklist input { width: auto; min-height: 0; }

.auction-box { display: grid; gap: 12px; text-align: center; }
.auction-bid { font: 700 40px/1 var(--font-display); color: var(--accent-2); font-variant-numeric: tabular-nums; }
.auction-lead { color: var(--muted); }
.bid-buttons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.bid-custom { display: grid; grid-template-columns: 1fr auto; gap: 8px; }

/* ---------- trades list, toast, connection banner ---------- */
.trade-list { display: grid; gap: 8px; }
.trade-item { display: grid; gap: 6px; padding: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
#toast, #conn {
  position: fixed; margin: 0; inset: auto; left: 50%; transform: translateX(-50%); max-width: calc(100vw - 24px);
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); box-shadow: var(--shadow);
}
#toast { bottom: 20px; border-color: var(--bad); }
#conn { top: 12px; border-color: var(--warn); color: var(--warn); }
#conn:not(:popover-open) { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .room-grid { grid-template-columns: minmax(0, 1fr) minmax(250px, 320px); }
  .col-left { grid-column: 1 / -1; grid-row: 2; height: auto; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: none; }
  .col-left .list { max-height: 220px; }
}
@media (max-width: 760px) {
  #room { padding: 8px; }
  .room-grid { grid-template-columns: minmax(0, 1fr); }
  .col-center { order: 1; }
  .col-right { order: 2; }
  .col-left { order: 3; grid-column: auto; grid-row: auto; grid-template-columns: minmax(0, 1fr); }
  .board { width: 100%; }
  .trade-cols { grid-template-columns: 1fr; }
  .color-grid { grid-template-columns: repeat(4, 1fr); }
  .die { width: 40px; height: 40px; font-size: 34px; }
  #dice { min-height: 40px; }
  #actions .btn { min-width: 0; padding: 6px 10px; min-height: 36px; }
  .board-center { gap: 6px; padding: 4px; }
}

/* with 12 seats the lobby list would push the host settings below the fold */
.phase-lobby #players { max-height: 38vh; overflow-y: auto; }
