@font-face {
  font-family: "WorksheetBody";
  src: url("/static/fonts/omyu-pretty.ttf") format("truetype");
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "WorksheetDisplay";
  src: url("/static/fonts/Griun_Mongtori-Rg.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-body: "WorksheetBody", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --font-display: "WorksheetDisplay", "WorksheetBody", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --bg: #f7f8f2;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-soft: #f7fff9;
  --ink: #223429;
  --muted: #657568;
  --line: rgba(34, 52, 41, 0.12);
  --accent: #4f8f6d;
  --accent-deep: #2f6f55;
  --accent-soft: #dff2e7;
  --orange: #f28d4f;
  --yellow: #fff1c7;
  --blue: #dff3ff;
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow: 0 22px 70px rgba(43, 70, 52, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 9% 8%, rgba(255, 225, 162, 0.65), transparent 28%),
    radial-gradient(circle at 92% 10%, rgba(201, 237, 255, 0.68), transparent 24%),
    radial-gradient(circle at 0% 95%, rgba(192, 235, 211, 0.72), transparent 28%),
    linear-gradient(180deg, #fffaf0 0%, var(--bg) 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 72px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.8fr);
  gap: 22px;
  margin-bottom: 22px;
}

.hero__copy,
.hero__status,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero__copy {
  padding: 36px 38px;
}

.hero__copy h1,
.panel-heading h2,
.empty-state h3,
.worksheet-title,
.answer-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.02em;
}

.hero__copy h1 {
  font-size: clamp(2.4rem, 5vw, 4.7rem);
  line-height: 1.02;
}

.hero__copy p {
  max-width: 58ch;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.72;
}

.seo-intro {
  max-width: 62ch;
  margin-top: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.68);
}

.seo-intro h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 400;
}

.seo-intro p {
  margin: 6px 0 0;
  font-size: 0.98rem;
  line-height: 1.65;
}

.eyebrow,
.step-label {
  margin: 0 0 10px;
  color: var(--accent-deep);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.hero__actions,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.hero__status {
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 28px;
  background:
    linear-gradient(145deg, rgba(223, 242, 231, 0.94), rgba(255, 255, 255, 0.92)),
    var(--surface);
}

.hero__status strong {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
}

.hero__status span {
  color: var(--muted);
  line-height: 1.6;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 800;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

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

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button--primary {
  color: #ffffff;
  background: linear-gradient(145deg, var(--orange), #df6c32);
  box-shadow: 0 16px 34px rgba(223, 108, 50, 0.24);
}

.button--ghost {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.panel {
  padding: 28px;
}

.panel-heading {
  margin-bottom: 20px;
}

.preview-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.panel-heading h2 {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.summary {
  max-width: 28ch;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: right;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field span,
.option-card legend {
  color: var(--ink);
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  outline: none;
}

.field input,
.field select {
  min-height: 48px;
  padding: 0 14px;
}

.field textarea {
  padding: 14px;
  line-height: 1.55;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(79, 143, 109, 0.58);
  box-shadow: 0 0 0 4px rgba(79, 143, 109, 0.12);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.option-card {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
}

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

.direction-grid label,
.toggle-stack label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid rgba(79, 143, 109, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-weight: 700;
}

.direction-grid input,
.toggle-stack input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.toggle-stack {
  display: grid;
  gap: 10px;
}

.feedback {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.feedback.is-error {
  color: #c53b2c;
}

.feedback.is-success {
  color: var(--accent-deep);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 36px;
  border: 2px dashed rgba(79, 143, 109, 0.2);
  border-radius: var(--radius-xl);
  background: linear-gradient(145deg, rgba(223, 242, 231, 0.56), rgba(255, 255, 255, 0.74));
  text-align: center;
}

.empty-state h3 {
  font-size: 2rem;
}

.empty-state p {
  max-width: 42ch;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.print-area {
  display: grid;
  gap: 22px;
}

.worksheet-page,
.answer-page {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: #ffffff;
}

.worksheet-header,
.answer-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 2px solid rgba(79, 143, 109, 0.15);
}

.worksheet-title,
.answer-title {
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.puzzle-grid {
  --grid-size: 12;
  display: grid;
  grid-template-columns: repeat(var(--grid-size), minmax(0, 1fr));
  width: min(100%, 760px);
  margin: 0 auto;
  border: 3px solid var(--accent-deep);
  border-radius: 18px;
  overflow: hidden;
}

.puzzle-cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(47, 111, 85, 0.2);
  background: #fbfffc;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: clamp(1.15rem, 2.45vw, 1.78rem);
  font-weight: 800;
  text-align: center;
  line-height: 1;
}

.puzzle-grid--compact .puzzle-cell {
  font-size: clamp(1.35rem, 3vw, 2.1rem);
}

.puzzle-grid--answer .puzzle-cell.is-solution {
  background: #ffe2b8;
  color: #9b4219;
  box-shadow: inset 0 0 0 2px rgba(242, 141, 79, 0.36);
}

.word-bank {
  margin-top: 18px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: #f6fbf7;
}

.word-bank strong,
.placement-list strong {
  display: block;
  margin-bottom: 10px;
  color: var(--accent-deep);
}

.word-list,
.placement-list ol {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.word-list li,
.placement-list li {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--yellow);
  color: #6c4b18;
  font-weight: 800;
}

.placement-list {
  margin-top: 18px;
}

.placement-list ol {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.placement-list li {
  border-radius: var(--radius-md);
  background: var(--blue);
}

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

  .summary {
    text-align: left;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1320px);
    padding-top: 16px;
  }

  .hero__copy,
  .hero__status,
  .panel,
  .worksheet-page,
  .answer-page {
    padding: 20px;
    border-radius: 24px;
  }

  .field-grid,
  .direction-grid {
    grid-template-columns: 1fr;
  }

  .preview-heading,
  .worksheet-header,
  .answer-header {
    display: grid;
  }

}

body {
  color: #322418;
  background:
    radial-gradient(circle at 18px 18px, rgba(217, 104, 42, 0.07) 0 2px, transparent 3px),
    radial-gradient(circle at 44px 42px, rgba(79, 143, 109, 0.055) 0 2px, transparent 3px),
    linear-gradient(180deg, #fbf0dc 0%, #fffaf1 48%, #f7f1e8 100%);
  background-size: 68px 68px, 68px 68px, auto;
}

.hero__copy,
.hero__status,
.panel {
  border-color: rgba(117, 78, 42, 0.14);
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 7px 0 rgba(117, 78, 42, 0.025), 0 12px 26px rgba(83, 56, 22, 0.055);
}

.hero__copy h1,
.panel-heading h2,
.empty-state h3,
.worksheet-title,
.answer-title,
.hero__status strong {
  color: #302016;
  font-family: var(--font-body);
  font-weight: 900;
  letter-spacing: -0.04em;
}

.eyebrow,
.step-label {
  color: #d45f23;
}

.hero__copy p,
.hero__status span,
.summary,
.empty-state p {
  color: #6f5b48;
}

.button {
  border-color: rgba(117, 78, 42, 0.16);
  background: #fffdf8;
  box-shadow: 0 4px 0 rgba(117, 78, 42, 0.035);
}

.button--primary {
  border-color: rgba(207, 91, 37, 0.28);
  background: linear-gradient(180deg, #ff9d5f 0%, #ed7432 100%);
  box-shadow: 0 5px 0 rgba(207, 91, 37, 0.1), 0 10px 18px rgba(217, 104, 42, 0.1);
}

.button--ghost {
  background: #fffdf8;
}

.field input,
.field select,
.field textarea {
  border-color: rgba(117, 78, 42, 0.16);
  background: #fffaf2;
}

.field select,
.field input[type="number"] {
  height: 58px;
  min-height: 58px;
  padding: 0 18px;
  border-radius: 18px;
  line-height: 1;
}

.field select {
  appearance: none;
  padding-right: 48px;
  background-image:
    linear-gradient(45deg, transparent 50%, #322418 50%),
    linear-gradient(135deg, #322418 50%, transparent 50%);
  background-position:
    calc(100% - 25px) 50%,
    calc(100% - 17px) 50%;
  background-size: 8px 8px, 8px 8px;
  background-repeat: no-repeat;
}

.field input[type="number"] {
  appearance: textfield;
}

.field input[type="number"]::-webkit-outer-spin-button,
.field input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.option-card,
.direction-grid label,
.toggle-stack label,
.empty-state,
.worksheet-page,
.answer-page {
  border-color: rgba(117, 78, 42, 0.13);
  background: rgba(255, 253, 248, 0.9);
}

.direction-grid input,
.toggle-stack input {
  accent-color: #5fa06b;
}

.puzzle-grid {
  border-color: #5f8f68;
}

.word-bank {
  background: #edf8f1;
}

/* Premium minimal layer shared with the portal. */
:root {
  --game-blue: #0066cc;
  --game-blue-focus: #0071e3;
  --game-ink: #1d1d1f;
  --game-muted: #747478;
  --game-page: #f5f5f7;
  --game-canvas: #ffffff;
  --game-pearl: #fafafc;
  --game-line: #e0e0e0;
  --game-pill: 9999px;
  --bg: var(--game-page);
  --surface: var(--game-canvas);
  --surface-soft: var(--game-pearl);
  --ink: var(--game-ink);
  --muted: var(--game-muted);
  --accent: var(--game-blue);
  --accent-deep: var(--game-blue);
  --line: var(--game-line);
}

body {
  color: var(--game-ink);
  background: var(--game-page);
  background-size: auto;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  padding: 14px 0 72px;
}

.hero {
  display: block;
  margin-bottom: 24px;
}

.hero__copy {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 68px;
  padding: 12px 18px;
  border: 1px solid var(--game-line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: none;
}

.hero__status,
.eyebrow,
.hero__copy p {
  display: none;
}

.hero__copy h1 {
  flex: 1 1 auto;
  color: var(--game-ink);
  font-family: var(--font-body);
  font-size: clamp(1.15rem, 2.4vw, 1.45rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.hero__actions {
  flex: 0 0 auto;
  margin: 0;
}

.panel,
.option-card,
.direction-grid label,
.toggle-stack label,
.empty-state,
.worksheet-page,
.answer-page {
  border-color: var(--game-line);
  background: var(--game-canvas);
  box-shadow: none;
}

.panel {
  border-radius: 24px;
}

.step-label {
  color: var(--game-muted);
}

.panel-heading h2,
.empty-state h3,
.worksheet-title,
.answer-title {
  color: var(--game-ink);
  font-family: var(--font-body);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.summary,
.empty-state p,
.hero__status span {
  color: var(--game-muted);
}

.field input,
.field select,
.field textarea {
  border-color: var(--game-line);
  background: var(--game-pearl);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--game-blue);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.12);
}

.field select {
  background-color: var(--game-pearl);
}

.button {
  border: 1px solid var(--game-line);
  border-radius: var(--game-pill);
  color: var(--game-ink);
  background: var(--game-canvas);
  box-shadow: none;
}

.button:hover:not(:disabled) {
  color: var(--game-blue);
  border-color: var(--game-blue);
}

.button--primary {
  color: #ffffff;
  border-color: var(--game-blue);
  background: var(--game-blue);
  box-shadow: none;
}

.button--primary:hover:not(:disabled) {
  color: #ffffff;
  background: var(--game-blue-focus);
}

.button--ghost {
  background: var(--game-canvas);
}

.direction-grid label,
.toggle-stack label,
.word-bank {
  background: var(--game-pearl);
}

.direction-grid input,
.toggle-stack input {
  accent-color: var(--game-blue);
}

.feedback.is-success {
  color: var(--game-blue);
}

.puzzle-grid {
  border-color: #d2d2d7;
}

.puzzle-cell {
  border-color: var(--game-line);
  background: #ffffff;
}

.puzzle-grid--answer .puzzle-cell.is-solution {
  color: var(--game-blue);
  background: #f5f9ff;
  box-shadow: inset 0 0 0 2px rgba(0, 102, 204, 0.22);
}

.word-list li,
.placement-list li {
  color: var(--game-ink);
  background: var(--game-pearl);
}

.layout {
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  align-items: start;
}

.preview-panel {
  padding: 28px;
  border: 1px solid var(--game-line);
  background: var(--game-canvas);
  box-shadow: none;
}

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

@media print {
  @page {
    size: A4 portrait;
    margin: 12mm;
  }

  body {
    margin: 0;
    background: #ffffff;
  }

  .hero,
  .controls-panel,
  .preview-heading,
  .empty-state {
    display: none !important;
  }

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

  .layout {
    display: block;
  }

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

  .print-area {
    gap: 0;
  }

  .worksheet-page,
  .answer-page {
    page-break-after: always;
    width: 184mm;
    min-height: 260mm;
    margin: 0 auto;
    padding: 6.5mm 6mm;
    box-sizing: border-box;
    border: 0;
    border-radius: 0;
  }

  .puzzle-grid {
    width: 100%;
    max-width: 158mm;
  }

  .puzzle-cell {
    font-size: 18pt;
  }

  .puzzle-grid--compact .puzzle-cell {
    font-size: 21pt;
  }

  .word-bank,
  .placement-list {
    margin-top: 4mm;
    padding: 4mm;
    break-inside: avoid;
  }

  .worksheet-header,
  .answer-header {
    margin-bottom: 4.5mm;
    padding-bottom: 3mm;
  }

  .worksheet-page:last-child,
  .answer-page:last-child {
    page-break-after: auto;
  }
}
