:root {
  --bg: #12161f;
  --panel: #1b2130;
  --panel-2: #232b3d;
  --line: #2f3a52;
  --text: #e9edf5;
  --muted: #93a0b8;
  --accent: #f2b33d;
  --accent-ink: #1b1405;
  --danger: #e5484d;
  --good: #2bb673;
  --board: #e9e2cf;
  --board-ink: #1d2230;
  --board-line: #b9ae92;
  --center: #d8e8d1;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* no accidental double-tap zoom on phones and tablets */
html, body, button, a, input, select, .space { touch-action: manipulation; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 Inter, system-ui, sans-serif; min-height: 100vh; }
a { color: var(--accent); }
h1, h2, .logo, .brand { font-family: Fraunces, Georgia, serif; }
h1 { margin: 0 0 8px; font-size: 32px; }
h2 { margin: 0 0 10px; font-size: 20px; }
h3 { margin: 0 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
h4 { margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.warn { color: #ffb4a8; }
.grow { flex: 1; min-width: 0; }

.top { display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: #0e1219; position: sticky; top: 0; z-index: 5; }
.top .back { color: var(--muted); text-decoration: none; font-size: 13px; }
.brand { color: var(--text); text-decoration: none; font-weight: 800; font-size: 20px; }
.who { margin-left: auto; font-size: 13px; color: var(--muted); }

button, .btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 9px; padding: 9px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:hover:not(:disabled), .btn:hover { border-color: #4a5876; }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.primary:hover:not(:disabled) { filter: brightness(1.07); border-color: var(--accent); }
.danger { background: transparent; color: #ffb4a8; border-color: #6b2b2e; }
.big { padding: 12px 18px; font-size: 16px; }
/* 16px stops iOS zooming into form fields */
input, select { font: inherit; font-size: 16px; background: #0f141d; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; }
.field > span { font-size: 13px; color: var(--muted); }
.row, .btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; display: inline-block; box-shadow: 0 0 0 2px rgba(255,255,255,.15); }
.chip { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }
.tag { margin-left: 6px; }

/* ---------- lobby ---------- */
.lobby { max-width: 1060px; margin: 0 auto; padding: 20px 16px 40px; display: grid; gap: 16px; }
.hero p { max-width: 70ch; }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-top: 12px; }
.mode { background: var(--panel-2); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.mode span { color: var(--muted); font-size: 13.5px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; align-items: start; }
.seatrow { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.seatrow select { flex: 1; }
.gamerow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.roomwrap { max-width: 560px; margin: 24px auto; padding: 0 16px; }
.room .seatrow { border-top: 1px solid var(--line); padding: 10px 0; }
.share { display: flex; gap: 8px; margin: 14px 0; }
.share input { flex: 1; min-width: 0; font-size: 13px; }

/* ---------- game ---------- */
.gamewrap { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; padding: 16px; max-width: 1400px; margin: 0 auto; align-items: start; }
.boardbox { width: 100%; max-width: calc((100vh - 90px) * 1263 / 1246); margin: 0 auto; }
/* The board is the picture; spaces and live numbers sit on top of it, sized in container units (cqw = 1% of the board's width). */
.board { position: relative; aspect-ratio: 1263 / 1246; background: #e9e2cf url('../img/board.jpg') center / 100% 100% no-repeat;
  border-radius: 1.2cqw; overflow: hidden; container-type: inline-size; color: var(--board-ink); box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.space { position: absolute; background: transparent; border: 0; border-radius: .6cqw; padding: 0; margin: 0; cursor: pointer; }
.space:hover { background: rgba(255,255,255,.18); border-color: transparent; }
.space:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.space.owned { box-shadow: inset 0 0 0 .55cqw var(--owner), inset 0 0 0 .8cqw rgba(255,255,255,.55); }
.space.owned::after { content: ''; position: absolute; top: .5cqw; right: .5cqw; width: 1.9cqw; height: 1.9cqw; border-radius: 50%;
  background: var(--owner); border: .3cqw solid #fff; box-shadow: 0 .15cqw .4cqw rgba(0,0,0,.5); }
.space .lv { position: absolute; top: .45cqw; left: .45cqw; font-size: 1.55cqw; line-height: 1; background: rgba(255,255,255,.9);
  border-radius: 99px; padding: .2cqw .35cqw; box-shadow: 0 .1cqw .3cqw rgba(0,0,0,.4); }
.space .lv:empty { display: none; }
.space .tokens { position: absolute; inset: auto .4cqw .5cqw .4cqw; display: flex; flex-wrap: wrap; gap: .3cqw; justify-content: center; pointer-events: none; }
/* per edge: tokens straddle the inner edge (half over the centre picture); owner dot and level badge sit on the colour band */
.space .tokens { z-index: 2; }
.side-bottom .tokens { inset: -1.7cqw 0 auto 0; }
.side-top .tokens { inset: auto 0 -1.7cqw 0; }
.side-left .tokens { inset: 0 -1.7cqw 0 auto; width: 3.4cqw; flex-direction: column; align-items: center; justify-content: center; }
.side-right .tokens { inset: 0 auto 0 -1.7cqw; width: 3.4cqw; flex-direction: column; align-items: center; justify-content: center; }
.c0 .tokens { inset: -1.7cqw auto auto -1.7cqw; }
.c8 .tokens { inset: -1.7cqw -1.7cqw auto auto; }
.c16 .tokens { inset: auto -1.7cqw -1.7cqw auto; }
.c24 .tokens { inset: auto auto -1.7cqw -1.7cqw; }
.side-top.owned::after { top: auto; bottom: .5cqw; }
.side-top .lv { top: auto; bottom: .45cqw; }
.side-left .lv { top: auto; left: auto; bottom: .45cqw; right: .45cqw; }
.side-right.owned::after { right: auto; left: .5cqw; }
.side-right .lv { top: auto; bottom: .45cqw; }
.token { width: 3.2cqw; height: 3.2cqw; border-radius: 50%; color: #fff; font-size: 1.7cqw; font-weight: 800;
  display: grid; place-items: center; border: .35cqw solid #fff; box-shadow: 0 .2cqw .5cqw rgba(0,0,0,.6); }
.token.cur { animation: bob 1s ease-in-out infinite alternate; }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-.5cqw); } }

.ov { position: absolute; display: flex; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.round { font-family: Fraunces, Georgia, serif; font-weight: 800; font-size: 2.6cqw; color: #2b1d0e; }
.dicebox { gap: 1.6cqw; }
.die { width: 7cqw; height: 7cqw; background: #fffdf6; border-radius: 1.3cqw; border: .3cqw solid #2b2b2b; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  padding: .9cqw; box-shadow: .3cqw .5cqw 0 rgba(0,0,0,.35); }
.die span { display: block; }
.die .pip { background: #151515; border-radius: 50%; margin: 12%; }
.dicebox.dbl .die { border-color: #b3261e; }
.dicebox.dbl .pip { background: #b3261e; }
.fund { font-family: Fraunces, Georgia, serif; font-size: 2.2cqw; color: #2b1d0e; gap: .5cqw; justify-content: flex-start; padding-left: .5cqw; }
.notice { flex-direction: column; gap: .7cqw; padding: .6cqw 2.4cqw; color: #2b1d0e; overflow: hidden; }
.whoseline { font-weight: 700; font-size: 1.75cqw; }
.logline { font-size: 1.6cqw; line-height: 1.25; }
.logline.old { opacity: .7; }
.headline { background: #fffdf3; border: .25cqw solid #2b1d0e; border-radius: .8cqw; padding: .6cqw 1.2cqw; font-size: 1.55cqw; line-height: 1.25; box-shadow: .3cqw .3cqw 0 #2b1d0e; max-width: 95%; }
.whose { background: linear-gradient(#e5483f, #b3261e); color: #fff; font-family: Fraunces, Georgia, serif; font-weight: 800; border-radius: 99px; padding: .6cqw 3cqw;
  font-size: 2.1cqw; text-shadow: 0 .15cqw .3cqw rgba(0,0,0,.4); box-shadow: inset 0 0 0 .3cqw var(--c), 0 .3cqw .6cqw rgba(0,0,0,.3); }

.side { display: flex; flex-direction: column; gap: 12px; }
.panel { padding: 14px; }
.actions { border-left: 5px solid var(--c); }
.actions h2 { margin-bottom: 2px; }
.clock { min-height: 1em; margin-bottom: 8px; }
.trade { border-color: var(--accent); }
.trade p { margin: 4px 0; }
.win ol { padding-left: 20px; }
.prow { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-radius: 8px; flex-wrap: wrap; }
.prow.cur { background: var(--panel-2); }
.prow.out { opacity: .5; text-decoration: line-through; }
.cash { font-weight: 700; }
.proprow { width: 100%; background: transparent; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 8px 2px; justify-content: flex-start; font-weight: 500; text-align: left; }
.log { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow: auto; font-size: 13px; }
.log li { padding: 4px 0; border-bottom: 1px solid var(--line); }

/* ---------- modals ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(5,8,14,.7); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; width: min(440px, 100%); max-height: 90vh; overflow: auto; }
.modal.wide { width: min(680px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.modal-head h2 { margin: 0; }
.x { background: transparent; border: 0; font-size: 26px; padding: 0 6px; color: var(--muted); }
.rents { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; margin: 10px 0; font-size: 14px; }
.rents div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dashed var(--line); padding: 2px 0; }
.chipline { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.summary { margin: 8px 0; }
.tcols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.picks { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; max-height: 240px; overflow: auto; }
.pick { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 8px; background: var(--panel-2); cursor: pointer; }
.pick input { width: 18px; height: 18px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #0e1219; border: 1px solid var(--accent); color: var(--text); padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast.bad { border-color: var(--danger); }

/* ---------- tablets and phones ---------- */
@media (max-width: 1000px) {
  .gamewrap { grid-template-columns: 1fr; padding: 10px; }
  .boardbox { max-width: min(100%, 720px); }
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .top { gap: 10px; padding: 8px 12px; }
  .top .back { font-size: 12px; }
  .tcols { grid-template-columns: 1fr; }
  .gamewrap { padding: 8px; gap: 10px; }
  h1 { font-size: 26px; }
}
