:root {
  color-scheme: dark;
  --bg: #1b1720;
  --panel: #30242a;
  --line: #725747;
  --ink: #f9ecd5;
  --muted: #c9b4a2;
  --gold: #efc386;
  --mint: #afd1a0;
  --serif: "Songti SC", "Noto Serif CJK SC", "STSong", "SimSun", Georgia, serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;
  font: 14px/1.5 var(--sans);
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body { background: #1b1720; }
h1, h2, h3, p { margin: 0; }
button, input, a { -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; color: inherit; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .50; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.world { position: relative; isolation: isolate; width: 100%; height: 100%; height: 100dvh; overflow: hidden; }
#map { position: absolute; inset: 0; touch-action: none; }
#map canvas { display: block; image-rendering: pixelated; }
.vignette { position: absolute; inset: 0; background: linear-gradient(to bottom, #1c141fc7, transparent 18%, transparent 79%, #1c141fe8); pointer-events: none; }
.masthead, .hud { position: absolute; inset-inline: 0; display: flex; justify-content: space-between; align-items: center; gap: 9px; pointer-events: none; }
.masthead { top: 0; padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left)); }
.masthead-actions, .hud-actions { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.masthead-actions > *, .hud-actions > *, .brand { pointer-events: auto; }
.brand { display: inline-flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand strong { display: block; font: 700 21px/1 var(--serif); letter-spacing: .07em; }
.brand small { display: block; margin-top: 4px; font: 12px/1 Georgia, serif; color: var(--gold); letter-spacing: .055em; }
.seal { display: grid; place-items: center; width: 37px; height: 40px; border: 1px solid #c08858; color: var(--gold); font: 25px/1 "Segoe UI Symbol", serif; border-radius: 3px 3px 50% 50%; background: #482b31; box-shadow: inset 0 0 0 2px #2e2027; }
.quiet, .primary, .game-link { display: inline-block; border: 1px solid #8e6a54; border-radius: 4px; background: #33252bea; color: var(--ink); padding: 7px 11px; text-decoration: none; line-height: 1.4; transition: background .15s, border-color .15s; }
.quiet:not(:disabled):hover, .game-link:hover { background: #573832; border-color: #c99168; }
.quiet[aria-pressed="true"], .account[data-signed-in="true"] { color: var(--gold); border-color: #b89163; }
.primary { background: #edbc7f; color: #2b201e; border-color: #edbc7f; font-weight: 700; }
.primary:not(:disabled):hover { background: #ffe2a7; }
.account { max-width: 155px; overflow: hidden; text-overflow: ellipsis; }
.hud { bottom: 0; padding: 0 max(16px, env(safe-area-inset-right)) max(11px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.hud-status { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.connection, #population { color: #dfcbb9; font-size: 11px; }
#population:not(:empty) { border-left: 1px solid #94735c8f; padding-left: 9px; }
.connection::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #c49c66; margin-right: 5px; vertical-align: 2px; }
.connection[data-status="online"]::before { background: var(--mint); box-shadow: 0 0 8px #a7dcb38c; }
.connection[data-status="offline"]::before { background: #e9a390; }
.keyboard { display: flex; align-items: center; justify-content: center; gap: 4px; margin-inline: auto; font-size: 11px; color: #e4cdb7; }
.keyboard span { margin: 0 6px 0 1px; }
kbd { min-width: 20px; padding: 2px 4px; text-align: center; color: var(--ink); border: 1px solid #82695a; border-radius: 3px; background: #3f2b2de6; box-shadow: inset 0 -1px #8b6251; font: 12px/1.3 var(--mono); }
.hud .quiet { padding: 5px 8px; font-size: 12px; }
.touch-help { display: none; }
#loading { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: #dfcba5; white-space: nowrap; pointer-events: none; }
.near, .round, .invitation { position: absolute; left: 50%; transform: translateX(-50%); max-width: calc(100% - 26px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 8px 15px; background: #302324f2; border: 1px solid #d5aa76; border-radius: 4px; color: #ffe0a9; box-shadow: 0 4px 15px #160e16a5; }
.near { bottom: calc(max(11px, env(safe-area-inset-bottom)) + 43px); }
.near:hover, .invitation:hover { background: #543633; }
.round { top: max(66px, calc(env(safe-area-inset-top) + 54px)); font-size: 12px; pointer-events: none; }
.invitation { top: max(66px, calc(env(safe-area-inset-top) + 54px)); font-size: 12px; }
.sheet { position: absolute; z-index: 2; left: 50%; transform: translateX(-50%); bottom: calc(max(10px, env(safe-area-inset-bottom)) + 44px); width: min(472px, calc(100% - 24px)); max-height: min(480px, 62dvh); display: flex; flex-direction: column; border: 1px solid #a37960; border-radius: 10px 10px 5px 5px; background: #2e2329fa; box-shadow: 0 15px 45px #160d17c9, inset 0 0 0 2px #382b2c; overflow: hidden; }
.sheet-handle { width: 26px; height: 3px; margin: 7px auto 0; border-radius: 6px; background: #b38c6c92; }
.panel-title { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 15px 11px; border-bottom: 1px solid #62483d; }
.panel-title h2, dialog h2 { font: 700 22px var(--serif); letter-spacing: .055em; }
.text-button { padding: 4px 0; background: none; border: 0; color: var(--gold); font-size: 12px; }
.text-button span { font-size: 15px; padding-left: 2px; }
.sheet-content { padding: 11px 14px 13px; overflow-y: auto; overscroll-behavior: contain; }
.districts, .games { display: grid; gap: 6px; }
.district { text-align: left; padding: 7px 9px; min-width: 0; display: grid; grid-template-columns: 27px minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 48px; width: 100%; border-radius: 4px; background: #382b2d; border: 1px solid #654d44; }
.district:hover, .district.destination { border-color: var(--accent); background: #493333; }
.district .glyph { font: 20px "Segoe UI Symbol", serif; color: var(--accent); text-align: center; }
.district strong, .district small { display: block; }
.district small, .aside-copy, .game-detail { font-size: 12px; color: var(--muted); }
.district .arrow { color: var(--accent); font-size: 11px; }
.game-row, .party, .arrival-note { padding: 9px 10px; border: 1px solid #6f5246; border-radius: 4px; background: #37292b; }
.arrival-note { border-color: #a67552; margin-bottom: 8px; }
.arrival-note p { color: var(--muted); font-size: 12px; }
.game-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 10px; }
.game-row strong, .game-row .game-detail { grid-column: 1; }
.game-row .game-actions { grid-column: 2; grid-row: 1 / span 2; margin: 0; }
.game-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.game-actions a, .game-actions button, .party > button { font-size: 12px; padding: 6px 9px; }
.party .phase { color: #eacfaa; margin-top: 8px; font-size: 12px; }
.party > button { margin-top: 9px; }
.chairs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.chair { display: grid; gap: 2px; padding: 6px 8px; border: 1px dashed #80614f; color: var(--muted); }
.chair span { color: var(--muted); font-size: 11px; }
.chair.filled { border-style: solid; border-color: #a8794f; background: #50352f; color: var(--ink); }
.xiangqi-rules { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; margin:10px 0 0; padding:7px 8px 8px; border:1px solid #80614f; }
.xiangqi-rules legend { padding:0 4px; color:#f5c27e; font-size:12px; }
.xiangqi-rules label { display:grid; gap:4px; color:var(--muted); font-size:12px; }
.xiangqi-rules label[hidden] { display:none; }
.xiangqi-rules select { width:100%; min-height:28px; padding:2px 4px; color:var(--ink); background:#2e2329; border:1px solid #80614f; font:inherit; }
.roster { border-top: 1px solid #62483d; padding: 9px 14px; flex: 0 0 auto; }
.roster > div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.roster h3 { font: 700 13px var(--sans); margin-bottom: 3px; }
#roster-count { color: var(--mint); font: 12px var(--mono); }
#people { margin: 0; padding: 0; list-style: none; max-height: 48px; overflow: auto; display: flex; flex-wrap: wrap; gap: 3px 11px; }
#people li { display: flex; align-items: center; gap: 5px; padding: 1px 0; color: var(--muted); font-size: 12px; }
.roster-crest { color: var(--player); min-width: 12px; text-align: center; }
input { min-width: 0; height: 35px; border: 1px solid #805e50; border-radius: 4px; background: #281e26; padding: 0 10px; }
.register { display: grid; gap: 7px; margin-top: 11px; }
.register label { color: var(--muted); font-size: 12px; }
.register .primary { justify-self: start; }
.crests { display: flex; gap: 6px; }
.crest { border: 1px solid #755547; background: #392a2b; color: var(--gold); border-radius: 3px; min-width: 35px; min-height: 35px; font-size: 20px; }
.crest[aria-pressed="true"] { border-color: var(--gold); background: #653e31; }
.journal { margin-top: 10px; }
.journal-row { color: var(--gold); display: flex; justify-content: space-between; gap: 6px; font-size: 12px; padding: 6px 1px; border-bottom: 1px solid #62483d8c; }
.journal-row small { color: var(--muted); }
.account-note { padding-bottom: 8px; }
.toast { position: absolute; z-index: 4; top: max(62px, calc(env(safe-area-inset-top) + 50px)); right: max(16px, env(safe-area-inset-right)); padding: 8px 12px; background: #49322ef0; color: var(--ink); border: 1px solid #ae805c; border-radius: 4px; max-width: calc(100% - 22px); pointer-events: none; }
dialog { background: #382a2a; color: var(--ink); border: 1px solid #ad805e; border-radius: 6px; width: min(430px, calc(100vw - 28px)); padding: 22px; }
dialog::backdrop { background: #150f17bf; }
dialog p { color: var(--muted); margin: 12px 0; }
dialog input { width: 100%; }
.dialog-actions { display: flex; justify-content: end; gap: 8px; margin-top: 12px; }
@media (pointer: coarse), (max-width: 700px) {
  .keyboard { display: none; }
  .hud .touch-help { display: block; margin-inline: auto; text-align: center; font-size: 11px; color: #dfcbb9; }
}
@media (max-width: 650px) {
  .masthead { padding-inline: 8px; }
  .masthead-actions { gap: 4px; }
  .masthead-actions > a.quiet { display: none; }
  .brand { gap: 5px; }
  .brand strong { font-size: 17px; }
  .brand small { font-size: 10px; }
  .seal { width: 26px; height: 31px; font-size: 19px; }
  .masthead .quiet { padding: 7px 6px; font-size: 12px; }
  .account { max-width: 96px; }
  .hud { padding-inline: 8px; }
  .hud-status { gap: 4px; }
  #population { display: none; }
  .hud-actions { gap: 4px; }
  .hud .quiet { padding-inline: 5px; }
  .hud .touch-help { display: none; }
  .sheet { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 38px); width: calc(100% - 12px); max-height: 55dvh; }
  .near { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 38px); }
  .toast { top: max(55px, calc(env(safe-area-inset-top) + 42px)); right: 6px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
