:root {
  --ink: #0b1730;
  --ink-soft: #24324a;
  --paper: #f3f6fa;
  --surface: #ffffff;
  --line: #cbd5e1;
  --muted: #64748b;
  --focus: #f6a800;
  --ordinary: #60caf3;
  --arena: #4ea72e;
  --public: #ee0000;
  --shadow: 0 18px 48px rgba(11, 23, 48, 0.12);
  --display: "Bahnschrift SemiCondensed", "Arial Narrow", "Microsoft YaHei UI", sans-serif;
  --body: "Microsoft YaHei UI", "Segoe UI", sans-serif;
  --utility: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--paper); }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(#dbe3ec 1px, transparent 1px),
    linear-gradient(90deg, #dbe3ec 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: var(--body);
  line-height: 1.55;
}

button, input, select { font: inherit; }
button, select, input { color: inherit; }
button { cursor: pointer; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: white;
  background: var(--ink);
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.site-header {
  min-height: 82px;
  padding: 14px clamp(18px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: #fff;
  background: var(--ink);
  border-bottom: 4px solid var(--ordinary);
}

.brand-lockup, .mode-switcher, .section-heading, .tool-actions, .placement-bar {
  display: flex;
  align-items: center;
}

.brand-lockup { gap: 14px; }
.brand-lockup img { border-radius: 50%; border: 2px solid rgba(255,255,255,.75); }

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: var(--display); letter-spacing: .01em; }
h1 { margin-bottom: 0; font-size: clamp(1.55rem, 3vw, 2.2rem); line-height: 1; }
h2 { margin-bottom: 0; font-size: clamp(1.35rem, 2vw, 1.8rem); line-height: 1.1; }
h3 { margin-bottom: 10px; font-size: 1.05rem; }

.eyebrow, .rail-label {
  margin-bottom: 3px;
  font: 700 .69rem/1.2 var(--utility);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.eyebrow { color: var(--muted); }
.site-header .eyebrow { color: #9fb3cc; }

.mode-switcher { gap: 12px; }
.mode-label {
  padding: 5px 9px;
  border: 1px solid #5d728f;
  font: 700 .72rem var(--utility);
  letter-spacing: .06em;
}

.admin-warning {
  padding: 10px clamp(18px, 4vw, 64px);
  color: #291800;
  background: #ffda7a;
  border-bottom: 1px solid #d99a00;
  font-size: .92rem;
}
.admin-warning strong { margin-right: 8px; }
.network-warning { padding: 9px clamp(18px, 4vw, 64px); color: #fff; background: #9f1239; font-weight: 700; }

.app-shell {
  width: min(1460px, calc(100% - 32px));
  margin: 28px auto 56px;
}

.status-rail {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  color: #fff;
  background: var(--ink);
  border: 1px solid var(--ink);
}
.status-rail > div { padding: 13px 16px; border-right: 1px solid #41516a; }
.status-rail > div:last-child { border-right: 0; }
.status-rail strong { display: block; font-family: var(--display); font-size: 1.05rem; }
.rail-label { color: #95aac4; }

.manager-tools, .board-panel, .inspector-panel, .score-section {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.manager-tools { margin-top: 16px; padding: 18px; border-top: 5px solid var(--focus); }
.password-panel { margin-top: 16px; padding: 12px 14px; border: 1px solid var(--line); background: #f8fafc; }
.password-panel summary { cursor: pointer; font-weight: 800; }
.password-panel form { display: grid; grid-template-columns: auto minmax(180px, 1fr) auto minmax(180px, 1fr) auto; gap: 8px; align-items: center; margin-top: 12px; }
.section-heading { justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading .eyebrow { margin-bottom: 4px; }
.tool-actions { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.placement-bar {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  gap: 10px 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.placement-bar label { font-weight: 800; }
.placement-bar p { grid-column: 2 / -1; margin: 0; color: var(--muted); font-size: .85rem; }

.button, .icon-button {
  min-height: 40px;
  border: 1px solid #9aa9bb;
  border-radius: 3px;
  background: #fff;
  font-weight: 700;
}
.button { padding: 8px 13px; }
.button:hover { border-color: var(--ink); background: #f8fafc; }
.button--dark { color: #fff; background: transparent; border-color: #6f829c; }
.button--dark:hover { background: #1b2c47; border-color: #fff; }
.button--primary { color: #fff; background: #194a7a; border-color: #194a7a; }
.button--primary:hover { background: #103759; }
.button--danger { color: #9f1239; border-color: #f0a2b8; background: #fff5f7; }
.button--quiet { color: var(--ink-soft); background: #f8fafc; }
.icon-button { width: 42px; padding: 0; font-size: 1.65rem; line-height: 1; }

select, input:not([type="color"]) {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #9aa9bb;
  border-radius: 2px;
  background: #fff;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(540px, .92fr) minmax(480px, 1.08fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.board-panel, .inspector-panel { padding: clamp(16px, 2vw, 24px); }
.board-panel { border-top: 5px solid var(--ordinary); }
.inspector-panel { border-top: 5px solid var(--arena); min-height: 660px; }
.board-heading { margin-bottom: 8px; }

.board-stage { width: min(100%, 600px); margin: 0 auto; }
.axis--columns {
  width: calc(100% - 32px);
  margin-left: 32px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  text-align: center;
  font: 800 .75rem/2 var(--utility);
  color: var(--muted);
}

.board {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: #fff;
  border: 2px solid #07101f;
}

.bingo-cell {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: #fff;
}
.bingo-cell svg { display: block; width: 100%; height: 100%; }
.bingo-cell:hover::after, .bingo-cell[aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 3px solid var(--focus);
  pointer-events: none;
}
.bingo-cell.is-line::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 6px;
  border: 2px dashed #7b4b00;
  pointer-events: none;
}
.bingo-cell.is-placement-target { cursor: copy; }
.bingo-cell.is-placement-target::after { border-style: dashed; border-color: #0b64a0; }

.board-key {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 16px;
  font-size: .84rem;
}
.board-key span { display: inline-flex; align-items: center; gap: 7px; }
.board-key i { width: 16px; height: 16px; background: var(--swatch); border: 1px solid #000; }

.count-chip {
  padding: 5px 8px;
  color: var(--ink-soft);
  background: #eef2f7;
  border: 1px solid var(--line);
  font: 700 .72rem var(--utility);
}

.task-overview { border: 1px solid var(--line); }
.task-entry {
  display: grid;
  grid-template-columns: 54px 36px 1fr;
  width: 100%;
  min-height: 42px;
  padding: 0;
  text-align: left;
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--line);
}
.task-entry:last-child { border-bottom: 0; }
.task-entry:hover, .task-entry[aria-current="true"] { background: #f1f6fb; }
.task-entry__group, .task-entry__row, .task-entry__text {
  display: flex;
  align-items: center;
  padding: 7px 9px;
}
.task-entry__group, .task-entry__row {
  justify-content: center;
  border-right: 1px solid var(--line);
  font: 800 .72rem var(--utility);
}
.task-entry__group { color: #fff; background: var(--ink-soft); }
.task-entry__group:empty { background: #eef2f7; }
.task-entry__text { overflow: hidden; color: #1e293b; font-size: .84rem; line-height: 1.35; }

.detail-content { display: grid; gap: 14px; }
.detail-badges, .owner-list { display: flex; flex-wrap: wrap; gap: 8px; }
.badge, .owner-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  background: #f8fafc;
  font-size: .82rem;
  font-weight: 700;
}
.badge i, .owner-chip i, .score-swatch { width: 14px; height: 14px; border: 1px solid #111; background: var(--chip-color); }
.difficulty-badge { color: #9ca3af; border-color: #d1d5db; background: #f4f5f7; }
.difficulty-key { color: #9ca3af !important; }
.detail-block { padding: 14px; border-left: 3px solid var(--line); background: #f8fafc; }
.detail-block h3 { margin-bottom: 5px; }
.detail-block p { margin-bottom: 0; white-space: pre-line; }
.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); border: 1px dashed #9aa9bb; }

.occupation-controls {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid #e0af3d;
  background: #fff9e8;
}
.occupation-controls label { display: block; margin-bottom: 5px; font-weight: 800; }
.occupation-controls select { width: 100%; margin-bottom: 10px; }
.action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.action-grid .button { min-height: 48px; }
.occupation-controls > .button--danger { width: 100%; }

.score-section { margin-top: 18px; padding: 20px; border-top: 5px solid var(--public); }
.scoreboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.score-card { padding: 14px; border: 1px solid var(--line); background: #fff; }
.score-card.is-inactive { opacity: .65; background: #f1f5f9; }
.score-card__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.score-card__team { display: flex; align-items: center; gap: 9px; font-weight: 800; }
.score-card__rank { font: 700 .75rem var(--utility); color: var(--muted); }
.score-card__numbers { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 12px; border-top: 1px solid var(--line); }
.score-card__numbers div { padding: 9px 6px 0; text-align: center; border-right: 1px solid var(--line); }
.score-card__numbers div:last-child { border-right: 0; }
.score-card__numbers strong { display: block; font-family: var(--display); font-size: 1.45rem; }
.score-card__numbers span { color: var(--muted); font-size: .72rem; }

.demo-note { margin-top: 18px; padding: 14px 16px; color: #334155; background: #e7edf4; border-left: 4px solid var(--ink); }
.demo-note strong { color: var(--ink); }

.dialog {
  width: min(820px, calc(100% - 28px));
  max-height: calc(100vh - 36px);
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
}
.dialog::backdrop { background: rgba(4, 12, 27, .72); }
.dialog-card { padding: 22px; background: #fff; border-top: 6px solid var(--focus); box-shadow: var(--shadow); }
.dialog-card > label { display: block; margin: 10px 0 5px; font-weight: 800; }
.dialog-card > input { width: 100%; }
.dialog-card > .button--primary { width: 100%; margin-top: 16px; }
.form-error { min-height: 1.5em; margin: 10px 0 0; color: #9f1239; font-weight: 700; }
.team-list { display: grid; gap: 8px; max-height: 46vh; overflow: auto; }
.team-row {
  display: grid;
  grid-template-columns: 44px minmax(120px, 1fr) 90px auto auto;
  gap: 8px;
  align-items: center;
  padding: 9px;
  background: #f8fafc;
  border: 1px solid var(--line);
}
.team-row__id { font: 800 .75rem var(--utility); color: var(--muted); }
.team-row input[type="color"] { width: 48px; height: 42px; padding: 2px; border: 1px solid #9aa9bb; background: #fff; }
.team-add {
  display: grid;
  grid-template-columns: auto minmax(150px, 1fr) auto 64px auto;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.team-add h3 { grid-column: 1 / -1; margin-bottom: 0; }
.team-add input[type="color"] { width: 60px; height: 42px; }
.dialog-note { margin: 14px 0 0; color: var(--muted); font-size: .82rem; }

.toast {
  position: fixed;
  z-index: 120;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100% - 44px));
  padding: 12px 16px;
  color: #fff;
  background: var(--ink);
  border-left: 5px solid var(--focus);
  box-shadow: 0 12px 34px rgba(0,0,0,.28);
}

.setup-shell { width: min(900px, calc(100% - 28px)); margin: 40px auto; padding: clamp(20px,4vw,42px); background: #fff; border-top: 6px solid var(--ordinary); box-shadow: var(--shadow); }
.setup-shell h1 { margin-bottom: 18px; }
.check-list { display: grid; grid-template-columns: repeat(auto-fit,minmax(210px,1fr)); gap: 10px; margin: 22px 0; }
.check-card { padding: 14px; border: 1px solid var(--line); border-left: 5px solid var(--muted); }
.check-card span { float: right; font: 800 .75rem var(--utility); }
.check-card p { clear: both; margin: 10px 0 0; color: var(--muted); }
.check-card.is-pass { border-left-color: #22863a; }.check-card.is-warning { border-left-color: #d99a00; }.check-card.is-fail { border-left-color: #be123c; }
.setup-message { padding: 12px; background: #eef2f7; border-left: 4px solid var(--ink); }
.setup-shell code { font-family: var(--utility); }

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; }
  .board-stage { width: min(100%, 620px); }
  .inspector-panel { min-height: 0; }
}

@media (max-width: 760px) {
  .site-header { align-items: flex-start; flex-direction: column; }
  .mode-switcher { width: 100%; justify-content: space-between; }
  .status-rail { grid-template-columns: repeat(2, 1fr); }
  .status-rail > div:nth-child(2) { border-right: 0; }
  .status-rail > div:nth-child(-n+2) { border-bottom: 1px solid #41516a; }
  .manager-tools .section-heading { align-items: flex-start; flex-direction: column; }
  .tool-actions { justify-content: flex-start; }
  .placement-bar { grid-template-columns: 1fr; }
  .placement-bar p { grid-column: 1; }
  .team-row { grid-template-columns: 40px 1fr 54px; }
  .team-row .button { grid-column: auto; }
  .team-row__state { grid-column: 2; }
  .team-add { grid-template-columns: auto 1fr; }
  .team-add h3, .team-add .button { grid-column: 1 / -1; }
  .password-panel form { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .app-shell { width: calc(100% - 20px); margin-top: 10px; }
  .site-header { padding: 12px 14px; }
  .brand-lockup img { width: 44px; height: 44px; }
  .mode-switcher { align-items: stretch; flex-direction: column; }
  .mode-switcher .button { width: 100%; }
  .admin-warning { padding: 9px 12px; font-size: .82rem; }
  .board-panel, .inspector-panel, .score-section { padding: 12px; }
  .axis--columns { width: calc(100% - 20px); margin-left: 20px; }
  .task-entry { grid-template-columns: 44px 32px 1fr; }
  .task-entry__text { font-size: .78rem; }
  .action-grid { grid-template-columns: 1fr; }
  .scoreboard { grid-template-columns: 1fr; }
  .toast { right: 10px; bottom: 10px; max-width: calc(100% - 20px); }
}

@media (prefers-reduced-motion: no-preference) {
  .bingo-cell, .button, .task-entry { transition: background-color .15s ease, border-color .15s ease, transform .15s ease; }
  .button:active { transform: translateY(1px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .site-header, .manager-tools, .admin-warning, .button, .demo-note { display: none !important; }
  body { background: #fff; }
  .app-shell { width: 100%; margin: 0; }
  .workspace { grid-template-columns: 1fr 1fr; }
  .board-panel, .inspector-panel, .score-section { box-shadow: none; break-inside: avoid; }
}

/* v1.3 · 精修蓝图公开页 */
.button, .icon-button, .segmented button { min-height: 44px; }
.public-v13 { --panel-radius: 12px; }
.public-v13 .status-rail { border-radius: var(--panel-radius); overflow: hidden; box-shadow: 0 12px 30px rgba(11,23,48,.14); }
.public-workspace { grid-template-columns: minmax(560px, 1.25fr) minmax(360px, .75fr); align-items: stretch; gap: 18px; }
.public-v13 .board-panel, .public-v13 .inspector-panel, .public-v13 .score-section { border-radius: var(--panel-radius); box-shadow: 0 14px 38px rgba(11,23,48,.1); }
.public-v13 .inspector-panel { max-height: min(760px, calc(100vh - 180px)); overflow: auto; }
.connection-dot { display: inline-block; width: 9px; height: 9px; margin-right: 8px; border-radius: 50%; background: #60caf3; box-shadow: 0 0 0 4px rgba(96,202,243,.18); }
#connection-state.is-offline .connection-dot { background: #f6a800; box-shadow: 0 0 0 4px rgba(246,168,0,.2); }
.mobile-leader { display: none; margin: 0 0 12px; padding: 9px 12px; color: #fff; background: var(--ink-soft); border-left: 4px solid var(--focus); font-weight: 800; }
.board-stack { position: relative; }
.line-overlay { position: absolute; z-index: 3; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; filter: drop-shadow(0 2px 2px rgba(11,23,48,.25)); }
.scan-line { position: absolute; z-index: 4; top: 0; bottom: 0; left: 0; width: 3px; opacity: 0; pointer-events: none; background: linear-gradient(180deg,transparent,#60caf3,transparent); box-shadow: 0 0 14px #60caf3; }
.owner-codes { position: absolute; z-index: 5; right: 3px; bottom: 3px; display: flex; gap: 2px; pointer-events: none; }
.owner-codes b { min-width: 18px; padding: 1px 3px; color: #fff; background: #0b1730; border: 1px solid #fff; font: 800 clamp(.43rem,1vw,.62rem)/1.25 var(--utility); text-align: center; }
.bingo-cell { position: relative; min-width: 0; min-height: 44px; }
.bingo-cell[aria-selected="true"] { outline: 4px solid var(--focus); outline-offset: -2px; z-index: 6; }
.segmented { display: inline-grid; grid-template-columns: repeat(2,auto); padding: 3px; background: #e7edf4; border: 1px solid #b7c3d2; border-radius: 8px; }
.segmented button { padding: 7px 11px; border: 0; border-radius: 5px; background: transparent; font-weight: 800; }
.segmented button.is-active { color: #fff; background: var(--ink); box-shadow: 0 2px 6px rgba(11,23,48,.24); }
.task-entry { min-height: 48px; }
.task-entry[aria-pressed="true"] { outline: 3px solid var(--focus); outline-offset: -3px; }
.evidence-section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.subheading, .evidence-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.subheading h3 { margin-bottom: 0; }
.evidence-list { display: grid; gap: 12px; margin-top: 12px; }
.evidence-card { padding: 14px; background: #f8fafc; border: 1px solid var(--line); border-left: 4px solid var(--ordinary); border-radius: 8px; }
.evidence-head time { color: var(--muted); font-size: .78rem; }
.evidence-values { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1px; margin-top: 10px; background: var(--line); border: 1px solid var(--line); }
.evidence-values > div { padding: 8px 10px; background: #fff; }
.evidence-values strong, .evidence-values span { display: block; }
.evidence-values span { color: var(--muted); font-size: .75rem; }
.evidence-note { margin: 10px 0 0; white-space: pre-wrap; }
.evidence-gallery { display: grid; grid-template-columns: repeat(auto-fit,minmax(120px,1fr)); gap: 8px; margin-top: 12px; }
.evidence-image { min-height: 44px; color: var(--ink); text-decoration: none; border: 1px solid var(--line); background: #fff; }
.evidence-image img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; background: #e7edf4; }
.evidence-image span { display: block; padding: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .72rem; }
.detail-backdrop { display: none; }
@keyframes board-scan { 0% { left: 0; opacity: 0; } 12% { opacity: .85; } 88% { opacity: .85; } 100% { left: calc(100% - 3px); opacity: 0; } }
@media (prefers-reduced-motion:no-preference) { .scan-line.is-scanning { animation: board-scan .7s ease-out 1; } .line-overlay polyline { animation: line-reveal .45s ease-out 1; } @keyframes line-reveal { from { opacity: 0; } } }

@media (max-width:1080px) {
  .public-workspace { grid-template-columns: minmax(0,1fr); }
  .public-v13 .inspector-panel { max-height: none; }
}
@media (max-width:600px) {
  .public-v13 .status-rail { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .public-v13 .status-rail strong { font-size: .92rem; }
  .mobile-leader { display: block; }
  .public-v13 .board-panel { padding: 12px; }
  .public-v13 .board-heading { align-items: flex-start; }
  .public-v13 .inspector-panel { position: fixed; z-index: 90; left: 0; right: 0; bottom: 0; max-height: min(78vh,720px); padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; transform: translateY(105%); transition: transform .22s ease; overflow: auto; box-shadow: 0 -18px 60px rgba(5,14,30,.32); }
  .public-v13 .inspector-panel.is-open { transform: translateY(0); }
  .public-v13 .inspector-panel:not(.is-open) { position: static; transform: none; max-height: none; border-radius: var(--panel-radius); }
  .public-v13 .inspector-panel:not(.is-open) #overview-view { display: block; }
  .detail-backdrop:not([hidden]) { display: block; position: fixed; z-index: 80; inset: 0; background: rgba(4,12,27,.55); }
  .segmented { width: 100%; grid-template-columns: 1fr 1fr; }
  #overview-view .section-heading { align-items: stretch; flex-direction: column; }
  .owner-codes { right: 1px; bottom: 1px; gap: 1px; }
  .owner-codes b { min-width: 13px; padding: 0 2px; font-size: .43rem; }
}
@media (prefers-reduced-motion:reduce) { .scan-line { display:none; } .public-v13 .inspector-panel { transition:none; } }
