/* Monopoly, played in a browser against the bots.

   Two ideas about layout. The board is a diagram, so every label stays upright
   and nothing is rotated: it reads top-down like a chess position. And the page
   is **light whatever the browser is set to** — `color-scheme: light` here and
   the meta tag in the head say so, because a board, a title deed and a die are
   printed things, and a browser left to auto-darken them turns a white die face
   with black pips into a black square with black pips. There is no dark palette
   to fall back to on purpose; one is not being maintained in parallel. */

:root {
  --bg: #eceadf;          /* the table the board sits on */
  --panel: #ffffff;
  --panel-2: #f2f3f6;     /* inputs, chips, the quiet fill */
  --line: #cfd3dc;
  --line-2: #e4e7ee;
  --ink: #1b1e24;
  --dim: #5c6472;
  --felt: #cfe3d4;
  --tile: #fbfcf9;
  --tile-line: #9aa89e;
  --accent: #1a6fd4;
  --accent-soft: #e6effc;
  --good: #17794c;
  --bad: #c4372a;
  --warn: #e0a316;
  --radius: 9px;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 ui-sans-serif, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.grow { flex: 1; }
.muted { color: var(--dim); }
.tiny { font-size: 11px; }
.error { color: var(--bad); min-height: 1.2em; margin: 6px 0; }

button {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 7px 12px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 650; }
button.primary:hover:not(:disabled) { background: #175fb6; border-color: #175fb6; }
button.ghost { background: transparent; }
button.danger { border-color: var(--bad); color: #8f2418; }

select, input[type=number], input[type=text] {
  font: inherit; background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px;
}
input[type=range] { accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); }

/* ── setup ─────────────────────────────────────────────────────────────── */
.setup { min-height: 100vh; display: grid; place-items: center; padding: 28px; }
.setup-card { width: min(860px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 26px 30px 30px; box-shadow: 0 2px 14px rgba(20, 25, 40, .07); }
.setup h1 { margin: 0 0 4px; font-size: 34px; letter-spacing: -.5px; }
.setup h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--dim); margin: 26px 0 10px; font-weight: 650; }
.setup .sub { color: var(--dim); margin: 0; max-width: 62ch; }
.setup .row { display: flex; gap: 22px; align-items: flex-end; flex-wrap: wrap; }
.setup label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--dim); }
.setup .hint { font-size: 11px; }
.setup .or { color: var(--dim); font-size: 13px; margin: 12px 0 0; }
button.linky { border: none; background: none; padding: 0; color: var(--accent);
  text-decoration: underline; font-size: inherit; }
button.linky:hover { color: #175fb6; }

.menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 10px; }
.bot {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; cursor: pointer; background: var(--panel-2);
  display: flex; flex-direction: column; gap: 4px; position: relative;
}
.bot:hover { border-color: #9aa4b6; }
.bot.on { border-color: var(--accent); background: var(--accent-soft); }
.bot .n { font-weight: 650; }
.bot .b { font-size: 11.5px; color: var(--dim); line-height: 1.35; }
.bot .pick { position: absolute; top: 8px; right: 10px; font-size: 11px;
  color: var(--accent); font-weight: 700; }

.picked { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.seatchip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
  border: 1px solid var(--accent); border-radius: 999px; padding: 3px 5px 3px 12px;
  background: var(--accent-soft); }
.seatchip.empty { border-style: dashed; border-color: var(--line); color: var(--dim);
  padding: 3px 12px; background: transparent; }
.seatchip .x { border: 0; background: transparent; padding: 0 5px; color: var(--dim);
  font-size: 14px; line-height: 1; }
.seatchip .x:hover { color: var(--bad); }

/* ── frame ─────────────────────────────────────────────────────────────── */
.game { height: 100vh; display: flex; flex-direction: column; }

.top { display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  border-bottom: 1px solid var(--line); background: var(--panel); }
.whose { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px;
  font-size: 12px; color: var(--dim); background: var(--panel-2); display: flex;
  align-items: center; gap: 6px; }
.chip select { border: none; background: transparent; padding: 0; }
#live-chip.past { color: #43310a; background: #ffe9b0; border-color: var(--warn); font-weight: 700; }

/* Said once, and left up: a loaded game that is not the game in the file is
   true for the rest of the session, so it does not get a toast. */
.banner { padding: 7px 14px; font-size: 13px; color: #43310a;
  background: #fff5da; border-bottom: 1px solid var(--warn); }

.layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 420px;
  gap: 12px; padding: 12px; min-height: 0; }

/* ── board ─────────────────────────────────────────────────────────────── */
.board-wrap { display: grid; place-items: center; min-height: 0; min-width: 0; }
.board {
  position: relative;
  width: min(100%, 88vh);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: 1.42fr repeat(9, 1fr) 1.42fr;
  grid-template-rows: 1.42fr repeat(9, 1fr) 1.42fr;
  background: var(--felt);
  border: 2px solid #2c3138;
  border-radius: 6px;
  overflow: hidden;
  user-select: none;
}

.sq {
  position: relative;
  background: var(--tile);
  border: 1px solid var(--tile-line);
  color: #16181d;
  display: flex; flex-direction: column;
  overflow: hidden;
  font-size: clamp(6px, 0.85vh, 10px);
  line-height: 1.08;
  cursor: default;
}
/* The colour strip faces the middle of the board, as it does on the sheet:
   the row/column a square sits in decides which edge that is. */
.sq.s-bottom { flex-direction: column; }
.sq.s-top    { flex-direction: column-reverse; }
.sq.s-left   { flex-direction: row-reverse; }
.sq.s-right  { flex-direction: row; }
.sq .bar { flex: 0 0 auto; }
.sq.s-bottom .bar { height: 19%; min-height: 7px; border-bottom: 1px solid var(--tile-line); }
.sq.s-top .bar    { height: 19%; min-height: 7px; border-top: 1px solid var(--tile-line); }
.sq.s-left .bar   { width: 19%; min-width: 7px; height: 100%; border-left: 1px solid var(--tile-line); }
.sq.s-right .bar  { width: 19%; min-width: 7px; height: 100%; border-right: 1px solid var(--tile-line); }
.sq.corner .bar { display: none; }
.sq .body { flex: 1; padding: 2px 2px 0; display: flex; flex-direction: column;
  align-items: center; text-align: center; gap: 1px; }
.sq .nm { font-weight: 600; word-break: break-word; hyphens: auto; }
.sq .pr { font-variant-numeric: tabular-nums; opacity: .62; font-size: .92em; }
.sq.corner { background: #f0f2ec; }
.sq.corner .nm { font-size: 1.15em; }
.sq.card .body, .sq.tax .body { justify-content: center; }
.sq .icon { font-size: 2em; line-height: 1; opacity: .55; }

/* ownership */
.sq .own { position: absolute; inset: auto 0 0 0; height: 4px; }
.sq.owned { box-shadow: inset 0 0 0 2px var(--o); }
.sq.mine { background: #fff8dc; }
.sq.mortg .body { opacity: .42; }
.sq .mflag { position: absolute; top: 1px; right: 2px; font-size: .9em;
  font-weight: 800; color: var(--bad); }
.sq .houses { display: flex; gap: 1px; justify-content: center; margin-top: auto;
  padding-bottom: 5px; }
.sq .h { width: .55em; height: .55em; background: #2c8f4f; border: 1px solid #1c5c33;
  border-radius: 1px; }
.sq .hotel { width: 1.1em; height: .6em; background: var(--bad); border: 1px solid #8c221b;
  border-radius: 1px; }
.sq.hit { animation: pulse 900ms ease-out; }
@keyframes pulse {
  0% { box-shadow: inset 0 0 0 3px var(--accent); }
  100% { box-shadow: inset 0 0 0 0 transparent; }
}
.sq.pick { cursor: pointer; outline: 2px solid var(--accent); outline-offset: -2px; }
.sq.hover { filter: brightness(.955); }

/* The hover card: who owns this square, right now. Everything in it is read
   out of the frame under the playhead or the static board payload — no rule and
   no valuation is worked out in JavaScript, here least of all. */
.sqtip {
  position: fixed; z-index: 60; pointer-events: none;
  max-width: 260px; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px;
  box-shadow: 0 4px 16px rgba(20, 25, 40, .18); font-size: 12.5px;
}
.sqtip h5 { margin: 0 0 3px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.sqtip h5 .g { width: 10px; height: 10px; border-radius: 2px; border: 1px solid rgba(0,0,0,.35); }
.sqtip .ow { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.sqtip .ow .token-dot { width: 11px; height: 11px; }
.sqtip .free { color: var(--dim); font-weight: 600; }
.sqtip .l { color: var(--dim); font-size: 11.5px; margin-top: 2px;
  font-variant-numeric: tabular-nums; }
.sqtip .warn { color: var(--bad); font-weight: 600; }

/* centre */
.centre { grid-column: 2 / 11; grid-row: 2 / 11; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; padding: 16px; text-align: center; }
.dice-row { display: flex; gap: 14px; }
.die {
  width: clamp(30px, 5.2vh, 54px); aspect-ratio: 1; background: #fffffc;
  border: 1px solid #c8cec6;
  border-radius: 12%; box-shadow: 0 2px 5px rgba(0,0,0,.22), inset 0 -3px 0 rgba(0,0,0,.05);
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 12%;
  opacity: .3; transition: opacity .2s;
}
.die.on { opacity: 1; }
.die i { border-radius: 50%; background: #14161b; display: block; }
.die.roll { animation: shake 480ms ease-in-out; }
@keyframes shake {
  0%   { transform: translateY(0) rotate(0); }
  25%  { transform: translateY(-16%) rotate(-24deg); }
  50%  { transform: translateY(6%) rotate(20deg); }
  75%  { transform: translateY(-9%) rotate(-11deg); }
  100% { transform: translateY(0) rotate(0); }
}
.caption { font-size: clamp(13px, 2.1vh, 20px); font-weight: 600; color: #1c2129;
  max-width: 34ch; }
.subcaption { font-size: clamp(10px, 1.5vh, 13px); color: #4a5460; max-width: 40ch; }

/* tokens */
/* Above the squares: they are `position: relative` and come later in the DOM,
   so without this they paint over the tokens. */
.tokens { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.tk {
  position: absolute; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,.5); box-shadow: 0 1px 3px rgba(0,0,0,.35);
  transform: translate(-50%, -50%);
  transition: left .16s linear, top .16s linear;
  display: grid; place-items: center; font-size: 9px; font-weight: 800; color: #fff;
}
.tk.jailed { border-style: dashed; }
.tk.out { opacity: .22; }
.tk.glide { transition: left .55s cubic-bezier(.4,0,.2,1), top .55s cubic-bezier(.4,0,.2,1); }
.tk.active { box-shadow: 0 0 0 3px rgba(26,111,212,.55), 0 1px 3px rgba(0,0,0,.35); }

/* ── side ──────────────────────────────────────────────────────────────── */
.side { display: flex; flex-direction: column; gap: 10px; min-height: 0; }

/* A box that folds. The bar is always there — folding something away has to
   leave the handle that brings it back. */
.box { background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; display: flex;
  flex-direction: column; min-height: 0; }
.boxbar { display: flex; align-items: center; gap: 8px; padding: 4px 9px 4px 5px;
  border-bottom: 1px solid var(--line-2); font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--dim); flex: 0 0 auto; background: var(--panel-2); }
.boxbar label { display: flex; align-items: center; gap: 4px; text-transform: none;
  letter-spacing: 0; cursor: pointer; }
.box.folded .boxbar { border-bottom: 0; }
.caret { border: 0; background: transparent; padding: 2px 5px; color: var(--dim);
  font-size: 12px; line-height: 1; border-radius: 5px; }
.caret:hover:not(:disabled) { color: var(--ink); background: var(--line-2); }
.box.folded .caret { transform: rotate(-90deg); }

#standbox { flex: 0 1 auto; }
#standbox.folded .players { display: none; }
.players { display: grid; gap: 6px; padding: 7px; overflow-y: auto; max-height: 34vh; }
.players.no-worth .pl .worth { display: none; }
.players.no-power .pl .power { display: none; }
.players.no-deeds .pl .deeds { display: none; }
.pl { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px 9px; display: grid; grid-template-columns: auto 1fr auto; gap: 8px;
  align-items: center; }
.pl.turn { border-color: var(--accent); background: var(--accent-soft); }
.pl.dead { opacity: .5; }
.pl.dead .nm { text-decoration: line-through; }
.pl .nm { font-weight: 650; }
.pl .cash { font-variant-numeric: tabular-nums; font-weight: 650; text-align: right; }
.pl .worth { font-size: 11px; color: var(--dim); text-align: right; }
/* The third line is the one you read against a price, so it is set in the same
   tabular figures as the cash it is compared with rather than the prose size. */
.pl .power { font-size: 11px; color: var(--dim); text-align: right;
  font-variant-numeric: tabular-nums; }
.pl .deeds { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 2px; }
.token-dot { width: 13px; height: 13px; border-radius: 50%; display: inline-block;
  border: 2px solid rgba(0,0,0,.45); }
.badge { font-size: 10px; border-radius: 4px; padding: 0 4px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--dim); }

.deed { width: 15px; height: 15px; border-radius: 3px; border: 1px solid rgba(0,0,0,.4);
  position: relative; cursor: default; }
.deed.m { opacity: .35; }
.deed .hh { position: absolute; inset: auto 0 0 0; height: 4px; background: #2c8f4f; }
.deed .ht { position: absolute; inset: auto 0 0 0; height: 5px; background: var(--bad); }

/* log */
/* It gives way to the decision panel rather than splitting the column with it:
   a smaller basis, a much larger shrink factor, and a floor of about three
   lines so that folding it away stays a choice rather than the only way to see
   what you have been asked. */
.logbox { flex: 1 4 96px; min-height: 58px; }
.logbox.folded { flex: 0 0 auto; min-height: 0; }
.logbox.folded .log { display: none; }
.log { list-style: none; margin: 0; padding: 5px 9px; overflow-y: auto; flex: 1;
  font-size: 12.5px; }
.log li { padding: 2px 0; border-bottom: 1px solid var(--line-2); display: flex; gap: 6px; }
.log li:last-child { border: 0; }
.log .r { color: #98a0b0; font-variant-numeric: tabular-nums; min-width: 2.2em;
  text-align: right; }
.log .me { color: var(--accent); font-weight: 600; }
.log .now { background: var(--accent-soft); margin: 0 -9px; padding-left: 9px; padding-right: 9px; }
.log b { font-weight: 650; }
.log .money { font-variant-numeric: tabular-nums; }

/* prefs */
.prefs { background: var(--panel); border: 1px solid var(--line); flex: 0 0 auto;
  border-radius: var(--radius); padding: 6px 10px; font-size: 12px; }
.prefs summary { cursor: pointer; color: var(--dim); }
.prefs label { display: flex; align-items: center; gap: 7px; margin: 7px 0; }

/* ── decision panel ────────────────────────────────────────────────────── */
/* The one thing on this page that is never big enough, so it takes the space
   the folded boxes give up rather than a fixed slice of the viewport. */
.decision { background: #f4f8ff; border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 11px 12px; flex: 3 0.4 340px; min-height: 200px; overflow-y: auto;
  box-shadow: 0 1px 8px rgba(26, 111, 212, .10); }
.decision h3 { margin: 0 0 2px; font-size: 15px; }
.decision .q { color: #4a5568; font-size: 12.5px; margin: 0 0 9px; }
.decision .acts { display: flex; flex-wrap: wrap; gap: 6px; }
.opt { display: flex; align-items: center; gap: 7px; width: 100%; justify-content: flex-start;
  text-align: left; background: #fff; }
.opt .g { width: 11px; height: 11px; border-radius: 3px; border: 1px solid rgba(0,0,0,.35); }
.opt .cost { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--dim); }
.opt.primary .cost { color: #dbe8fb; }
.optlist { display: grid; gap: 4px; max-height: 34vh; overflow-y: auto; margin-bottom: 8px; }
.bidrow { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.bidrow input[type=number] { width: 8em; font-variant-numeric: tabular-nums; }
.bidrow input[type=range] { flex: 1; }
.note { font-size: 11.5px; color: var(--dim); margin: 6px 0 0; }
.replay-lock { text-align: center; padding: 10px; }

/* trade builder */
.tb { display: grid; gap: 8px; }
.tb .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tb .col { background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 7px; }
.tb .col h4 { margin: 0 0 5px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--dim); }
.tb .chips { display: flex; flex-wrap: wrap; gap: 3px; }
.tb .dc { display: flex; align-items: center; gap: 4px; font-size: 11px;
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px 1px 3px;
  cursor: pointer; background: #fff; }
.tb .dc.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.tb .dc .g { width: 9px; height: 9px; border-radius: 2px; }
.tb .cash { display: flex; align-items: center; gap: 8px; }
.tb .cash input { flex: 1; }
.summary { background: #fff; border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 9px; font-size: 12.5px; }
.summary .line { display: flex; gap: 6px; }
.summary .who { color: var(--dim); min-width: 5.5em; }
.reprise { font-size: 11.5px; color: var(--dim); margin: 4px 0 0; }

/* ── transport ─────────────────────────────────────────────────────────── */
.transport { display: flex; align-items: center; gap: 8px; padding: 7px 14px;
  border-top: 1px solid var(--line); background: var(--panel); }
.transport button { padding: 5px 11px; }
.transport input[type=range] { flex: 1; }
.counter { font-variant-numeric: tabular-nums; color: var(--dim); font-size: 12px;
  min-width: 7em; text-align: right; }

.toast { position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%);
  background: #fdeceb; border: 1px solid var(--bad); color: #8f2418;
  padding: 8px 14px; border-radius: 8px; z-index: 70; font-size: 13px;
  box-shadow: 0 3px 14px rgba(20, 25, 40, .18); }
.toast.ok { background: #eef6ff; border-color: var(--accent); color: #14406f; }

@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto auto; overflow-y: auto; }
  .board { width: min(100%, 78vh); }
  .decision { min-height: 0; }
}
