:root {
  --ink: #1d1930;
  --muted: #615d75;
  --paper: #fffaf3;
  --surface: #f4f0ff;
  --white: #ffffff;
  --line: #d8cfea;
  --purple: #6a3dbf;
  --purple-dark: #45277e;
  --blue: #1376d1;
  --blue-soft: #e7f3ff;
  --orange: #f28b24;
  --orange-soft: #fff1df;
  --shadow: 0 18px 45px rgba(37, 31, 61, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, #f3a04a 0%, #9b6bd8 48%, #4d9bdd 100%);
  background-attachment: fixed;
  font-family: "Oswald", Arial, sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px clamp(16px, 3vw, 34px);
  background: #38b6ff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.brand img {
  display: block;
  width: 500px;
  max-height: 168px;
  object-fit: contain;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  color: white;
  font-family: "Oswald", Arial, sans-serif;
  font-weight: 600;
  text-transform: uppercase;
}

.site-nav a {
  text-decoration: none;
}

.site-nav a:hover {
  color: #ffe4bd;
}

.nav-select-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.nav-select {
  min-height: 38px;
  padding: 6px 9px;
  color: white;
  background: rgba(13, 101, 154, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 7px;
  font: inherit;
  text-transform: uppercase;
}

.hero-band {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding: clamp(30px, 5vw, 62px) clamp(18px, 4vw, 48px);
  background:
    linear-gradient(110deg, rgba(255, 250, 243, 0.9), rgba(255, 246, 236, 0.82));
  border-bottom: 1px solid rgba(255, 255, 255, 0.38);
}

.hero-band > div {
  max-width: 850px;
}

.hero-band p:not(.eyebrow) {
  max-width: 680px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.category-strip {
  padding: 24px clamp(18px, 4vw, 48px);
  background:
    linear-gradient(135deg, rgba(243, 160, 74, 0.86) 0%, rgba(155, 107, 216, 0.86) 48%, rgba(77, 155, 221, 0.86) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.38);
  backdrop-filter: blur(10px);
}

body:not([data-initial-category="All"]) .category-strip {
  display: none;
}

.seo-panel {
  padding: clamp(24px, 4vw, 44px) clamp(18px, 4vw, 48px);
  background: rgba(255, 250, 243, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.38);
}

body:not([data-initial-category="All"]) .seo-panel {
  padding-top: clamp(18px, 3vw, 30px);
}

.seo-panel h2 {
  max-width: 900px;
}

.seo-panel > p:not(.eyebrow) {
  max-width: 820px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1.06rem;
}

.seo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.seo-grid article {
  padding: 16px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.seo-grid p {
  margin: 8px 0 0;
  color: var(--muted);
}

.strip-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.category-strip .eyebrow,
.category-strip h2 {
  color: white;
}

.category-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
}

.category-card {
  display: grid;
  gap: 10px;
  min-height: 116px;
  padding: 14px;
  color: var(--ink);
  background: var(--orange-soft);
  border: 1px solid #f3c58f;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}

.category-card:nth-child(2n) {
  background: var(--blue-soft);
  border-color: #a9d5f7;
}

.category-card:nth-child(3n) {
  background: #f0e9ff;
  border-color: #cdbcf1;
}

.category-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.category-card strong {
  font-family: "Oswald", Arial, sans-serif;
  font-size: 1.35rem;
  line-height: 1.05;
  text-transform: uppercase;
}

.category-card span {
  color: var(--muted);
  font-weight: 700;
}

.app-shell {
  min-height: calc(100vh - 89px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-family: "Oswald", Arial, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.05;
  letter-spacing: 0;
}

h1 {
  max-width: 880px;
  font-family: "Handmade", "HandMade", cursive;
  font-size: clamp(2.6rem, 5vw, 5.2rem);
  text-transform: uppercase;
}

h2 {
  font-size: clamp(1.6rem, 2.4vw, 2.7rem);
  text-transform: uppercase;
}

h3 {
  font-size: 0.95rem;
  text-transform: uppercase;
}

.search-label {
  display: block;
  margin-bottom: 5px;
  font-family: "Oswald", Arial, sans-serif;
  font-weight: 700;
  text-transform: uppercase;
}

input[type="search"] {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
}

input[type="text"] {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
}

.library-panel {
  padding: clamp(18px, 3vw, 34px);
  background: rgba(255, 255, 255, 0.16);
}

.toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.toolbar-actions {
  display: grid;
  grid-template-columns: minmax(240px, 360px) auto;
  gap: 8px 12px;
  align-items: end;
}

.toolbar-actions .search-label {
  grid-column: 1 / -1;
}

.count-pill {
  flex: 0 0 auto;
  padding: 7px 10px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--purple-dark);
  font-family: "Oswald", Arial, sans-serif;
  font-weight: 700;
}

.content-grid {
  display: block;
}

.puzzle-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.puzzle-card {
  display: grid;
  gap: 9px;
  width: 100%;
  padding: 14px;
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 5px solid var(--orange);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  text-decoration: none;
}

.puzzle-card:hover {
  border-color: var(--purple);
  border-left-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(106, 61, 191, 0.13);
}

.card-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-family: "Oswald", Arial, sans-serif;
  font-size: 1.12rem;
  font-weight: 700;
  text-transform: uppercase;
}

.card-meta {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.card-cipher {
  margin: 0;
  color: #30302d;
  font-family: "Oswald", Arial, sans-serif;
  font-size: 1.18rem;
  overflow-wrap: anywhere;
}

.puzzle-page {
  width: min(980px, calc(100% - 36px));
  margin: clamp(24px, 5vw, 54px) auto;
  min-height: calc(100vh - 190px);
  padding: clamp(18px, 3vw, 28px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.preview-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 3px solid var(--purple-dark);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 13px;
  border-radius: 7px;
  cursor: pointer;
  font-family: "Oswald", Arial, sans-serif;
  font-weight: 700;
  letter-spacing: 0;
  text-decoration: none;
  text-transform: uppercase;
}

.button.primary {
  color: white;
  background: var(--purple);
  border: 1px solid var(--purple);
}

.button.primary:hover {
  background: var(--purple-dark);
}

.button.secondary {
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
}

.button.secondary:hover {
  border-color: var(--orange);
  color: var(--purple-dark);
}

.preview-section {
  margin-top: 24px;
}

.supporting-copy {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.cipher-text,
.blank-text {
  margin: 10px 0 0;
  font-family: "Oswald", Arial, sans-serif;
  font-size: clamp(1.45rem, 2.4vw, 2rem);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.blank-text {
  white-space: pre-wrap;
}

.hint-box {
  display: inline-block;
  margin: 16px 0 0;
  padding: 7px 10px;
  background: var(--orange-soft);
  border: 1px solid #f3c58f;
  border-radius: 6px;
  color: #723d05;
  font-weight: 900;
}

.author-line {
  margin: 12px 0 0;
  font-weight: 900;
}

.spoiler {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.spoiler-content {
  margin-top: 14px;
  padding: 16px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.spoiler-content p {
  margin: 10px 0 0;
  font-size: 1.05rem;
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.legal-page {
  width: min(920px, calc(100% - 36px));
  margin: clamp(26px, 5vw, 60px) auto;
  padding: clamp(22px, 4vw, 42px);
  background: rgba(255, 250, 243, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.not-found-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.legal-page h1 {
  margin-bottom: 18px;
}

.legal-page h2 {
  margin-top: 28px;
  font-size: 1.35rem;
}

.legal-page p {
  color: var(--muted);
  font-size: 1.05rem;
}

.legal-page a:not(.button) {
  color: var(--purple-dark);
  font-weight: 700;
}

.generator-page {
  width: min(1180px, calc(100% - 36px));
  margin: clamp(24px, 5vw, 54px) auto;
}

.generator-intro {
  margin-bottom: 22px;
  padding: clamp(22px, 4vw, 38px);
  background: rgba(255, 250, 243, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.generator-intro p:not(.eyebrow) {
  max-width: 720px;
  color: var(--muted);
  font-size: 1.08rem;
}

.generator-grid {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.generator-form,
.generator-result {
  display: flex;
  min-height: 10.2in;
  flex-direction: column;
  padding: clamp(18px, 3vw, 28px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.generator-print-brand {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--ink);
}

.generator-print-brand img {
  width: 220px;
  max-height: 82px;
  object-fit: contain;
}

.generator-print-brand p {
  margin: 0;
  text-align: right;
  font-weight: 700;
}

.solve-boxes {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  margin-top: 12px;
}

.solve-word {
  display: inline-flex;
  gap: 4px;
}

.solve-letter {
  display: grid;
  width: 32px;
  gap: 3px;
  text-align: center;
}

.solve-square {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  background: white;
  border: 2px solid var(--ink);
  font-weight: 700;
}

.solve-cipher {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
}

.solve-punctuation {
  align-self: end;
  padding-bottom: 18px;
  font-weight: 700;
}

.generator-key-grid {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 8px;
  margin-top: auto;
  padding-top: 28px;
}

.generator-key-grid .key-cell {
  min-height: 48px;
  padding: 5px;
  background: white;
  border: 1px solid var(--ink);
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
}

.generator-key-grid .key-cell span {
  display: block;
  color: var(--muted);
}

.generator-sheet-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}

.generator-form {
  display: grid;
  gap: 16px;
}

.generator-form label,
.generator-form legend {
  font-weight: 700;
  text-transform: uppercase;
}

.generator-form textarea {
  width: 100%;
  min-height: 150px;
  padding: 12px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
  resize: vertical;
}

.generator-form fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.form-note {
  margin: 4px 0 12px;
  color: var(--muted);
}

.letter-choice-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
}

.letter-choice {
  display: grid;
  min-height: 38px;
  place-items: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
}

.letter-choice input {
  position: absolute;
  opacity: 0;
}

.letter-choice:has(input:checked) {
  color: white;
  background: var(--purple);
  border-color: var(--purple);
}

@media (max-width: 900px) {
  .generator-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: Letter;
    margin: 0.55in;
  }

  body {
    background: white;
  }

  .site-header,
  .site-footer,
  .generator-intro,
  .generator-form,
  .preview-header .button,
  .spoiler,
  .preview-actions {
    display: none !important;
  }

  .generator-page,
  .generator-grid,
  .generator-result {
    display: block;
    width: auto;
    margin: 0;
    padding: 0;
    background: white;
    border: 0;
    box-shadow: none;
  }

  .generator-result {
    position: relative;
    height: 9.9in;
    min-height: 0;
    overflow: hidden;
    padding: 0.38in;
    border: 2px solid #191919;
  }

  .generator-print-brand {
    display: flex;
  }

  .preview-header {
    border-bottom: 2px solid #191919;
  }

  .cipher-text,
  .blank-text {
    font-size: 20pt;
    line-height: 1.45;
  }

  .cipher-text {
    font-size: 18pt;
  }

  .solve-boxes {
    gap: 0.1in 0.14in;
  }

  .solve-letter {
    width: 0.28in;
  }

  .solve-square {
    width: 0.28in;
    height: 0.28in;
    border: 1px solid #191919;
    font-size: 11pt;
  }

  .solve-cipher {
    color: #555;
    font-size: 10pt;
    font-weight: 800;
  }

  .solve-punctuation {
    padding-bottom: 0.14in;
  }

  .generator-key-grid {
    grid-template-columns: repeat(13, 1fr);
    gap: 0.08in;
    padding-top: 0.28in;
  }

  .generator-key-grid .key-cell {
    min-height: 0.42in;
    border-color: #191919;
    font-size: 8pt;
  }

  .generator-sheet-footer {
    margin-top: 0.16in;
    border-color: #777;
    color: #555;
    font-size: 9pt;
  }

  .hint-box {
    color: #191919;
    background: white;
    border-color: #191919;
  }

  .generator-result::after {
    content: none;
    display: none;
  }
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px clamp(18px, 4vw, 48px);
  color: white;
  background: rgba(69, 39, 126, 0.82);
  font-size: 0.95rem;
}

.site-footer nav {
  display: flex;
  gap: 14px;
}

.site-footer a {
  color: white;
  font-weight: 700;
  text-decoration: none;
}

.site-footer a:hover {
  color: #ffe4bd;
}

@media (max-width: 1180px) {
  .category-cards {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }
}

@media (max-width: 1000px) {
  .puzzle-list {
    grid-template-columns: 1fr;
  }

  .puzzle-page {
    max-height: none;
    min-height: auto;
  }
}

@media (max-width: 700px) {
  .hero-band,
  .site-header,
  .site-nav,
  .toolbar,
  .toolbar-actions,
  .preview-header,
  .strip-heading,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar-actions {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .category-cards {
    grid-template-columns: 1fr;
  }

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

  .brand img {
    width: 260px;
    max-height: 96px;
  }
}
