:root {
  --bg: #f3efe7;
  --bg-soft: #fbf8f2;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --text: #1f2328;
  --muted: #5b646f;
  --line: rgba(34, 41, 50, 0.12);
  --accent: #2f5d50;
  --accent-2: #b47b43;
  --shadow: 0 18px 48px rgba(36, 28, 18, 0.12);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html {
  background:
    radial-gradient(circle at top left, rgba(180, 123, 67, 0.16), transparent 32%),
    radial-gradient(circle at right 15%, rgba(47, 93, 80, 0.14), transparent 24%),
    linear-gradient(180deg, #f8f5ef 0%, var(--bg) 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Manrope", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 1px 1px, rgba(31, 35, 40, 0.06) 1px, transparent 0) 0 0 / 26px 26px,
    transparent;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 30%);
}

.page-shell {
  width: min(1180px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 2rem 0 1.5rem;
}

.hero {
  margin-bottom: 1.25rem;
}

.hero--simple {
  display: block;
  padding: 0.5rem 0 0.25rem;
}

.hero--simple h1 {
  font-size: clamp(2.1rem, 4vw, 3.3rem);
  max-width: none;
}

.hero-copy,
.hero-card,
.panel {
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero-copy {
  border-radius: calc(var(--radius) + 8px);
  padding: 2rem 2rem 1.75rem;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--accent);
}

h1,
h2 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(2.4rem, 5vw, 4.8rem);
  line-height: 0.96;
  max-width: 11ch;
}

.lede {
  margin: 1rem 0 0;
  max-width: 58ch;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.65;
}

.hero-card {
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
}

.hero-card__top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.9rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.hero-card ol {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text);
  line-height: 1.8;
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(420px, 1.45fr);
  gap: 1.25rem;
  align-items: start;
}

.panel {
  border-radius: var(--radius);
  padding: 1.25rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
}

.panel h2 {
  font-size: clamp(1.55rem, 2.4vw, 2.2rem);
}

.panel-note {
  margin: 0;
  color: var(--muted);
  max-width: 26ch;
  line-height: 1.5;
  font-size: 0.95rem;
}

.input-label {
  display: inline-block;
  margin-bottom: 0.55rem;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 280px;
  resize: vertical;
  border-radius: 18px;
  border: 1px solid rgba(47, 59, 71, 0.18);
  background: var(--panel-strong);
  color: var(--text);
  padding: 1rem 1rem 1.1rem;
  font: inherit;
  line-height: 1.6;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

textarea:focus {
  outline: 2px solid rgba(47, 93, 80, 0.28);
  outline-offset: 2px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.9rem 1.15rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, opacity 140ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

#generate {
  background: linear-gradient(135deg, var(--accent), #21463d);
  color: white;
  box-shadow: 0 12px 24px rgba(47, 93, 80, 0.22);
}

.secondary {
  background: rgba(31, 35, 40, 0.08);
  color: var(--text);
}

.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(47, 93, 80, 0.18);
}

.status {
  margin: 1rem 0 0;
  color: var(--muted);
  min-height: 1.5em;
}

.result-empty {
  min-height: 570px;
  border-radius: 20px;
  border: 1px dashed rgba(31, 35, 40, 0.18);
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.42);
  padding: 1.5rem;
}

.puzzle {
  position: relative;
  background: var(--panel-strong);
  border: 1px solid rgba(31, 35, 40, 0.1);
  border-radius: 22px;
  padding: 1rem;
}

.puzzle__print {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 1;
  background: linear-gradient(135deg, var(--accent), #21463d);
  color: white;
  box-shadow: 0 12px 24px rgba(47, 93, 80, 0.22);
}

.puzzle__heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-right: 6.5rem;
}

.puzzle__heading h3 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.35rem, 2vw, 1.8rem);
}

.puzzle__meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.puzzle__body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: start;
}

.grid-wrap {
  width: min(100%, 780px);
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  border: 1px solid rgba(31, 35, 40, 0.12);
  padding: 0.75rem;
  background: linear-gradient(180deg, #fff, #f7f3eb);
}

.grid {
  width: 100%;
  height: 100%;
  display: grid;
  gap: 0;
  background: #fff;
  border: 1px solid rgba(31, 35, 40, 0.12);
}

.cell {
  display: grid;
  place-items: center;
  border-right: 1px solid rgba(31, 35, 40, 0.08);
  border-bottom: 1px solid rgba(31, 35, 40, 0.08);
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  user-select: none;
  line-height: 1;
  color: #222;
}

.clues {
  border-radius: 18px;
  border: 1px solid rgba(31, 35, 40, 0.12);
  background: rgba(255, 255, 255, 0.72);
  padding: 1rem;
}

.clues h4 {
  margin: 0 0 0.75rem;
  font-size: 0.96rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
}

.clues ol {
  margin: 0;
  padding-left: 1.2rem;
  columns: 1;
  line-height: 1.65;
}

.clues li {
  break-inside: avoid;
  margin-bottom: 0.2rem;
  font-weight: 600;
}

.footer {
  padding: 1rem 0 0.3rem;
  text-align: center;
  color: var(--muted);
}

.footer a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(91, 100, 111, 0.35);
}

.footer a:hover {
  color: var(--accent);
  border-bottom-color: rgba(47, 93, 80, 0.5);
}

@media (max-width: 980px) {
  .hero,
  .layout,
  .puzzle__body {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .puzzle__heading {
    align-items: start;
  }

  .panel-note {
    max-width: none;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100vw - 1rem, 1180px);
    padding-top: 0.5rem;
  }

  .hero-copy,
  .panel,
  .hero-card {
    padding: 1rem;
  }

  h1 {
    font-size: clamp(2.1rem, 15vw, 3rem);
  }

  textarea {
    min-height: 230px;
  }

  .actions {
    gap: 0.6rem;
  }

  button {
    width: 100%;
  }
}

@media print {
  @page {
    margin: 10mm;
  }

  html,
  body {
    background: #fff !important;
  }

  body::before,
  .hero,
  .editor,
  .footer {
    display: none !important;
  }

  .page-shell {
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .layout {
    display: block;
  }

  .result {
    border: 0;
    box-shadow: none;
    padding: 0;
    background: transparent;
  }

  .panel-head {
    display: none;
  }

  .puzzle {
    border: 0;
    box-shadow: none;
    padding: 0;
    background: transparent;
    page-break-inside: avoid;
    break-inside: avoid;
  }

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

  .grid-wrap,
  .clues {
    border-color: #bbb;
    background: #fff;
    box-shadow: none;
  }

  .grid-wrap {
    width: 100%;
    max-width: 100%;
  }

  .status,
  .actions,
  .result-empty,
  .puzzle__print {
    display: none !important;
  }
}
