:root {
  color-scheme: light;
  --paper: #f7f6f2;
  --ink: #11110f;
  --muted: #6c6a63;
  --line: #cfcdc5;
  --soft: #e9e7df;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

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

.game-shell {
  position: relative;
  display: grid;
  width: min(100%, 780px);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: 88px 28px 68px;
  place-items: center;
}

.masthead {
  position: absolute;
  top: 27px;
  left: 28px;
  right: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.back-link,
.score {
  margin: 0;
  color: var(--ink);
}

.back-link {
  text-decoration: none;
  text-underline-offset: 4px;
}

.back-link:hover {
  text-decoration: underline;
}

.screen {
  width: 100%;
  text-align: center;
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(4.4rem, 15vw, 8.5rem);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 0.82;
}

.intro {
  max-width: 530px;
  margin: 28px auto 36px;
  color: var(--muted);
  font-size: clamp(0.94rem, 2vw, 1.03rem);
  line-height: 1.65;
}

form {
  width: min(100%, 650px);
  margin: 0 auto;
}

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

legend {
  width: 100%;
  margin-bottom: 12px;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.35rem;
}

.choice-grid {
  display: grid;
  gap: 7px;
}

.time-grid {
  grid-template-columns: repeat(6, 1fr);
}

.difficulty-grid {
  grid-template-columns: repeat(3, 1fr);
}

.choice-grid label {
  position: relative;
  min-width: 0;
  cursor: pointer;
}

.choice-grid input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.choice-grid span {
  display: flex;
  min-height: 58px;
  padding: 10px 7px;
  border: 1px solid var(--line);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.choice-grid b {
  overflow: hidden;
  max-width: 100%;
  font-size: 0.82rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.choice-grid small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.choice-grid label:hover span {
  border-color: var(--ink);
}

.choice-grid input:checked + span {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.choice-grid input:checked + span small {
  color: #cac8c0;
}

.choice-grid input:focus-visible + span {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.primary-button,
.text-button {
  border: 0;
  cursor: pointer;
}

.primary-button {
  min-width: 250px;
  min-height: 54px;
  padding: 15px 28px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: transform 140ms ease, opacity 140ms ease;
}

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

.primary-button:active:not(:disabled) {
  transform: translateY(0);
}

.primary-button:focus-visible,
.text-button:focus-visible,
.back-link:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

.primary-button:disabled {
  cursor: default;
  opacity: 0.3;
}

.text-button {
  display: block;
  margin: 19px auto 0;
  padding: 6px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
}

.text-button:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.fine-print,
.storage-note {
  color: var(--muted);
  font-size: 0.66rem;
  letter-spacing: 0.03em;
}

.fine-print {
  margin: 18px 0 0;
}

.storage-note {
  position: absolute;
  right: 28px;
  bottom: 22px;
  left: 28px;
  margin: 0;
  text-align: center;
}

.appointment-time {
  font-size: clamp(5rem, 19vw, 10.5rem);
  font-variant-numeric: tabular-nums;
}

.success-message {
  width: min(100%, 520px);
  margin: 0 auto clamp(34px, 6vh, 54px);
  padding: 18px 22px;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

.success-message .eyebrow {
  margin-bottom: 6px;
}

.success-message > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.success-message strong {
  color: var(--ink);
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.35rem;
  font-weight: 400;
}

.appointment-date {
  margin: 18px 0 0;
  color: var(--muted);
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(1.3rem, 4vw, 1.8rem);
}

.countdown-wrap {
  margin: clamp(42px, 8vh, 72px) auto 30px;
}

.countdown-label {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.countdown {
  margin: 0;
  font-size: clamp(1.45rem, 5vw, 2.2rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.07em;
}

.instruction {
  width: min(100%, 420px);
  min-height: 48px;
  margin: 0 auto 24px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.is-open .appointment-time,
.is-open .appointment-date {
  font-style: italic;
}

.is-open .primary-button {
  animation: quiet-pulse 1.8s ease-in-out infinite;
}

.result-score {
  margin: 28px 0 0;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(2rem, 7vw, 3.5rem);
}

@keyframes quiet-pulse {
  50% {
    opacity: 0.72;
  }
}

@media (max-width: 620px) {
  .game-shell {
    padding: 82px 18px 58px;
  }

  .masthead {
    top: 22px;
    right: 18px;
    left: 18px;
  }

  .time-grid {
    grid-template-columns: repeat(3, 1fr);
  }

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

  .difficulty-grid span {
    min-height: 47px;
    flex-direction: row;
    gap: 8px;
  }

  .difficulty-grid small {
    margin: 0;
  }

  .storage-note {
    right: 18px;
    bottom: 16px;
    left: 18px;
  }
}

@media (max-height: 760px) {
  .game-shell {
    display: block;
    align-items: start;
  }

  .screen {
    margin-top: 12px;
  }

  .intro {
    margin-top: 20px;
    margin-bottom: 24px;
  }

  fieldset {
    margin-bottom: 20px;
  }

  .storage-note {
    position: static;
    margin-top: 42px;
  }
}

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