/* Landlord: a survey-map board on a dark drafting table, with property-deed cards. */
:root {
  --table: #22303c;
  --table-2: #2b3b49;
  --rule: #3c4f5f;
  --text: #e9ece8;
  --muted: #9fb0bb;
  --paper: #f2f1ea;
  --survey: #dde3df;
  --ink: #1d2a36;
  --line: #8d9aa2;
  --stamp: #b23a2e;
  --brass: #d4a441;
  --danger: #e2685c;
  --focus: #ffd166;
  --display: "Zilla Slab", "Rockwell", "Roboto Slab", Georgia, serif;
  --ui: "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--table);
  color: var(--text);
  font: 15px/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--danger); min-height: 1.5em; margin: .5rem 0 0; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--rule);
  background: var(--table-2);
  padding: .6rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--brass); border-color: var(--brass); color: #231a05; font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: #e2b553; }
.btn.danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.btn.wide { width: 100%; }

/* ---------- home / waiting ---------- */
.screen { min-height: 100vh; }
#lobby, #waiting { display: grid; place-items: center; padding: 2rem 1rem; }
.home { width: min(420px, 100%); }
.stamp {
  font: 700 clamp(3rem, 12vw, 4.6rem)/1 var(--display);
  letter-spacing: .04em;
  color: var(--stamp);
  background: var(--paper);
  border: 4px double var(--stamp);
  padding: .9rem .5rem .7rem;
  text-align: center;
  transform: rotate(-4deg);
  margin: 0 0 2rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
.home-lede { font-size: 1.05rem; color: var(--muted); margin: 0 0 1.5rem; }
.field { display: grid; gap: .35rem; margin-bottom: 1rem; font-weight: 500; }
.field input, .field select, .join-row input {
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; padding: .6rem .75rem; width: 100%;
}
.or { display: flex; align-items: center; gap: .75rem; color: var(--muted); margin: 1.5rem 0 1rem; font-size: .9rem; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }
.join-row { display: flex; gap: .5rem; }
.join-row input { text-transform: uppercase; letter-spacing: .15em; }
.big-code { font: 700 3.2rem/1 var(--display); letter-spacing: .18em; margin: .25rem 0 1rem; color: var(--brass); }
.wplayers { list-style: none; padding: 0; margin: 0 0 1.25rem; }
.wplayers li { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--rule); }
#waiting .leave { margin-top: 1rem; }

/* ---------- game layout ---------- */
#game { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; padding: 16px; align-items: start; }
#boardWrap { container-type: inline-size; width: min(100%, calc(100vh - 32px)); justify-self: center; position: sticky; top: 16px; }
#panel { display: flex; flex-direction: column; gap: 1.1rem; min-width: 0; }
@media (max-width: 900px) {
  #game { grid-template-columns: 1fr; padding: 8px; }
  #boardWrap { width: 100%; position: static; }
}

/* ---------- board ---------- */
#board {
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: 1.55fr repeat(9, 1fr) 1.55fr;
  grid-template-rows: 1.55fr repeat(9, 1fr) 1.55fr;
  background: var(--ink);
  gap: 1px;
  border: 2px solid var(--ink);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  color: var(--ink);
}
.tile {
  position: relative;
  display: flex;
  background: var(--paper);
  border: 0; padding: 0; margin: 0;
  cursor: pointer;
  overflow: hidden;
  min-width: 0; min-height: 0;
  text-align: center;
  color: var(--ink);
}
.tile.bottom { flex-direction: column; }
.tile.top    { flex-direction: column-reverse; }
.tile.left   { flex-direction: row-reverse; }
.tile.right  { flex-direction: row; }
.tile:hover { background: #fffef7; }
.tile.selected { box-shadow: inset 0 0 0 3px var(--stamp); z-index: 1; }
.tile:focus-visible { outline-offset: -3px; z-index: 2; }

.band { flex: 0 0 24%; display: flex; align-items: center; justify-content: center; gap: 6%; border: 0 solid var(--ink); }
.tile.bottom .band { border-bottom-width: 1px; }
.tile.top .band    { border-top-width: 1px; }
.tile.left .band   { border-left-width: 1px; flex-direction: column; }
.tile.right .band  { border-right-width: 1px; flex-direction: column; }
.house { width: 1.3cqi; height: 1.3cqi; background: #2f8a4c; border: 1px solid #fff; }
.hotel { width: 2.8cqi; height: 1.5cqi; background: var(--stamp); border: 1px solid #fff; }
.tile.left .hotel, .tile.right .hotel { width: 1.5cqi; height: 2.8cqi; }

.tbody { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 6% 4%; min-width: 0; }
.tname { font: 600 1.15cqi/1.15 var(--ui); overflow-wrap: anywhere; }
.ticon { font-size: 2.4cqi; line-height: 1; }
.tprice { font: 500 1.1cqi/1 var(--ui); color: #4a5864; }
.tile.owned::after {
  content: ""; position: absolute; width: 1.5cqi; height: 1.5cqi; border-radius: 50%;
  background: var(--owner); border: 1px solid #fff; box-shadow: 0 0 0 1px var(--ink);
  right: 4%; bottom: 4%;
}
.tile.top.owned::after { bottom: 27%; }
.tile.mortgaged .tbody { background: repeating-linear-gradient(-45deg, transparent 0 6px, rgba(29, 42, 54, .12) 6px 8px); }
.tile.mortgaged .tname { text-decoration: line-through; }

.tile.corner { flex-direction: column; justify-content: center; align-items: center; }
.tile.corner .tname { font: 700 1.6cqi/1.1 var(--display); }
.tile.corner .ticon { font-size: 3.6cqi; margin: 4% 0; }

.tokens { position: absolute; inset: auto 0 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; padding: 2px; pointer-events: none; }
.tile.top .tokens { bottom: 24%; }
.token {
  width: 2.3cqi; height: 2.3cqi; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .5);
  font: 700 1.2cqi/1 var(--ui); color: #fff; display: grid; place-items: center;
}
.token.jailed { border-color: var(--ink); border-style: dashed; }

.center {
  grid-row: 2 / 11; grid-column: 2 / 11;
  background-color: var(--survey);
  background-image:
    linear-gradient(rgba(29, 42, 54, .07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29, 42, 54, .07) 1px, transparent 1px);
  background-size: 4cqi 4cqi;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3cqi;
  padding: 4cqi;
}
.center .stamp { font-size: 7.5cqi; padding: 1.4cqi 2cqi 1cqi; margin: 0; transform: rotate(-8deg); border-width: .6cqi; box-shadow: none; }
.dice { display: flex; gap: 2cqi; }
.die {
  width: 7cqi; height: 7cqi; background: #fff; border-radius: 1.2cqi; border: 1px solid var(--line);
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: .9cqi;
  box-shadow: 0 .4cqi 0 var(--line);
}
.die i { width: 1.3cqi; height: 1.3cqi; border-radius: 50%; background: var(--ink); place-self: center; }
.dice.rolled .die { animation: tumble .5s cubic-bezier(.2, .8, .3, 1.2); }
.dice.rolled .die:nth-child(2) { animation-delay: .06s; }
@keyframes tumble { from { transform: rotate(-200deg) scale(.6); opacity: .3; } to { transform: none; opacity: 1; } }
.turnline { font: 500 1.9cqi/1.2 var(--ui); color: var(--ink); text-align: center; }
.cardnote {
  max-width: 46cqi; background: var(--paper); border: 1px solid var(--line);
  padding: 1.6cqi 2cqi; font-size: 1.6cqi; line-height: 1.35; text-align: center;
  box-shadow: 0 .5cqi 1.5cqi rgba(0, 0, 0, .15);
}
.cardnote b { display: block; font: 700 1.8cqi/1.2 var(--display); margin-bottom: .4cqi; }
.cardnote.fortune b { color: #c26b12; }
.cardnote.treasury b { color: #1b6ec2; }
.winner { font: 700 4cqi/1.1 var(--display); color: var(--stamp); text-align: center; }

@container (max-width: 560px) {
  .tile:not(.corner) .tname { display: none; }
  .tile.corner .tname { font-size: 2cqi; }
  .tprice { font-size: 1.9cqi; }
  .ticon { font-size: 3.4cqi; }
  .token { width: 3.2cqi; height: 3.2cqi; border-width: 1px; font-size: 0; }
  .house { width: 1.6cqi; height: 1.6cqi; }
  .turnline { font-size: 3cqi; }
  .cardnote { font-size: 2.8cqi; max-width: 66cqi; }
  .cardnote b { font-size: 3cqi; }
}

/* ---------- panel ---------- */
.panel-top { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .9rem; }
.panel-top strong { color: var(--text); letter-spacing: .12em; }
.panel-top .leave { margin-left: auto; }
.conn { width: 8px; height: 8px; border-radius: 50%; background: #4caf50; }
.conn.down { background: var(--danger); }
.status { font: 700 1.45rem/1.25 var(--display); margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.actions .btn.primary { flex: 1 1 100%; padding: .8rem; font-size: 1.05rem; }
.owe { flex-basis: 100%; margin: 0; padding: .6rem .75rem; border-left: 3px solid var(--danger); background: rgba(226, 104, 92, .1); }
.sec { font: 700 1.05rem/1.2 var(--display); margin: 0 0 .5rem; color: var(--text); }

.players { list-style: none; margin: 0; padding: 0; }
.players li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .1rem .6rem; padding: .45rem .5rem; border-radius: 6px; }
.players li.turn { background: var(--table-2); }
.players li.out { opacity: .45; }
.players .money { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--brass); }
.players .money.neg { color: var(--danger); }
.players .meta { grid-column: 2 / 4; font-size: .8rem; color: var(--muted); }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; display: inline-block; flex: none; }

.mine { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--table-2); border: 1px solid var(--rule); border-radius: 4px;
  padding: .2rem .5rem; font-size: .82rem; cursor: pointer;
}
.chip .sw { width: 10px; height: 10px; border-radius: 2px; }
.chip.mort { text-decoration: line-through; opacity: .7; }

/* Deed card for the selected space */
.deed { background: var(--paper); color: var(--ink); border-radius: 4px; overflow: hidden; box-shadow: 0 6px 18px rgba(0, 0, 0, .3); }
.deed-head { padding: .7rem 1rem; text-align: center; border-bottom: 1px solid var(--line); }
.deed-head h3 { margin: 0; font: 700 1.25rem/1.2 var(--display); }
.deed-head p { margin: .15rem 0 0; font-size: .82rem; }
.deed-body { padding: .7rem 1rem 1rem; }
.deed table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.deed td { padding: .18rem 0; }
.deed td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.deed tr.sep td { border-top: 1px solid #cfd3cf; padding-top: .4rem; }
.deed .own { margin: .7rem 0 0; font-size: .9rem; }
.deed .deed-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }
.deed .btn { background: #fff; border-color: var(--line); color: var(--ink); font-size: .85rem; padding: .4rem .7rem; }
.deed .btn:hover:not(:disabled) { border-color: var(--ink); }

.tradebox { border: 1px solid var(--brass); border-radius: 6px; padding: .8rem 1rem; }
.tradebox p { margin: .25rem 0; }
.tradebox .row { display: flex; gap: .5rem; margin-top: .6rem; }

.log { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; font-size: .85rem; color: var(--muted); }
.log li { padding: .25rem 0; border-bottom: 1px solid var(--rule); }
.log li:first-child { color: var(--text); }

/* ---------- trade dialog ---------- */
dialog {
  width: min(640px, 94vw); max-height: 90vh; overflow: auto;
  background: var(--table); color: var(--text);
  border: 1px solid var(--rule); border-radius: 8px; padding: 1.25rem;
}
dialog::backdrop { background: rgba(10, 16, 22, .7); }
dialog h2 { font: 700 1.5rem/1.2 var(--display); margin: 0 0 1rem; }
.trade-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 560px) { .trade-cols { grid-template-columns: 1fr; } }
fieldset { border: 1px solid var(--rule); border-radius: 6px; padding: .6rem .8rem; margin: 0; min-width: 0; }
legend { font-weight: 700; padding: 0 .3rem; }
.tlist { display: grid; gap: .25rem; max-height: 220px; overflow-y: auto; margin-bottom: .6rem; }
.tlist label { display: flex; align-items: center; gap: .45rem; font-size: .9rem; }
.tlist .none { color: var(--muted); font-size: .9rem; }
.small-note { font-size: .82rem; margin: .8rem 0 0; }
.dlg-row { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .5rem; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 150%);
  background: var(--paper); color: var(--ink); padding: .7rem 1.1rem; border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4); transition: transform .25s ease, visibility .25s; max-width: 90vw; z-index: 50;
  visibility: hidden;
}
#toast.show { transform: translate(-50%, 0); visibility: visible; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
