/* codex: 2026-02-13 新增 chesshorse 样式：自适应棋盘/访问态变色/春节横幅/弹窗与记录卡 */
:root {
  --bg: #0b1020;
  --fg: #e8eaf1;
  --muted: #a8aec6;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-strong: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.14);
  --accent: #7c5cff;
  --good: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --board-max: 560px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7fb;
    --fg: #0b1020;
    --muted: #4b5563;
    --panel: rgba(0, 0, 0, 0.045);
    --panel-strong: rgba(0, 0, 0, 0.075);
    --border: rgba(0, 0, 0, 0.16);
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto,
    Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: radial-gradient(1200px 600px at 20% 10%, rgba(124, 92, 255, 0.25), transparent 50%),
    radial-gradient(900px 600px at 80% 0%, rgba(34, 197, 94, 0.18), transparent 60%),
    var(--bg);
  color: var(--fg);
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 14px 28px;
}

.spring-banner {
  border: 1px solid rgba(239, 68, 68, 0.45);
  background: linear-gradient(90deg, rgba(185, 28, 28, 0.95), rgba(220, 38, 38, 0.92));
  color: #fff7ed;
  border-radius: calc(var(--radius) + 8px);
  padding: 10px 12px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.spring-banner-text {
  font-weight: 800;
  letter-spacing: 0.6px;
  font-size: 14px;
}

.spring-banner-decor {
  font-size: 18px;
  line-height: 1;
}

.spring-banner + .header {
  margin-top: 14px;
}

.header {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 860px) {
  .header {
    grid-template-columns: 1fr auto;
    align-items: start;
    gap: 18px;
  }
}

.title {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.3px;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 14px;
}

.header-right {
  display: grid;
  gap: 10px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (min-width: 860px) {
  .stats {
    width: 360px;
  }
}

.stat {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
}

.stat-value {
  font-size: 20px;
  font-weight: 800;
  margin-top: 4px;
}

.header-actions {
  display: grid;
  gap: 10px;
}

.btn-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 640px) {
  .btn-row {
    grid-template-columns: repeat(6, 1fr);
  }
}

.field {
  display: grid;
  gap: 6px;
}

.field-inline {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
}

.field-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.2px;
}

.field-input {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
  border-radius: 14px;
  padding: 10px 10px;
  font-size: 14px;
}

select.field-input {
  padding-right: 28px;
}

.btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
  border-radius: 14px;
  padding: 10px 10px;
  font-size: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.07);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.primary {
  border-color: rgba(124, 92, 255, 0.65);
  background: rgba(124, 92, 255, 0.22);
}

.board-wrap {
  margin-top: 16px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: calc(var(--radius) + 6px);
  padding: 14px;
  box-shadow: var(--shadow);
}

.legend {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

@media (min-width: 720px) {
  .legend {
    grid-template-columns: repeat(3, 1fr);
  }
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.legend-icon {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg);
  flex: 0 0 auto;
  font-size: 14px;
}

.legend-icon.visited {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.75), rgba(245, 158, 11, 0.6));
  border-color: rgba(239, 68, 68, 0.45);
}

.legend-icon.target {
  background: rgba(34, 197, 94, 0.22);
  border-color: rgba(34, 197, 94, 0.65);
}

.board {
  --board-size: 4;
  width: min(94vw, var(--board-max));
  max-width: 100%;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(var(--board-size), 1fr);
  grid-template-rows: repeat(var(--board-size), 1fr);
  gap: 8px;
  touch-action: manipulation;
}

.cell {
  border: 1px solid var(--border);
  background: var(--panel-strong);
  border-radius: 14px;
  display: grid;
  place-items: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  position: relative;
  padding: 0;
  min-height: 44px;
  overflow: hidden;
}

.cell:focus-visible {
  outline: 3px solid rgba(124, 92, 255, 0.75);
  outline-offset: 3px;
}

.cell[data-color="dark"] {
  background: rgba(0, 0, 0, 0.16);
}

.cell.visited {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.55), rgba(245, 158, 11, 0.35));
  border-color: rgba(239, 68, 68, 0.42);
}

.cell.move-target {
  border-color: rgba(34, 197, 94, 0.95);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.cell.move-target::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 12px;
  background: radial-gradient(circle, rgba(34, 197, 94, 0.22), transparent 60%);
  pointer-events: none;
}

.cell.current {
  border-color: rgba(124, 92, 255, 0.9);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.2);
}

.cell-start-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 11px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(124, 92, 255, 0.55);
  border: 1px solid rgba(124, 92, 255, 0.55);
  border-radius: 10px;
  padding: 2px 6px;
}

.cell-step {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-size: 12px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.92);
  opacity: 0.9;
  text-shadow: 0 10px 18px rgba(0, 0, 0, 0.35);
}

.cell-content {
  font-size: 22px;
  line-height: 1;
}

.help {
  margin-top: 12px;
  text-align: center;
  color: var(--muted);
  min-height: 22px;
  font-size: 13px;
}

.records {
  margin-top: 12px;
}

.record-card {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.035);
  border-radius: calc(var(--radius) + 6px);
  padding: 12px;
}

.record-title {
  font-weight: 800;
  letter-spacing: 0.2px;
  font-size: 14px;
}

.record-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 860px) {
  .record-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.record-item {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 14px;
  padding: 10px 10px;
}

.record-label {
  font-size: 12px;
  color: var(--muted);
}

.record-value {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 800;
}

.record-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.firework {
  position: absolute;
  will-change: transform, opacity, filter;
  font-size: 18px;
  line-height: 1;
  transform: translate(-50%, -50%) rotate(var(--fw-rot, 0deg)) scale(0.6);
  opacity: 0;
  animation-name: firework-pop;
  animation-timing-function: ease-out;
  animation-fill-mode: forwards;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.35));
}

@keyframes firework-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--fw-rot, 0deg)) scale(0.6);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -60%) rotate(calc(var(--fw-rot, 0deg) + 20deg)) scale(1.25);
  }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.55);
}

.modal {
  width: min(620px, 96vw);
  border: 1px solid var(--border);
  background: rgba(10, 14, 28, 0.95);
  color: var(--fg);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 16px 16px 14px;
}

@media (prefers-color-scheme: light) {
  .modal {
    background: rgba(255, 255, 255, 0.96);
  }
}

.modal-title {
  margin: 0;
  font-size: 20px;
}

.modal-body {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.rule-list {
  margin: 10px 0 0;
  padding-left: 18px;
}

.rule-list li {
  margin: 6px 0;
}

.rule-ops {
  margin: 10px 0 0;
}

.answer-block {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 14px;
  padding: 10px 10px;
}

.answer-block + .answer-block {
  margin-top: 10px;
}

.answer-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
}

.answer-value {
  font-size: 16px;
  font-weight: 900;
  color: var(--fg);
}

.answer-hint {
  margin-top: 10px;
  font-size: 13px;
}

.modal-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

@media (prefers-reduced-motion: reduce) {
  .btn:active {
    transform: none;
  }
}

