/* 오늘의 초성 — 모바일 우선, 다크 기본 */

:root {
  --point: #3ddc97;
  --bg: #0e1113;
  --surface: #171b1e;
  --surface-2: #1f2427;
  --line: #2b3134;
  --text: #f2f5f4;
  --text-dim: #9aa4a7;
  --wrong: #3a2b2f;
}

* {
  box-sizing: border-box;
}

/* display: flex 가 걸린 요소는 hidden 속성만으로 숨겨지지 않는다 (명시도에서 밀림) */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  /* CDN이 정의하는 패밀리명은 'Pretendard Variable'. 로컬 설치본(Pretendard)은 그다음. */
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont,
    'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 28px 20px calc(32px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* ── 헤더 ─────────────────────────── */
.series {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.series .bar {
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: var(--point);
}

.series .round {
  margin-left: auto;
  color: var(--point);
  font-variant-numeric: tabular-nums;
}

/* ── 문제 ─────────────────────────── */
.puzzle {
  text-align: center;
  padding: 28px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.category {
  margin: 0 0 18px;
  display: inline-block;
  padding: 5px 12px;
  border: 1px solid var(--point);
  border-radius: 999px;
  color: var(--point);
  font-size: 12px;
  font-weight: 700;
}

/* 아직 안 열린 카테고리 — 자리는 지키면서 "열릴 것"임을 알린다 */
.category.is-locked {
  border-color: var(--line);
  color: var(--text-dim);
  letter-spacing: 0.16em;
}

.chosung {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.chosung-tile {
  min-width: 46px;
  padding: 10px 6px;
  background: var(--surface-2);
  border-radius: 10px;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
}

/* 초성은 최대 6글자. 5~6글자는 타일을 줄여 320px 화면에서도 한 줄에 담는다.
   6 × 34px + 5 × 6px = 234px — 320px 화면의 가용 폭(246px)보다 좁게 잡아 여유를 둔다. */
.chosung[data-count='5'],
.chosung[data-count='6'] {
  gap: 6px;
}

.chosung[data-count='5'] .chosung-tile,
.chosung[data-count='6'] .chosung-tile {
  min-width: 34px;
  padding: 9px 4px;
  font-size: 24px;
}

.meta {
  margin: 18px 0 0;
  color: var(--text-dim);
  font-size: 12px;
}

/* ── 힌트 ─────────────────────────── */
.hints {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hint {
  margin: 0;
  padding: 12px 14px;
  background: var(--surface);
  border-left: 3px solid var(--point);
  border-radius: 0 10px 10px 0;
  font-size: 14px;
  line-height: 1.5;
  animation: rise 0.25s ease-out;
}

.hint-no {
  display: block;
  margin-bottom: 3px;
  color: var(--point);
  font-size: 11px;
  font-weight: 700;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ── 시도 보드 ─────────────────────── */
.board {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slot {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
}

.slot.is-wrong {
  background: var(--wrong);
  border-color: transparent;
  color: var(--text-dim);
  text-decoration: line-through;
}

.slot.is-correct {
  background: var(--point);
  border-color: transparent;
  color: #06231a;
}

/* ── 입력 ─────────────────────────── */
.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  flex: 1;
  min-width: 0;
  height: 50px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
}

.input-row input::placeholder {
  color: var(--text-dim);
  font-weight: 500;
}

.input-row input:focus {
  outline: 2px solid var(--point);
  outline-offset: -1px;
}

button {
  height: 50px;
  padding: 0 20px;
  background: var(--point);
  border: 0;
  border-radius: 12px;
  color: #06231a;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

button:active {
  transform: scale(0.97);
}

/* ── 토스트 ───────────────────────── */
.toast {
  margin: -12px 0 0;
  min-height: 18px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s;
}

.toast.is-visible {
  opacity: 1;
}

/* ── 결과 ─────────────────────────── */
.result {
  padding: 24px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  text-align: center;
}

.result h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.result-answer {
  margin: 0 0 16px;
  color: var(--point);
  font-size: 26px;
  font-weight: 800;
}

.card-preview {
  margin: 0 0 16px;
  min-height: 60px;
  color: var(--text-dim);
  font-size: 13px;
}

/* 카드는 1080×1350 캔버스 — 컨테이너 폭에 맞춰 축소해 보여준다 */
.card-preview canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-actions button {
  width: 100%;
}

button.secondary {
  background: var(--surface-2);
  color: var(--text);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.countdown {
  margin: 14px 0 0;
  color: var(--text-dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ── 푸터 ─────────────────────────── */
footer {
  padding-top: 8px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 12px;
  font-weight: 600;
}

footer a {
  display: inline-block;
  padding: 6px 10px;
  color: var(--text-dim);
  text-decoration: none;
  opacity: 0.75;
}

footer a:hover,
footer a:focus-visible {
  color: var(--point);
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
