:root {
  color-scheme: light;
  --paper: #f6f0e4;
  --paper-deep: #eee4d1;
  --surface: #fbf7ec;
  --ink: #17191a;
  --muted: #5f5d57;
  --blue: #173b79;
  --blue-soft: #d7deed;
  --ochre: #a87822;
  --red: #a44637;
  --green: #2f6957;
  --rule: rgba(23, 25, 26, 0.22);
  --shadow: rgba(55, 43, 23, 0.13);
  --serif: Georgia, "Times New Roman", serif;
  --sans: "Avenir Next", Avenir, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #171b22;
  --paper-deep: #222834;
  --surface: #202733;
  --ink: #f2ecde;
  --muted: #bbb7ac;
  --blue: #8caeea;
  --blue-soft: #34435f;
  --ochre: #dbb466;
  --red: #e68170;
  --green: #76bca5;
  --rule: rgba(242, 236, 222, 0.2);
  --shadow: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 18% 33%, rgba(94, 72, 32, 0.035) 0 0.65px, transparent 0.8px),
    radial-gradient(circle at 72% 68%, rgba(94, 72, 32, 0.03) 0 0.55px, transparent 0.75px);
  background-size: 7px 9px, 11px 13px;
  font-family: var(--sans);
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  height: 86px;
  padding: 0 clamp(24px, 4vw, 56px);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  flex-direction: column;
  line-height: 0.82;
}

.wordmark > span {
  font-family: var(--serif);
  font-size: 34px;
  letter-spacing: -0.035em;
}

.wordmark small {
  margin: 10px 0 0 2px;
  color: var(--blue);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 26px;
}

.text-button {
  padding: 10px 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
}

.text-button::after {
  content: "";
  display: block;
  width: 0;
  height: 1px;
  margin-top: 3px;
  background: currentColor;
  transition: width 180ms ease;
}

.text-button:hover::after,
.text-button:focus-visible::after {
  width: 100%;
}

.theme-button,
.dialog-close {
  display: grid;
  place-items: center;
  background: transparent;
  cursor: pointer;
}

.theme-button {
  width: 46px;
  height: 46px;
  border: 1px solid var(--blue);
  border-radius: 50%;
  color: var(--blue);
}

.theme-button svg {
  width: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.6;
}

.theme-button:hover {
  color: var(--paper);
  background: var(--blue);
}

.game-shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 44px 0 64px;
}

.intro {
  text-align: center;
}

.intro h1 {
  max-width: 980px;
  margin: 0 auto;
  font-family: var(--serif);
  font-size: clamp(43px, 5vw, 68px);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.045em;
}

.intro p {
  margin: 13px 0 31px;
  color: var(--muted);
  font-size: 18px;
}

.seed-panel {
  min-height: 126px;
  padding: 20px clamp(24px, 3vw, 38px);
  border: 1px solid var(--ochre);
  box-shadow: inset 0 0 0 5px var(--paper), inset 0 0 0 6px color-mix(in srgb, var(--ochre) 65%, transparent);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 30px;
}

.seed-copy h2 {
  margin: 0;
  color: var(--ochre);
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.seed-copy p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.seed-numbers {
  display: flex;
  align-items: center;
  gap: clamp(18px, 3vw, 36px);
  color: var(--blue);
  font-family: var(--serif);
  font-size: clamp(46px, 5vw, 66px);
  line-height: 1;
}

.seed-numbers i {
  width: 7px;
  height: 7px;
  background: var(--ochre);
  rotate: 45deg;
}

.seed-mark {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--green);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.seed-mark svg {
  width: 28px;
  height: 28px;
  padding: 5px;
  border: 1px solid var(--green);
  border-radius: 50%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.workbench {
  margin-top: 26px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(330px, 0.8fr);
  border: 1px solid var(--rule);
  background: color-mix(in srgb, var(--surface) 45%, transparent);
}

.experiment-panel,
.history-panel {
  min-width: 0;
  padding: 30px clamp(24px, 3vw, 38px) 34px;
}

.history-panel {
  border-left: 1px solid var(--rule);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 17px;
}

.section-heading > span {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid var(--ochre);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ochre);
  font-family: var(--serif);
  font-size: 13px;
}

.section-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 29px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

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

.number-inputs {
  margin: 28px 0 22px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 18px;
}

.number-inputs b {
  display: none;
}

.number-inputs label,
.hypothesis-panel form > label {
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.number-inputs label span {
  display: block;
  margin-bottom: 7px;
}

.number-inputs input {
  width: 100%;
  height: 76px;
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--ochre) 55%, var(--rule));
  border-radius: 5px;
  outline: 0;
  background: var(--surface);
  color: var(--blue);
  font-family: var(--serif);
  font-size: 36px;
  text-align: center;
  box-shadow: 2px 3px 0 var(--paper-deep);
}

.number-inputs input:focus,
.hypothesis-entry input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent);
}

.primary-button,
.reset-button {
  min-height: 52px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 150ms ease, background-color 150ms ease, color 150ms ease;
}

.primary-button {
  width: 100%;
  border: 1px solid var(--blue);
  background: var(--blue);
  color: var(--paper);
}

.primary-button svg,
.reset-button svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.primary-button:hover:not(:disabled),
.reset-button:hover {
  transform: translateY(-2px);
}

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

.tip {
  margin-top: 22px;
  padding-top: 17px;
  border-top: 1px dashed color-mix(in srgb, var(--ochre) 65%, transparent);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tip strong {
  color: var(--ochre);
}

.history-list {
  max-height: 286px;
  margin: 25px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-color: var(--blue-soft) transparent;
}

.history-item {
  min-height: 52px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 15px;
}

.history-sequence {
  overflow: hidden;
  color: var(--blue);
  font-family: var(--serif);
  font-size: 21px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.result i {
  width: 20px;
  height: 20px;
  margin-right: 4px;
  border: 1px solid currentColor;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-style: normal;
}

.result.fits {
  color: var(--green);
}

.result.does-not-fit {
  color: var(--red);
}

.history-item small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.history-empty {
  margin: 20px 0 0;
  color: var(--muted);
  font-family: var(--serif);
  font-style: italic;
  text-align: center;
}

.new-item {
  animation: draw-in 260ms ease-out both;
}

.hypothesis-panel {
  margin-top: 26px;
  padding: 30px clamp(24px, 3vw, 38px) 34px;
  border: 1px solid var(--rule);
}

.hypothesis-panel form {
  margin: 26px 0 0 51px;
}

.hypothesis-panel form > label {
  display: block;
  margin-bottom: 8px;
}

.hypothesis-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 0.3fr);
  gap: 14px;
}

.hypothesis-entry input {
  min-width: 0;
  height: 54px;
  padding: 0 17px;
  border: 1px solid color-mix(in srgb, var(--ochre) 55%, var(--rule));
  border-radius: 5px;
  outline: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
}

.hypothesis-entry input::placeholder {
  color: color-mix(in srgb, var(--muted) 68%, transparent);
}

.form-error {
  margin: 9px 0 0;
  color: var(--red);
  font-size: 13px;
}

.reveal-panel {
  margin-top: 26px;
  padding: clamp(30px, 4vw, 50px);
  border: 1px solid var(--ochre);
  background: color-mix(in srgb, var(--surface) 62%, transparent);
  box-shadow: inset 0 0 0 5px var(--paper), inset 0 0 0 6px color-mix(in srgb, var(--ochre) 65%, transparent);
  outline: 0;
}

.reveal-rule {
  max-width: 870px;
}

.reveal-rule > p:first-child {
  margin: 0 0 10px;
  color: var(--ochre);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.reveal-rule h2 {
  margin: 0;
  color: var(--blue);
  font-family: var(--serif);
  font-size: clamp(33px, 4.3vw, 53px);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

#guess-response {
  margin: 17px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.bias-explanation {
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 0.7fr 1fr 1fr;
  gap: clamp(20px, 3vw, 38px);
}

.bias-explanation h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
  line-height: 1.2;
}

.bias-explanation p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.62;
}

.bias-explanation strong {
  color: var(--blue);
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 400;
}

.reset-button {
  margin-top: 30px;
  padding: 0 24px;
  border: 1px solid var(--blue);
  background: transparent;
  color: var(--blue);
}

.reset-button:hover {
  background: var(--blue);
  color: var(--paper);
}

.guide-dialog {
  width: min(600px, calc(100% - 32px));
  padding: 44px;
  border: 1px solid var(--ochre);
  border-radius: 2px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
}

.guide-dialog::backdrop {
  background: rgba(15, 18, 22, 0.58);
  backdrop-filter: blur(3px);
}

.dialog-close {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 38px;
  height: 38px;
  border: 0;
  color: var(--blue);
}

.dialog-close svg {
  width: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

.dialog-number {
  margin: 0 0 24px;
  color: var(--ochre);
  font-family: var(--serif);
  font-size: 20px;
}

.guide-dialog h2 {
  margin: 0;
  max-width: 500px;
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.035em;
}

.guide-dialog > p:not(.dialog-number) {
  margin: 20px 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.guide-example {
  padding: 18px 0;
  border-block: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--blue);
  font-size: 14px;
}

.guide-example b {
  color: var(--ochre);
}

.dialog-button {
  margin-top: 26px;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 55%, transparent);
  outline-offset: 3px;
}

@keyframes draw-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

@media (max-width: 860px) {
  .game-shell {
    width: min(700px, calc(100% - 32px));
  }

  .seed-panel {
    grid-template-columns: 1fr auto;
  }

  .seed-numbers {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
  }

  .seed-mark {
    grid-column: 2;
    grid-row: 1;
  }

  .workbench {
    grid-template-columns: 1fr;
  }

  .history-panel {
    border-top: 1px solid var(--rule);
    border-left: 0;
  }

  .history-list {
    max-height: 240px;
  }

  .bias-explanation {
    grid-template-columns: 1fr 1fr;
  }

  .bias-explanation h3 {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  .site-header {
    height: 72px;
    padding-inline: 18px;
  }

  .wordmark > span {
    font-size: 28px;
  }

  .wordmark small {
    max-width: 112px;
    font-size: 7px;
    letter-spacing: 0.17em;
  }

  .header-actions {
    gap: 13px;
  }

  .text-button {
    font-size: 13px;
  }

  .guide-trigger {
    display: none;
  }

  .theme-button {
    width: 40px;
    height: 40px;
  }

  .game-shell {
    width: calc(100% - 28px);
    padding-top: 29px;
  }

  .intro h1 {
    font-size: 39px;
  }

  .intro p {
    margin: 11px 12px 24px;
    font-size: 16px;
    line-height: 1.45;
  }

  .seed-panel {
    padding: 20px;
    gap: 18px;
  }

  .seed-copy p {
    display: none;
  }

  .seed-mark {
    font-size: 12px;
  }

  .seed-mark svg {
    width: 24px;
    height: 24px;
  }

  .seed-numbers {
    gap: 24px;
    font-size: 50px;
  }

  .experiment-panel,
  .history-panel,
  .hypothesis-panel {
    padding: 24px 20px 27px;
  }

  .section-heading h2 {
    font-size: 26px;
  }

  .section-heading p {
    font-size: 13px;
  }

  .number-inputs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .number-inputs label span {
    height: 22px;
    font-size: 9px;
    line-height: 1.15;
  }

  .number-inputs input {
    height: 68px;
    padding-inline: 5px;
    font-size: 29px;
  }

  .history-sequence {
    font-size: 19px;
  }

  .hypothesis-panel form {
    margin-left: 0;
  }

  .hypothesis-entry {
    grid-template-columns: 1fr;
  }

  .bias-explanation {
    grid-template-columns: 1fr;
  }

  .bias-explanation h3 {
    grid-column: auto;
  }

  .reveal-panel {
    padding: 30px 24px;
  }

  .reset-button {
    width: 100%;
  }

  .guide-dialog {
    padding: 38px 24px 26px;
  }

  .guide-dialog h2 {
    font-size: 34px;
  }
}

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