:root {
  color: #1b1612;
  background: #15243c;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(circle at 16% 12%, rgba(247, 216, 107, 0.2), transparent 18rem),
    linear-gradient(135deg, #0e1b33 0%, #25345b 47%, #224848 100%);
}

.game-paper {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 22px;
  border: 5px solid #111;
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.34)),
    repeating-linear-gradient(0deg, #fff5dd 0 38px, #f8edcf 39px 40px);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
}

.masthead {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding-bottom: 18px;
  border-bottom: 4px solid #111;
}

.header-logo p,
.instructions,
.cartoon-caption,
.bank-panel p {
  margin: 0;
}

.logo-word {
  color: #f3eee4;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 8vw, 6.8rem);
  font-weight: 900;
  line-height: 0.88;
  letter-spacing: 0;
  text-shadow:
    3px 3px 0 #111,
    -3px 3px 0 #111,
    3px -3px 0 #111,
    -3px -3px 0 #111,
    8px 8px 0 #ef7d34;
}

.header-logo p {
  margin-top: 10px;
  color: #111;
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 900;
  text-transform: uppercase;
}

.daily-card {
  display: grid;
  gap: 12px;
  min-width: 280px;
  padding: 14px;
  border: 4px solid #111;
  border-radius: 6px;
  background: #ffd86b;
  box-shadow: 6px 6px 0 #111;
  text-align: left;
}

.daily-card-heading {
  display: grid;
  gap: 6px;
}

.daily-card-heading > span {
  display: block;
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.daily-card-heading > strong {
  display: block;
  font-family: Georgia, serif;
  font-size: 1.25rem;
  line-height: 1.1;
}

.difficulty-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.difficulty-label {
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 950;
  text-transform: uppercase;
}

.difficulty-bar {
  flex: 1 1 auto;
  min-width: 84px;
  height: 12px;
  overflow: hidden;
  border: 3px solid #111;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.12);
}

.difficulty-fill {
  height: 100%;
  background: linear-gradient(90deg, #48ba7d 0%, #ffd86b 100%);
}

.difficulty-pill {
  flex: 0 0 auto;
  padding: 5px 10px;
  border: 3px solid #111;
  border-radius: 999px;
  background: #fff7df;
  font-size: 0.9rem;
  font-weight: 950;
  line-height: 1;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(340px, 0.95fr) minmax(360px, 1.05fr);
  gap: 26px;
  padding-top: 24px;
}

.word-column,
.cartoon-column {
  min-width: 0;
}

.instructions {
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.25;
  max-width: 33rem;
}

.word-stack {
  display: grid;
  gap: 18px;
  margin-top: 20px;
}

.word-row {
  display: grid;
  gap: 8px;
  transition:
    transform 180ms ease,
    filter 180ms ease;
}

.word-row.is-solved {
  filter: saturate(1.15);
}

.scrambled-label {
  width: fit-content;
  min-width: 210px;
  padding: 8px 18px 6px;
  border: 4px solid #111;
  background: #fffaf0;
  font-size: clamp(1.6rem, 4vw, 2.35rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
  text-align: center;
}

.letter-grid,
.final-group {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
}

.letter-box {
  position: relative;
  display: grid;
  width: clamp(42px, 8vw, 58px);
  aspect-ratio: 1;
}

.letter-box input {
  width: 100%;
  height: 100%;
  border: 4px solid #111;
  border-radius: 0;
  background: #fffdf4;
  color: #111;
  font-size: clamp(1.35rem, 4vw, 2.1rem);
  font-weight: 950;
  text-align: center;
  text-transform: uppercase;
}

.letter-box input:focus-visible,
.bank-letter:focus-visible,
.game-controls button:focus-visible,
.result-modal button:focus-visible {
  outline: 4px solid #31b8c2;
  outline-offset: 3px;
}

.letter-box.is-circled::after {
  pointer-events: none;
  position: absolute;
  inset: 7px;
  border: 4px solid #111;
  border-radius: 50%;
  z-index: 1;
  content: "";
}

.word-row.is-solved .letter-box.is-circled::after {
  border-color: #ef7d34;
  box-shadow: 0 0 0 3px rgba(239, 125, 52, 0.24);
}

.letter-box.is-invalid::before {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  color: #cf2f21;
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: 950;
  content: "X";
}

.cartoon-panel {
  display: grid;
  gap: 12px;
}

.cartoon-frame {
  overflow: hidden;
  border: 6px solid #111;
  border-radius: 18px;
  background: #111;
}

.cartoon-image {
  display: block;
  width: 100%;
  height: auto;
}

.cartoon-caption {
  padding: 12px 16px;
  border: 4px solid #111;
  background: #fffaf0;
  font-family: Georgia, serif;
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
}

.caption-blank {
  display: inline-block;
  min-width: 4ch;
  width: var(--blank-width);
  border-bottom: 0.16em solid currentColor;
  vertical-align: baseline;
}

.final-zone {
  display: grid;
  grid-template-columns: minmax(250px, 0.8fr) minmax(320px, 1.2fr);
  gap: 18px;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 4px solid #111;
}

.bank-panel,
.final-answer {
  padding: 14px;
  border: 4px solid #111;
  border-radius: 6px;
  background: #fffaf0;
}

.bank-title,
.final-title {
  display: block;
  margin-bottom: 10px;
  font-size: 0.85rem;
  font-weight: 950;
  text-transform: uppercase;
}

.letter-bank {
  display: flex;
  min-height: 58px;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.letter-bank p {
  color: #554;
  font-weight: 800;
}

.bank-letter {
  width: 44px;
  height: 44px;
  border: 4px solid #111;
  border-radius: 50%;
  background: #ffd86b;
  color: #111;
  font-weight: 950;
  box-shadow: 3px 3px 0 #111;
}

.bank-letter:disabled {
  opacity: 0.35;
  box-shadow: none;
}

.final-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
}

.final-box {
  width: clamp(40px, 7vw, 54px);
}

.is-shaking {
  animation: shake 420ms ease;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-8px);
  }
  50% {
    transform: translateX(7px);
  }
  75% {
    transform: translateX(-4px);
  }
}

.game-controls {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  align-items: center;
  margin-top: 18px;
}

.past-puzzles {
  display: grid;
  gap: 16px;
  margin-top: 22px;
  padding-top: 22px;
  border-top: 4px solid #111;
}

.past-puzzles-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
}

.past-puzzles-side {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.past-puzzles-head h2,
.archive-poster-copy strong {
  font-family: Georgia, serif;
}

.past-puzzles-head h2 {
  margin: 4px 0 0;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  line-height: 0.98;
}

.past-puzzles-head p {
  max-width: 34rem;
  margin: 0;
  color: #5b4b3f;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.4;
  text-align: right;
}

.past-puzzles-kicker,
.archive-poster-meta span {
  display: block;
}

.past-puzzles-kicker {
  font-size: 0.78rem;
  font-weight: 950;
  text-transform: uppercase;
}

.poster-archive {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 54px;
  gap: 16px;
  align-items: center;
}

.archive-arrow {
  display: grid;
  width: 54px;
  height: 54px;
  min-height: 0;
  padding: 0;
  place-items: center;
  border: 4px solid #111;
  border-radius: 50%;
  background: #ffd86b;
  color: #111;
  appearance: none;
  -webkit-appearance: none;
  font-size: 2rem;
  font-weight: 950;
  line-height: 1;
  box-shadow: 4px 4px 0 #111;
}

.archive-return {
  min-height: 0;
  padding: 10px 14px;
  border: 4px solid #111;
  border-radius: 999px;
  background: #ffd86b;
  color: #111;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
  box-shadow: 4px 4px 0 #111;
}

.archive-arrow:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 #111;
}

.archive-return:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 #111;
}

.archive-arrow span {
  transform: translateY(-1px);
}

.poster-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  min-width: 0;
}

.archive-poster {
  display: grid;
  min-width: 0;
  padding: 0;
  border: 3px solid #111;
  border-radius: 10px;
  background: #fff7df;
  color: #111;
  text-align: left;
  box-shadow: 4px 4px 0 #111;
  overflow: hidden;
}

.archive-poster:hover {
  transform: translateY(-2px);
}

.archive-poster:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 #111;
}

.archive-poster-art {
  position: relative;
  height: 0;
  padding-top: 62.5%;
  border-bottom: 3px solid #111;
  background: #111;
}

.archive-poster-art img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.archive-poster-copy {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.archive-poster-copy strong {
  display: block;
  min-height: 2.3em;
  font-size: clamp(1.1rem, 2vw, 1.65rem);
  line-height: 1;
}

.archive-poster-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.archive-poster-meta span {
  color: #1b1612;
  font-size: 0.95rem;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.archive-poster-meta span:last-child {
  padding: 7px 12px;
  border: 3px solid #111;
  border-radius: 999px;
  background: #ffd86b;
}

.archive-empty {
  display: grid;
  place-items: center;
  min-height: 96px;
  padding: 12px 14px;
  border: 3px solid #111;
  border-radius: 10px;
  background: #fff7df;
  margin: 0;
  color: #473a30;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

.control-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.game-controls button,
.result-modal button {
  min-height: 44px;
  padding: 9px 16px;
  border: 4px solid #111;
  border-radius: 6px;
  background: #f8edcf;
  color: #111;
  font-weight: 950;
  text-transform: uppercase;
  box-shadow: 4px 4px 0 #111;
}

.game-controls .submit-button {
  background: #ef7d34;
}

.game-controls button:active,
.result-modal button:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 #111;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(11, 19, 32, 0.72);
}

.result-modal {
  width: min(440px, 100%);
  padding: 24px;
  border: 5px solid #111;
  border-radius: 8px;
  background: #fff5dd;
  box-shadow: 10px 10px 0 #111;
  text-align: center;
}

.result-modal h2 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: clamp(2rem, 8vw, 3.4rem);
  line-height: 1;
}

.result-modal p {
  margin: 14px 0 20px;
  font-size: 1.05rem;
  font-weight: 800;
}

.result-modal.is-success {
  background: #dff3d1;
}

.result-modal.is-error {
  background: #ffe3d3;
}

.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;
}

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

  .game-paper {
    padding: 14px;
  }

  .masthead,
  .game-controls,
  .past-puzzles-head {
    align-items: stretch;
    flex-direction: column;
  }

  .daily-card {
    min-width: 0;
    text-align: left;
  }

  .game-layout,
  .final-zone {
    grid-template-columns: 1fr;
  }

  .cartoon-column {
    order: -1;
  }

  .control-buttons {
    justify-content: flex-start;
  }

  .past-puzzles-head p {
    text-align: left;
  }

  .past-puzzles-side {
    justify-items: start;
  }

  .poster-archive {
    grid-template-columns: 1fr;
  }

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

  .archive-arrow {
    width: 100%;
    height: 48px;
    min-height: 48px;
    border-radius: 8px;
  }
}

@media (max-width: 520px) {
  .logo-word {
    font-size: 3.3rem;
    text-shadow:
      2px 2px 0 #111,
      -2px 2px 0 #111,
      2px -2px 0 #111,
      -2px -2px 0 #111,
      5px 5px 0 #ef7d34;
  }

  .letter-box {
    width: min(13vw, 48px);
  }

  .scrambled-label {
    min-width: 0;
    width: 100%;
  }

  .game-controls button {
    flex: 1 1 120px;
  }
}
