/* game.css의 표지판·입력 카드 구성을 주제 게임에 한정해 사용한다. */
.topic-page { --line-c: #0f7b77; max-width: 820px; padding-top: 26px; padding-bottom: 24px; }
.topic-heading { margin-bottom: 24px; }
.topic-eyebrow { color: var(--line-c); font-size: 12px; font-weight: 800; letter-spacing: .05em; margin: 0 0 8px; }
.topic-heading h1 { font-size: clamp(26px, 5vw, 34px); margin: 0 0 10px; }
.topic-heading p:not(.topic-eyebrow) { color: var(--ink-2); line-height: 1.7; }
.topic-page .line-select { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.topic-page .line-select-card { display: block; overflow: hidden; border: 5px solid var(--line-c); border-radius: 22px; background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); transition: transform .15s; }
.topic-page .line-select-card:hover { transform: translateY(-3px); }
.topic-page .lsc-main { padding: 14px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topic-page .lsc-thumb { width: 100%; height: 88px; object-fit: contain; }
/* Keep the selection card's full thumbnail row, clipping only its 120 × 84 artwork window. */
.topic-page .lsc-thumb-slot { display: flex; justify-content: center; align-items: center; width: 100%; height: 88px; flex: none; }
.topic-page .lsc-thumb-frame { display: block; width: 120px; height: 84px; max-width: 100%; max-height: 100%; overflow: hidden; }
.topic-page .lsc-thumb-frame .lsc-thumb { display: block; width: 100%; height: 100%; max-width: none; object-fit: cover; object-position: var(--thumb-position); transform: scale(var(--thumb-scale, 1)); transform-origin: var(--thumb-position); }
.topic-page .lsc-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.topic-page .lsc-body b { font-size: 20px; letter-spacing: -.03em; }
.topic-page .lsc-body small { color: var(--ink-2); font-size: 11px; }
.topic-page .lsc-count { margin-left: auto; border-radius: 50%; background: var(--line-c); color: #fff; display: grid; place-items: center; width: 36px; height: 36px; font-size: 13px; font-weight: 800; }
.topic-page .lsc-direction { display: flex; justify-content: space-between; gap: 8px; padding: 9px 14px; background: color-mix(in srgb, var(--line-c) 8%, white); font-size: 11px; color: var(--line-c); font-weight: 700; }
.topic-page.game-play { max-width: 1000px; padding-top: 18px; }
.topic-page .map-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.topic-page .map-back { color: var(--ink-2); font-size: 12px; }
.topic-page .map-head h1 { display: flex; align-items: center; font-size: 21px; margin: 0 auto 0 2px; }
.topic-page .game-line-dot { width: 13px; height: 13px; background: var(--line-c); border-radius: 50%; margin-right: 8px; }
.topic-page .sound-toggle, .topic-page .fullscreen-toggle { border: 1px solid var(--line); border-radius: 99px; background: var(--surface); color: var(--ink); height: 38px; cursor: pointer; font: inherit; font-size: 13px; padding: 0 12px; }
.topic-page .sound-toggle { width: 38px; padding: 0; font-size: 17px; }
.topic-page .game-stats { display: flex; flex-wrap: wrap; gap: 6px 20px; color: var(--ink-2); font-size: 12px; margin-bottom: 10px; }
.topic-page .game-stats b { color: var(--ink); font-variant-numeric: tabular-nums; }
.topic-page .game-stage { position: relative; display: flex; flex-direction: column; height: clamp(340px, calc(100dvh - 238px), 620px); border: 1px solid var(--line); border-radius: 24px; background: var(--surface-2); overflow: hidden; }
.topic-page .topic-art { flex: 1; min-height: 0; padding: 14px; display: flex; justify-content: center; align-items: center; }
.topic-page .topic-art { position: relative; }
.topic-page .topic-auxiliary { position: absolute; right: 10px; bottom: 8px; margin: 0; width: clamp(86px, 22%, 180px); max-height: 94%; padding: 5px; border: 1px solid #b8c3d1; border-radius: 10px; background: #f8fafc; color: #273547; }
.topic-page .topic-auxiliary img { display: block; width: 100%; height: min(16vh, 145px); object-fit: contain; }
.topic-page .topic-auxiliary figcaption { font-size: 10px; line-height: 1.3; text-align: center; }
/* Native circuit SVGs use dark strokes; keep their canvas light in every theme. */
.topic-page[data-topic="electronics"] .topic-art, .topic-page[data-topic="semiconductor"] .topic-art,
.topic-page[data-topic="electronics"] .lsc-thumb, .topic-page[data-topic="semiconductor"] .lsc-thumb { background: #f8fafc; border-radius: 12px; }
.topic-page .topic-credits { margin-top: 32px; font-size: 13px; line-height: 1.8; }
.topic-page .topic-content { margin: 40px auto 0; max-width: 780px; line-height: 1.85; overflow-wrap: anywhere; }
.topic-page .topic-content h2 { margin: 32px 0 14px; font-size: 22px; line-height: 1.4; }
.topic-page .topic-content h3 { margin: 22px 0 8px; font-size: 17px; line-height: 1.5; }
.topic-page .topic-content p, .topic-page .topic-content li { color: var(--ink-2); }
.topic-page .topic-content ul, .topic-page .topic-name-list { padding-left: 1.6em; }
.topic-page .topic-content li { margin: 6px 0; }
.topic-page .topic-name-list { columns: 2; column-gap: 36px; }
.topic-page .topic-name-list li { break-inside: avoid; }
.topic-page .topic-content a, .topic-page .topic-credits a { color: var(--line-c); text-decoration: underline; text-underline-offset: 3px; }
.topic-page .topic-how-to-play { padding-left: 1.6em; }
.topic-page .topic-content .topic-start { color: #fff; text-decoration: none; white-space: normal; }
.topic-page .topic-related { display: flex; flex-wrap: wrap; gap: 10px 20px; }
.topic-page:fullscreen .topic-content, .topic-page:fullscreen .topic-draft, .topic-page:fullscreen .topic-credits { display: none; }
@media (max-width: 640px) {
  .topic-page .topic-name-list { columns: 1; }
  .topic-page .topic-content { margin-top: 32px; }
}
.topic-page #gImage { display: block; width: 100%; height: 100%; object-fit: contain; }
.topic-page .game-card { position: relative; flex: none; margin: 0 12px 12px; border: 5px solid var(--line-c); border-radius: 22px; padding: 12px; background: var(--surface); overflow: hidden; }
.topic-page .station-sign { position: relative; z-index: 1; margin-bottom: 10px; text-align: center; }
.topic-page .station-neighbors { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr); align-items: center; gap: 8px; }
.topic-page .station-neighbors p, .topic-page .g-reading { margin: 0; }
.topic-page .g-current { color: var(--line-c); font-size: clamp(24px, 4vw, 34px); font-weight: 850; line-height: 1.25; overflow-wrap: anywhere; }
.topic-page .g-prev, .topic-page .g-next { color: var(--ink-2); font-size: 12px; overflow-wrap: anywhere; }
.topic-page .g-prev { text-align: left; }
.topic-page .g-next { text-align: right; }
.topic-page .g-reading { color: var(--ink-2); font-size: 13px; line-height: 1.5; margin-top: 4px; }
.topic-page #gInput { position: relative; z-index: 1; width: 100%; height: 48px; padding: 8px 12px; border: 2px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; font-size: 20px; text-align: center; outline: none; }
.topic-page #gInput:focus { border-color: var(--line-c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--line-c) 12%, transparent); }
.topic-page #gInput.miss { border-color: #d23c3c; }
.topic-page .g-hint { margin: 8px 0 0; color: var(--ink-2); text-align: center; font-size: 11px; }
.topic-page .game-bar { height: 6px; margin-top: 12px; border-radius: 99px; background: var(--line); overflow: hidden; }
.topic-page .game-bar i { display: block; width: 0; height: 100%; background: var(--line-c); border-radius: inherit; transition: width .2s; }
.topic-page .g-flash { position: absolute; inset: 0; opacity: 0; background: #fff; pointer-events: none; }
.topic-page .game-stage.is-complete { height: auto; min-height: 360px; justify-content: center; }
.topic-page .is-complete .topic-art { display: none; }
.topic-page .game-done { padding: 32px 20px; text-align: center; }
.topic-page .game-done h2 { font-size: 28px; }
.topic-page .gd-time { font-size: 48px; font-weight: 850; color: var(--line-c); margin: 14px 0 6px; font-variant-numeric: tabular-nums; }
.topic-page .gd-badge { display: inline-block; background: var(--line-c); color: white; border-radius: 99px; padding: 4px 12px; font-size: 12px; font-weight: 700; }
.topic-page .gd-stats { font-size: 13px; color: var(--ink-2); margin: 12px 0 22px; }
.topic-page .gd-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.topic-page .gd-actions .btn { font-size: 13px; }
.topic-page .topic-draft { margin: 16px 0 0; color: var(--ink-3); text-align: center; font-size: 11px; }
.topic-page [hidden] { display: none !important; }
.topic-page:fullscreen { width: 100%; max-width: none; height: 100dvh; padding: 16px; overflow-y: auto; background: var(--surface); display: flex; flex-direction: column; }
.topic-page:fullscreen .game-stage { flex: 1; min-height: 220px; height: auto; }
@media (max-width: 640px) {
  .topic-page { padding-top: 18px; }
  .topic-page .line-select { grid-template-columns: 1fr; gap: 12px; }
  .topic-page .lsc-main { flex-wrap: nowrap; padding: 10px; gap: 10px; }
  .topic-page .lsc-thumb { width: 70px; height: 64px; flex: none; }
  .topic-page .lsc-thumb-slot { width: 70px; height: 64px; }
  .topic-page .lsc-body b { font-size: 18px; }
  .topic-page .lsc-count { width: 30px; height: 30px; flex: none; }
  .topic-page.game-play { padding-top: 12px; }
  .topic-page .map-head { gap: 6px; margin-bottom: 8px; }
  .topic-page .map-head h1 { font-size: 17px; }
  .topic-page .map-back { font-size: 11px; }
  .topic-page .fullscreen-toggle { width: 34px; padding: 0; }
  .topic-page .fullscreen-toggle span { display: none; }
  .topic-page .sound-toggle { width: 34px; height: 34px; }
  .topic-page .game-stats { gap: 4px 11px; font-size: 11px; }
  .topic-page .game-stage { height: calc(100dvh - 216px); border-radius: 18px; }
  .topic-page .topic-art { padding: 6px; }
  .topic-page .game-card { margin: 0 6px 6px; border-width: 4px; padding: 9px; border-radius: 18px; }
  .topic-page .g-current { font-size: 25px; }
  .topic-page .g-prev, .topic-page .g-next { font-size: 10px; }
  .topic-page .g-reading { font-size: 12px; }
  .topic-page #gInput { height: 43px; font-size: 18px; }
  .topic-page .g-hint { font-size: 10px; line-height: 1.4; margin-top: 6px; }
  .topic-page .is-compact .g-hint { display: none; }
  .topic-page .is-compact .station-neighbors { grid-template-columns: minmax(0, 1fr) minmax(0, 3fr) minmax(0, 1fr); gap: 4px; }
  .topic-page .is-compact .g-current { font-size: 22px; }
  .topic-page .is-compact .g-prev, .topic-page .is-compact .g-next { font-size: 9px; }
  .topic-page .gd-actions { flex-direction: column; }
  .topic-page .game-done { padding: 26px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .topic-page *, .topic-page *::before, .topic-page *::after { transition: none !important; }
}

/* Hub cards reuse the topic selection colors and thumbnail layout. */
.topic-page .topic-hub-back { margin-bottom: 14px; }
.topic-page:fullscreen .topic-hub-back { display: none; }
.topic-page .topic-hub-group { margin: 28px 0; }
.topic-page [data-ad-placement="typing-hub-mid"] { margin-top: 150px; margin-bottom: 150px; }
.topic-page .topic-hub-group .line-select { align-items: start; }
.topic-page .topic-hub-card { --topic-hub-ink: color-mix(in srgb, var(--line-c) 65%, var(--ink)); min-width: 0; overflow: hidden; border: 5px solid var(--line-c); border-radius: 22px; background: var(--surface); box-shadow: var(--sh-1); }
.topic-page .topic-hub-card h3 { margin: 0; font-size: 20px; line-height: 1.35; overflow-wrap: anywhere; }
.topic-page .topic-hub-card a { color: var(--topic-hub-ink); text-decoration: none; }
.topic-page .topic-hub-card a:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: var(--r-s); }
.topic-page .topic-hub-card .lsc-main { align-items: center; flex-wrap: nowrap; padding: var(--s4); }
.topic-page .topic-hub-card .lsc-main > a { flex: none; }
.topic-page .topic-hub-card .lsc-thumb { width: 76px; height: 72px; }
.topic-page .topic-hub-card .lsc-thumb-slot { width: 76px; height: 72px; }
.topic-page .topic-hub-card .lsc-thumb-frame .lsc-thumb { width: 100%; height: 100%; }
.topic-page .topic-hub-sets { display: grid; gap: var(--s2); list-style: none; margin: 0; padding: 0 var(--s4) var(--s4); }
.topic-page .topic-hub-sets > li { min-width: 0; margin: 0; padding: 0; }
.topic-page .topic-hub-card .topic-hub-set { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s2); min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface-2); color: var(--ink); line-height: 1.45; transition: background-color .15s, border-color .15s; }
.topic-page .topic-hub-set-name { min-width: 0; font-size: 14px; font-weight: 800; overflow-wrap: anywhere; }
.topic-page .topic-hub-set-meta { display: flex; align-items: center; gap: var(--s2); white-space: nowrap; }
.topic-page .topic-hub-set-count { padding: 4px 8px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--line-c) 12%, var(--surface)); color: var(--topic-hub-ink); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.topic-page .topic-hub-set-arrow { display: inline-block; color: var(--topic-hub-ink); transition: transform .15s; }
.topic-page .topic-hub-set:hover,
.topic-page .topic-hub-set:focus-visible { background: color-mix(in srgb, var(--line-c) 7%, var(--surface)); border-color: color-mix(in srgb, var(--line-c) 30%, var(--line)); }
.topic-page .topic-hub-set:hover .topic-hub-set-arrow,
.topic-page .topic-hub-set:focus-visible .topic-hub-set-arrow { transform: translateX(3px); }
.topic-page .topic-hub-card[data-topic="electronics"] .lsc-thumb,
.topic-page .topic-hub-card[data-topic="semiconductor"] .lsc-thumb { background: #f8fafc; border-radius: 12px; }

/* 국기는 투명 외곽과 원래 비율을 보존하고 흰 바탕의 경계를 드러낸다. */
.topic-page[data-topic="flag"] #gImage,
.topic-page[data-topic="flag"] .lsc-thumb,
.topic-page .topic-hub-card[data-topic="flag"] .lsc-thumb {
  object-fit: contain;
  filter: drop-shadow(0 0 1px #64748b) drop-shadow(0 2px 3px #64748b55);
}

/* 구름 장면은 하늘 전체를 보존한다. 게임에서는 정사각형을 최대 크기로 표시한다. */
.topic-page[data-topic="cloud"] .topic-art { padding: 0; }
.topic-page[data-topic="cloud"] #gImage { object-fit: contain; filter: none; }
.topic-page[data-topic="cloud"] .lsc-thumb,
.topic-page .topic-hub-card[data-topic="cloud"] .lsc-thumb { width: 76px; height: 76px; object-fit: cover; border-radius: 8px; filter: none; }

/* 희귀 원소 한자용 운영체제 폴백. 미설치 글꼴을 내려받는 경로는 만들지 않는다. */
.topic-page[data-topic="element"],
.topic-page .topic-hub-card[data-topic="element"] {
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "PingFang SC", "PingFang TC", "Hiragino Sans GB", "Heiti SC", "Heiti TC", "Microsoft YaHei", "Microsoft JhengHei", "Noto Sans CJK SC", "Noto Sans CJK TC", "Noto Sans SC", "Noto Sans TC", "HanaMinB", "BabelStone Han", "SimSun-ExtB", "SimSun-ExtG", "MingLiU-ExtB", sans-serif;
}
