:root {
  --bg: #f6f1e7;
  --panel: #fffdf8;
  --ink: #1f2a2e;
  --muted: #6b7478;
  --line: #e4dccb;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --gold: #d99a1e;
  --good: #15803d;
  --bad: #c2410c;
  --shadow: 0 1px 2px rgba(31, 42, 46, .06), 0 6px 20px rgba(31, 42, 46, .07);
  --radius: 14px;

  --sp-payday: #fde68a;
  --sp-invest: #bbf7d0;
  --sp-news: #bfdbfe;
  --sp-spend: #fbcfe8;
  --sp-emergency: #fecaca;
  --sp-learn: #ddd6fe;
  --sp-family: #fed7aa;
  --sp-work: #cbd5e1;
  --sp-goal: #fcd34d;
  --sp-dividend: #a7f3d0;
  --sp-bizdeal: #99f6e4;
  --sp-crisis: #fca5a5;
  --sp-tax: #e5e7eb;
  --sp-merit: #fde68a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151b1d;
    --panel: #1e2629;
    --ink: #edf2f3;
    --muted: #9aa6aa;
    --line: #2f3a3e;
    --brand: #2dd4bf;
    --brand-ink: #0b1f1d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    --sp-payday: #5c4a12;
    --sp-invest: #164a2c;
    --sp-news: #1e3a5f;
    --sp-spend: #5b2142;
    --sp-emergency: #5f1f1f;
    --sp-learn: #3b2f66;
    --sp-family: #5c3413;
    --sp-work: #334155;
    --sp-goal: #6b5410;
    --sp-dividend: #14532d;
    --sp-bizdeal: #134e4a;
    --sp-crisis: #7f1d1d;
    --sp-tax: #374151;
    --sp-merit: #713f12;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans Thai", "Noto Sans SC", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

:lang(zh) body, html[lang="zh"] body { font-family: "Noto Sans SC", "Noto Sans Thai", system-ui, sans-serif; }

h1, h2, h3, .display { font-family: "Kanit", "Noto Sans Thai", "Noto Sans SC", sans-serif; letter-spacing: .01em; }
h2 { margin: 0 0 .5rem; font-size: 1.25rem; }
h3 { margin: 0 0 .4rem; font-size: 1rem; }

button {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 10px;
  padding: .45rem .8rem;
  cursor: pointer;
  transition: transform .06s ease, background .15s ease;
}
button:hover:not(:disabled) { background: color-mix(in srgb, var(--brand) 10%, var(--panel)); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; }
button.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--brand) 85%, black); }
button.small { padding: .2rem .55rem; font-size: .85rem; border-radius: 8px; }
button.big { padding: .7rem 1.4rem; font-size: 1.05rem; }

input, select {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .35rem .5rem;
  min-width: 0;
}

/* ---------- header ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand h1 { margin: 0; font-size: 1.6rem; color: var(--brand); }
.brand span { color: var(--muted); font-size: .95rem; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.top-actions .ico { display: none; }
.langs { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.langs button { border: 0; border-radius: 0; }
.langs button.on { background: var(--brand); color: var(--brand-ink); font-weight: 700; }

main { padding: 20px max(20px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); max-width: 1500px; margin: 0 auto; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }

/* ---------- setup ---------- */
.setup { max-width: 900px; margin: 0 auto; }
.setup .hint { color: var(--muted); margin-top: 0; }
.setup-row {
  display: grid; grid-template-columns: 14px 1.2fr auto 1.6fr auto; gap: 10px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.setup-row .dot { width: 14px; height: 14px; border-radius: 50%; }
.toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.toggle button { border: 0; border-radius: 0; padding: .3rem .6rem; }
.toggle button.on { background: var(--ink); color: var(--panel); }
.setup-actions { display: flex; justify-content: space-between; margin-top: 16px; gap: 10px; }

/* ---------- game layout ---------- */
.game { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.board-wrap { min-width: 0; }
.right { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
/* Tablets in landscape and up: board on the left, controls and statement on the right,
   and the board shrinks to fit the screen height so no row is cut off. */
@media (min-width: 900px) {
  .game { grid-template-columns: minmax(0, 1fr) minmax(330px, 400px); gap: 20px; }
  .game .board { max-width: min(920px, calc(100dvh - 192px)); }
  .right { position: sticky; top: 76px; max-height: calc(100dvh - 92px); overflow: auto; padding-right: 2px; }
}
@media (min-width: 1400px) {
  .game { grid-template-columns: minmax(0, 1fr) 440px; }
}
/* Phones held sideways: board and controls side by side, board fits the short screen. */
@media (orientation: landscape) and (max-height: 520px) and (min-width: 560px) {
  .game { grid-template-columns: auto minmax(260px, 1fr); gap: 12px; }
  .game .board { width: calc(100dvh - 72px); max-width: calc(100dvh - 72px); }
  .right { position: sticky; top: 56px; max-height: calc(100dvh - 64px); overflow: auto; }
  .topbar { padding-top: 6px; padding-bottom: 6px; }
  .brand span { display: none; }
  .space .label { display: none; }
  .top-actions .txt { display: none; }
  .top-actions .ico { display: inline; }
  .hub-brand { display: none; }
  .hub { gap: 3px; }
}

.board {
  --moat: clamp(7px, 1.8vw, 18px);
  display: grid;
  grid-template-columns: 1fr var(--moat) repeat(7, 1fr) var(--moat) 1fr;
  grid-template-rows: 1fr var(--moat) repeat(7, 1fr) var(--moat) 1fr;
  gap: 4px; aspect-ratio: 1 / 1; width: 100%; max-width: 920px; margin: 0 auto;
}
.space {
  border-radius: 10px; padding: 6px; position: relative; display: flex; flex-direction: column;
  justify-content: space-between; border: 1px solid color-mix(in srgb, var(--ink) 10%, transparent);
  min-width: 0; overflow: hidden;
}
.space .icon { font-size: 1.3rem; line-height: 1; }
.space .label { font-size: .72rem; font-weight: 600; line-height: 1.15; }
.space.here { outline: 3px solid var(--ink); outline-offset: -1px; }
.tokens { display: flex; flex-wrap: wrap; gap: 3px; position: absolute; right: 5px; top: 5px; max-width: 60%; justify-content: flex-end; }
.token { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 1px 2px rgba(0,0,0,.3); }

.center { display: flex; flex-direction: column; gap: 10px; }

/* Middle of the board: turn, dice and landed space. */
.hub {
  grid-column: 4 / 9; grid-row: 4 / 9; position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(4px, 1.5vw, 12px); text-align: center; border-radius: var(--radius);
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--brand) 14%, var(--panel)), var(--bg) 75%);
  border: 1px dashed var(--line); min-width: 0; overflow: hidden; padding: 6px;
}
.hub-brand { font-family: Kanit, sans-serif; font-weight: 700; color: var(--brand); font-size: clamp(1rem, 4vw, 2.4rem); letter-spacing: .06em; }
@media (max-width: 340px) { .hub-brand { display: none; } }
.hub-turn { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: clamp(.8rem, 2.2vw, 1.2rem); max-width: 100%; }
.hub-round { color: var(--muted); font-size: clamp(.7rem, 1.8vw, .95rem); }
.hub-space {
  display: flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-weight: 600;
  font-size: clamp(.7rem, 2vw, 1rem); background: color-mix(in srgb, var(--card-tint) 60%, var(--panel)); animation: cardIn .35s;
}
.hub .die { width: clamp(30px, 7vw, 52px); height: clamp(30px, 7vw, 52px); font-size: clamp(1rem, 3.5vw, 1.8rem); }
.turn-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.turn-head .who { display: flex; align-items: center; gap: 8px; font-family: Kanit, sans-serif; font-size: 1.2rem; }
.turn-head .month { color: var(--muted); font-size: .9rem; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }

.section-title { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 4px 0; }

.market-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.market-table td, .market-table th { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.market-table th { color: var(--muted); font-weight: 600; font-size: .78rem; }
.market-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.qty { width: 64px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.dice { display: flex; gap: 8px; }
.die {
  width: 44px; height: 44px; border-radius: 10px; background: var(--ink); color: var(--panel);
  display: grid; place-items: center; font-family: Kanit, sans-serif; font-size: 1.5rem;
  animation: pop .25s ease;
}
@keyframes pop { from { transform: scale(.6) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }

.card {
  border-radius: 12px; padding: 12px 14px; border: 1px solid var(--line);
  background: color-mix(in srgb, var(--card-tint, var(--sp-invest)) 45%, var(--panel));
}
.card .kind { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.card h3 { font-size: 1.15rem; margin: 2px 0 6px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 6px 12px; font-size: .9rem; margin: 6px 0; }
.facts div span { display: block; color: var(--muted); font-size: .75rem; }
.facts div b { font-variant-numeric: tabular-nums; }
.deal-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.note { font-size: .85rem; color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }

.offer-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }

.winner { text-align: center; padding: 20px; }
.winner .trophy { font-size: 3rem; }

/* ---------- side panel ---------- */
.side { display: flex; flex-direction: column; gap: 16px; }
.statement .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.statement .career { color: var(--muted); font-size: .9rem; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.badge { font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: var(--line); }
.badge.free { background: var(--gold); color: #1f1300; font-weight: 700; }
.big-numbers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.big-numbers div { background: color-mix(in srgb, var(--brand) 7%, var(--panel)); border-radius: 10px; padding: 8px 10px; }
.big-numbers span { display: block; font-size: .75rem; color: var(--muted); }
.big-numbers b { font-family: Kanit, sans-serif; font-size: 1.15rem; font-variant-numeric: tabular-nums; }

.progress { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 4px 0 10px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--gold)); border-radius: inherit; transition: width .4s ease; }
.progress-label { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); }

.lines { width: 100%; font-size: .85rem; border-collapse: collapse; }
.lines td { padding: 3px 0; border-bottom: 1px solid var(--line); }
.lines td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
details { margin-top: 8px; }
summary { cursor: pointer; font-weight: 600; font-size: .9rem; padding: 4px 0; }

.players-list .row { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .88rem; }
.players-list .row.active { font-weight: 700; }
.players-list .sub { color: var(--muted); font-size: .78rem; font-weight: 400; }
.mini-progress { width: 70px; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.mini-progress > i { display: block; height: 100%; background: var(--brand); }

.log { max-height: 240px; overflow: auto; font-size: .82rem; }
.log div { padding: 3px 0; border-bottom: 1px solid var(--line); }
.log .m { color: var(--muted); margin-right: 6px; font-variant-numeric: tabular-nums; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal { max-width: 620px; width: 100%; max-height: 85vh; overflow: auto; }
.modal ol { padding-left: 1.2rem; }
.modal li { margin: 6px 0; }

/* ---------- responsive ---------- */
/* Phones */
@media (max-width: 720px) {
  main { padding: 12px max(12px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .topbar { padding: 8px 12px; gap: 8px; padding-top: max(8px, env(safe-area-inset-top)); }
  .brand h1 { font-size: 1.3rem; }
  .brand span { display: none; }
  .top-actions { gap: 6px; flex-wrap: nowrap; }
  .top-actions .txt { display: none; }
  .top-actions .ico { display: inline; }
  .top-actions > button, .langs button { padding: .35rem .55rem; }
  .board { gap: 2px; }
  .space { padding: 2px; border-radius: 5px; }
  .space .label { display: none; }
  .space .icon { font-size: clamp(.75rem, 3.6vw, 1rem); }
  .tokens { right: 2px; top: 2px; gap: 1px; }
  .token { width: 9px; height: 9px; border-width: 1px; }
  .panel { padding: 12px; }
  .setup-row { grid-template-columns: 14px 1fr auto; }
  .setup-row select { grid-column: 2 / -1; }
  .setup-actions { flex-wrap: wrap; }
  .market-table th:nth-child(3), .market-table td:nth-child(3) { display: none; }
  .qty { width: 54px; }
  .deal-cards { grid-template-columns: 1fr; }
  .big-numbers b { font-size: 1rem; }
  /* iOS zooms into inputs under 16px */
  input, select { font-size: 16px; }
}
@media (max-width: 380px) {
  .langs button { padding: .3rem .4rem; font-size: .85rem; }
  .brand h1 { font-size: 1.1rem; }
}
/* Fingers need bigger targets than mouse pointers. */
@media (pointer: coarse) {
  button { min-height: 40px; }
  button.small { min-height: 36px; }
}

/* ---------- online lobby ---------- */
.mode-tabs { margin-bottom: 14px; }
.mode-tabs button { padding: .45rem .9rem; }
.online-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.online-form label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
.join-row { display: flex; gap: 10px; align-items: center; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.code-input { width: 12ch; text-transform: uppercase; letter-spacing: .2em; font-weight: 700; text-align: center; }
.share { display: flex; gap: 10px; align-items: center; margin: 8px 0 16px; flex-wrap: wrap; }
.share input { flex: 1; min-width: 200px; }
.room-code { font-family: Kanit, monospace; font-size: 1.6rem; letter-spacing: .15em; color: var(--brand); padding: 2px 10px; border: 2px dashed var(--brand); border-radius: 10px; }
.room-row { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.badge.ready { background: var(--good); color: #fff; }
@media (max-width: 720px) {
  .online-form { grid-template-columns: 1fr; }
}

button.choice { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px; text-align: left; border-radius: 12px; }
button.choice b { font-family: Kanit, sans-serif; font-size: 1.15rem; }
button.choice span { font-size: .85rem; color: var(--muted); }

/* ---------- Investor Avenue (outer ring) ---------- */
.avenue-space { border: 2px solid color-mix(in srgb, var(--gold) 70%, transparent); filter: saturate(1.15); }
.avenue-space .label { font-size: .62rem; }
.space .label { font-size: .66rem; }

/* ---------- effects ---------- */
.die.rolling { animation: spin .12s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) scale(1.08); } }
.ghost-token {
  position: fixed; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; z-index: 30; pointer-events: none;
  border: 3px solid #fff; box-shadow: 0 4px 10px rgba(0,0,0,.35); transition: transform .13s ease-out;
}
.ghost-token.landed { animation: land .18s ease-out; }
@keyframes land { 50% { transform-origin: center; filter: brightness(1.4); } }
.hidden-token { opacity: 0; }
.space.stepped { transform: translateY(-3px); box-shadow: 0 6px 14px rgba(0,0,0,.18); transition: transform .1s; }
.await-landing .card, .await-landing .deal-cards, .await-landing > .btn-row { visibility: hidden; }
.center .card { animation: cardIn .35s cubic-bezier(.2,1.4,.4,1); }
@keyframes cardIn { from { transform: scale(.85) translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.float-money {
  position: fixed; z-index: 40; pointer-events: none; font-family: Kanit, sans-serif; font-size: 1.6rem; font-weight: 700;
  transform: translateX(-50%); animation: floatUp 1.5s ease-out forwards; text-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.float-money.good { color: var(--good); }
.float-money.bad { color: var(--bad); }
@keyframes floatUp { from { opacity: 0; transform: translate(-50%, 10px) scale(.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } to { opacity: 0; transform: translate(-50%, -70px) scale(1); } }
.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.storm { animation: storm 1.2s; }
@keyframes storm { 0%, 100% { filter: none; } 20% { filter: grayscale(.8) brightness(.7); transform: rotate(-.4deg); } 50% { filter: grayscale(.6) brightness(.8); transform: rotate(.4deg); } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 105vh; transform: rotate(720deg) translateX(40px); } }
.turn-banner { position: fixed; inset: 0; display: grid; place-items: center; z-index: 45; pointer-events: none; }
.turn-banner span {
  font-family: Kanit, sans-serif; font-size: clamp(2rem, 7vw, 4rem); font-weight: 700; color: #fff; padding: 12px 34px;
  border-radius: 999px; background: var(--c); box-shadow: 0 12px 40px rgba(0,0,0,.3); animation: bannerIn 1.5s ease forwards;
}
@keyframes bannerIn { 0% { transform: scale(.4); opacity: 0; } 20% { transform: scale(1.08); opacity: 1; } 75% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.1); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .center .card, .turn-banner span, .float-money { animation-duration: .01s; }
}

/* =====================================================================
   Theme: "Bangkok night market" — one game look for every device.
   ===================================================================== */
:root, :root:not([data-theme="light"]) {
  --bg: #0b1026;
  --panel: #151d44;
  --ink: #f5f3ff;
  --muted: #aab1d8;
  --line: #2b3770;
  --brand: #2dd4bf;
  --brand-ink: #03211c;
  --gold: #ffcc4d;
  --good: #34d399;
  --bad: #fb7185;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 18px;

  --sp-payday: #f5b72e;
  --sp-invest: #22b573;
  --sp-news: #3b82f6;
  --sp-spend: #ec4899;
  --sp-emergency: #ef4444;
  --sp-learn: #8b5cf6;
  --sp-family: #fb923c;
  --sp-work: #6b7a99;
  --sp-goal: #eab308;
  --sp-dividend: #10b981;
  --sp-bizdeal: #0ea5a4;
  --sp-crisis: #dc2626;
  --sp-tax: #64748b;
  --sp-merit: #f59e0b;
}

body {
  background:
    radial-gradient(1100px 600px at 15% -10%, #33227a 0%, transparent 60%),
    radial-gradient(900px 520px at 110% 5%, #0e5f66 0%, transparent 55%),
    linear-gradient(180deg, #0b1026 0%, #070a18 100%);
  background-attachment: fixed;
  min-height: 100dvh;
}
/* city lights */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image:
    radial-gradient(1.5px 1.5px at 20px 30px, rgba(255, 214, 102, .9), transparent),
    radial-gradient(1.5px 1.5px at 120px 80px, rgba(94, 234, 212, .8), transparent),
    radial-gradient(1px 1px at 180px 20px, rgba(255, 255, 255, .8), transparent),
    radial-gradient(1.5px 1.5px at 60px 120px, rgba(244, 114, 182, .7), transparent);
  background-size: 220px 150px;
}
#app { position: relative; z-index: 1; }

/* header */
.topbar { background: rgba(11, 16, 38, .78); backdrop-filter: blur(10px); border-bottom: 1px solid rgba(255, 204, 77, .25); }
.brand h1, .hub-brand {
  background: linear-gradient(180deg, #fff6c4 0%, #ffcc4d 45%, #f59e0b 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 rgba(120, 60, 0, .7));
}

/* buttons: chunky, pressable */
button {
  background: #222c5f; border: 1px solid #36438a; color: var(--ink); border-radius: 12px;
  box-shadow: 0 3px 0 #0a1030; transition: transform .06s, box-shadow .06s, filter .15s;
}
button:hover:not(:disabled) { background: #2a3672; filter: brightness(1.08); }
button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #0a1030; }
button.primary {
  background: linear-gradient(180deg, #5eead4, #14b8a6); color: var(--brand-ink); border-color: #0f766e;
  box-shadow: 0 4px 0 #0f766e, 0 6px 18px rgba(20, 184, 166, .35);
}
button.primary:hover:not(:disabled) { background: linear-gradient(180deg, #7ff0dd, #2dd4bf); }
button.primary:active:not(:disabled) { box-shadow: 0 1px 0 #0f766e; }
.center [data-action="roll"], .center [data-action="goal"] {
  background: linear-gradient(180deg, #ffe08a, #f5b72e); color: #3a2400; border-color: #b7791f;
  box-shadow: 0 4px 0 #9a5b12, 0 8px 22px rgba(245, 183, 46, .45); font-family: Kanit, sans-serif;
}
.langs { border-color: #36438a; }
.langs button { box-shadow: none; background: transparent; }
.langs button.on { background: linear-gradient(180deg, #ffe08a, #f5b72e); color: #3a2400; }
.toggle button.on { background: var(--gold); color: #3a2400; }
input, select { background: #0f1636; border-color: #36438a; color: var(--ink); border-radius: 10px; }

/* panels */
.panel {
  background: linear-gradient(180deg, rgba(27, 36, 84, .92), rgba(18, 25, 60, .92));
  border: 1px solid #2b3770; box-shadow: var(--shadow); border-radius: var(--radius);
}

/* players bar */
.players-bar { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 12px; scrollbar-width: thin; }
.chip {
  position: relative; display: flex; align-items: center; gap: 10px; min-width: 150px; padding: 8px 12px 8px 8px;
  border-radius: 16px; background: linear-gradient(180deg, #1f2a62, #161f4a); border: 2px solid #2b3770;
  box-shadow: 0 4px 0 #0a1030; text-align: left; flex: 0 0 auto;
}
.chip.active { border-color: var(--pc); box-shadow: 0 4px 0 #0a1030, 0 0 0 3px color-mix(in srgb, var(--pc) 35%, transparent), 0 0 22px color-mix(in srgb, var(--pc) 55%, transparent); }
.chip.locked { cursor: default; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--pc) 60%, white), var(--pc) 60%, color-mix(in srgb, var(--pc) 70%, black));
  color: #fff; font-family: Kanit, sans-serif; font-weight: 700; font-size: 1.1rem;
  border: 2px solid rgba(255, 255, 255, .85); box-shadow: 0 3px 8px rgba(0, 0, 0, .4);
}
.chip-body { display: grid; gap: 1px; min-width: 0; }
.chip-name { font-weight: 700; font-size: .9rem; white-space: nowrap; }
.chip-name .star { color: var(--gold); }
.chip-sub { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.chip-cash { font-family: Kanit, sans-serif; font-size: .9rem; font-variant-numeric: tabular-nums; }
.chip-bar { display: block; height: 4px; border-radius: 99px; background: #2b3770; overflow: hidden; width: 100%; }
.chip-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--gold)); }
.chip-turn {
  position: absolute; top: -9px; right: 10px; font-size: .66rem; font-weight: 700; padding: 1px 8px; border-radius: 99px;
  background: var(--pc); color: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}

/* board tray */
.board {
  position: relative; padding: clamp(6px, 1.3vw, 14px); border-radius: 26px;
  background: linear-gradient(145deg, #1e2b63, #0f1634);
  border: 3px solid var(--gold);
  box-shadow: 0 0 0 6px rgba(255, 204, 77, .12), 0 24px 60px rgba(0, 0, 0, .55), inset 0 0 50px rgba(0, 0, 0, .45);
}
.board::before {
  content: ''; position: absolute; inset: 5px; border-radius: 21px; pointer-events: none;
  border: 1px dashed rgba(255, 204, 77, .45);
}

/* tiles */
.space {
  --tile: #555;
  background: linear-gradient(160deg, color-mix(in srgb, var(--tile) 85%, white), color-mix(in srgb, var(--tile) 70%, black));
  border: 1px solid color-mix(in srgb, var(--tile) 55%, white);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 3px 0 color-mix(in srgb, var(--tile) 45%, black), 0 6px 12px rgba(0, 0, 0, .3);
  color: #fff; align-items: center; justify-content: center; text-align: center; gap: 2px; border-radius: 12px;
}
.space .icon { font-size: clamp(.85rem, 2.3vw, 1.7rem); filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35)); }
.space .label { color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .65); font-weight: 600; }
.avenue-space {
  border: 2px solid var(--gold); filter: saturate(1.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 3px 0 color-mix(in srgb, var(--tile) 45%, black), 0 0 12px rgba(255, 204, 77, .3);
}
.space.here { outline: 3px solid #fff; outline-offset: 1px; animation: here 1.6s ease-in-out infinite; }
@keyframes here { 50% { box-shadow: 0 0 0 4px var(--gold), 0 0 26px var(--gold); } }
.tokens { justify-content: flex-end; }
.token { width: 18px; height: 18px; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .55), 0 0 10px rgba(255, 255, 255, .35); }

/* hub */
.hub {
  background: radial-gradient(circle at 50% 40%, #2b3c86 0%, #172056 55%, #0f1634 100%);
  border: 2px solid rgba(255, 204, 77, .35); box-shadow: inset 0 0 40px rgba(0, 0, 0, .5);
}
.hub-brand { font-size: clamp(1.2rem, 5vw, 3rem); letter-spacing: .08em; line-height: 1; }
.hub-sub { color: var(--gold); font-size: clamp(.6rem, 1.5vw, .9rem); opacity: .85; letter-spacing: .04em; }
.die, .hub .die {
  background: linear-gradient(180deg, #ffffff, #e6e8f2); color: #12183a; border-radius: 14px; line-height: 1;
  box-shadow: 0 4px 0 #9aa3c7, 0 8px 18px rgba(0, 0, 0, .45);
}
.hub .die { width: clamp(34px, 7vw, 58px); height: clamp(34px, 7vw, 58px); font-size: clamp(1.8rem, 6vw, 3.4rem); }
.hub-space { color: #fff; border: 1px solid rgba(255, 255, 255, .25); background: color-mix(in srgb, var(--card-tint) 70%, #0f1634); }

/* cards */
.card {
  background: linear-gradient(180deg, color-mix(in srgb, var(--card-tint, var(--sp-invest)) 22%, #18214a), #141c42);
  border: 1px solid color-mix(in srgb, var(--card-tint, var(--sp-invest)) 45%, #2b3770);
  border-top: 6px solid var(--card-tint, var(--sp-invest)); border-radius: 16px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .35);
}
.card .kind {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; color: #fff;
  background: color-mix(in srgb, var(--card-tint, var(--sp-invest)) 75%, black); text-transform: none; letter-spacing: 0;
}
.card h3 { font-family: Kanit, sans-serif; font-size: 1.3rem; }
button.choice { background: linear-gradient(180deg, #24306a, #1a2352); }
button.choice b { color: var(--gold); }

/* statement & log */
.big-numbers div { background: rgba(255, 255, 255, .05); border: 1px solid #2b3770; }
.progress, .mini-progress { background: #2b3770; }
.badge { background: #2b3770; color: var(--ink); }
.badge.free { background: linear-gradient(180deg, #ffe08a, #f5b72e); color: #3a2400; }
.log div, .lines td, .market-table td, .market-table th, .offer-line, .room-row, .setup-row { border-color: #263166; }
.modal-bg { background: rgba(3, 6, 20, .7); backdrop-filter: blur(4px); }

@media (max-width: 720px) {
  .chip { min-width: 128px; padding: 6px 10px 6px 6px; gap: 8px; }
  .avatar { width: 30px; height: 30px; font-size: .9rem; }
  .board { border-radius: 16px; border-width: 2px; }
  .board::before { inset: 3px; border-radius: 13px; }
  .space { border-radius: 6px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 2px 0 color-mix(in srgb, var(--tile) 45%, black); }
  .token { width: 10px; height: 10px; border-width: 1px; }
  .hub-sub { display: none; }
}

/* ---------- full financial statement ---------- */
.statement .head { align-items: center; }
.modal.statement-sheet { max-width: 980px; width: 100%; max-height: 92dvh; display: flex; flex-direction: column; gap: 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sheet-head h2 { margin: 0; font-size: 1.2rem; }
.sheet-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sheet-summary div { background: rgba(255, 255, 255, .05); border: 1px solid #2b3770; border-radius: 12px; padding: 8px 10px; }
.sheet-summary span { display: block; font-size: .75rem; color: var(--muted); }
.sheet-summary b { font-family: Kanit, sans-serif; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sheet-sec { background: rgba(255, 255, 255, .03); border: 1px solid #2b3770; border-radius: 14px; padding: 10px 12px; border-top: 5px solid var(--sec); }
.sheet-sec h3 { font-family: Kanit, sans-serif; color: var(--sec); margin-bottom: 6px; }
.sheet-sec.income { --sec: #34d399; }
.sheet-sec.expenses { --sec: #fb7185; }
.sheet-sec.assets { --sec: #ffcc4d; }
.sheet-sec.liabilities { --sec: #a78bfa; }
.lines tr.total td { font-weight: 700; border-top: 2px solid #3a4a8c; border-bottom: 0; padding-top: 6px; }
.lines.three td:nth-child(2) { text-align: right; padding-right: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lines tr.th td { font-size: .72rem; color: var(--muted); }
@media (max-width: 720px) {
  .modal-bg { padding: 0; place-items: stretch; }
  .modal.statement-sheet { max-height: 100dvh; height: 100dvh; border-radius: 0; padding: 14px max(14px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
  .sheet-summary { grid-template-columns: 1fr 1fr; }
  .sheet-grid { grid-template-columns: 1fr; }
}

/* ---------- chat ---------- */
.setup + .setup { margin-top: 16px; }
.chat h3 { margin-bottom: 8px; }
.chat-list { max-height: 220px; min-height: 80px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 4px 2px; }
.msg { align-self: flex-start; max-width: 85%; background: #1f2a62; border: 1px solid #2b3770; border-radius: 14px 14px 14px 4px; padding: 6px 10px; font-size: .9rem; overflow-wrap: anywhere; }
.msg b { display: block; font-size: .75rem; }
.msg.mine { align-self: flex-end; background: color-mix(in srgb, var(--brand) 22%, #1f2a62); border-radius: 14px 14px 4px 14px; }
.chat-form { display: flex; gap: 8px; margin-top: 8px; }
.chat-form input { flex: 1; min-width: 0; }

/* dev environment marker */
.env-badge { align-self: center; font-size: .7rem; letter-spacing: .08em; padding: 2px 8px; border-radius: 99px; background: #f43f5e; color: #fff; }

/* ---------- decision previews and market history ---------- */
.preview { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .85rem; margin: 8px 0; padding: 6px 10px; border-radius: 10px; background: rgba(255, 255, 255, .05); border: 1px dashed #36438a; font-variant-numeric: tabular-nums; }
.market-table .range { font-size: .72rem; }
.market-table .trade-hint { font-size: .7rem; margin-top: 3px; white-space: nowrap; }
.spark-cell { line-height: 0; margin-top: 2px; }
.spark { display: inline-block; }
@media (max-width: 720px) {
  .spark-cell { display: none; }
  .market-table .trade-hint { white-space: normal; }
}

/* Selling a drawn deal: the listing banner and the race buttons. */
.sale-box { border: 2px solid var(--gold, #f2a541); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; display: grid; gap: 6px; background: rgba(242, 165, 65, .08); }
.sale-box.done { border-style: dashed; }
.sale-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.sale-clock b { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.sale-claim { border-left: 6px solid var(--pc); }
.sale-claim .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
.sale-form { margin-top: 8px; padding-top: 8px; border-top: 1px dashed rgba(255, 255, 255, .15); display: grid; gap: 4px; }
.sale-form label { display: inline-flex; align-items: center; gap: 6px; }
.sale-buys { margin: 0; padding-left: 18px; font-size: .9rem; }

/* =====================================================================
   Two rings, told apart at a glance (feedback B23), "city and highway" style:
   - outer ring = Investor Avenue, an elevated gold highway: wider lanes, flat sign-like
     tiles with a colour stripe, and the 4 corner dividend days as big landmarks;
   - inner ring = the salary loop, round tiles on a teal city plaza;
   - a dark moat between them.
   ===================================================================== */
.board {
  grid-template-columns: 1.35fr var(--moat) repeat(7, 1fr) var(--moat) 1.35fr;
  grid-template-rows: 1.35fr var(--moat) repeat(7, 1fr) var(--moat) 1.35fr;
  background: linear-gradient(145deg, #4a3510, #2a1d07 55%, #1c1405);
  border-radius: 14px;
}
.board::before { border-radius: 10px; border-color: rgba(255, 204, 77, .6); }
.space { z-index: 1; }

/* highway tiles */
.avenue-space {
  border-radius: 6px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tile) 30%, #3a2a0b), #22180a);
  border: 1.5px solid rgba(255, 204, 77, .55); border-top: 5px solid var(--tile);
  box-shadow: 0 3px 0 #120c03, 0 6px 12px rgba(0, 0, 0, .35); filter: none;
}
.avenue-space .icon { font-size: clamp(.9rem, 2.4vw, 1.7rem); }
.avenue-space .label { color: #ffe9b0; }
.avenue-space.landmark {
  background: radial-gradient(circle at 50% 35%, #fff1b8 0%, #ffcc4d 45%, #d68a12 100%);
  border: 3px solid #fff3c4; border-radius: 12px;
  box-shadow: 0 4px 0 #8a5409, 0 0 22px rgba(255, 204, 77, .6);
}
.avenue-space.landmark .icon { font-size: clamp(1.3rem, 4vw, 2.6rem); }
.avenue-space.landmark .label { color: #4a2c00; text-shadow: none; font-weight: 700; }
.board.avenue-locked .avenue-space { filter: saturate(.55) brightness(.85); }
.board.avenue-locked .avenue-space.landmark { filter: saturate(.75) brightness(.92); }

/* city plaza and round tiles */
.city-plate {
  grid-column: 3 / 10; grid-row: 3 / 10; z-index: 0; pointer-events: none;
  margin: calc(var(--moat) * -.5);
  border-radius: clamp(16px, 4vw, 40px);
  background:
    repeating-linear-gradient(0deg, rgba(94, 234, 212, .07) 0 1px, transparent 1px 22px),
    repeating-linear-gradient(90deg, rgba(94, 234, 212, .07) 0 1px, transparent 1px 22px),
    linear-gradient(160deg, #0f5a5c, #0a3440 55%, #0b2238);
  border: 2px solid var(--brand);
  box-shadow: 0 0 0 clamp(3px, .6vw, 6px) #0b0904, 0 0 26px rgba(45, 212, 191, .4), inset 0 0 30px rgba(0, 0, 0, .4);
}
.city-space {
  place-self: center; width: 92%; height: auto; aspect-ratio: 1; border-radius: 50%; overflow: visible;
  border: 2px solid rgba(255, 255, 255, .75); padding: 2px;
}
.city-space .label { font-size: clamp(.5rem, .9vw, .62rem); max-width: 90%; }
.city-space .tokens { right: -3px; top: -3px; }
.space.city-space.here { outline-offset: 2px; }
.hub { border-color: rgba(45, 212, 191, .4); border-radius: 18px; }

.ring-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 auto 10px; max-width: 920px; }
.ring-tag {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 12px; min-width: 0;
  background: rgba(15, 22, 54, .8); border: 1px solid var(--line);
}
.ring-tag > span:nth-child(2) { display: flex; flex-direction: column; min-width: 0; }
.ring-tag b { font-size: .85rem; line-height: 1.2; }
.ring-tag small { color: var(--muted); font-size: .72rem; line-height: 1.2; }
.ring-tag .swatch { flex: none; width: 22px; height: 22px; }
.ring-tag.city .swatch { border-radius: 50%; background: #0f4f53; border: 3px solid var(--brand); }
.ring-tag.avenue .swatch { border-radius: 4px; background: #3a2a0b; border: 2px solid var(--gold); border-top-width: 5px; }
.ring-tag.city { border-color: rgba(45, 212, 191, .55); }
.ring-tag.avenue { border-color: rgba(255, 204, 77, .6); }
.ring-tag.avenue.locked { opacity: .75; }
.ring-tag .dots { margin-left: auto; display: flex; gap: 3px; flex: none; }
.ring-tag .dots .dot { width: 10px; height: 10px; border: 1px solid #fff; }
.hub-ring {
  font-size: clamp(.6rem, 1.6vw, .85rem); font-weight: 600; padding: 2px 10px; border-radius: 999px;
}
.hub-ring.city { color: #5eead4; background: rgba(45, 212, 191, .15); border: 1px solid rgba(45, 212, 191, .5); }
.hub-ring.avenue { color: var(--gold); background: rgba(255, 204, 77, .12); border: 1px solid rgba(255, 204, 77, .55); }
@media (max-width: 560px) {
  .ring-legend { gap: 6px; }
  .ring-tag { padding: 5px 7px; gap: 6px; }
  .ring-tag b { font-size: .74rem; }
  .ring-tag small { font-size: .64rem; }
  .ring-tag .swatch { width: 14px; height: 14px; border-width: 2px; }
}

/* ---------- in-game guide: how to play, and the lesson behind each space ---------- */
.modal.manual { max-width: 720px; display: flex; flex-direction: column; gap: 12px; }
.manual-tabs button.on { background: linear-gradient(180deg, #ffe08a, #f5b72e); color: #3a2400; }
.manual-goal { font-weight: 600; font-size: 1.02rem; line-height: 1.5; margin: 0; }
.manual-steps li { margin: 8px 0; line-height: 1.5; }
.manual details summary { cursor: pointer; color: var(--muted); }
.ring-head { margin: 8px 0 4px; font-size: .95rem; }
.ring-head.city { color: #5eead4; }
.ring-head.avenue { color: var(--gold); }
.manual-spaces { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px; }
.manual-space { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 12px;
  background: color-mix(in srgb, var(--tile) 14%, #0f1636); border: 1px solid color-mix(in srgb, var(--tile) 45%, transparent); }
.manual-space.city .manual-icon { border-radius: 50%; }
.manual-space.avenue .manual-icon { border-radius: 6px; }
.manual-icon { flex: none; width: 38px; height: 38px; display: grid; place-items: center; font-size: 1.3rem;
  background: color-mix(in srgb, var(--tile) 70%, #0f1636); border: 2px solid rgba(255, 255, 255, .6); }
.manual-space b { display: block; }
.lesson { color: var(--gold); font-size: .85rem; line-height: 1.45; margin: 4px 0 0; }
.center > .lesson { padding: 8px 12px; border-radius: 10px; background: rgba(255, 204, 77, .08); border: 1px dashed rgba(255, 204, 77, .35); }
