:root {
  --ink: #17242d;
  --muted: #64727a;
  --paper: #f4f3ec;
  --surface: #ffffff;
  --line: #d9ddd5;
  --coral: #ef6b4a;
  --coral-dark: #ca4e32;
  --teal: #237a70;
  --teal-dark: #145c55;
  --mustard: #e9bd4c;
  --tile: #ece6d6;
  --tile-pressed: #17242d;
  --danger: #bc4545;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: ui-rounded, "Avenir Next", Avenir, "Nunito Sans", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 20px;
}

.app-header {
  display: flex;
  width: min(100%, 680px);
  align-items: center;
  justify-content: space-between;
  margin: 0 auto;
}

.wordmark {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 850;
  letter-spacing: 0;
  padding: 4px 0;
}

.header-date,
.eyebrow,
.round-count {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0;
  text-transform: uppercase;
}

.centered-screen,
.welcome-screen,
.result-screen,
.archive-screen,
.game-screen {
  width: min(100%, 500px);
  margin: auto;
}

.centered-screen,
.welcome-screen,
.result-screen,
.archive-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.welcome-screen,
.result-screen,
.archive-screen {
  gap: 18px;
  padding: 44px 0 24px;
}

.welcome-unplayed {
  display: grid;
  gap: 18px;
  justify-items: center;
}

.loading-mark,
.welcome-number {
  display: grid;
  width: 104px;
  height: 104px;
  place-items: center;
  border: 5px solid var(--ink);
  border-radius: 8px;
  color: var(--ink);
  font-size: 3.4rem;
  font-weight: 900;
  line-height: 1;
}

.welcome-number {
  background: var(--mustard);
  box-shadow: 9px 9px 0 var(--teal);
}

h1 {
  max-width: 15ch;
  font-size: clamp(2rem, 6vw, 3.6rem);
  letter-spacing: 0;
  line-height: 0.98;
  margin: 0;
}

.welcome-copy,
.archive-copy,
.result-copy,
.muted {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
  margin: 0;
  max-width: 38ch;
}

.primary-action,
.secondary-action,
.text-action {
  border-radius: 8px;
  font-weight: 850;
  letter-spacing: 0;
}

.primary-action {
  border: 2px solid var(--teal-dark);
  background: var(--teal);
  box-shadow: 4px 4px 0 var(--teal-dark);
  color: #fff;
  padding: 13px 20px;
}

.primary-action:active {
  box-shadow: 1px 1px 0 var(--teal-dark);
  transform: translate(3px, 3px);
}

.secondary-action {
  border: 2px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  padding: 11px 17px;
}

.text-action {
  border: 0;
  background: transparent;
  color: var(--teal-dark);
  padding: 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.stats-line {
  display: flex;
  gap: 10px 18px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.stats-line {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0;
}

.played-today {
  display: grid;
  max-width: 38ch;
  gap: 8px;
  padding: 4px 0;
}

.played-today p {
  margin: 0;
}

.played-today-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.played-today-copy {
  color: var(--ink);
  font-size: 1.12rem;
  font-weight: 850;
  line-height: 1.35;
}

.played-today-target {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
}

.played-today-target span {
  color: var(--teal-dark);
}

.played-today-next {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.35;
}

.stats-line {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 16px;
}

.game-screen {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  padding: 26px 0;
}

.game-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.timer {
  color: var(--teal-dark);
  font-size: 1.55rem;
  font-weight: 900;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.timer--urgent {
  color: var(--danger);
}

.answer-assembly {
  display: flex;
  width: 100%;
  justify-content: center;
  gap: 7px;
  border: 0;
  background: transparent;
  padding: 8px 0;
}

.answer-slot {
  display: grid;
  width: clamp(34px, 9vw, 48px);
  height: clamp(42px, 11vw, 56px);
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: clamp(1.15rem, 4vw, 1.5rem);
  font-weight: 900;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease,
    transform 140ms ease;
}

.answer-slot--empty {
  border-color: #a6afb0;
  color: transparent;
}

.answer-assembly--correct .answer-slot {
  border-color: var(--teal-dark);
  background: var(--teal);
  color: #fff;
}

.answer-assembly--correct {
  animation: success-exit 680ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.answer-assembly--incorrect {
  animation: answer-shake 320ms ease;
}

.answer-assembly--incorrect .answer-slot {
  border-color: #8f2f2f;
  background: var(--danger);
  color: #fff;
}

.feedback {
  min-height: 1.5em;
  color: var(--coral-dark);
  font-weight: 750;
  margin: 0;
  text-align: center;
}

.tile-grid {
  display: grid;
  width: min(100%, calc(var(--columns) * 78px + (var(--columns) - 1) * 10px));
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  gap: 10px;
  margin: 0 auto;
}

.letter-tile {
  display: grid;
  aspect-ratio: 1;
  min-width: 0;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--tile);
  color: var(--ink);
  font-size: clamp(1.45rem, 7vw, 2.2rem);
  font-weight: 900;
  transition: transform 120ms ease, background 120ms ease, color 120ms ease;
}

.letter-tile:hover {
  transform: translateY(-2px);
}

.letter-tile--selected {
  background: var(--tile-pressed);
  color: #fff;
  transform: translateY(-2px);
}

.tile-grid--correct .letter-tile--selected {
  border-color: var(--teal-dark);
  background: var(--teal);
  color: #fff;
}

.tile-grid--correct {
  animation: success-exit 680ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.tile-grid--incorrect {
  animation: answer-shake 320ms ease;
}

.tile-grid--incorrect .letter-tile--selected {
  border-color: #8f2f2f;
  background: var(--danger);
  color: #fff;
}

@keyframes success-exit {
  0% {
    opacity: 1;
    transform: scale(1);
  }

  28% {
    opacity: 1;
    transform: scale(1.055);
  }

  62% {
    opacity: 1;
    transform: scale(1.015);
  }

  100% {
    opacity: 0;
    transform: scale(0.92);
  }
}

@keyframes answer-shake {
  0%, 100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-5px);
  }

  40% {
    transform: translateX(4px);
  }

  60% {
    transform: translateX(-3px);
  }

  80% {
    transform: translateX(2px);
  }
}

.game-hint {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
  margin: 0;
  text-align: center;
}

.result-score {
  display: flex;
  align-items: baseline;
  gap: 4px;
  color: var(--teal-dark);
}

.result-score strong {
  font-size: clamp(4rem, 20vw, 6.3rem);
  line-height: 0.85;
}

.result-score span {
  color: var(--muted);
  font-size: 1.35rem;
  font-weight: 800;
}

.result-target {
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: clamp(1.15rem, 5vw, 1.55rem);
  font-weight: 900;
  margin: 0;
  padding: 12px 16px;
}

.result-target-word {
  color: var(--teal-dark);
}

.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.archive-list {
  display: flex;
  width: min(100%, 380px);
  max-height: min(52vh, 520px);
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  padding: 2px 4px 8px;
}

.archive-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 11px 12px;
  text-align: left;
}

.archive-row--played {
  border-color: var(--line);
  background: #f0efe9;
  color: var(--muted);
  cursor: default;
}

.archive-row--played:disabled {
  opacity: 1;
}

.archive-row-date,
.archive-row-score {
  font-weight: 850;
}

.archive-row-score {
  border-radius: 999px;
  background: var(--tile);
  color: var(--muted);
  padding: 4px 10px;
  white-space: nowrap;
}

.archive-row-score--played {
  background: var(--line);
  color: var(--muted);
}

@media (max-width: 420px) {
  .app-shell {
    padding: 16px;
  }

  .tile-grid {
    width: min(100%, calc(var(--columns) * 70px + (var(--columns) - 1) * 8px));
    gap: 8px;
  }

  .answer-assembly {
    gap: 5px;
  }
}
