:root {
  color-scheme: light dark;
  --paper: #f3f0e8;
  --ink: #171815;
  --muted: #6c6b63;
  --line: #c9c5b9;
  --soft: #e9e5db;
  --accent: #5b6948;
  --danger: #835047;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 50% -20%, rgba(255, 255, 255, 0.72), transparent 45%),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

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

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.shell {
  width: min(100% - 36px, 600px);
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 27px 0 18px;
  border-bottom: 1px solid var(--line);
}

.wordmark,
.text-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.wordmark b {
  color: var(--accent);
}

.mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 0.7rem;
  letter-spacing: 0;
}

.text-button,
footer,
footer a {
  color: var(--muted);
  font-size: 0.8rem;
}

.text-button:hover,
footer a:hover {
  color: var(--ink);
}

#app {
  flex: 1;
  padding: clamp(38px, 8vh, 76px) 0 54px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--muted);
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 520px;
  margin-bottom: 13px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 9vw, 4.7rem);
  font-weight: 400;
  letter-spacing: -0.05em;
  line-height: 0.98;
}

h2 {
  margin-bottom: 8px;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.lede {
  max-width: 440px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.scoreboard {
  display: flex;
  gap: clamp(28px, 10vw, 64px);
  margin: 36px 0 48px;
}

.stat strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.stat span {
  color: var(--muted);
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.section-label {
  margin: 36px 0 10px;
  color: var(--muted);
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 21px 0;
  border-top: 1px solid var(--line);
}

.card:last-child {
  border-bottom: 1px solid var(--line);
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.card .available {
  color: var(--accent);
  font-weight: 650;
}

.button {
  min-height: 46px;
  border: 1px solid var(--ink);
  padding: 0 20px;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: transform 120ms ease, background 120ms ease, color 120ms ease;
}

.button:hover {
  transform: translateY(-1px);
  background: transparent;
  color: var(--ink);
}

.button.secondary {
  background: transparent;
  color: var(--ink);
}

.button.secondary:hover {
  background: var(--ink);
  color: var(--paper);
}

.center-view {
  min-height: 56vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.memory-number {
  margin: clamp(26px, 7vh, 54px) 0 18px;
  font-family: "Courier New", ui-monospace, monospace;
  font-size: clamp(2rem, 10vw, 4.3rem);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.07em;
  line-height: 1.1;
  white-space: nowrap;
}

.countdown {
  margin: 0 0 34px;
  color: var(--accent);
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.instructions {
  max-width: 410px;
  margin: 0 auto;
  color: var(--muted);
  line-height: 1.65;
}

.honesty {
  max-width: 390px;
  margin: 34px auto 0;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

.wait-time {
  margin: 26px 0 33px;
  font-family: "Courier New", ui-monospace, monospace;
  font-size: clamp(2.1rem, 11vw, 4.2rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.recall-form {
  width: 100%;
  max-width: 500px;
  margin-top: 46px;
}

.recall-form label {
  display: block;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.84rem;
}

.recall-input {
  width: 100%;
  border: 0;
  border-bottom: 2px solid var(--ink);
  border-radius: 0;
  padding: 12px 4px 15px;
  background: transparent;
  color: var(--ink);
  text-align: center;
  font-family: "Courier New", ui-monospace, monospace;
  font-size: clamp(1.65rem, 8vw, 3.2rem);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.recall-input::placeholder {
  color: var(--line);
  opacity: 1;
}

.form-actions {
  margin-top: 28px;
}

.input-note,
.form-error {
  min-height: 1.3em;
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.form-error {
  color: var(--danger);
}

.result-symbol {
  margin: 22px 0 7px;
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(4rem, 18vw, 7rem);
  line-height: 1;
}

.result-symbol.missed {
  color: var(--danger);
}

.result-view .button {
  margin-top: 32px;
}

.perfect {
  text-shadow: 0 0 35px rgba(91, 105, 72, 0.25);
  animation: arrive 800ms ease-out both;
}

.perfect .memory-number {
  color: var(--accent);
}

.history-list {
  margin-top: 38px;
  border-top: 1px solid var(--line);
}

.history-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 17px 4px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.history-row:hover {
  background: var(--soft);
}

.history-row span:last-child {
  color: var(--muted);
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 0.78rem;
}

.recall-records {
  width: min(100%, 390px);
  margin: 30px auto;
  border-top: 1px solid var(--line);
}

.record {
  display: flex;
  justify-content: space-between;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
}

.record span:last-child {
  font-family: "Courier New", ui-monospace, monospace;
  font-weight: 700;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 0 25px;
  border-top: 1px solid var(--line);
}

footer a {
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

@keyframes arrive {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
  .shell {
    width: min(100% - 28px, 600px);
  }

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

  .card .button {
    width: 100%;
  }

  .scoreboard {
    margin-bottom: 38px;
  }

  .memory-number {
    font-size: clamp(1.8rem, 9vw, 2.8rem);
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171814;
    --ink: #efede5;
    --muted: #a5a49c;
    --line: #44453e;
    --soft: #22231e;
    --accent: #b7c39a;
    --danger: #d39a8e;
  }

  body {
    background:
      radial-gradient(circle at 50% -20%, rgba(255, 255, 255, 0.05), transparent 45%),
      var(--paper);
  }
}

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