/* —— 짬짬이 낱말 — Coral 디자인 시스템 ——
   자매 사이트(게임·퀴즈·영상·이야기·쉼)와 같은 상단바 구조(색 띠 + 로고 46px + 제목 + 부제),
   띠 색만 이 사이트의 코럴을 쓴다.

   출제 화면은 이 제품의 전부다. 문제 한 줄이 전자칠판 뒷자리에서 읽혀야 하므로
   글자 크기는 문제 길이에 따라 세 단계로 갈라진다(.quiz-prompt[data-len]). */

/* —— 웹폰트: Pretendard(가변) 자가 호스팅 ——
   assets/fonts/PretendardVariable.subset.woff2 는 짬짬이 가족이 쓰는 글자만 남긴
   서브셋. 서브셋에 없는 글자는 시스템 한글 폰트로 자연스럽게 넘어간다.
   라이선스: SIL OFL 1.1 — assets/fonts/LICENSE.txt */
@font-face {
  font-family: 'Pretendard Variable';
  font-style: normal;
  font-weight: 45 920;
  font-display: swap;
  src: url('../assets/fonts/PretendardVariable.subset.woff2') format('woff2-variations');
}

:root {
  /* 브랜드 색 — 원값은 여기 한 곳뿐이다. 나머지는 color-mix 로 파생된다.
     (PRD 10절: 아이콘 시안 보고 확정 → 이 한 줄만 바꾸면 전체가 따라온다) */
  --accent: #E4576E;

  --accent-deep: color-mix(in srgb, var(--accent) 74%, #000);
  --accent-soft: color-mix(in srgb, var(--accent) 16%, #fff);
  --on-accent: #ffffff;

  --bg: color-mix(in srgb, var(--accent) 5%, #fff);
  --card: #ffffff;
  --surface: color-mix(in srgb, var(--accent) 10%, #fff);
  --surface-high: color-mix(in srgb, var(--accent) 20%, #fff);
  --outline-variant: color-mix(in srgb, var(--accent) 28%, #fff);

  --ink: #3a1219;
  --ink-soft: #6f4a52;

  --radius: 20px;
  --radius-sm: 12px;
  --radius-pill: 9999px;

  --gutter: 32px;
  --maxw: 1180px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

[hidden] { display: none !important; }

html { font-size: 18px; }

body {
  font-family: "Pretendard Variable", "Pretendard", "Noto Sans KR",
               "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}

button { font-family: inherit; cursor: pointer; }

kbd {
  font-family: inherit;
  font-size: 0.72em;
  font-weight: 700;
  padding: 0.1em 0.42em;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.14);
  vertical-align: 0.08em;
  white-space: nowrap;
}

.ic { width: 1.5em; height: 1.5em; flex: 0 0 auto; vertical-align: -0.35em; user-select: none; }
.brand-icon .ic { width: 46px; height: 46px; }   /* 사이트 아이콘 — 자매 로고와 같은 크기 */

/* —— 상단바 — 가족 공통 구조: 색 띠, 본문과 같은 max-width 가운데 정렬 —— */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0.9rem var(--gutter);
  background: var(--accent);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 30%, transparent);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; color: var(--on-accent); }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-size: 1.28rem; font-weight: 800; letter-spacing: -0.01em; }
.brand-sub { font-size: 0.78rem; font-weight: 600; opacity: 0.88; }

.topbar-actions { display: flex; align-items: center; gap: 0.4rem; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--on-accent);
  transition: background 0.12s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.16); }
.icon-btn:focus-visible { outline: 3px solid #FFD34D; outline-offset: 2px; }
.icon-btn .ic-line { width: 26px; height: 26px; }
.ic-line path { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ic-line .spk { fill: currentColor; stroke: none; }
/* 음소거 상태에서만 X 가 보이고 음파가 사라진다 */
.icon-btn .spk-x { display: none; }
.icon-btn[aria-pressed="true"] .spk-x { display: inline; }
.icon-btn[aria-pressed="true"] .spk-wave { display: none; }
/* 전체화면 — 켜져 있으면 모서리가 안쪽을 향한다(끄기). API 가 없으면 숨긴다(inline-flex 가 hidden 을 이기지 않게). */
.icon-btn[hidden] { display: none; }
.icon-btn .fs-out { display: none; }
.icon-btn[aria-pressed="true"] .fs-in { display: none; }
.icon-btn[aria-pressed="true"] .fs-out { display: inline; }

/* —— 수업 타이머 — 오른쪽 위에 따로 사는 패널 ——
   화면(.screen)이 아니라 그 밖에 있다. 여섯 화면을 토글해도 이 패널은 그대로다.
   숫자가 이 패널의 주인공이라 크게 둔다 — 교실 뒷자리에서 읽혀야 한다. */
.clock {
  position: fixed;
  top: 92px;
  /* 창 오른쪽 끝이 아니라 *본문 오른쪽*에 붙인다. 넓은 화면에서 창 끝에 두면
     문제 글자와 시계가 멀어져, 둘을 번갈아 보는 사이 눈이 화면을 가로지른다.
     --rail = 창 끝에서 본문(1180px) 끝까지의 여백. */
  --rail: max(0px, calc((100vw - var(--maxw)) / 2));
  right: calc(var(--rail) - 260px);
  z-index: 9;
  width: 276px;
  padding: 0.85rem 0.9rem 0.8rem;
  border: 2px solid var(--outline-variant);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 12px 30px color-mix(in srgb, var(--accent) 18%, transparent);
  text-align: center;
}

/* 제목("수업 타이머")은 두지 않는다. 숫자만 보면 시계인 줄 아는데, 제목이 있으면
   그만큼 숫자가 작아진다. 그 자리를 숫자에 준다 — 교실 뒷자리 기준이다.
   (읽어 주는 이름은 aria-label 로 남아 있다.) */
.clock-time {
  /* 숫자 폭을 고정한다 — 3:59→3:58 마다 패널이 들썩이면 눈이 그리로 끌린다. */
  font-variant-numeric: tabular-nums;
  font-size: 5.4rem;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--accent-deep);
  transition: color 0.12s, transform 0.12s;
}
.clock[data-state="idle"] .clock-time { color: color-mix(in srgb, var(--ink-soft) 45%, #fff); }
/* 멈춤 — 색을 빼서 "지금은 안 흐른다"를 조용히 알린다. */
.clock[data-state="paused"] .clock-time { color: var(--ink-soft); }

/* 마지막 10초 — 색만으로 알리지 않는다. 크기도 커지고, 1초마다 한 번 부풀었다 준다.
   가만히 있는 큰 숫자보다 움직이는 숫자가 교실 뒤에서 먼저 눈에 걸린다. */
.clock[data-state="urgent"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, #fff); }
.clock[data-state="urgent"] .clock-time { color: var(--accent); transform: scale(1.1); }
.clock[data-state="urgent"] .clock-time.is-beat { animation: clock-beat 0.5s ease-out; }

@keyframes clock-beat {
  0% { transform: scale(1.1); }
  22% { transform: scale(1.28); }
  100% { transform: scale(1.1); }
}

/* 마지막 10초 — 상단바 하나만 쓴다.
   화면을 빙 두르는 테두리도 만들어 봤지만, 늘 거기 있는 굵은 선이 되어 무엇을
   알리는지 알 수 없었다. 이미 색 띠인 상단바가 1초마다 밝아졌다 돌아오면
   그 자체로 초침이 되고, 본문은 조금도 가려지지 않는다. */
body.is-urgent .topbar { animation: topbar-pulse 1s ease-in-out infinite; }
body.is-over .topbar { background: var(--accent-deep); }

@keyframes topbar-pulse {
  0%, 100% { background: var(--accent); }
  50% { background: var(--accent-deep); }
}

/* 0 초 — 숫자 대신 말로 알린다. 놀이는 그대로 두고 알리기만 한다.
   패널 전체를 진한 색으로 덮지는 않는다 — 그러면 지금 걸려 있는 시간 표시와
   [잠깐]·[↺] 이 배경에 묻혀, 정작 다음에 눌러야 할 것이 안 보인다. */
.clock[data-state="over"] { border-color: var(--accent); background: var(--accent-soft); }
.clock[data-state="over"] .clock-time { color: var(--accent); font-size: 3.4rem; }

.clock-picks { display: flex; gap: 0.25rem; margin-top: 0.5rem; }
.clock-picks button {
  flex: 1;
  padding: 0.42rem 0;
  border: 1px solid var(--outline-variant);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
}
.clock-picks button:hover { background: var(--surface); }
.clock-picks button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.clock-controls { display: flex; gap: 0.25rem; margin-top: 0.35rem; }
.clock-tickbtn { width: 100%; margin-top: 0.25rem; font-size: 0.8rem; }
.clock-tickbtn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.clock-btn {
  flex: 1;
  padding: 0.42rem 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 700;
}
.clock-btn:hover { background: var(--surface-high); }
.clock-btn[disabled] { opacity: 0.42; cursor: default; }
.clock-reset { flex: 0 0 2.6rem; font-size: 1.05rem; line-height: 1; }
.clock-picks button:focus-visible,
.clock-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.clock-btn kbd { background: rgba(0, 0, 0, 0.09); }

@media (prefers-reduced-motion: reduce) {
  .clock-time { transition: none; }
  /* 움직임을 줄여 달라고 한 사람에게는 깜빡이지 않는다. 색과 크기는 그대로 남으므로
     "곧 끝난다"는 여전히 보인다. */
  .clock[data-state="urgent"] .clock-time.is-beat { animation: none; }
  body.is-urgent .topbar { animation: none; background: var(--accent-deep); }
}

/* —— 화면 공통 —— */
.screen {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.6rem var(--gutter) 2.4rem;
}

/* —— 안내 띠 — 헤더 아래 흰 한 줄 (가족 공통) —— */
.cta-strip {
  background: var(--card);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius);
  padding: 0.9rem 1.3rem;
  margin-bottom: 1.6rem;
  text-align: center;
}
.cta-copy { font-size: 1.05rem; color: var(--ink-soft); }
.cta-copy b { color: var(--accent-deep); font-weight: 800; }

.group-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink-soft);
  margin: 1.5rem 0 0.7rem;
}
.group-title:first-of-type { margin-top: 0.4rem; }

/* —— 유형 카드 —— */
.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.9rem;
}

.type-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  text-align: left;
  padding: 1.15rem 1.25rem;
  background: var(--card);
  border: 2px solid var(--outline-variant);
  border-radius: var(--radius);
  transition: transform 0.1s, border-color 0.12s, box-shadow 0.12s;
}
.type-card:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 18%, transparent);
}
.type-card:active { transform: translateY(1px); }
.type-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.type-emoji { font-size: 2.1rem; line-height: 1; flex: 0 0 auto; }
.type-body { display: flex; flex-direction: column; gap: 0.15rem; }
.type-label { font-size: 1.16rem; font-weight: 800; color: var(--ink); }
.type-blurb { font-size: 0.86rem; color: var(--ink-soft); }

/* —— 조건 선택 —— */
.setup-title { font-size: 1.9rem; font-weight: 900; margin-bottom: 1.1rem; }

.setup-card {
  background: var(--card);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}
.setup-group h2 { font-size: 1rem; font-weight: 800; color: var(--ink-soft); margin-bottom: 0.6rem; }

.option-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.option-btn {
  padding: 0.62rem 1.15rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
  transition: background 0.12s, color 0.12s;
}
.option-btn:hover { background: var(--surface-high); }
.option-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.option-btn[aria-checked="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

.setup-count { font-size: 0.94rem; color: var(--ink-soft); }
.setup-count.is-empty { color: var(--accent-deep); font-weight: 700; }
.setup-live {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  padding-top: 1rem;
  border-top: 1px dashed var(--outline-variant);
}
.setup-live span { font-size: 0.9rem; color: var(--ink-soft); }

.setup-actions { display: flex; justify-content: space-between; gap: 0.8rem; margin-top: 1.3rem; }

/* —— 버튼 —— */
.btn {
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
  font-weight: 800;
  padding: 0.7rem 1.5rem;
  font-size: 1.02rem;
  transition: transform 0.1s, background 0.12s, box-shadow 0.12s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 32%, transparent);
}
.btn-primary:hover { background: var(--accent-deep); }

.btn-ghost {
  background: transparent;
  color: var(--accent-deep);
  border-color: var(--outline-variant);
}
.btn-ghost:hover { background: var(--surface); }

.btn-big { font-size: 1.24rem; padding: 0.86rem 2.1rem; }
.btn-sm { font-size: 0.86rem; padding: 0.42rem 0.9rem; }

/* —— 출제 화면 — 전자칠판 전면 ——
   문제 하나가 화면의 주인이다. 나머지는 전부 물러난다. */
.quiz, .chain, .gesture {
  min-height: calc(100vh - 84px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  position: relative;
  padding-top: 3.4rem;
}

.quiz-topic, .gesture-topic {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--accent-deep);
  background: var(--accent-soft);
  padding: 0.32rem 1rem;
  border-radius: var(--radius-pill);
}
.quiz-topic:empty, .gesture-topic:empty { display: none; }

/* 글자 크기는 폭(vw)만이 아니라 높이(vh)도 본다. 배율 125~150% 전자칠판을 창 모드로 쓰면
   폭은 넓은데 높이가 740px 안팎이라, 폭만 보고 키운 글자가 [다음 문제] 를 화면 밖으로 밀었다
   (1536×740 에서 초성·반대말·인물 40문항 중 40). 크기는 --prompt-fs 한 곳에 두고,
   낮은 화면의 정답 단계에서 줄일 때 같은 값에 배율만 곱한다(아래 max-height 900px). */
.quiz-prompt {
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: 0.02em;
  text-align: center;
  word-break: keep-all;
  color: var(--ink);
  /* 초성 몇 자짜리 짧은 문제 — 화면 폭을 최대한 쓴다 */
  --prompt-fs: clamp(3rem, min(13vw, 22vh), 11rem);
  font-size: var(--prompt-fs);
}
/* 긴 문제(속담·수수께끼)는 한 화면에 담기도록 단계적으로 줄인다 */
.quiz-prompt[data-len="mid"]  { --prompt-fs: clamp(2.4rem, min(8vw, 14vh), 7rem); letter-spacing: 0; }
.quiz-prompt[data-len="long"] { --prompt-fs: clamp(2rem, min(5.5vw, 9vh), 4.6rem); letter-spacing: 0; line-height: 1.28; }

.quiz-hint {
  font-size: clamp(1.2rem, min(2.6vw, 4.2vh), 2rem);
  font-weight: 700;
  color: var(--ink-soft);
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.7rem 1.5rem;
}

/* 속담처럼 빈칸이 있는 문제는 그 자리에 답이 채워진다. 채워진 부분만 색을 달리해
   무엇이 답이었는지 한눈에 보이게 한다. inline 요소라 transform 대신 opacity 로
   나타낸다 — inline-block 으로 만들면 긴 답이 통째로 줄바꿈을 못 해 화면을 넘긴다. */
@keyframes fill-in { from { opacity: 0; } to { opacity: 1; } }
/* 4글자 이어말하기의 빈칸 — 글자 한 자 폭의 밑줄을 정답 글자 수만큼 끊어 긋는다 */
.quiz-prompt .slot {
  display: inline-block;
  width: 0.9em;
  height: 0.08em;
  margin: 0 0.06em;
  background: currentColor;
  border-radius: 0.04em;
  vertical-align: baseline;
}
.quiz-prompt .filled { color: var(--accent); animation: fill-in 0.28s ease-out both; }
@media (prefers-reduced-motion: reduce) {
  .quiz-prompt .filled { animation: none; }
}

/* —— 우리말 퀴즈 — 글자 칸과 힌트 카드 ——
   문제는 글자 수만큼의 칸이다. 빈칸은 비우고 한 칸에만 초성이 든다(○ㄴ → [ ][ㄴ]).
   칸은 다른 문제보다 한 단계 작게 — 칸 테두리만큼 커 보이고, 아래에 힌트 카드가 붙는다. */
.quiz-prompt.is-tiles {
  --prompt-fs: clamp(2.6rem, min(11vw, 18vh), 10rem);
  display: flex;
  gap: 0.14em;
  justify-content: center;
  letter-spacing: 0;
}
.quiz-prompt .tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2em;
  height: 1.2em;
  border: 0.045em solid var(--outline-variant);
  border-radius: 0.16em;
  background: var(--card);
  line-height: 1;
}
.quiz-prompt .tile.is-blank { border-style: dashed; background: var(--surface); }
.quiz-prompt .tile.is-filled { color: var(--accent); border-color: var(--accent); animation: fill-in 0.28s ease-out both; }

/* 힌트 카드 셋. 닫힌 카드는 점수만, 열린 카드는 힌트 낱말까지. 지금 맞히면 받는 점수의 카드에 테를 두른다. */
.quiz-hints {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(0.5rem, 1.4vw, 1.1rem);
}
.quiz-hints[hidden] { display: none; }
.hint-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  min-width: clamp(7rem, 16vw, 14rem);
  padding: 0.55rem 1.1rem 0.75rem;
  border: 3px dashed var(--outline-variant);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-soft);
}
.hint-card.is-open { border-style: solid; background: var(--card); color: var(--ink); }
.hint-card.is-now {
  border-color: var(--accent);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 22%, transparent);
}
.hint-points {
  font-size: clamp(0.9rem, min(1.7vw, 2.6vh), 1.25rem);
  font-weight: 800;
  padding: 0.1rem 0.75rem;
  border-radius: var(--radius-pill);
  background: var(--surface-high);
  color: var(--ink-soft);
}
.hint-card.is-now .hint-points { background: var(--accent); color: var(--on-accent); }
.hint-word {
  font-size: clamp(1.6rem, min(4.6vw, 7.4vh), 4.4rem);
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  word-break: keep-all;
}
.hint-card:not(.is-open) .hint-word { color: var(--outline-variant); }
.hint-card.is-now .hint-word { animation: fill-in 0.28s ease-out both; }
/* 정답 때 붙는 설명 — 이 힌트가 정답과 어떻게 이어지는지(손 → 손장난). 두 줄까지. */
.hint-why {
  max-width: 10.5em;
  font-size: clamp(0.95rem, min(1.8vw, 3vh), 1.6rem);
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  word-break: keep-all;
  color: var(--accent-deep);
  animation: fill-in 0.28s ease-out both;
}
/* 열기 전에 맞혀서 정답과 함께 열린 힌트 — 점수는 받지 않았으니 점수 표만 물린다. */
.hint-card.is-late .hint-points { opacity: 0.5; }
@media (prefers-reduced-motion: reduce) {
  .quiz-prompt .tile.is-filled, .hint-card.is-now .hint-word, .hint-why { animation: none; }
}

.quiz-answer { text-align: center; }
.answer-text {
  font-size: clamp(2.4rem, min(8vw, 13vh), 6.4rem);
  font-weight: 900;
  color: var(--accent-deep);
  line-height: 1.15;
}
.answer-text[data-len="mid"], .answer-text[data-len="long"] { font-size: clamp(2rem, min(5.5vw, 9vh), 4.6rem); }
.answer-also { font-size: clamp(1rem, 1.9vw, 1.4rem); font-weight: 700; color: var(--ink-soft); margin-top: 0.4rem; }
.answer-note { font-size: clamp(0.95rem, 1.7vw, 1.25rem); color: var(--ink-soft); margin-top: 0.5rem; }
/* 사진 출처 — 라이선스가 요구하는 표시. 읽히되 정답을 가리지 않을 만큼 작게. */
.answer-credit { font-size: 0.8rem; color: var(--ink-soft); margin-top: 0.7rem; }
.answer-credit a { color: inherit; }

/* 인물퀴즈 사진 — 뒷자리에서도 얼굴이 보이도록 화면 높이의 절반 넘게 쓴다(2026-09-30 선생님 요청으로
   38vh → 56vh). 높이를 max 가 아니라 height 로 준다 — max-height 만 주면 사진이 제 크기(720px)보다
   커지지 않아 큰 칠판에서 도로 작아진다. 가로로 긴 사진은 max-width 에 걸리고 object-fit 이 비율을 지킨다. */
.quiz-photo {
  display: block;
  height: 56vh;
  width: auto;
  max-width: min(92vw, 60rem);
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}
.quiz-photo[hidden] { display: none; }
/* 사진이 주인공일 때는 "누구일까요?" 가 사진을 밀어내지 않게 줄인다. */
.quiz-photo:not([hidden]) + .quiz-prompt { font-size: clamp(1.8rem, min(4.6vw, 6.4vh), 3.2rem); }
/* 힌트·정답이 열리면 사진이 물러난다. 안 그러면 좁은 화면에서 [다음 문제] 가 화면 밖으로 밀린다.
   정답 단계에서는 "누구일까요?" 도 할 일을 다 했으니 접는다. */
.quiz[data-stage="HINT"] .quiz-photo { height: 44vh; }
.quiz[data-stage="ANSWER"] .quiz-photo { height: 32vh; }
.quiz[data-stage="ANSWER"] .quiz-photo:not([hidden]) + .quiz-prompt { display: none; }

@keyframes answer-pop {
  0%   { opacity: 0; transform: scale(0.86); }
  60%  { opacity: 1; transform: scale(1.04); }
  100% { opacity: 1; transform: scale(1); }
}
.quiz-answer:not([hidden]) { animation: answer-pop 0.34s cubic-bezier(.2,.9,.3,1.2) both; }
@media (prefers-reduced-motion: reduce) {
  .quiz-answer:not([hidden]) { animation: none; }
}

.quiz-actions, .gesture-actions, .chain-actions {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 0.6rem;
}

/* 오른쪽 위는 수업 타이머가 쓴다(.clock). 진행 버튼은 그 반대편으로 비켜 앉는다 —
   겹치면 좁은 전자칠판에서 [마치기] 가 타이머 밑으로 숨는다. */
.quiz-corner, .gesture-corner, .chain-corner {
  position: absolute;
  top: 1rem;
  left: 0;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.quiz-count, .gesture-count { font-size: 0.9rem; font-weight: 700; color: var(--ink-soft); }

/* —— 끝말잇기 도우미 ——
   시작 단어가 주인공이고, 그 아래 차례와 남은 시간이 큼직하게 붙는다.
   교사는 [성공]·[탈락] 두 버튼만 본다. */
.chain-label, .gesture-topic { font-size: 1rem; font-weight: 800; color: var(--ink-soft); }
.chain-word {
  font-size: clamp(3.4rem, min(14vw, 17vh), 11rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.chain-turn {
  font-size: clamp(1.4rem, 3.4vw, 2.4rem);
  font-weight: 800;
  color: var(--accent-deep);
  background: var(--accent-soft);
  padding: 0.3rem 1.4rem;
  border-radius: var(--radius-pill);
}
/* 남은 시간 링 — 남은 비율을 --left(0~1)로 받아 원호로 그린다.
   전자칠판 뒷자리에서는 두 자리 숫자보다 "얼마나 남았나"가 먼저 읽힌다. */
.chain-clock {
  --left: 1;
  position: relative;
  display: grid;
  place-items: center;
  /* 세로도 함께 본다 — 링만 커지고 아래 [성공]·[탈락]이 화면 밖으로 밀리면 안 된다.
     전자칠판은 넓지만 교탁 노트북 화면은 낮다. */
  width: clamp(5.4rem, min(16vw, 14vh), 11rem);
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(
    var(--accent) calc(var(--left) * 360deg),
    var(--outline-variant) 0
  );
}
/* 가운데를 파내 링으로 만든다 — 통 원이면 숫자가 묻힌다. */
.chain-clock::before {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  background: var(--bg);
}
/* 멈춤 — 색만 가라앉히고 호는 그대로 둔다. 얼마나 남았는지는 계속 보여야 한다. */
.chain-clock.is-paused {
  background: conic-gradient(
    var(--ink-soft) calc(var(--left) * 360deg),
    var(--outline-variant) 0
  );
}
.chain-clock.is-over { background: var(--accent-deep); }

.chain-timer {
  position: relative;   /* 파낸 가운데 위로 */
  font-size: clamp(1.9rem, min(6.4vw, 6.8vh), 4.6rem);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;   /* 숫자가 바뀔 때 폭이 흔들리지 않게 */
  color: var(--ink-soft);
}
/* 남은 3초 — 색으로만 알리지 않는다. 크기도 함께 커져 색을 못 보는 아이도 안다. */
.chain-timer.is-urgent { color: var(--accent); transform: scale(1.12); }
.chain-timer.is-over { color: var(--accent-deep); }

/* 시간 초과 — 판은 아직 살아 있고 교사의 판정을 기다리는 중이다. */
.chain-turn.is-expired {
  background: var(--accent);
  color: var(--on-accent);
}

.chain-log { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; max-width: 42rem; }
/* 낱말을 적으면 기록이 길어진다 — 한 줄만 두고 넘치는 앞쪽은 가린다(최근 것만 js 가 넣는다).
   기록이 줄을 늘리면 [성공]·[탈락]이 화면 밖으로 밀린다. */
.chain-log { flex-wrap: nowrap; overflow: hidden; max-width: min(56rem, 94vw); }
.chain-log-item { white-space: nowrap; }
.chain-log-item {
  font-size: 0.94rem;
  font-weight: 700;
  padding: 0.22rem 0.7rem;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink-soft);
}
.chain-log-item.is-out { background: var(--accent-soft); color: var(--accent-deep); }

/* 이어진 말 한 줄 — 최근 말이 오른쪽 끝. 넘치는 앞쪽은 js 가 빼고 … 을 붙인다. */
.chain-log.is-trail {
  /* 가운데 칸 폭을 넘지 않는다 — 넘치면 왼쪽 끝 낱말이 화면 밖으로 삐져나간다. */
  max-width: min(48rem, 100%);
  align-items: baseline;
  gap: 0.45rem;
  font-size: clamp(1rem, 1.9vw, 1.35rem);
  font-weight: 800;
  color: var(--ink-soft);
}
.chain-trail-word { white-space: nowrap; }
.chain-trail-word:last-child { color: var(--accent-deep); }
.chain-trail-sep, .chain-trail-more { color: var(--outline-variant); font-weight: 700; }
.chain-trail-more { color: var(--ink-soft); }

/* 판 끝 요약 — 이어진 말 전부. 타이머 링 자리를 내주고 여러 줄로 편다. */
.chain-summary { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; max-width: min(64rem, 94vw); }
.chain-summary-title { font-size: clamp(1.4rem, 3.4vw, 2.4rem); font-weight: 900; color: var(--accent-deep); }
.chain-summary-words {
  text-align: center;
  word-break: keep-all;
  font-weight: 800;
  line-height: 1.5;
  color: var(--ink);
  max-height: 34vh;
  overflow-y: auto;
}
.chain-summary-words[data-size="l"] { font-size: clamp(1.3rem, 2.8vw, 2.2rem); }
.chain-summary-words[data-size="m"] { font-size: clamp(1.1rem, 2.1vw, 1.7rem); }
.chain-summary-words[data-size="s"] { font-size: clamp(0.95rem, 1.6vw, 1.3rem); }

/* 다음 글자 — 방금 나온 말 바로 아래. 두음법칙으로 바뀐 글자도 함께 띄운다(력 · 역). */
.chain-next {
  font-size: clamp(1.2rem, 2.8vw, 2rem);
  font-weight: 800;
  color: var(--accent-deep);
  margin-top: -0.4rem;
}

/* 낱말 적기 — 쓰고 싶을 때만. 버튼보다 앞에 두되 눈에 덜 띄게. */
.chain-entry { position: relative; display: flex; flex-direction: column; align-items: center; width: min(30rem, 92%); }
.chain-input {
  width: 100%;
  font: inherit;
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  padding: 0.5rem 1rem;
  border: 2px solid var(--outline-variant);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink);
}
.chain-input::placeholder { color: var(--ink-soft); font-weight: 500; font-size: 1rem; }
.chain-input:focus { outline: none; border-color: var(--accent); }
.chain-warn {
  /* 입력칸 바로 위, 기록 줄에 겹쳐 뜬다 — 경고가 줄을 차지하면 버튼이 밀린다. */
  position: absolute;
  bottom: calc(100% + 0.3rem);
  white-space: nowrap;
  z-index: 1;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-deep);
  background: var(--accent-soft);
  padding: 0.25rem 0.9rem;
  border-radius: var(--radius-pill);
}

/* 교탁 노트북처럼 낮은 화면 — 시작 단어와 간격을 조금 내주고 [성공]·[탈락]을 지킨다.
   판정 버튼이 화면 밖으로 밀리면 도우미가 아니라 방해물이 된다. */
@media (max-height: 860px) {
  .chain { gap: 0.45rem; padding-top: 3rem; }
  /* 낱말 적기 칸이 들어오면서 한 화면에 담을 것이 늘었다 — 낱말·링을 화면 높이에 맞춘다. */
  .chain-word { font-size: clamp(2.6rem, min(11vw, 14vh), 8rem); }
  .chain-turn { font-size: clamp(1.2rem, 3.4vh, 2rem); padding: 0.2rem 1.2rem; }
  .chain-clock { width: clamp(4.6rem, min(16vw, 13vh), 11rem); }
  .chain-timer { font-size: clamp(1.6rem, min(6.4vw, 5.4vh), 4.6rem); }
  .chain-next { margin-top: -0.2rem; }
  .chain-input { font-size: 1.1rem; padding: 0.35rem 1rem; }
}
/* 넘칠 때는 위에서부터 쌓는다 — 가운데 맞춤이 넘치면 맨 위 낱말이 머리띠 밑으로 잘린다. */
.chain { justify-content: safe center; }

/* 출제 화면도 낮은 화면에서는 간격을 내준다 — 문제·힌트·정답이 한꺼번에 쌓이는 정답 단계에서
   [다음 문제] 가 화면 안에 남아야 교사가 칠판을 손으로 스크롤하지 않는다.
   끝말잇기(860px)보다 기준이 높다 — 1536×864 에서 인물퀴즈의 두 줄 힌트·긴 이름이 넘쳤다. */
@media (max-height: 900px) {
  .quiz { gap: 0.6rem; padding-top: 3rem; }
  /* 정답이 문제 아래에 따로 뜨는 단계 — 문제는 할 일을 다 했으니 한 걸음 물러나 정답에 자리를 준다.
     속담처럼 빈칸에 정답이 채워지는 문항(data-filled)은 문제 줄이 곧 정답이라 줄이지 않는다.
     높이가 넉넉한 칠판(1920×1080)에서는 줄이지 않는다 — 거기서는 원래 다 들어갔다. */
  .quiz[data-stage="ANSWER"]:not([data-filled]) .quiz-prompt { font-size: calc(var(--prompt-fs) * 0.62); }
  .quiz-hint { padding: 0.45rem 1.2rem; }
  .quiz-actions { margin-top: 0.2rem; }
  /* 인물 사진도 낮은 화면에서는 한 걸음씩 덜 쓴다 — 1280×720 에서 [다음 문제] 를 지킨다. */
  .quiz-photo { height: 48vh; }
  .quiz[data-stage="HINT"] .quiz-photo { height: 36vh; }
  .quiz[data-stage="ANSWER"] .quiz-photo { height: 22vh; }
  /* 우리말 퀴즈 힌트 카드도 낮은 화면에서는 한 걸음 줄인다 — 카드가 [정답 보기] 를 밀지 않게. */
  .hint-card { padding: 0.35rem 0.9rem 0.5rem; gap: 0.15rem; }
  .hint-word { font-size: clamp(1.4rem, min(3.4vw, 5.4vh), 2.8rem); }
  .hint-why { font-size: clamp(0.9rem, min(1.5vw, 2.4vh), 1.2rem); }
}
.quiz { justify-content: safe center; }

/* —— 몸으로 말해요 — 한 명만 화면을 등지고 맞힌다. 단어가 화면의 절반이다. —— */
.gesture-word {
  font-size: clamp(4rem, 18vw, 14rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--ink);
  word-break: keep-all;
}

/* —— 마무리 —— */
.done { text-align: center; }
.done-emoji { font-size: 4.4rem; line-height: 1; }
.done h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); font-weight: 900; }
.done-actions { display: flex; gap: 0.8rem; flex-wrap: wrap; justify-content: center; margin-top: 0.6rem; }

.site-footer { margin-top: 2.4rem; text-align: center; font-size: 0.86rem; color: var(--ink-soft); }
.site-footer kbd { background: var(--surface-high); }

/* 1920 전자칠판에서는 본문(1180px)과 패널이 서로 닿지 않는다. 그보다 좁아지면
   패널이 본문 위로 올라와 홈의 말놀이 카드를 덮어 버린다 — 실제로 [수수께끼] 가
   눌리지 않았다. 그 구간에서는 본문이 패널만큼 자리를 비켜 준다(가리지 않게). */
@media (min-width: 1101px) and (max-width: 1799px) {
  .screen { padding-right: calc(var(--gutter) + 292px); }
  /* 이 구간에서는 비켜 준 그 자리에 들어앉는다 — 여기서도 본문 바로 옆이다. */
  .clock { right: calc(var(--rail) + 32px); }
}

/* 본문 폭이 더 좁아지면 비켜 줄 자리도 없다.
   그때는 띄우지 말고 상단바 아래에 그냥 얹는다 — 가리는 것보다 밀어내는 편이 낫다. */
@media (max-width: 1100px) {
  .clock {
    position: static;
    width: min(100%, 340px);
    margin: 0.9rem auto 0;
  }
}
/* 세로로 쌓인 패널은 260px 넘게 차지해, 1024×768 칠판에서는 출제 화면의 버튼이 모든 단계에서
   화면 밖으로 밀렸다. 폭이 좁고 높이도 낮으면 숫자·시간 고르기·조작을 한 줄로 접는다.
   숫자는 여전히 가장 크다 — 한 줄 안에서의 주인공이다. */
@media (max-width: 1100px) and (min-width: 721px) {
  .clock {
    width: min(100%, 760px);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.8rem;
    margin-top: 0.6rem;
  }
  .clock-time { font-size: 2.6rem; flex: 0 0 auto; }
  .clock-picks { flex: 1 1 auto; margin-top: 0; }
  .clock-controls { flex: 0 0 auto; margin-top: 0; }
  .clock-controls .clock-btn:first-child { padding: 0.42rem 0.7rem; }
  .clock-tickbtn { width: auto; flex: 0 0 auto; margin-top: 0; padding: 0.42rem 0.7rem; }
  /* 패널이 본문 위에 얹히므로, 출제 화면은 창 높이 전부가 아니라 남은 높이만큼만 채운다. */
  .quiz, .chain, .gesture { min-height: 0; padding-top: 3rem; }
  /* 본문이 창 폭을 다 쓰는 구간 — 모서리 버튼이 창 끝에 붙지 않게 여백만큼 들인다. */
  .quiz-corner, .gesture-corner, .chain-corner { left: var(--gutter); }
}

/* —— 좁은 화면 —— */
@media (max-width: 720px) {
  :root { --gutter: 18px; }
  html { font-size: 16px; }
  .brand-sub { display: none; }

  /* 자매 바로가기는 이름이 빠져도 아이콘 여러 개라 폭이 넓다. 브랜드와 음소거
     버튼까지 한 줄에 넣으면 폰 폭을 넘겨 페이지가 옆으로 밀린다.
     .jjam-switch 의 스타일은 상류 공통 파일(shared/jjam-switcher.js) 안에 있어
     여기서 줄일 수 없으므로, 상단바를 두 줄로 접어 가로 스크롤을 없앤다. */
  .topbar { flex-wrap: wrap; row-gap: 0.5rem; }
  .topbar-actions { width: 100%; justify-content: flex-end; }
  .setup-actions { flex-direction: column-reverse; }
  .setup-actions .btn { width: 100%; }
  .quiz-corner, .gesture-corner, .chain-corner { position: static; margin-top: 0.8rem; }
  .quiz, .chain, .gesture { padding-top: 0.6rem; }
}

/* 아주 좁은 폰 — 여백을 줄여 자매 바로가기 다섯 개가 한 줄에 들어오게 한다 */
@media (max-width: 420px) {
  :root { --gutter: 10px; }
}
