:root {
  --ink: #1d1f24;
  --muted: #6b7280;
  --line: rgba(29, 31, 36, 0.08);
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #ffffff;
  --accent: #2f6df6;
  --good: #1f9d5a;
  --bad: #d64545;
  --player: #F0564D;
  --radius: 18px;
  --shadow: 0 12px 34px rgba(20, 24, 40, 0.14), 0 1px 2px rgba(20, 24, 40, 0.08);
  --font: ui-sans-serif, -apple-system, "SF Pro Text", Inter, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: #EFE9DC;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
#scene { position: fixed; inset: 0; }
#scene canvas { display: block; width: 100%; height: 100%; }
#scene::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(60, 50, 30, 0.16) 100%);
}
body.blur #scene canvas { filter: blur(6px) saturate(1.05); transform: scale(1.03); transition: filter .6s, transform .6s; }

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: default; }
.mono { font-variant-numeric: tabular-nums; }

/* ----- HUD ----- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.chip {
  position: absolute; display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 999px;
  background: var(--panel); backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,0.6);
}
.chip.player { top: 18px; left: 18px; padding-right: 18px; }
.chip.brand { top: 18px; right: 18px; gap: 14px; }
.dot { width: 34px; height: 34px; border-radius: 50%; background: var(--player); box-shadow: inset 0 -3px 0 rgba(0,0,0,.18), 0 0 0 3px rgba(255,255,255,.9); flex: none; }
.chip .name { font-weight: 700; font-size: 15px; line-height: 1.1; }
.chip .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.chip .points { margin-left: 8px; padding-left: 14px; border-left: 1px solid var(--line); font-weight: 800; font-size: 20px; letter-spacing: -0.02em; }
.chip .points small { font-weight: 600; font-size: 11px; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.chip .points.bump { animation: bump .5s ease; }
@keyframes bump { 30% { transform: scale(1.12); } }
.wordmark { font-weight: 900; letter-spacing: -0.03em; font-size: 18px; }
.chip.brand .sub { font-size: 12px; }
.link { color: var(--muted); font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 8px; }
.link:hover { background: rgba(0,0,0,.05); color: var(--ink); }

/* ----- dock: die + roll ----- */
.dock {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  padding: 10px 12px 10px 10px; border-radius: 999px;
  background: var(--panel); backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,0.6);
  transition: transform .35s cubic-bezier(.2,.8,.2,1), opacity .35s;
}
.dock.hidden { transform: translate(-50%, 140%); opacity: 0; }
.die {
  width: 56px; height: 56px; border-radius: 14px; background: #fff;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.12);
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); padding: 9px; gap: 2px;
  transition: transform .2s;
}
.die.rolling { animation: tumble .12s linear infinite; }
@keyframes tumble { 0% { transform: rotate(-8deg) scale(1.02); } 50% { transform: rotate(8deg) scale(.98); } 100% { transform: rotate(-8deg) scale(1.02); } }
.die.land { animation: landed .35s cubic-bezier(.2,.8,.2,1); }
@keyframes landed { 0% { transform: scale(1.25) rotate(6deg); } 100% { transform: none; } }
.die i { display: block; border-radius: 50%; background: var(--ink); opacity: 0; }
.die i.on { opacity: 1; }
.roll {
  height: 52px; padding: 0 26px; border-radius: 999px; background: var(--ink); color: #fff;
  font-weight: 800; font-size: 16px; letter-spacing: -0.01em;
  box-shadow: 0 8px 18px rgba(29,31,36,.25);
  transition: transform .15s, opacity .2s, background .2s;
}
.roll:hover:not(:disabled) { transform: translateY(-1px); }
.roll:active:not(:disabled) { transform: translateY(1px); }
.roll:disabled { opacity: .45; box-shadow: none; }
.hint { font-size: 13px; color: var(--muted); max-width: 200px; padding-right: 10px; }

/* ----- lot card ----- */
.card {
  position: absolute; right: 18px; bottom: 24px; width: 340px; max-width: calc(100vw - 36px);
  padding: 18px 18px 16px; border-radius: var(--radius);
  background: var(--panel-solid); box-shadow: var(--shadow);
  transform: translateY(20px); opacity: 0; transition: transform .35s cubic-bezier(.2,.8,.2,1), opacity .3s;
}
.card.show { transform: none; opacity: 1; }
.card[hidden] { display: none; }
.card .head { display: flex; align-items: center; gap: 12px; }
.card .icon { width: 46px; height: 46px; border-radius: 14px; background: #f3f1ea; display: grid; place-items: center; font-size: 24px; flex: none; }
.card h3 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.card .type { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }
.card p { margin: 12px 0 0; font-size: 14px; line-height: 1.45; color: #3d414a; }
.card .facts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.fact { font-size: 12px; font-weight: 600; padding: 5px 9px; border-radius: 8px; background: #f3f1ea; color: #3d414a; }
.fact.owner { background: color-mix(in srgb, var(--player) 14%, white); color: var(--ink); }
.card .actions { display: flex; gap: 8px; margin-top: 16px; }
.card .field { margin-top: 12px; }
.card input {
  width: 100%; font: inherit; font-weight: 600; padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(29,31,36,.14);
  background: #fbfaf7; color: var(--ink); outline: none;
}
.card input:focus { border-color: var(--accent); }
.btn {
  flex: 1; min-height: 44px; padding: 8px 16px; border-radius: 12px; font-weight: 700; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-align: center; line-height: 1.25;
  background: #f0eee7; color: var(--ink); transition: transform .12s, background .2s;
}
.btn:hover:not(:disabled) { background: #e8e5db; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #33363e; }
.btn.accent { background: var(--player); color: #fff; }
.btn.accent:hover:not(:disabled) { filter: brightness(1.06); }
.btn:disabled { opacity: .4; }

/* ----- interior modal ----- */
.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(30, 28, 22, 0.22); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); z-index: 20; opacity: 0; transition: opacity .3s; }
.modal.show { opacity: 1; }
.modal[hidden] { display: none; }
.sheet {
  width: 380px; max-width: calc(100vw - 32px); padding: 26px 24px 22px; border-radius: 24px; background: #fff; box-shadow: var(--shadow);
  text-align: center; transform: translateY(14px) scale(.98); transition: transform .35s cubic-bezier(.2,.8,.2,1);
}
.modal.show .sheet { transform: none; }
.sheet .big { font-size: 56px; line-height: 1; }
.sheet h3 { margin: 12px 0 2px; font-size: 20px; letter-spacing: -0.01em; }
.sheet .type { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.sheet p { font-size: 15px; line-height: 1.5; color: #3d414a; margin: 16px 0 0; }
.delta { display: inline-block; margin-top: 14px; padding: 8px 14px; border-radius: 999px; font-weight: 800; font-size: 18px; letter-spacing: -0.01em; }
.delta.up { background: #e6f6ec; color: var(--good); }
.delta.down { background: #fdeaea; color: var(--bad); }
.delta.zero { background: #f3f1ea; color: var(--muted); }
.sheet .actions { margin-top: 20px; display: flex; gap: 8px; }

/* ----- toasts ----- */
#toasts { position: absolute; top: 84px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 10px 16px; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 700; font-size: 14px;
  box-shadow: var(--shadow); animation: toast 3.2s cubic-bezier(.2,.8,.2,1) forwards; white-space: nowrap;
}
.toast.good { background: var(--good); }
.toast.bad { background: var(--bad); }
@keyframes toast { 0% { opacity: 0; transform: translateY(-8px); } 10%, 82% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-6px); } }

/* ----- start overlay ----- */
.overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: rgba(239, 233, 220, 0.35); transition: opacity .5s; }
.overlay.out { opacity: 0; pointer-events: none; }
.overlay[hidden] { display: none; }
.welcome {
  width: 420px; max-width: 100%; padding: 30px 28px 26px; border-radius: 28px; background: #fff; box-shadow: 0 30px 80px rgba(20,24,40,.22);
}
.welcome .eyebrow { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; }
.welcome h1 { margin: 6px 0 0; font-size: 40px; letter-spacing: -0.04em; line-height: 1; }
.welcome .tag { margin: 10px 0 0; color: #3d414a; font-size: 15px; line-height: 1.5; }
.welcome label { display: block; margin-top: 22px; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.welcome input {
  width: 100%; margin-top: 8px; font: inherit; font-weight: 600; font-size: 16px; padding: 12px 14px; border-radius: 14px; border: 1px solid rgba(29,31,36,.14);
  background: #fbfaf7; color: var(--ink); outline: none;
}
.welcome input:focus { border-color: var(--accent); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.1); transition: transform .15s, box-shadow .15s; }
.swatch.on { transform: scale(1.12); box-shadow: 0 0 0 2px var(--ink); }
.welcome .start { margin-top: 24px; width: 100%; height: 54px; border-radius: 16px; background: var(--ink); color: #fff; font-weight: 800; font-size: 16px; box-shadow: 0 10px 22px rgba(29,31,36,.25); }
.welcome .start:hover { background: #33363e; }
.welcome .continue { margin-top: 10px; width: 100%; height: 46px; border-radius: 14px; background: #f0eee7; font-weight: 700; font-size: 14px; }
.welcome .fine { margin: 14px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; text-align: center; }

@media (max-width: 720px) {
  .chip.player { left: 12px; top: 12px; }
  .chip.brand { right: 12px; top: 12px; }
  .chip.brand .sub, .chip.brand .link { display: none; }
  .hint { display: none; }
  .card { right: 12px; left: 12px; width: auto; bottom: 96px; }
  .dock { bottom: 16px; }
}

/* ----- multiplayer: players panel, inbox, status ----- */
.panel {
  position: absolute; width: 250px; max-width: calc(100vw - 36px); padding: 12px 12px 10px; border-radius: var(--radius);
  background: var(--panel); backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,0.6);
}
.panel[hidden] { display: none; }
.ptitle { font-size: 11px; font-weight: 800; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; padding: 2px 6px 8px; display: flex; justify-content: space-between; align-items: center; }
.ptitle small { font-weight: 600; letter-spacing: 0; text-transform: none; }
.panel.players { top: 78px; right: 18px; }
.players-list { display: flex; flex-direction: column; gap: 2px; max-height: 40vh; overflow: auto; }
.prow { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 8px; border-radius: 10px; text-align: left; font-size: 13px; }
.prow:hover { background: rgba(0,0,0,.05); }
.prow.me { background: rgba(0,0,0,.04); }
.pdot { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px #fff; }
.prow.off .pdot { opacity: .35; }
.prow.off .pname { color: var(--muted); }
.pname { flex: 1; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pname small { font-weight: 600; color: var(--muted); font-size: 11px; margin-left: 4px; }
.ppts { font-weight: 700; color: #3d414a; }
.panel.inbox { top: 78px; left: 18px; width: 300px; flex: none; }
.offer { padding: 10px 8px; border-top: 1px solid var(--line); }
.offer:first-of-type { border-top: 0; }
.otext { font-size: 13px; line-height: 1.4; color: #3d414a; }
.waiting { color: var(--muted); font-weight: 600; font-size: 12px; }
.oacts { display: flex; gap: 6px; margin-top: 8px; }
.oacts .btn { height: 36px; font-size: 13px; }
.status { position: absolute; left: 50%; bottom: 100px; transform: translateX(-50%); padding: 8px 14px; border-radius: 999px; background: var(--bad); color: #fff; font-weight: 700; font-size: 13px; box-shadow: var(--shadow); }
.status[hidden] { display: none; }
.card .row { display: flex; gap: 8px; }
.card .row label { flex: 1; display: block; font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.card .row input, .card .row select { margin-top: 4px; }
.card select { width: 100%; font: inherit; font-weight: 600; padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(29,31,36,.14); background: #fbfaf7; color: var(--ink); }
.card .actions { flex-wrap: wrap; }
.welcome .street { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.welcome .street b { color: var(--ink); }
@media (max-width: 720px) {
  .panel.players { display: none; }
  .panel.inbox { top: auto; bottom: 96px; left: 12px; right: 12px; width: auto; }
}

/* ----- v2: stacks, portfolio, chat, interior sections ----- */
.left-stack { position: absolute; top: 78px; left: 18px; display: flex; flex-direction: column; gap: 10px; width: 300px; max-width: calc(100vw - 36px); max-height: calc(100vh - 268px); }
.right-stack { position: absolute; top: 78px; right: 18px; display: flex; flex-direction: column; gap: 10px; width: 270px; max-width: calc(100vw - 36px); max-height: calc(100vh - 200px); }
.left-stack .panel, .right-stack .panel { position: static; width: auto; }
.panel.players { flex: none; }
.panel.chat { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.panel.chat[hidden] { display: none; }
.chat-log { flex: 1 1 auto; min-height: 120px; max-height: 34vh; overflow: auto; display: flex; flex-direction: column; gap: 6px; padding: 2px 4px 6px; }
.chat-line { font-size: 13px; line-height: 1.35; color: #3d414a; word-break: break-word; }
.chat-line b { font-weight: 800; }
.chat-line .when { color: var(--muted); font-size: 11px; margin-left: 6px; }
.chat-line.me { color: var(--ink); }
.chat-empty { font-size: 12px; color: var(--muted); padding: 6px 4px; }
.chat-form { display: flex; gap: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; font: inherit; font-size: 13px; padding: 9px 10px; border-radius: 10px; border: 1px solid rgba(29,31,36,.14); background: #fff; color: var(--ink); outline: none; }
.chat-form input:focus { border-color: var(--accent); }
.chat-form .btn { flex: none; height: 36px; padding: 0 12px; font-size: 13px; }
.panel.portfolio { flex: 0 1 auto; min-height: 0; overflow: auto; }
.assets { display: flex; flex-direction: column; gap: 8px; }
.asset { padding: 10px 10px 8px; border-radius: 12px; background: #fff; border: 1px solid var(--line); }
.asset .ahead { display: flex; align-items: center; gap: 8px; }
.asset .aicon { font-size: 20px; width: 30px; text-align: center; }
.asset .aname { font-weight: 800; font-size: 13px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset .astake { font-weight: 800; font-size: 13px; color: var(--player); }
.asset .ameta { font-size: 11px; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.asset .ameta b { color: #3d414a; font-weight: 700; }
.asset .actl { display: flex; gap: 6px; align-items: center; margin-top: 8px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.asset .actl input { width: 52px; font: inherit; font-size: 12px; padding: 4px 6px; border-radius: 8px; border: 1px solid rgba(29,31,36,.14); }
.asset .actl .mini { height: 26px; padding: 0 10px; border-radius: 8px; background: #f0eee7; font-weight: 700; font-size: 11px; }
.asset .actl .mini.on { background: var(--player); color: #fff; }
.asset-empty { font-size: 12px; color: var(--muted); padding: 4px 4px 6px; line-height: 1.4; }
.panel .ptitle small { text-transform: none; letter-spacing: 0; font-weight: 600; }
body.no-portfolio #portfolio, body.no-chat #chatPanel { display: none !important; }

/* interior sheet: left-aligned, scrollable, with sections */
.sheet { text-align: left; max-height: min(88vh, 720px); overflow: auto; width: 440px; }
.sheet-head { display: flex; align-items: center; gap: 14px; }
.sheet-head .big { font-size: 44px; line-height: 1; }
.sheet-head h3 { margin: 0; }
.sheet .fee { margin-top: 12px; font-size: 13px; font-weight: 700; color: var(--bad); }
.sheet .fee.free { color: var(--good); }
.sheet .facts { margin-top: 10px; }
.sheet p { margin-top: 12px; }
.sheet .delta { display: inline-block; }
.sheet .delta[hidden] { display: none; }
.sections { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.sec { padding: 12px; border-radius: 14px; background: #f7f5ef; }
.sec .sect { font-size: 11px; font-weight: 800; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
.sec p { margin: 0 0 8px; font-size: 13px; color: #3d414a; line-height: 1.4; }
.sec .row { display: flex; gap: 8px; align-items: flex-end; }
.sec .row label { flex: 1; display: block; font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.sec .row input, .sec .row select { width: 100%; margin-top: 4px; font: inherit; font-weight: 600; padding: 9px 10px; border-radius: 10px; border: 1px solid rgba(29,31,36,.14); background: #fff; color: var(--ink); }
.sec .row .btn { flex: none; height: 40px; }
.sec .muted { font-size: 12px; color: var(--muted); }
.sheet .actions { margin-top: 16px; }

/* build chooser */
.opts { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow: auto; margin-top: 8px; }
.opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 12px; background: #f7f5ef; border: 2px solid transparent; text-align: left; }
.opt:hover:not(:disabled) { background: #f0eee7; }
.opt.on { border-color: var(--player); background: #fff; }
.opt:disabled { opacity: .45; }
.opt .oicon { font-size: 20px; width: 28px; text-align: center; }
.opt .oname { font-weight: 800; font-size: 13px; }
.opt .osub { font-size: 11px; color: var(--muted); }
.opt .ocost { margin-left: auto; font-weight: 800; font-size: 13px; white-space: nowrap; }
.card .field { margin-top: 10px; }
.card .field input { margin-top: 8px; }

@media (max-width: 720px) {
  /* phones: the inbox stays put; portfolio and chat open as sheets from the Assets / Chat buttons */
  .left-stack { top: 66px; left: 12px; right: 12px; width: auto; max-height: 55vh; z-index: 12; }
  .right-stack { display: none; top: 66px; left: 12px; right: 12px; width: auto; max-height: 62vh; z-index: 12; }
  body:not(.no-chat) .right-stack { display: flex; }
  body:not(.no-chat) .panel.players { display: none; }
  body:not(.no-chat) .panel.chat { flex: 1 1 auto; }
  .chat-log { max-height: 36vh; }
  .chip.brand { gap: 8px; padding: 8px 10px; }
  .chip.brand .link { display: inline-block; font-size: 12px; padding: 4px 6px; }
  .chip.brand .wordmark { font-size: 15px; }
  .chip.brand .link.on { background: var(--ink); color: #fff; }
  .sheet { width: 100%; }
}
@media (max-width: 480px) {
  #inviteBtn, #switchBtn { display: none; }
}
.chip.brand .link.on { background: rgba(0,0,0,.08); color: var(--ink); }

/* roll budget */
.hint { display: flex; flex-direction: column; gap: 2px; }
.rolls { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.rolls[hidden] { display: none; }

/* police warning */
.police { font-size: 12px; font-weight: 800; color: var(--bad); }
.police[hidden] { display: none; }
.police.soon { animation: blink .6s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

/* ----- polish: pill spacing everywhere, hover states that get stronger rather than greyer ----- */
.facts { display: flex; gap: 8px; flex-wrap: wrap; }
.sheet .facts { margin-top: 10px; }
.sec .facts { margin-top: 4px; }
.fact { line-height: 1.2; }
.btn:hover:not(:disabled) { background: #f0eee7; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(20, 24, 40, 0.12); }
.btn.primary:hover:not(:disabled) { background: var(--ink); }
.btn.accent:hover:not(:disabled) { filter: brightness(1.04); }
.btn:active:not(:disabled) { transform: translateY(0); box-shadow: none; }
.welcome .start:hover { background: var(--ink); transform: translateY(-1px); box-shadow: 0 12px 26px rgba(29, 31, 36, 0.28); }
.roll:hover:not(:disabled) { background: var(--ink); box-shadow: 0 10px 22px rgba(29, 31, 36, 0.3); }
.link:hover { background: rgba(0, 0, 0, 0.06); color: var(--ink); }
.opt:hover:not(:disabled) { background: #fff; border-color: rgba(29, 31, 36, 0.12); }
.mini:hover { filter: brightness(0.97); }
.oacts .btn:hover:not(:disabled) { transform: none; }

/* device linking */
.welcome .tiny { display: inline-block; margin-top: 8px; padding: 2px 0; font-size: 12px; font-weight: 700; color: var(--accent); }
.welcome .coderow { display: flex; gap: 8px; margin-top: 8px; }
.welcome .coderow input { margin-top: 0; flex: 1; font-size: 18px; letter-spacing: .15em; }
.welcome .coderow .btn { flex: none; height: 48px; }
.welcome .coderow[hidden] { display: none; }

/* small dialog (link codes, notices) */
.modal.small { z-index: 40; }
.modal.small .sheet { width: 380px; }
.code { margin-top: 14px; padding: 14px; border-radius: 14px; background: #f7f5ef; text-align: center; font-size: 34px; font-weight: 900; letter-spacing: .25em; }
.code[hidden] { display: none; }

/* city rows */
.srow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.srow:first-child { border-top: 0; }
.srow .muted { font-size: 12px; color: var(--muted); margin-top: 2px; }
.srow .btn { flex: none; height: 36px; padding: 0 14px; }
.srow small { color: var(--muted); font-weight: 600; }

.asset.bank { background: #f3f6fb; border-color: rgba(47,109,246,.18); }
.asset .actl input#bankAmt, .asset .actl input#repayAmt { width: 72px; }

/* hover: coloured buttons keep their colour and white text; only the plain beige button stays beige */
.btn.accent:hover:not(:disabled) { background: var(--player); color: #fff; filter: brightness(1.06); }
.btn.primary:hover:not(:disabled) { background: var(--ink); color: #fff; }
.oacts .btn.accent:hover:not(:disabled) { background: var(--player); color: #fff; }
.mini.on:hover { background: var(--player); color: #fff; filter: brightness(1.06); }

/* welcome pitch */
.pitch { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pitch li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.4; color: #3d414a; }
.pitch li span { font-size: 18px; line-height: 1.2; flex: none; width: 24px; text-align: center; }

/* coach tips: one floating card above the dock, and inline notes inside cards and sheets */
.coach {
  position: absolute; left: 50%; bottom: 112px; transform: translateX(-50%); width: 360px; max-width: calc(100vw - 32px);
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 14px 12px; border-radius: 16px;
  background: #fff8e1; border: 1px solid #f1d98a; box-shadow: var(--shadow); z-index: 15;
  animation: coachIn .35s cubic-bezier(.2,.8,.2,1);
}
.coach[hidden] { display: none; }
.coach::after { content: ""; position: absolute; left: 50%; bottom: -8px; width: 14px; height: 14px; background: #fff8e1; border-right: 1px solid #f1d98a; border-bottom: 1px solid #f1d98a; transform: translateX(-50%) rotate(45deg); }
@keyframes coachIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.coach-icon { font-size: 22px; line-height: 1; flex: none; }
.coach-body { flex: 1; min-width: 0; }
.coach-body b { display: block; font-size: 14px; }
.coach-body p { margin: 3px 0 0; font-size: 13px; line-height: 1.4; color: #4a4633; }
.coach-ok { flex: none; align-self: center; height: 32px; padding: 0 12px; border-radius: 10px; background: var(--ink); color: #fff; font-weight: 700; font-size: 12px; }
.coach-inline { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: #fff8e1; border: 1px solid #f1d98a; margin: 10px 0 4px; font-size: 13px; line-height: 1.4; color: #4a4633; }
.coach-inline .ci { font-size: 18px; line-height: 1; flex: none; }
.coach-inline b { display: block; color: var(--ink); }
.coach-inline button { margin-left: auto; align-self: center; flex: none; height: 28px; padding: 0 10px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 700; }
.guide { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.guide .g { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: #f7f5ef; font-size: 13px; line-height: 1.4; color: #3d414a; }
.guide .g span { font-size: 20px; line-height: 1; flex: none; }
.guide .g b { display: block; color: var(--ink); }
.more { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.more:hover { color: var(--ink); }
.sec.hidden { display: none; }

/* welcome: nothing of the game shows through until you have joined */
body.blur #hud { display: none; }
.overlay { overflow: auto; align-content: center; }
.welcome { max-height: none; }
.welcome .fine { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 8px; align-items: baseline; }
.welcome .fine .tiny { margin-top: 0; }
.menu-only { display: none; }
@media (max-width: 720px) {
  .overlay { padding: 12px; align-items: start; }
  .welcome { padding: 22px 20px 18px; border-radius: 22px; }
  .welcome h1 { font-size: 32px; }
  .welcome .eyebrow { font-size: 11px; }
  .pitch li { font-size: 13px; }
  .welcome label { margin-top: 14px; }
  .welcome .start { margin-top: 16px; height: 50px; }
  .swatch { width: 34px; height: 34px; }
  /* top bar: only Assets, Chat and a menu on phones */
  .chip.brand { gap: 6px; padding: 8px 10px; max-width: calc(100vw - 24px); }
  .chip.brand .wordmark { font-size: 14px; }
  .chip.brand #howBtn, .chip.brand #cityBtn, .chip.brand #inviteBtn, .chip.brand #linkBtn, .chip.brand #switchBtn, .chip.brand #mapBtn { display: none; }
  .menu-only { display: inline-block; font-size: 16px; line-height: 1; padding: 2px 8px; }
  .dock { max-width: calc(100vw - 24px); }
  .dock .hint { display: flex; }
  .dock #hint { display: none; }
}
.menu-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.menu-list .btn { height: 44px; justify-content: flex-start; text-align: left; }
@media (max-width: 720px) {
  /* two rows on phones: the player chip, then the bar; panels start below both */
  .chip.player { top: 12px; left: 12px; max-width: calc(100vw - 24px); }
  .chip.brand { top: 76px; right: 12px; }
  .left-stack, .right-stack { top: 128px; }
  .left-stack { max-height: calc(100vh - 230px); }
  .coach { bottom: 104px; }
}

/* chat and players: hard bounds so the input row never spills out of the panel */
.right-stack { min-height: 0; }
.panel.players { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; }
.players-list { max-height: 26vh; }
.panel.chat { overflow: hidden; flex: 1 1 260px; min-height: 200px; }
.chat-log { min-height: 60px; max-height: none; flex: 1 1 auto; }
.chat-form { flex: none; }
.chat-form input { width: 0; }
.chat-line { overflow-wrap: anywhere; }
@media (max-width: 720px) {
  body:not(.no-chat) .right-stack { max-height: 62vh; }
  .panel.chat { min-height: 180px; }
}

/* city peeks */
.peek { padding: 12px; border-radius: 14px; background: #f7f5ef; margin-top: 8px; font-size: 13px; }
.peek.here { background: #eef3ff; }
.peek-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 15px; }
.peek-head b { font-size: 15px; }
.peek .muted { color: var(--muted); font-size: 12px; margin-top: 2px; }
.peek-grid { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; color: #3d414a; line-height: 1.4; }

/* the orin symbol */
.chip .points small.sym { margin: 0 2px 0 0; font-size: 15px; font-weight: 800; color: var(--muted); }

/* dialog body: paragraphs and boxes with consistent spacing */
.dlg-text { margin-top: 12px; font-size: 15px; line-height: 1.5; color: #3d414a; }
.dlg-text .sec, .dlg-text .peek, .dlg-text .guide, .dlg-text .menu-list { margin-top: 10px; }
.dlg-text .peek + .peek, .dlg-text .sec + .sec { margin-top: 10px; }
.dlg-text .sec p:last-child { margin-bottom: 0; }
.dlg-text .row { margin-top: 10px; }

/* ----- bird's-eye view ----- */
#pins { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#pins[hidden] { display: none; }
.pin {
  position: absolute; transform: translate(-50%, -100%); pointer-events: auto; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; max-width: 170px;
}
.pin .tag {
  padding: 4px 8px; border-radius: 9px; background: rgba(255,255,255,.95); border: 1px solid rgba(29,31,36,.1);
  box-shadow: 0 3px 10px rgba(20,24,40,.14); font-size: 11px; font-weight: 800; color: var(--ink); white-space: nowrap; line-height: 1.2;
}
.pin .tag.sale { background: #fff4d6; border-color: #f1d98a; }
.pin .tag.shares { background: #e6f6ec; border-color: #b7e2c7; }
.pin .tag.jv { background: #eef3ff; border-color: #bfd0ff; }
.pin .tag.gap { background: #ffe9e6; border-color: #f5b3ab; animation: pulse 1.4s ease-in-out infinite; }
.pin .tag.earn { background: #fff; }
.pin .tag.city { background: rgba(255,255,255,.75); color: var(--muted); font-weight: 700; }
.pin .tag.player { padding-left: 6px; }
.pin .tag.player i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.pin .stem { width: 2px; height: 10px; background: rgba(29,31,36,.35); border-radius: 1px; }
.pin.dim { opacity: .55; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.overview-bar {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 999px; background: var(--panel); backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,.6); max-width: calc(100vw - 24px); z-index: 14;
}
.overview-bar[hidden] { display: none; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chip-f { padding: 7px 10px; border-radius: 999px; background: #f0eee7; font-size: 12px; font-weight: 700; color: var(--muted); }
.chip-f.on { background: var(--ink); color: #fff; }
.overview-bar .btn { flex: none; height: 40px; padding: 0 16px; }
body.overview .dock, body.overview .left-stack, body.overview .right-stack, body.overview .coach { display: none !important; }
.panel.opps { position: absolute; top: 78px; left: 18px; width: 320px; max-width: calc(100vw - 36px); max-height: calc(100vh - 200px); overflow: auto; z-index: 13; }
.panel.opps[hidden] { display: none; }
.opps-list { display: flex; flex-direction: column; gap: 8px; }
.opp { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 12px; background: #fff; border: 1px solid var(--line); text-align: left; width: 100%; }
.opp:hover { border-color: rgba(29,31,36,.25); }
.opp .oi { font-size: 20px; line-height: 1; flex: none; width: 26px; text-align: center; }
.opp .ot { font-weight: 800; font-size: 13px; }
.opp .od { font-size: 12px; color: #3d414a; margin-top: 2px; line-height: 1.35; }
.opp .om { font-size: 11px; color: var(--muted); margin-top: 3px; }
.opp.gap { background: #fff7f5; border-color: #f5b3ab; }
.inspect .facts { margin-top: 8px; }
@media (max-width: 720px) {
  .panel.opps { top: auto; bottom: 92px; left: 12px; right: 12px; width: auto; max-height: 38vh; }
  .overview-bar { bottom: 12px; padding: 8px 10px; flex-direction: column; gap: 8px; }
  .overview-bar .btn { height: 36px; width: 100%; }
  .chip-f { font-size: 11px; padding: 6px 8px; }
  .pin .tag { font-size: 10px; padding: 3px 6px; }
}

/* map controls */
.ov-actions { display: flex; gap: 8px; }
.ov-actions .btn { flex: none; }
#scene { touch-action: none; }
body.overview #scene { cursor: grab; }
@media (max-width: 720px) {
  .overview-bar { left: 12px; right: 12px; transform: none; max-width: none; border-radius: 18px; padding: 8px; gap: 8px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; width: 100%; padding-bottom: 2px; scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .chip-f { flex: none; }
  .ov-actions { width: 100%; }
  .ov-actions .btn { flex: 1; height: 40px; }
  .ov-actions .menu-only { display: inline-flex; }
  body.overview .panel.opps { display: none; bottom: 128px; max-height: 44vh; }
  body.overview.opps-open .panel.opps { display: block; }
  .pin .tag { font-size: 10px; padding: 3px 6px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
}

/* map focus: the hovered plot lights up, the rest steps back, a preview card sits beside it */
body.overview .chip.brand { display: none !important; }
#pins.focus .pin:not(.hot):not(.is-player) { opacity: .35; }
.pin.hot { z-index: 5; }
.pin.hot .tag { transform: scale(1.18); border-color: var(--player); box-shadow: 0 0 0 3px rgba(255,209,102,.55), 0 8px 20px rgba(20,24,40,.25); }
.peek-card {
  position: absolute; width: 300px; max-width: calc(100vw - 32px); padding: 14px; border-radius: 16px; background: #fff;
  box-shadow: 0 16px 40px rgba(20,24,40,.22); border: 1px solid rgba(29,31,36,.08); z-index: 16; pointer-events: auto;
  animation: peekIn .18s ease;   /* its own entrance: coachIn shifts left by half a width, which put the card under the pointer */
}
@keyframes peekIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.peek-card[hidden] { display: none; }
.pk-head { display: flex; gap: 10px; align-items: center; }
.pk-icon { font-size: 28px; line-height: 1; }
.pk-head b { font-size: 15px; }
.pk-type { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-top: 1px; }
.pk-lines { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #3d414a; line-height: 1.4; }
.pk-lines b { color: var(--ink); }
.pk-actions { display: flex; gap: 8px; margin-top: 12px; }
.pk-actions .btn { height: 38px; font-size: 13px; }
.opp.hot { border-color: var(--player); box-shadow: 0 0 0 2px rgba(255,209,102,.5); }
@media (max-width: 720px) { .peek-card { left: 12px !important; right: 12px; width: auto; top: auto !important; bottom: 128px; } }

/* the minimap tile: a live plan of the street, and the door to the bird's-eye view (same width as the side panels) */
#mapBtn { display: none !important; }
.minimap {
  position: absolute; left: 18px; bottom: 24px; width: 300px; max-width: calc(100vw - 36px); display: flex; flex-direction: column; gap: 6px; align-items: stretch;
  padding: 10px 12px 12px; border-radius: var(--radius); background: rgba(255,255,255,.96); text-align: left;
  box-shadow: 0 16px 36px rgba(20,24,40,.22), 0 1px 3px rgba(20,24,40,.1); border: 1px solid rgba(29,31,36,.12); cursor: pointer; transition: transform .15s, box-shadow .15s; z-index: 12;
}
.minimap:hover { transform: translateY(-2px); box-shadow: 0 20px 44px rgba(20,24,40,.28), 0 1px 3px rgba(20,24,40,.1); }
.mm-head { display: flex; justify-content: space-between; align-items: center; font-size: 11px; font-weight: 800; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; padding: 0 2px; }
.mm-cta { color: var(--ink); letter-spacing: 0; text-transform: none; font-size: 12px; font-weight: 700; }
.minimap:hover .mm-cta { text-decoration: underline; }
.minimap canvas { display: block; width: 100%; height: auto; aspect-ratio: 552 / 200; border-radius: 10px; background: #D8D0BC; border: 1px solid rgba(29,31,36,.1); }
body.overview .minimap { display: none; }
@media (max-width: 900px) {
  .minimap { left: auto; right: 12px; bottom: 96px; width: 176px; padding: 6px 8px 8px; gap: 4px; border-radius: 14px; }
  .mm-head { font-size: 9px; }
  .mm-cta { font-size: 9px; }
}

/* welcome: usernames and the free-colour palette */
.welcome label small { font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--muted); margin-left: 6px; }
.field-error { margin-top: 8px; font-size: 12px; font-weight: 700; color: var(--bad); line-height: 1.4; }
.field-error[hidden] { display: none; }
@media (max-width: 720px) { #rollsLeft { white-space: nowrap; } }

/* the mark */
.brandmark { width: 18px; height: 18px; border-radius: 5px; vertical-align: -4px; margin-right: 7px; }
.welcome .mark { display: block; width: 56px; height: 56px; border-radius: 14px; box-shadow: 0 6px 16px rgba(20,24,40,.18); margin-bottom: 12px; }
