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

:root {
  --font-body: "WorksheetBody", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --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;
  --cw-cell-line: #9d9da4;
  --cw-number: #7c6bd9;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--game-ink);
  font-family: var(--font-body);
  background: var(--game-page);
}

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

button {
  cursor: pointer;
}

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

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

.hero__copy,
.hero__status,
.panel,
.worksheet-page,
.empty-state {
  border: 1px solid var(--game-line);
  border-radius: 24px;
  background: var(--game-canvas);
}

.hero__copy {
  padding: 28px 30px;
}

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

.hero__copy h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.04;
}

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

.seo-intro {
  margin-top: 14px;
}

.seo-intro h2 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--game-muted);
}

.seo-intro p {
  margin: 6px 0 0;
  color: var(--game-muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

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

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

.hero__actions {
  margin-top: 20px;
}

.hero__status {
  padding: 24px;
}

.hero__status strong {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
}

.hero__status span {
  display: block;
  margin-top: 8px;
  color: var(--game-muted);
  line-height: 1.6;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid var(--game-line);
  border-radius: var(--game-pill);
  color: var(--game-ink);
  background: var(--game-canvas);
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

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

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

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

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

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

.panel {
  padding: 24px;
}

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

.preview-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.summary {
  margin: 0;
  color: var(--game-muted);
  font-size: 0.95rem;
}

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

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

.field > span {
  font-weight: 800;
  font-size: 0.95rem;
}

.field input[type="text"],
.field textarea {
  padding: 12px 14px;
  border: 1px solid var(--game-line);
  border-radius: 14px;
  background: var(--game-pearl);
  color: var(--game-ink);
}

.field textarea {
  resize: vertical;
  min-height: 180px;
  line-height: 1.6;
}

.field-hint {
  color: var(--game-muted);
  font-size: 0.85rem;
}

.option-card {
  margin: 0;
  padding: 14px 16px 16px;
  border: 1px solid var(--game-line);
  border-radius: 18px;
  background: var(--game-pearl);
}

.option-card legend {
  padding: 0 6px;
  font-weight: 800;
  font-size: 0.95rem;
}

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

.toggle-stack label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--game-ink);
  line-height: 1.5;
}

.feedback {
  min-height: 1.4em;
  margin: 0;
  padding: 0 2px;
  color: var(--game-muted);
  line-height: 1.55;
}

.feedback.is-success {
  color: #167044;
}

.feedback.is-warning {
  color: #9a6b15;
}

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

.empty-state {
  display: grid;
  gap: 8px;
  place-content: center;
  min-height: 260px;
  padding: 24px;
  text-align: center;
  background: var(--game-pearl);
}

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

.empty-state p {
  margin: 0;
  color: var(--game-muted);
  line-height: 1.6;
}

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

/* --- 낱말퍼즐 활동지 --- */

.worksheet-page {
  padding: 26px 28px 30px;
}

.worksheet-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--game-ink);
}

.worksheet-title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.worksheet-name {
  color: var(--game-muted);
  font-size: 1rem;
  white-space: nowrap;
}

.cw-grid-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
  container-type: inline-size;
}

.cw-grid {
  display: grid;
  gap: 0;
  max-width: 100%;
  /* 폭이 좁아지면 칸과 함께 글자도 줄어들도록 칸 크기 기준으로 계산한다. */
  font-size: calc(var(--cw-cell-px, 48px) * 0.52);
}

@supports (width: 1cqw) {
  .cw-grid {
    font-size: calc(min(var(--cw-cell-px, 48px), 100cqw / var(--cw-cols, 10)) * 0.52);
  }
}

.cw-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

.cw-cell--filled {
  border: 1.5px solid var(--cw-cell-line);
  background: #ffffff;
  margin: -0.75px;
}

.cw-cell--empty {
  visibility: hidden;
}

.cw-num {
  position: absolute;
  top: 2px;
  left: 4px;
  color: var(--cw-number);
  font-size: 0.62em;
  font-weight: 800;
  line-height: 1;
}

.cw-answer .cw-cell--filled {
  color: var(--game-ink);
}

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

.cw-clue-group h4 {
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1.5px solid var(--game-line);
  font-size: 1.1rem;
  font-weight: 800;
}

.cw-clue-group ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 7px;
}

.cw-clue-group li {
  display: flex;
  gap: 8px;
  color: var(--game-ink);
  font-size: 0.98rem;
  line-height: 1.5;
}

.cw-clue-group li strong {
  flex: 0 0 auto;
  color: var(--cw-number);
  font-weight: 800;
}

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

  .cw-clues {
    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 {
    border: 0;
    border-radius: 0;
    padding: 0 0 18px;
    page-break-after: always;
  }

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

  .cw-cell--filled {
    border-color: #6f6f76;
  }
}
