:root {
  color-scheme: light;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --blue: #0071e3;
  --surface: #f5f5f7;
  --line: #d2d2d7;
  --small: 14px;
  --body: 17px;
  --heading: 32px;
  --display: 64px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 32px; }
body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
p, h1, h2, h3 { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
a, button, summary, input { touch-action: manipulation; }
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 5px;
}
.content-width { width: min(980px, calc(100% - 64px)); margin-inline: auto; }
.skip-link { position: absolute; top: -100px; left: 24px; padding: 12px; background: #fff; z-index: 2; }
.skip-link:focus { top: 12px; }

.site-header {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}
.wordmark { font-weight: 600; letter-spacing: -.02em; }
.site-header nav { display: flex; gap: 28px; font-size: var(--small); }
.site-header nav a:hover { color: var(--blue); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 24px;
  border: 0;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: var(--small);
  white-space: nowrap;
}
.button:hover:not(:disabled) { filter: brightness(1.08); }
.button:disabled { background: var(--surface); color: var(--muted); }
.text-link { color: var(--blue); display: inline-flex; align-items: center; gap: 7px; }
.text-link:hover { text-decoration: underline; text-underline-offset: 3px; }

input { font: inherit; color: var(--ink); }
input[type="number"] { appearance: textfield; }
input::-webkit-inner-spin-button, input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.generator-section { background: var(--surface); padding-block: 36px 28px; }
.generator-section h1 { text-align: center; font-size: var(--heading); font-weight: 600; letter-spacing: -.025em; line-height: 1.15; }
.playground { max-width: 800px; margin: 24px auto 0; }
.game-card { padding: 24px 32px; background: #fff; border-radius: 24px; }
.game-toolbar { display: flex; justify-content: space-between; gap: 16px; font-size: var(--small); }
#score-label, .output-meta { color: var(--muted); }
.output-meta { font-size: var(--small); margin-top: 4px; }
.game-stage { display: grid; align-items: center; min-height: 220px; text-align: center; padding-block: 16px; }
.game-stage h3, .operation-text { font-size: var(--heading); line-height: 1.2; font-weight: 600; letter-spacing: -.025em; }
#ready-stage h3 { font-size: var(--body); letter-spacing: 0; }
.starting-points { display: flex; justify-content: center; gap: 16px; margin: 16px auto 12px; }
.starting-points > div { display: grid; gap: 4px; background: var(--surface); border-radius: 14px; padding: 12px 20px; min-width: 100px; }
.starting-points span { font-size: var(--small); color: var(--muted); }
.starting-points strong { font-size: var(--heading); line-height: 1.2; font-weight: 600; font-variant-numeric: tabular-nums; }
.stage-note { font-size: var(--small); color: var(--muted); }
.operation-text { margin: 20px auto 24px; max-width: 600px; }
progress { appearance: none; width: 200px; max-width: 100%; height: 4px; border: 0; border-radius: 2px; overflow: hidden; background: var(--surface); color: var(--blue); }
progress::-webkit-progress-bar { background: var(--surface); }
progress::-webkit-progress-value { background: var(--blue); }
progress::-moz-progress-bar { background: var(--blue); }
.result-answer { font-size: var(--display); line-height: 1.2; font-weight: 600; margin: 12px 0; font-variant-numeric: tabular-nums; }
.game-actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 20px; }
.game-actions .button { min-width: 136px; }
.answer-form { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 12px 20px; }
input { width: 100%; min-width: 0; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 8px 12px; font-size: var(--body); }
#player-answer { width: 150px; text-align: center; }
.text-button { background: none; border: 0; color: var(--blue); padding: 10px 0; min-height: 44px; font-size: var(--small); text-align: left; }
.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
summary { cursor: pointer; }
.solution { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); font-size: var(--small); }
.solution summary { color: var(--blue); }
.solution-tools { display: flex; gap: 24px; margin-block: 8px; }
#generated-prompt { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 300px; overflow-y: auto; overscroll-behavior: contain; margin: 0; padding-right: 12px; font: inherit; line-height: 1.6; }
.trace-scroll { max-height: 280px; overflow: auto; margin-top: 24px; overscroll-behavior: contain; }
.solution table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; text-align: right; }
.solution th, .solution td { padding: 7px 5px; border-bottom: 1px solid var(--line); }
.solution th { font-weight: 400; color: var(--muted); }
.solution th:first-child { text-align: left; }
.solution thead { position: sticky; top: 0; background: #fff; }
.target-state { color: var(--blue); }
.game-settings { margin-top: 20px; font-size: var(--small); }
.game-settings summary { color: var(--muted); }
.settings-form, #batch-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 12px 20px; align-items: end; }
.settings-form { margin-top: 20px; }
.settings-form label, .batch-form label { display: grid; gap: 8px; font-size: var(--small); }
.field-hint { grid-column: 1 / -1; color: var(--muted); font-size: var(--small); }
.batch-export { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 24px; }
.summary-note { color: var(--muted); font-size: var(--small); margin-left: 16px; }
.batch-form { margin-top: 24px; }
#batch-fields { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; border: 0; padding: 0; margin: 0 0 12px; }
.batch-progress { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.action-status { font-size: var(--small); margin-top: 16px; color: var(--muted); }
.action-status:empty { display: none; }
.generator-note { color: var(--muted); font-size: var(--small); text-align: center; margin: 28px auto 0; max-width: 800px; }
.generator-note a { color: var(--blue); white-space: nowrap; }
.generator-note a:hover { text-decoration: underline; text-underline-offset: 3px; }
.noscript-note { text-align: center; margin-top: 24px; font-size: var(--small); }

.project-summary { text-align: center; padding-block: 28px; }
.project-summary h2 { font-size: var(--body); font-weight: 600; }
.project-summary p { color: var(--muted); font-size: var(--small); margin-block: 8px 12px; }
.project-summary .text-link { font-size: var(--small); }
.site-footer { padding-block: 24px 32px; border-top: 1px solid var(--line); color: var(--muted); font-size: var(--small); }
.site-footer a { text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 760px) {
  :root { --display: 48px; --heading: 28px; }
  #batch-fields { grid-template-columns: 1fr 1fr; }
  #batch-fields .button { justify-self: start; }
}

@media (max-width: 480px) {
  :root { --display: 40px; }
  .content-width { width: calc(100% - 40px); }
  .site-header nav { gap: 20px; }
  .generator-section { padding-block: 20px 24px; }
  .playground { margin-top: 20px; }
  .game-card { padding: 16px 20px 20px; border-radius: 20px; }
  .game-stage { min-height: 200px; }
  .starting-points { gap: 8px; }
  .starting-points > div { min-width: 0; flex: 1; padding: 12px 8px; }
  .answer-form .text-button { flex-basis: 100%; text-align: center; }
  .settings-form { grid-template-columns: 1fr 1fr; }
  .settings-form .button { justify-self: start; }
  .summary-note { display: block; margin: 4px 0 0 18px; }
}

@media (max-width: 350px) {
  :root { --display: 36px; }
  .game-card { padding-inline: 16px; }
  .game-toolbar { gap: 8px; }
  .button { padding-inline: 20px; }
  #batch-fields { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
