:root {
  color-scheme: dark;
  --base: #0c1512;
  --panel: #14211b;
  --stroke: #2b3a30;
  --paper: #f1ebd9;
  --muted: #a0aa94;
  --dim: #788976;
  --gold: #e6bd75;
  --gold-ink: #281e10;
  --red: #ee937f;
  --blue: #86b9ef;
  --green: #9dca8a;
  --sans: "Inter", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  --serif: "Instrument Serif", "Songti SC", "SimSun", "Noto Serif CJK SC", Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 300px; min-height: 100vh; background: var(--base); color: var(--paper); font: 14px/1.5 var(--sans); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
button:disabled { cursor: default; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.backdrop { position: absolute; z-index: -1; inset: 58px 0 auto; width: 100%; height: 770px; opacity: .7; pointer-events: none; mask-image: linear-gradient(black 35%, transparent); }
body { isolation: isolate; }
.topbar { border-bottom: 1px solid #29362c; background: #0e1914; }
.topbar-inner, .shell, .footer { width: min(1216px, calc(100% - 80px)); margin-inline: auto; }
.topbar-inner { height: 69px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 13px; font-weight: 750; font-size: 17px; letter-spacing: .075em; }
.brand small { display: block; margin-top: 1px; font-size: 8px; letter-spacing: .165em; font-weight: 650; color: var(--muted); }
.brand-mark { width: 33px; height: 33px; display: grid; place-items: center; border: 1px solid #7b6944; border-radius: 9px; background: #2b2920; }
.brand-mark i, .tiny-diamond { position: relative; display: inline-block; width: 12px; height: 12px; rotate: 45deg; border: 1px solid var(--gold); }
.brand-mark i::after { content: ""; position: absolute; inset: 3px; background: var(--gold); }
.topbar nav { display: flex; align-items: center; gap: 23px; }
.text-button, .outline, .primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 7px; white-space: nowrap; }
.text-button { background: none; border: 0; color: #b8c0ac; padding: 6px 0; }
.text-button:hover { color: var(--gold); }
.outline { background: #19261e; border: 1px solid #3a4939; color: var(--paper); min-height: 36px; padding: 7px 12px; }
.outline:hover { background: #243326; border-color: #687b57; }
.icon { display: inline-block; position: relative; width: 13px; height: 13px; flex: 0 0 auto; }
.book { border: 1px solid currentColor; border-radius: 2px; }
.book::after { content: ""; position: absolute; left: 50%; height: 100%; border-left: 1px solid currentColor; }
.shield { background: var(--gold); clip-path: polygon(50% 0, 95% 17%, 88% 60%, 71% 83%, 50% 100%, 29% 83%, 12% 60%, 5% 17%); }
.shield::after { content: ""; position: absolute; inset: 1px 2px 2px; background: #19261e; clip-path: inherit; }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 22px; padding: 35px 0 23px; }
.eyebrow { display: flex; gap: 10px; align-items: center; color: var(--gold); font-weight: 650; font-size: 12px; letter-spacing: .18em; }
.tiny-diamond { width: 6px; height: 6px; background: var(--gold); }
.hero h1 { font-family: var(--serif); font-size: clamp(40px, 5.25vw, 72px); font-weight: 700; margin: 7px 0 5px; line-height: 1.14; letter-spacing: .09em; overflow-wrap: anywhere; }
.hero p { color: #aeb9a2; font-size: 14px; letter-spacing: .035em; }
.hero-signal, .map-scale, .count, .tag { white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; border: 1px solid #354534; border-radius: 999px; padding: 4px 9px; font-size: 11px; color: #a5b498; line-height: 1.4; }
.hero-signal { margin-bottom: 2px; background: #18271d; padding: 6px 11px; }
.hero-signal span, .status-dot { flex: 0 0 auto; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #a3c18e; box-shadow: 0 0 7px #a6c08b4c; }
.hero-signal.offline span { background: var(--gold); }
.layout { display: grid; grid-template-columns: minmax(0, 1.88fr) minmax(0, 1fr); gap: 21px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--stroke); border-radius: 14px; box-shadow: 0 12px 30px #050d0a24; min-width: 0; }
.panel-heading { min-height: 72px; padding: 13px 21px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.heading-content { display: flex; align-items: center; gap: 12px; }
.heading-content h2, .side-heading h2, .create-panel h2, .report h2 { font-size: 18px; font-weight: 720; letter-spacing: .05em; }
.heading-content p { color: var(--dim); margin-top: 2px; font: 11px/1.2 var(--sans); letter-spacing: .06em; }
.map-icon { display: grid; align-content: center; justify-content: center; gap: 3px; width: 37px; height: 37px; border-radius: 8px; background: #283329; border: 1px solid #3b4834; }
.map-icon i { width: 15px; height: 3px; border: solid #bfaa72; border-width: 1px 0 0; transform: skewY(-14deg); }
.map-scale i { width: 5px; height: 5px; background: #c7a966; rotate: 45deg; }

.cartography { position: relative; overflow: hidden; display: grid; place-items: center; border-block: 1px solid #303e31; padding: 24px 24px 16px 40px; background: radial-gradient(ellipse at 52% 46%, #283c2a 0%, #1b2b21 57%, #16221b 100%); }
.board-workspace { width: min(100%, 510px); display: grid; grid-template: 15px auto / 17px minmax(0, 1fr); gap: 4px; }
.axis { color: #b3b8a0; font: 11px/1 ui-monospace, Consolas, monospace; user-select: none; text-align: center; }
.columns { display: grid; grid-template-columns: repeat(9, 1fr); grid-column: 2; align-items: start; }
.rows { display: grid; grid-template-rows: repeat(9, 1fr); grid-row: 2; place-items: center start; padding-left: 3px; }
.board-frame { position: relative; grid-area: 2 / 2; width: 100%; aspect-ratio: 1; border: 1px solid #697653; background: #253b2b; box-shadow: 0 0 0 5px #0c19125c, 0 8px 26px #0b1810a3; }
.terrain, .board { position: absolute; inset: 0; width: 100%; height: 100%; }
.board { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); grid-template-rows: repeat(9, minmax(0, 1fr)); }
.cell { position: relative; display: grid; place-items: center; margin: 0; padding: 0; border: solid #b4bc8645; border-width: 0 1px 1px 0; background: #0b261c0c; color: var(--gold); min-width: 0; min-height: 0; }
.cell:nth-child(9n) { border-right: 0; }
.cell:nth-child(n+73) { border-bottom: 0; }
.cell.blocked { background: repeating-linear-gradient(135deg, #0b1713a1 0 3px, #16221db5 3px 6px); }
.cell.point { background: #d0aa6924; box-shadow: inset 0 0 0 1px #d5b67642; }
.cell .letter, .legend-point { width: 51%; aspect-ratio: 1; max-width: 30px; display: grid; place-items: center; border: 1px solid #ccae6f88; border-radius: 5px; background: #414533; color: #f0c984; font-family: Georgia, serif; font-weight: 700; font-size: clamp(11px, 1.65vw, 18px); line-height: 1; }
.cell:not(:disabled):hover { background-color: #bde69c32; box-shadow: inset 0 0 0 1px #dfd897; }
.cell:not(:disabled) { background-color: #f0ce772e; }
.cell.selected { box-shadow: inset 0 0 0 2px var(--gold); background: #f0ce7747; }
.cell:focus-visible { outline-offset: -3px; z-index: 1; }
.red { --seat: var(--red); } .blue { --seat: var(--blue); } .green { --seat: var(--green); } .neutral { --seat: #c7c8a5; }
.cross { width: 17px; height: 17px; display: inline-grid; place-items: center; position: relative; color: var(--seat, var(--gold)); }
.cross::before, .cross::after { position: absolute; content: ""; width: 2px; height: 86%; border-radius: 1px; background: currentColor; rotate: 45deg; }
.cross::after { rotate: -45deg; }
.cross.fixed { color: #8a9785; }
.cross.dashed::before, .cross.dashed::after { width: 2px; border-radius: 0; background: repeating-linear-gradient(currentColor 0 3px, transparent 3px 5px); }
.cell .cross { width: 44%; height: 44%; max-width: 26px; max-height: 26px; }
.compass { position: absolute; top: 19px; right: 23px; display: grid; justify-items: center; gap: 1px; color: #c9b486; font: 10px Georgia, serif; }
.compass i { width: 17px; height: 26px; clip-path: polygon(50% 0, 100% 100%, 50% 76%, 0 100%); background: linear-gradient(90deg, #b49d69 50%, #625a3f 50%); }
.legend { min-height: 49px; padding: 9px 19px; display: flex; justify-content: center; align-items: center; column-gap: clamp(12px, 2.4vw, 32px); row-gap: 6px; flex-wrap: wrap; color: #aeb7a4; font-size: 12px; }
.legend > span { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.legend-point { width: 16px; height: 16px; border-radius: 3px; font-size: 11px; }
.board-badges { bottom: 1px; right: 2px; position: absolute; display: flex; gap: 1px; z-index: 1; }
.board-badges > b, .pawns > b { display: grid; place-items: center; background: var(--seat); color: #142019; box-shadow: 0 0 0 1px #16251b; border-radius: 50%; line-height: 1; font-size: 9px; font-weight: 900; width: 13px; height: 13px; }
.pawns { position: absolute; display: flex; align-items: center; justify-content: center; gap: 2px; inset: 0; z-index: 2; pointer-events: none; }
.pawns > b { width: clamp(12px, 2vw, 24px); height: auto; aspect-ratio: 1; font-size: clamp(8px, 1vw, 12px); }
.pawns:has(b:nth-child(2)) > b { max-width: 31%; }

.sidebar { display: grid; gap: 15px; }
.lobby, .side-card, .create-panel { padding: 19px; }
.side-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.count { background: #1e2d22; }
.muted { color: var(--muted); font-size: 13px; }
.seat-list { display: grid; gap: 9px; margin-top: 15px; }
.seat { display: flex; align-items: center; gap: 12px; text-align: left; padding: 9px 11px; width: 100%; min-height: 58px; background: #19281f; border: 1px solid #304132; border-radius: 8px; color: var(--paper); }
button.seat:hover { background: #223326; border-color: #53674d; }
.seat.current { border-color: #a18755; background: #2d3424; }
.seat-icon { display: grid; place-items: center; width: 35px; height: 35px; flex: 0 0 auto; color: var(--seat); background: color-mix(in srgb, var(--seat) 12%, #19241d); border-radius: 7px; border: 1px solid color-mix(in srgb, var(--seat) 28%, #26372a); }
.seat-icon i { width: 10px; height: 10px; border: 1px solid currentColor; border-radius: 2px; rotate: 45deg; }
.seat-copy { display: grid; min-width: 0; flex: 1; gap: 2px; }
.seat-copy strong { font-size: 13px; overflow-wrap: anywhere; }
.seat-copy small { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.chevron { color: #92a187; font-size: 23px; line-height: 1; padding-inline: 4px; }
.status-dot.inactive { background: #667163; box-shadow: none; }
.create-panel { position: relative; overflow: hidden; background: radial-gradient(ellipse at 100% 6%, #343821, transparent 70%), #1a271e; border-color: #455141; }
.create-copy { position: relative; z-index: 1; }
.create-panel p { margin: 5px 0 14px; }
.create-illustration { position: absolute; width: 122px; height: 122px; right: -14px; top: -32px; rotate: 24deg; opacity: .45; pointer-events: none; }
.create-illustration i { position: absolute; inset: 6px; border: 1px solid #a8aa6b66; border-radius: 50%; }
.create-illustration i:nth-child(2) { inset: 17px; border-style: dashed; }
.create-illustration b { position: absolute; inset: 23px 39px; background: linear-gradient(90deg, #a9975f 50%, #766a40 50%); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.primary { min-height: 41px; width: 100%; padding: 8px 14px; border: 1px solid #f3cc89; background: linear-gradient(100deg, #eec983, #dcb471); color: var(--gold-ink); font-weight: 750; }
.primary:hover { background: #f5d89f; }
.primary:disabled { opacity: .45; }
.plus { display: grid; place-items: center; width: 13px; height: 13px; }
.plus::before, .plus::after { content: ""; grid-area: 1 / 1; width: 11px; height: 1.5px; background: currentColor; }
.plus::after { width: 1.5px; height: 11px; }
#saved-host:empty { display: none; }
#saved-host a { display: inline-block; color: var(--gold); margin-top: 11px; font-size: 12px; }
.side-card > .muted { margin-bottom: 13px; }
.side-card form, .step-picker, .color-options, .invite-list { display: grid; gap: 9px; }
label.field { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input[type=text], input[type=url] { width: 100%; min-width: 0; padding: 9px 10px; background: #101b15; color: var(--paper); border: 1px solid #43503d; border-radius: 7px; }
.color-options { grid-template-columns: repeat(3, 1fr); }
.color-options button { color: var(--seat); padding-inline: 3px; min-width: 0; }
.color-options button[aria-pressed=true], .step-picker button[aria-pressed=true] { border-color: var(--gold); background: #353923; }
.color-options button:disabled { opacity: .35; }
.step-picker { grid-template-columns: repeat(2, 1fr); margin: 11px 0 13px; }
.step-picker b { color: var(--gold); }
.invite-list { margin: 12px 0; }
.invite { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 7px; }
.invite > strong { overflow-wrap: anywhere; font-size: 13px; }
.invite a, .invite button { font-size: 12px; min-height: 32px; }
.side-card .host-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.side-card .turn-detail { margin-bottom: 12px; color: var(--gold); font-weight: 650; }
.result-items { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 8px; }
.result-items li { display: grid; grid-template-columns: 31px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 8px; border: 1px solid #344234; border-radius: 7px; }
.place { color: var(--gold); font-family: Georgia, serif; text-align: center; font-size: 23px; }

.reports { display: grid; grid-template-columns: 1fr 1fr; gap: 21px; margin-top: 18px; }
.report { padding: 17px 19px; }
.report h2 { margin-bottom: 8px; }
.entries { list-style: none; padding: 0; margin: 0; max-height: 280px; overflow: auto; }
.entries li { display: grid; grid-template-columns: 61px minmax(0, 1fr); gap: 6px; padding: 8px 0; border-bottom: 1px solid #2b3a2f; }
.entries li:last-child { border-bottom: 0; }
.entries time { color: var(--dim); font: 11px/1.9 ui-monospace, Consolas, monospace; }
.entries small { display: block; color: var(--gold); }
.player-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
.player-table td, .player-table th { padding: 9px 5px; border-bottom: 1px solid #2b3a2f; }
.player-table th { color: var(--muted); font-weight: 500; }
.table-scroll { overflow-x: auto; }
.footer { display: flex; justify-content: space-between; align-items: center; min-height: 58px; color: var(--dim); font-size: 11px; }
.footer > span { display: inline-flex; align-items: center; gap: 8px; }
.footer .tiny-diamond { opacity: .65; }
.toast { position: fixed; z-index: 5; bottom: 22px; left: 50%; max-width: min(90vw, 440px); translate: -50% 0; padding: 10px 16px; color: var(--paper); border: 1px solid #7e704a; border-radius: 8px; background: #263127; box-shadow: 0 8px 28px #050e09aa; }
.error { color: #ffaf9f; margin-top: 8px; }
dialog { width: min(92vw, 490px); padding: 0; color: var(--paper); background: #1a281f; border: 1px solid #526249; border-radius: 12px; box-shadow: 0 20px 80px #0009; }
dialog::backdrop { background: #080e0bc4; }
.dialog-inner { padding: 20px; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.dialog-header h2 { font-size: 20px; }
.dialog-header .close { padding: 0; width: 32px; min-height: 32px; font-size: 21px; }
.dialog-inner form { display: grid; gap: 12px; }
.dialog-inner ol { display: grid; gap: 9px; padding-left: 24px; margin: 0; }
.rules-note { color: var(--muted); margin-top: 14px; font-size: 12px; }

@media (max-width: 1120px) { .compass { right: 14px; top: 12px; } }
@media (max-width: 980px) {
  .topbar-inner, .shell, .footer { width: calc(100% - 48px); }
  .layout { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 14px; }
  .compass { display: none; }
  .cartography { padding: 18px 16px 14px 11px; }
}
@media (max-width: 700px) {
  .topbar-inner, .shell, .footer { width: calc(100% - 28px); }
  .topbar-inner { height: 58px; }
  .topbar nav { gap: 11px; }
  .topbar nav button { font-size: 11px; }
  .topbar nav .outline { min-height: 32px; padding-inline: 6px; }
  .brand { gap: 7px; font-size: 14px; }
  .brand small { font-size: 6px; }
  .brand-mark { width: 27px; height: 27px; }
  .topbar .icon { display: none; }
  .hero { padding: 22px 0 14px; }
  .hero p { font-size: 12px; }
  .hero h1 { letter-spacing: .055em; }
  .hero-signal { display: none; }
  .layout, .reports { grid-template-columns: 1fr; gap: 12px; }
  .panel-heading { min-height: 54px; padding: 8px 12px; }
  .map-icon { width: 31px; height: 31px; }
  .cartography { padding: 12px 13px 11px 5px; }
  .legend { min-height: 39px; padding: 5px 8px; font-size: 10px; }
  .legend > span { gap: 4px; }
  .lobby, .side-card, .create-panel { padding: 14px; }
  body[data-room-stage=setup] .sidebar, body[data-room-stage=ready] .sidebar, body[data-room-stage=locked] .sidebar { grid-row: 1; }
}
@media (prefers-reduced-motion: no-preference) {
  button, a { transition: background-color .14s, color .14s, border-color .14s; }
}
