:root {
  color-scheme: dark;
  --ink: #f2eee5;
  --muted: #96918a;
  --ground: #101315;
  --panel: #181c1e;
  --line: #343a3c;
  --accent: #e0533f;
  --accent-soft: #f07864;
  --gold: #c7a45e;
  --green: #78a88b;
  --blue: #70a0ae;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--ink); background: radial-gradient(circle at 76% 4%, #41231f52, transparent 30rem), linear-gradient(145deg, #111517, #0d1011 75%); }
body::before { position: fixed; z-index: -1; inset: 0; content: ""; opacity: 0.1; background-image: linear-gradient(#ffffff08 1px, transparent 1px), linear-gradient(90deg, #ffffff08 1px, transparent 1px); background-size: 44px 44px; mask-image: linear-gradient(to bottom, black, transparent 82%); }
button, input, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.shell { width: min(1380px, calc(100% - 48px)); margin: 0 auto; padding: 24px 0 64px; }

.masthead { display: flex; align-items: center; justify-content: space-between; min-height: 52px; margin-bottom: 18px; }
.brand { display: flex; gap: 12px; align-items: center; border: 0; padding: 0; color: inherit; background: transparent; text-align: left; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--accent); color: var(--accent-soft); font-family: Georgia, serif; font-weight: 700; }
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, "Songti SC", serif; font-size: 1rem; font-weight: 500; letter-spacing: 0.08em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 0.54rem; letter-spacing: 0.18em; }
.session-state { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 0.68rem; }
.session-state code { margin-left: 8px; border-left: 1px solid var(--line); padding-left: 18px; color: #6f7576; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px #e0533f18; }
.status-dot.connected { background: var(--green); box-shadow: 0 0 0 4px #78a88b18; }

.eyebrow, .section-number { margin: 0; color: var(--accent-soft); font-size: 0.63rem; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; }
.panel { border: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 94%, transparent); box-shadow: 0 16px 60px #00000012; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.panel-heading h2 { margin: 7px 0 0; font-family: Georgia, "Songti SC", serif; font-size: 1.45rem; font-weight: 400; }
.panel-heading.compact { margin-bottom: 16px; }

button { border: 1px solid var(--line); border-radius: 0; padding: 10px 14px; cursor: pointer; background: transparent; transition: border-color 120ms, background 120ms, opacity 120ms, transform 120ms; }
button:hover:not(:disabled) { border-color: var(--accent-soft); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled, .busy button { cursor: not-allowed; opacity: 0.4; }
.primary { border-color: var(--accent); background: var(--accent); font-weight: 800; }
.primary:hover:not(:disabled) { background: #c94634; }
.secondary { color: #d6d1c8; background: #24292b; }
.danger { border-color: #58322e; color: #dc7669; }
.icon-button { padding: 7px 9px; color: var(--muted); font-family: ui-monospace, monospace; font-size: 0.66rem; }
.text-button { border: 0; padding: 0; color: var(--muted); font-size: 0.66rem; }

label { display: grid; gap: 7px; color: var(--muted); font-size: 0.69rem; font-weight: 700; letter-spacing: 0.06em; }
label span { color: #717676; font-weight: 400; }
input, select { width: 100%; border: 1px solid var(--line); border-radius: 0; padding: 10px 12px; color: var(--ink); background: #111517; outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px #e0533f1d; }
input::placeholder { color: #555b5d; }
.stack-form { display: grid; gap: 14px; }
.room-code-input { font-family: ui-monospace, monospace; font-size: 1.1rem; font-weight: 800; letter-spacing: 0.3em; text-transform: uppercase; }
.check-line { display: flex; gap: 9px; align-items: center; cursor: pointer; }
.check-line input { width: 15px; height: 15px; accent-color: var(--accent); }

/* 前置封面 */
.landing { display: grid; grid-template-columns: minmax(390px, 0.86fr) minmax(430px, 1.14fr); min-height: calc(100vh - 118px); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.landing-copy { display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--line); padding: clamp(42px, 7vh, 82px) clamp(28px, 5vw, 72px) 34px 0; }
.landing-title h1 { margin: 20px 0 14px; font-family: Georgia, "Songti SC", serif; font-size: clamp(4.4rem, 8vw, 8rem); font-weight: 400; line-height: 0.85; letter-spacing: -0.08em; }
.landing-title > p:last-child { margin: 0; color: var(--muted); font-size: 0.74rem; letter-spacing: 0.18em; }
.landing-menu { display: grid; border-top: 1px solid var(--line); }
.menu-item { display: flex; align-items: center; justify-content: space-between; min-height: 55px; border-width: 0 0 1px; padding: 0 4px; text-align: left; }
.menu-item span { font-family: Georgia, "Songti SC", serif; font-size: 1rem; }
.menu-item small { display: inline-block; width: 32px; color: #62686a; font-family: ui-monospace, monospace; font-size: 0.56rem; }
.menu-item b { color: #696f70; font-size: 0.56rem; font-weight: 500; letter-spacing: 0.1em; }
.menu-item strong { color: var(--accent-soft); font-family: Georgia, serif; font-size: 1.25rem; font-weight: 400; }
.menu-item.primary-menu { min-height: 68px; border-color: #674039; color: #fff7ec; }
.menu-item.primary-menu span { font-size: 1.15rem; }
.menu-item.subdued { color: var(--muted); }
.landing-art { position: relative; display: grid; place-items: center; overflow: hidden; }
.landing-art::after { position: absolute; inset: 6% 7%; border: 1px solid #272d2f; content: ""; }
.landing-art > p { position: absolute; right: 9%; bottom: 9%; margin: 0; color: #596062; font-family: ui-monospace, monospace; font-size: 0.56rem; line-height: 1.7; letter-spacing: 0.18em; text-align: right; }
.roulette-emblem { position: relative; display: grid; place-items: center; width: min(52vw, 550px); aspect-ratio: 1; border: 1px solid #596062; border-radius: 50%; box-shadow: inset 0 0 0 22px #111517, inset 0 0 0 23px #414749, inset 0 0 0 62px #171b1d, inset 0 0 0 63px #343a3c, 0 30px 100px #0008; }
.roulette-emblem::before { width: 48%; aspect-ratio: 1; border: 1px solid var(--accent); border-radius: 50%; content: ""; background: #1a1717; box-shadow: 0 0 80px #e0533f24; }
.roulette-emblem::after { position: absolute; width: 8%; aspect-ratio: 1; border-radius: 50%; content: ""; background: var(--accent); box-shadow: 0 -152px 0 #5e6567, 132px -76px 0 #5e6567, 132px 76px 0 #5e6567, 0 152px 0 #5e6567, -132px 76px 0 #5e6567, -132px -76px 0 #5e6567; }
.emblem-letter { position: absolute; z-index: 2; color: var(--ink); font-family: Georgia, serif; font-size: clamp(5rem, 10vw, 9rem); }
.roulette-emblem i { position: absolute; width: 1px; height: 42%; background: #343a3c; transform-origin: 50% 100%; }
.roulette-emblem i:nth-of-type(1) { transform: translateY(-50%) rotate(0deg); }
.roulette-emblem i:nth-of-type(2) { transform: translateY(-50%) rotate(60deg); }
.roulette-emblem i:nth-of-type(3) { transform: translateY(-50%) rotate(120deg); }
.roulette-emblem i:nth-of-type(4) { transform: translateY(-50%) rotate(180deg); }
.roulette-emblem i:nth-of-type(5) { transform: translateY(-50%) rotate(240deg); }
.roulette-emblem i:nth-of-type(6) { transform: translateY(-50%) rotate(300deg); }

/* 房间大厅 */
.lobby-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 38px 0 30px; }
.lobby-header .text-button { margin-bottom: 26px; }
.lobby-header h1 { margin: 8px 0 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(2.8rem, 5vw, 5rem); font-weight: 400; letter-spacing: -0.05em; }
.lobby-tools { display: flex; gap: 8px; align-items: center; }
.room-directory { min-height: 560px; padding: 28px 0 0; }
.directory-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.directory-heading h2 { margin: 0 0 7px; font-family: Georgia, "Songti SC", serif; font-size: 1.25rem; font-weight: 400; }
.directory-heading p { margin: 0; color: var(--muted); font-size: 0.68rem; }
.directory-stat { display: flex; gap: 10px; align-items: baseline; }
.directory-stat strong { font-family: Georgia, serif; font-size: 2.1rem; font-weight: 400; }
.directory-stat span { color: var(--muted); font-size: 0.53rem; letter-spacing: 0.14em; }
.directory-stat button { margin-left: 8px; }
.room-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.room-card { display: flex; flex-direction: column; min-height: 250px; border: 1px solid var(--line); padding: 20px; background: #15191b; transition: border-color 140ms, background 140ms, transform 140ms; }
.room-card:hover { border-color: #51585a; background: #181d1f; transform: translateY(-2px); }
.room-card-code { color: var(--accent-soft); font-family: ui-monospace, monospace; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.24em; }
.room-card-body { display: flex; gap: 18px; align-items: flex-start; justify-content: space-between; margin: 32px 0 auto; }
.room-card h3 { margin: 0 0 7px; font-family: Georgia, "Songti SC", serif; font-size: 1.4rem; font-weight: 400; }
.room-card p { margin: 0; color: var(--muted); font-size: 0.67rem; }
.seat-count { display: flex; gap: 5px; align-items: flex-end; white-space: nowrap; }
.seat-count strong { font-family: Georgia, serif; font-size: 2.5rem; font-weight: 400; line-height: 0.8; }
.seat-count span { color: var(--muted); font-size: 0.55rem; line-height: 1.3; }
.room-card-meta { display: flex; gap: 14px; margin: 25px 0 13px; color: #777d7e; font-family: ui-monospace, monospace; font-size: 0.6rem; }
.room-card button { width: 100%; padding: 9px; font-size: 0.7rem; }
.empty-state { display: grid; place-items: center; align-content: center; gap: 14px; min-height: 420px; border: 1px dashed #313739; color: var(--muted); text-align: center; }
.empty-wheel { color: #373d3f; font-family: Georgia, serif; font-size: 5rem; line-height: 1; }
.empty-state strong { color: var(--ink); font-family: Georgia, "Songti SC", serif; font-size: 1.45rem; font-weight: 400; }
.empty-state > span:not(.empty-wheel) { font-size: 0.7rem; }
.empty-state > div { display: flex; gap: 8px; margin-top: 8px; }

/* 模态对话框 */
.modal { width: min(470px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 40px)); border: 1px solid #4a5153; padding: 26px; color: var(--ink); background: #171b1d; box-shadow: 0 30px 100px #000c; }
.modal::backdrop { background: #080a0bd9; backdrop-filter: blur(7px); }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 23px; }
.modal-heading h2 { margin: 7px 0 0; font-family: Georgia, "Songti SC", serif; font-size: 2rem; font-weight: 400; }
.modal-close { width: 34px; height: 34px; padding: 0; color: var(--muted); font-size: 1.2rem; }
.modal-copy { margin: -8px 0 22px; color: var(--muted); font-size: 0.72rem; line-height: 1.7; }
.settings-modal { width: min(520px, calc(100vw - 32px)); }
.debug-modal { width: min(980px, calc(100vw - 32px)); max-height: min(840px, calc(100vh - 36px)); padding: 24px; background: #0f1214; border: 1px solid #3d4648; }
.debug-heading-tools { display: flex; gap: 8px; align-items: center; }
.debug-toggle-btn { color: var(--gold); border-color: #5c4e30; font-size: 0.65rem; padding: 4px 8px; }
.debug-toggle-btn:hover { border-color: var(--gold); background: #3d321c33; }
.debug-board-btn { color: var(--gold); border-color: #5c4e30; font-size: 0.62rem; padding: 4px 7px; }
.debug-board-btn:hover { border-color: var(--gold); background: #3d321c33; }
.debug-meta-bar { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 9px 4px; margin-bottom: 16px; color: var(--muted); font-size: 0.66rem; font-family: ui-monospace, monospace; }
.debug-keyhint { color: #6f7576; }
.debug-content-scroll { max-height: calc(840px - 160px); overflow-y: auto; padding-right: 6px; display: grid; gap: 16px; }
.debug-empty { text-align: center; color: var(--muted); font-size: 0.74rem; padding: 48px 16px; border: 1px dashed var(--line); font-family: ui-monospace, monospace; }

.terrain-modal { width: min(880px, calc(100vw - 32px)); max-height: min(840px, calc(100vh - 36px)); padding: 24px; background: #0f1214; border: 1px solid #3d4648; }
.terrain-modal-meta { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 9px 4px; margin-bottom: 16px; color: var(--muted); font-size: 0.66rem; font-family: ui-monospace, monospace; }
.terrain-stat { color: var(--gold); font-weight: 700; }
.terrain-modal-scroll { max-height: calc(840px - 160px); overflow-y: auto; padding-right: 6px; display: grid; gap: 14px; }

.terrain-card { border: 1px solid #2d3437; background: #14181a; padding: 14px; display: grid; gap: 10px; transition: border-color 140ms; }
.terrain-card.present { border-color: #43545b; background: #141a1d; }
.terrain-card.absent { opacity: 0.85; }
.terrain-card-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; border-bottom: 1px solid #262c2e; padding-bottom: 8px; }
.terrain-title-group { display: flex; align-items: center; gap: 10px; }
.terrain-symbol-box { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid #3d4648; font-size: 1rem; font-weight: 900; background: #0c0e10; }
.terrain-symbol-box.wall { background: repeating-linear-gradient(135deg, #32383a 0 6px, #272c2e 6px 12px); color: #747b7d; }
.terrain-symbol-box.crate { color: #c29f68; border-color: #59472e; }
.terrain-symbol-box.water { background: #17292e; color: #6ba3ac; border-color: #2b4952; }
.terrain-symbol-box.ice { background: #182e38; color: #8ad2ff; border-color: #3b5b6b; }
.terrain-symbol-box.high_ground { background: #332d21; color: var(--gold); border-color: #5c4e30; }
.terrain-symbol-box.mine { color: var(--accent-soft); border-color: #69423b; }
.terrain-symbol-box.medkit { color: var(--green); border-color: #345c43; }
.terrain-card-name { margin: 0; font-size: 1.05rem; font-family: Georgia, "Songti SC", serif; font-weight: 400; color: var(--ink); }
.terrain-card-id { color: #6f7576; font-size: 0.68rem; font-family: ui-monospace, monospace; }
.terrain-present-badge { font-size: 0.62rem; font-family: ui-monospace, monospace; padding: 2px 7px; font-weight: 700; }
.terrain-present-badge.active { background: #1b2e23; color: #90c3a1; border: 1px solid #376349; }
.terrain-present-badge.inactive { background: #1e2426; color: #6f7576; border: 1px solid #2d3538; }

.terrain-props-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; background: #0c0e10; padding: 10px; border: 1px solid #23292b; }
.terrain-prop-item { display: grid; gap: 3px; font-family: ui-monospace, monospace; }
.prop-label { color: var(--muted); font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.08em; }
.prop-val { color: var(--ink); font-size: 0.72rem; }
.prop-val.layer-above_ground { color: #e5dfd5; }
.prop-val.layer-underground { color: #ff9888; }
.prop-val.layer-above_and_below { color: #8ad2ff; }
.prop-val.layer-special { color: var(--gold); }

.terrain-bullet-rule { display: flex; align-items: flex-start; gap: 8px; background: #171b1d; border-left: 3px solid var(--accent); padding: 8px 10px; font-size: 0.66rem; line-height: 1.5; color: #d0d6d9; }
.bullet-rule-tag { background: #2b1f1d; color: var(--accent); padding: 2px 5px; font-size: 0.58rem; font-weight: 700; white-space: nowrap; font-family: ui-monospace, monospace; }
.bullet-rule-desc strong { color: #ffab9d; }
.terrain-card-desc { margin: 0; color: #9aa2a6; font-size: 0.68rem; line-height: 1.6; }

.trace-card { border: 1px solid #2d3437; background: #14181a; padding: 14px; display: grid; gap: 12px; }
.trace-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; border-bottom: 1px solid #262c2e; padding-bottom: 8px; font-family: ui-monospace, monospace; font-size: 0.68rem; }
.trace-title { display: flex; align-items: center; gap: 8px; }
.trace-id-badge { background: #262e32; color: #b7bec2; padding: 2px 6px; font-weight: 700; }
.trace-root-trigger { color: var(--gold); }
.trace-meta-info { color: #6f7576; font-size: 0.62rem; }

.trace-nodes-container { display: grid; gap: 10px; }
.tree-node { border-left: 3px solid #343c3f; padding-left: 12px; margin-left: calc(var(--indent, 0) * 18px); display: grid; gap: 8px; background: #11141680; padding: 10px 12px; }
.tree-node.root-wave { border-left-color: var(--accent); }
.tree-node.child-wave { border-left-color: var(--blue); }
.tree-node-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; font-family: ui-monospace, monospace; font-size: 0.68rem; }
.wave-tag { background: #2b3337; color: #a4b0b6; padding: 2px 6px; font-size: 0.6rem; font-weight: 700; }
.wave-tag.wave-0 { background: #4a2822; color: #ffab9d; }
.pool-tag { background: #1c262c; color: var(--blue); padding: 2px 6px; font-size: 0.62rem; }
.roll-info { color: #7f888c; font-size: 0.62rem; }
.tree-node-trigger { font-size: 0.72rem; color: var(--ink); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.tree-node-outcome { color: var(--green); font-size: 0.68rem; font-family: ui-monospace, monospace; background: #17241d40; border-left: 2px solid var(--green); padding: 4px 8px; }

.candidates-wrap { margin-top: 4px; display: grid; gap: 4px; }
.candidates-heading { font-size: 0.6rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.candidate-row { display: grid; gap: 3px; padding: 4px 6px; background: #0c0e10; font-family: ui-monospace, monospace; font-size: 0.63rem; }
.candidate-row.selected { background: #261f1d; border-left: 2px solid var(--accent); }
.candidate-row-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.candidate-row-title { display: flex; align-items: center; gap: 5px; min-width: 0; overflow: hidden; }
.candidate-marker { color: #5f6566; font-weight: 900; }
.candidate-row.selected .candidate-marker { color: var(--accent); }
.candidate-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.63rem; }
.candidate-row.selected .candidate-name { color: #fff; font-weight: 700; }
.candidate-dampener-badge { font-size: 0.54rem; color: #bca068; }
.candidate-lethal-badge { font-size: 0.54rem; color: #ff7865; font-weight: 700; margin-left: 2px; }
.candidate-pct { font-weight: 700; color: #8e9699; font-size: 0.62rem; }
.candidate-row.selected .candidate-pct { color: var(--accent-soft); }
.candidate-bar-cell { display: flex; align-items: center; gap: 6px; }
.candidate-weights { color: #62696b; font-size: 0.56rem; min-width: 60px; }
.candidate-bar-track { flex: 1; height: 5px; background: #1e2426; position: relative; overflow: hidden; }
.candidate-bar-fill { height: 100%; background: #405058; }
.candidate-row.selected .candidate-bar-fill { background: var(--accent); }

.settings-row, .settings-title, .server-setting { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.settings-row { border-top: 1px solid var(--line); padding: 17px 0; }
.settings-row strong, .settings-row small, .settings-title strong, .settings-title small, .server-setting strong, .server-setting small { display: block; }
.settings-row strong, .settings-title strong, .server-setting strong { font-size: 0.74rem; }
.settings-row small, .settings-title small, .server-setting small { margin-top: 5px; color: var(--muted); font-size: 0.62rem; }
.identity-row code { color: var(--muted); font-size: 0.66rem; }
.settings-section { border-top: 1px solid var(--line); padding: 18px 0; }
.settings-title { margin-bottom: 14px; }
.mini-badge { border: 1px solid var(--line); padding: 5px 8px; color: var(--muted); font-size: 0.56rem; }
.mini-badge.verified { border-color: #4b765e; color: #90c3a1; }
.inline-form { display: grid; grid-template-columns: 1fr auto; }
.inline-form button { border-left: 0; }
.server-setting { border-top: 1px solid var(--line); padding-top: 18px; }
.switch { display: block; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { position: relative; display: block; width: 42px; height: 23px; border: 1px solid var(--line); background: #101315; }
.switch span::after { position: absolute; top: 4px; left: 4px; width: 13px; height: 13px; content: ""; background: #747a7b; transition: transform 140ms, background 140ms; }
.switch input:checked + span::after { transform: translateX(19px); background: var(--green); }
.switch input:disabled + span { opacity: 0.4; cursor: not-allowed; }

/* 房间与对局 */
.room-topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 12px; padding: 25px 28px; }
.room-topbar h1 { margin: 8px 0 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(2rem, 4vw, 3.5rem); font-weight: 400; }
.back-button { margin-bottom: 22px; border: 0; padding: 0; color: var(--muted); font-size: 0.69rem; }
.room-facts { display: flex; gap: 50px; padding-bottom: 8px; }
.room-facts small, .room-facts strong { display: block; }
.room-facts small { margin-bottom: 8px; color: var(--muted); font-size: 0.58rem; letter-spacing: 0.12em; }
.room-facts strong { font-family: ui-monospace, monospace; font-size: 0.8rem; }
.room-layout { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 12px; align-items: start; }
.room-sidebar { display: grid; gap: 12px; min-width: 0; }
.room-members { padding: 20px; }
.room-event-inspector { padding: 18px; border: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 96%, transparent); }
.room-event-inspector .panel-heading h2 { font-size: 1.15rem; }
.sidebar-debug-meta { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 7px 2px; margin-bottom: 12px; font-size: 0.62rem; color: var(--muted); font-family: ui-monospace, monospace; }
.live-dot { color: var(--green); font-weight: 800; font-size: 0.58rem; letter-spacing: 0.08em; display: flex; align-items: center; gap: 4px; }
.sidebar-debug-scroll { max-height: 480px; overflow-y: auto; padding-right: 4px; display: grid; gap: 10px; }
#members { display: grid; gap: 8px; }
.member-card { border: 1px solid #303638; padding: 10px; background: #15191b; }
.member-card.self { border-color: #69423b; background: #1d1919; }
.member-main, .member-main > div:first-child { display: flex; align-items: center; }
.member-main { justify-content: space-between; gap: 8px; }
.member-main > div:first-child { gap: 9px; min-width: 0; }
.member-avatar { display: grid; flex: 0 0 auto; place-items: center; width: 30px; height: 30px; border: 1px solid #646b6d; color: #cbd0cf; font-size: 0.7rem; font-weight: 800; }
.member-avatar.bot { border-color: #647049; color: #b6c579; }
.member-main strong, .member-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-main strong { max-width: 95px; font-size: 0.73rem; }
.member-main small { max-width: 95px; margin-top: 3px; color: var(--muted); font-size: 0.56rem; }
.member-badges { display: flex; gap: 3px; }
.member-badge { border: 1px solid var(--line); padding: 3px 5px; color: var(--muted); font-size: 0.5rem; white-space: nowrap; }
.member-badge.owner { border-color: #675637; color: var(--gold); }
.member-badge.alive { color: var(--green); }
.member-badge.eliminated { color: var(--accent-soft); }
.member-actions { margin-top: 8px; padding-left: 39px; }
.member-actions button { padding: 4px 7px; color: var(--muted); font-size: 0.55rem; }
.owner-controls { display: grid; gap: 8px; margin-top: 16px; border-top: 1px solid var(--line); padding-top: 16px; }
.owner-controls input { padding: 8px; }
.room-hint { margin: 14px 0 0; color: var(--muted); font-size: 0.62rem; line-height: 1.6; }
.waiting-room { display: grid; place-items: center; min-height: 570px; padding: 50px; text-align: center; }
.waiting-room .section-number { align-self: start; justify-self: start; }
.waiting-symbol { display: grid; place-items: center; width: 160px; height: 160px; margin: 30px 0 0; border: 1px solid var(--line); border-radius: 50%; color: #32383a; font-family: Georgia, serif; font-size: 4.8rem; box-shadow: inset 0 0 0 15px #121618, inset 0 0 0 16px #2b3032; }
.waiting-room h2 { margin: 10px 0 -20px; font-family: Georgia, "Songti SC", serif; font-size: 2rem; font-weight: 400; }
.waiting-room > p:last-child { max-width: 440px; margin: 0; color: var(--muted); font-size: 0.76rem; line-height: 1.8; }
.game-workspace { display: grid; gap: 12px; min-width: 0; }
.board-wrap, .records { padding: 20px; }
.board-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.board-heading h2 { margin: 7px 0 0; font-family: Georgia, "Songti SC", serif; font-size: 1.45rem; font-weight: 400; }
.board-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stalemate-badge { border: 1px solid #7c3a2f; padding: 7px 10px; color: #ff7865; font-family: ui-monospace, monospace; font-size: 0.64rem; background: #2b1714; font-weight: 700; }
.weather-badge { border: 1px solid var(--line); padding: 7px 10px; color: var(--gold); font-family: ui-monospace, monospace; font-size: 0.64rem; background: #202628; }
.revision { border: 1px solid var(--line); padding: 7px 10px; color: var(--muted); font-family: ui-monospace, monospace; font-size: 0.64rem; }
.board-stage { display: grid; grid-template-columns: minmax(350px, 1fr) 160px; gap: 14px; align-items: center; }
.playfield { min-width: 0; }
.board { --board-size: 5; display: grid; grid-template-columns: repeat(var(--board-size), minmax(38px, 1fr)); gap: 4px; width: min(60vh, 100%); aspect-ratio: 1; margin: 0 auto; }
.cell { position: relative; display: grid; place-items: center; min-width: 0; border: 1px solid #303638; background: #252b2d; color: #8e9698; font-family: ui-monospace, monospace; font-size: clamp(0.75rem, 1.5vw, 1.25rem); }
.cell.wall { background: repeating-linear-gradient(135deg, #32383a 0 8px, #272c2e 8px 16px); color: #747b7d; }
.cell.water { background: #17292e; color: #6ba3ac; }
.cell.ice { background: #182e38; color: #8ad2ff; border-color: #3b5b6b; }
.cell.high_ground { background: #332d21; color: var(--gold); }
.cell.mine { color: var(--accent-soft); }
.cell.medkit { color: var(--green); }
.player-token { position: absolute; display: grid; place-items: center; width: 61%; aspect-ratio: 1; border: 2px solid #d9d6cd; border-radius: 50%; color: #121516; background: #d6d2c8; font-size: clamp(0.58rem, 1.1vw, 0.86rem); font-weight: 900; box-shadow: 0 4px 16px #0008; }
.player-token.bot { border-color: #c2cf90; background: #8c9b5b; }
.player-token.self { border-color: #ffd5cc; color: white; background: var(--accent); }
.legend { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; width: min(60vh, 100%); margin: 13px auto 0; color: var(--muted); font-size: 0.62rem; }
.legend-items { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.legend-help-btn { background: transparent; border: 1px solid #3d4648; color: var(--gold); padding: 3px 8px; font-size: 0.62rem; cursor: pointer; transition: all 140ms; border-radius: 2px; }
.legend-help-btn:hover { border-color: var(--gold); background: #3d321c33; color: #fff; }
.terrain-board-btn { color: #a4b0b6; border-color: #3d4648; font-size: 0.62rem; padding: 4px 7px; }
.terrain-board-btn:hover { color: var(--ink); border-color: #5c6668; }
.controls { border: 1px solid var(--line); padding: 13px; background: #14181a; }
.controls button { padding: 7px 8px; font-size: 0.7rem; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; margin: 12px 0 10px; }
.mode { color: var(--muted); }
.mode.active { border-color: var(--accent); color: var(--ink); background: #e0533f1f; }
.direction-pad { display: grid; grid-template-columns: repeat(3, 36px); justify-content: center; gap: 4px; margin-bottom: 9px; }
.direction-pad button { width: 36px; height: 36px; padding: 0; font-size: 0.9rem; }
.direction-pad button:nth-child(1) { grid-column: 2; }
.direction-pad button:nth-child(2) { grid-column: 1; grid-row: 2; }
.direction-pad button:nth-child(3) { grid-column: 2; grid-row: 2; }
.direction-pad button:nth-child(4) { grid-column: 3; grid-row: 2; }
.minor-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.step-panel { margin: 12px 0; text-align: center; }
.next-step-btn { width: 100%; min-height: 44px; font-size: 0.82rem; font-weight: 700; letter-spacing: 0.08em; }
.step-hint { margin: 10px 0 0; color: var(--muted); font-size: 0.62rem; line-height: 1.5; text-align: center; }
.shortcut { margin: 10px 0 0; color: #686e70; font-size: 0.55rem; line-height: 1.5; text-align: center; }
.records-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.records-heading h2 { margin: 6px 0 0; font-family: Georgia, "Songti SC", serif; font-size: 1.2rem; font-weight: 400; }
.records-heading > p { margin: 0; color: var(--muted); font-size: 0.62rem; letter-spacing: 0.08em; }
#records { display: flex; flex-direction: column; gap: 10px; max-height: 400px; margin: 15px 0 0; padding: 0; overflow-y: auto; list-style: none; }
.turn-frame-card {
  display: flex;
  flex-direction: column;
  background: rgba(22, 27, 29, 0.75);
  border: 1px solid #333a3d;
  border-radius: 6px;
  padding: 10px 14px;
  transition: border-color 0.2s, background 0.2s;
}
.turn-frame-card:first-child {
  border-color: #526065;
  border-left: 3px solid var(--accent);
  background: rgba(28, 34, 37, 0.9);
}
.turn-frame-card.notification-frame {
  border-left: 3px solid var(--green);
}
.turn-frame-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px solid #2a3133;
}
.turn-frame-actor {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--paper);
}
.turn-frame-round {
  color: var(--muted);
  font-size: 0.62rem;
  font-family: ui-monospace, monospace;
}
.turn-actor-badge {
  display: inline-block;
  font-size: 0.52rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.05em;
}
.turn-actor-badge.human {
  background: #3e321e;
  color: #e5c178;
  border: 1px solid #6b552d;
}
.turn-actor-badge.bot {
  background: #252b35;
  color: #8da4c4;
  border: 1px solid #3d4a5c;
}
.turn-frame-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.turn-action-chip {
  font-size: 0.65rem;
  font-family: ui-monospace, monospace;
  color: #e5c178;
  background: rgba(229, 193, 120, 0.1);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid rgba(229, 193, 120, 0.25);
}
.turn-frame-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.turn-record-empty {
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 0.68rem;
  padding: 4px 0;
  font-style: italic;
}
.turn-record-row {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 8px;
  align-items: baseline;
  padding: 3px 0;
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 0.68rem;
  line-height: 1.5;
}
.turn-record-row.lethal {
  color: #ff6b6b;
  font-weight: 600;
}
.turn-record-row.lethal .record-badge {
  color: #ff4757 !important;
}
.turn-record-row.dramatic {
  color: #f1c40f;
}
.turn-record-row.dramatic .record-badge {
  color: #f39c12 !important;
}
.record { display: grid; grid-template-columns: 42px 1fr auto; gap: 10px; align-items: baseline; border-top: 1px solid #2d3335; padding: 8px 0; color: var(--muted); font-family: ui-monospace, monospace; font-size: 0.68rem; line-height: 1.5; }
.record-badge { color: #a4a09a; font-size: 0.56rem; font-weight: 800; letter-spacing: 0.12em; }
.record.action .record-badge { color: #d7b56c; }
.record.event .record-badge { color: var(--accent-soft); }
.record.turn .record-badge { color: var(--blue); }
.record.notification .record-badge { color: var(--green); }
.record-sequence { color: #5f6566; font-size: 0.56rem; }
.toast { position: fixed; z-index: 5; right: 24px; bottom: 24px; max-width: min(420px, calc(100vw - 48px)); border: 1px solid var(--accent); padding: 13px 17px; color: var(--ink); background: #211a19; box-shadow: 0 18px 60px #000a; font-size: 0.75rem; }

@media (max-width: 980px) {
  .landing { grid-template-columns: minmax(330px, 0.9fr) 1.1fr; }
  .landing-copy { padding-right: 35px; }
  .roulette-emblem { width: min(50vw, 430px); }
  .roulette-emblem::after { box-shadow: 0 -118px 0 #5e6567, 102px -59px 0 #5e6567, 102px 59px 0 #5e6567, 0 118px 0 #5e6567, -102px 59px 0 #5e6567, -102px -59px 0 #5e6567; }
  .room-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .room-layout { grid-template-columns: 310px minmax(0, 1fr); }
  .board-stage { grid-template-columns: 1fr; }
  .controls { display: grid; grid-template-columns: 120px 125px 1fr; gap: 10px; align-items: center; }
  .controls > .section-number { display: none; }
  .step-panel { grid-column: 1 / -1; margin: 0; }
  .step-panel .next-step-btn { width: min(320px, 100%); margin: 0 auto; display: block; }
  .mode-switch, .direction-pad { margin: 0; }
  .shortcut { display: none; }
}

@media (max-width: 700px) {
  .shell { width: min(100% - 20px, 580px); padding-top: 12px; }
  .masthead { align-items: flex-start; }
  .session-state { align-items: flex-end; flex-direction: column; gap: 3px; }
  .status-dot { display: none; }
  .session-state code { margin: 2px 0 0; border: 0; padding: 0; }
  .landing { display: flex; flex-direction: column-reverse; min-height: calc(100vh - 92px); }
  .landing-copy { flex: 1; border-top: 1px solid var(--line); border-right: 0; padding: 26px 0 16px; }
  .landing-title { display: none; }
  .landing-art { min-height: 38vh; }
  .landing-art::after { inset: 3%; }
  .landing-art > p { display: none; }
  .roulette-emblem { width: min(72vw, 300px); box-shadow: inset 0 0 0 13px #111517, inset 0 0 0 14px #414749, inset 0 0 0 36px #171b1d, inset 0 0 0 37px #343a3c; }
  .roulette-emblem::after { width: 7%; box-shadow: 0 -82px 0 #5e6567, 71px -41px 0 #5e6567, 71px 41px 0 #5e6567, 0 82px 0 #5e6567, -71px 41px 0 #5e6567, -71px -41px 0 #5e6567; }
  .emblem-letter { font-size: 5rem; }
  .menu-item { min-height: 48px; }
  .menu-item.primary-menu { min-height: 58px; }
  .lobby-header { align-items: flex-start; flex-direction: column; padding: 28px 0 20px; }
  .lobby-header .text-button { margin-bottom: 20px; }
  .lobby-tools { display: grid; grid-template-columns: 1fr 1fr auto; width: 100%; }
  .lobby-tools button { padding: 9px 7px; font-size: 0.65rem; }
  .directory-heading { align-items: flex-start; }
  .directory-heading p { max-width: 240px; }
  .room-list { grid-template-columns: 1fr; }
  .room-card { min-height: 220px; }
  .empty-state { min-height: 370px; }
  .room-topbar { align-items: flex-start; flex-direction: column; padding: 20px; }
  .room-facts { width: 100%; gap: 25px; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 15px; }
  .room-layout { display: flex; flex-direction: column; }
  .room-members, .waiting-room, .game-workspace, .room-sidebar, .room-event-inspector { width: 100%; }
  .waiting-room { min-height: 430px; padding: 25px; }
  .game-workspace { display: flex; flex-direction: column; }
  .board-wrap { order: 1; padding: 12px; }
  .records { order: 2; }
  .board-stage { display: block; }
  .board { gap: 3px; }
  .controls { display: block; margin-top: 14px; }
  .controls > .section-number { display: block; text-align: center; }
  .step-panel { width: min(260px, 100%); margin: 12px auto; }
  .step-panel .next-step-btn { width: 100%; }
  .mode-switch { width: min(260px, 100%); margin: 12px auto 10px; }
  .direction-pad { margin: 0 auto 9px; }
  .minor-actions { width: min(260px, 100%); margin: 0 auto; }
  .records-heading { align-items: flex-start; flex-direction: column; gap: 7px; }
}
