:root {
  color-scheme: light;
  --ink: #191817;
  --muted: #6c665c;
  --paper: #f6f1e7;
  --panel: #fffaf0;
  --line: #25221d;
  --soft-line: #d9d0bf;
  --green: #1f8a5b;
  --green-dark: #0f5c3b;
  --amber: #df9b24;
  --red: #c94732;
  --cyan: #0b7a8f;
  --shadow: 0 18px 50px rgba(25, 24, 23, 0.12);
  --mono: "SFMono-Regular", "Cascadia Code", "Liberation Mono", Menlo, monospace;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Avenir Next, "Helvetica Neue", Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(90deg, rgba(25, 24, 23, 0.04) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(rgba(25, 24, 23, 0.035) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  letter-spacing: 0;
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1420px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 22px 0 30px;
}

.command-panel,
.history-panel,
.simulation-panel {
  border: 2px solid var(--line);
  background: rgba(255, 250, 240, 0.94);
  box-shadow: var(--shadow);
}

.command-panel {
  padding: 18px;
}

.topbar,
.status-strip,
.play-surface,
.lower-grid,
.action-row,
.sim-actions,
.state-board {
  display: grid;
  gap: 14px;
}

.topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  border-bottom: 2px solid var(--line);
  padding-bottom: 16px;
}

.eyebrow,
.section-kicker,
.metric-label {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
  color: var(--muted);
}

h1,
h2 {
  margin: 0;
  line-height: 1;
}

h1 {
  margin-top: 6px;
  font-family: var(--serif);
  font-size: clamp(34px, 6vw, 74px);
  font-weight: 700;
}

h2 {
  margin-top: 5px;
  font-size: 19px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 2px solid var(--line);
  background: var(--line);
  min-width: 240px;
}

.mode-button {
  border: 0;
  padding: 11px 14px;
  background: var(--panel);
  color: var(--line);
  font-weight: 700;
}

.mode-button + .mode-button {
  border-left: 2px solid var(--line);
}

.mode-button.active {
  background: var(--green);
  color: white;
}

.status-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 16px;
}

.status-strip > div {
  min-width: 0;
  border: 1px solid var(--soft-line);
  background: #fffdf6;
  padding: 12px;
}

.status-strip strong {
  display: block;
  margin-top: 5px;
  font-family: var(--mono);
  font-size: clamp(18px, 2.8vw, 28px);
  white-space: nowrap;
}

.play-surface {
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.9fr);
  margin-top: 18px;
  align-items: start;
}

.recommendation-zone,
.side-panel,
.panel-block,
.history-panel,
.simulation-panel {
  min-width: 0;
}

.recommendation-zone {
  padding: 18px;
  border: 2px solid var(--line);
  background: #fffdf7;
}

.side-panel {
  display: grid;
  gap: 14px;
}

.panel-block {
  border: 1px solid var(--soft-line);
  background: #fffdf7;
  padding: 14px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
}

.section-header.compact {
  align-items: baseline;
}

.primary-guess {
  display: grid;
  grid-template-columns: repeat(4, minmax(54px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.digit-cell {
  display: grid;
  place-items: center;
  min-height: clamp(78px, 13vw, 128px);
  border: 2px solid var(--line);
  background:
    linear-gradient(135deg, rgba(31, 138, 91, 0.12), rgba(223, 155, 36, 0.1)),
    var(--panel);
  font-family: var(--mono);
  font-size: clamp(36px, 8vw, 76px);
  font-weight: 800;
  line-height: 1;
  box-shadow: inset 0 -8px 0 rgba(25, 24, 23, 0.08);
}

.digit-cell.skeleton {
  color: var(--muted);
}

.reason-line {
  min-height: 42px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.split-bars {
  display: grid;
  gap: 8px;
  margin: 16px 0 18px;
}

.split-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 58px;
  gap: 8px;
  align-items: center;
  font-family: var(--mono);
  font-size: 12px;
}

.split-track {
  height: 12px;
  border: 1px solid var(--line);
  background: #efe5d1;
}

.split-fill {
  height: 100%;
  background: var(--green);
}

.state-board {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 16px 0 18px;
}

.state-board > div {
  min-width: 0;
  border: 1px solid var(--soft-line);
  background: #fffaf0;
  padding: 10px;
}

.state-board strong {
  display: block;
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 18px;
  white-space: nowrap;
}

.feedback-form {
  display: grid;
  gap: 14px;
  border-top: 2px solid var(--line);
  padding-top: 16px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 800;
}

.digit-editors {
  display: grid;
  grid-template-columns: repeat(4, minmax(54px, 80px));
  gap: 10px;
}

.digit-select {
  width: 100%;
  height: 46px;
  border: 2px solid var(--line);
  background: white;
  color: var(--line);
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 800;
  text-align: center;
}

.score-buttons {
  display: grid;
  grid-template-columns: repeat(5, minmax(44px, 72px));
  gap: 8px;
}

.score-button,
.primary-action,
.secondary-action,
.use-alt {
  min-height: 42px;
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--line);
  font-weight: 800;
}

.score-button.selected {
  background: var(--amber);
}

.primary-action {
  background: var(--green);
  color: white;
}

.primary-action:disabled,
.secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.action-row {
  grid-template-columns: minmax(160px, 1fr) auto auto;
  align-items: center;
}

.alternate-list,
.candidate-list,
.history-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.alt-card,
.candidate-row,
.history-row {
  display: grid;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--soft-line);
  background: #fffaf0;
  padding: 9px;
}

.alt-card {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.candidate-row,
.history-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.mini-code {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 900;
  white-space: nowrap;
}

.meta-text {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.use-alt {
  min-height: 34px;
  padding: 0 10px;
  background: white;
}

.comparison-copy {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.comparison-copy p {
  margin: 0;
  border: 1px solid var(--soft-line);
  background: #fffaf0;
  padding: 11px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.comparison-copy strong {
  color: var(--line);
}

.lower-grid {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
  margin-top: 18px;
}

.history-panel,
.simulation-panel {
  padding: 14px;
}

.history-list:empty::before {
  content: "暂无记录";
  color: var(--muted);
}

.sim-actions {
  grid-template-columns: 1fr 1fr;
  margin-top: 12px;
}

.simulation-output {
  min-height: 68px;
  margin-top: 12px;
  border: 1px solid var(--soft-line);
  background: #fffdf7;
  padding: 12px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.notice-bad {
  color: var(--red);
}

.notice-good {
  color: var(--green-dark);
}

@media (max-width: 920px) {
  .topbar,
  .play-surface,
  .lower-grid {
    grid-template-columns: 1fr;
  }

  .mode-switch {
    min-width: 0;
  }

  .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .state-board {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100vw - 16px, 1420px);
    padding-top: 8px;
  }

  .command-panel,
  .recommendation-zone,
  .history-panel,
  .simulation-panel {
    padding: 10px;
  }

  .primary-guess {
    gap: 7px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .digit-cell {
    min-height: 70px;
    font-size: 34px;
  }

  .digit-editors,
  .score-buttons {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .score-buttons .score-button:last-child {
    grid-column: span 4;
  }

  .action-row,
  .sim-actions {
    grid-template-columns: 1fr;
  }

  .alt-card,
  .candidate-row,
  .history-row {
    grid-template-columns: 1fr;
  }
}
