/* Quiz of Legend — 768px 기준 모바일 / 데스크톱(태블릿 포함), 공통 밝은 테마 */
/* 공통 글꼴을 직접 제공해 운영체제별 기본 글꼴 차이를 줄인다. */
@font-face {
  font-family: "QOL Pretendard";
  src: url("/static/fonts/PretendardVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
:root {
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --text: #1b2130;
  --muted: #5e6880;
  --line: #d9deea;
  --primary: #4f6df5;
  --primary-ink: #ffffff;
  --primary-soft: #e4e9ff;
  --accent: #ff8f3c;
  --ok: #22a06b;
  --ok-soft: #dcf5ea;
  --bad: #e5484d;
  --bad-soft: #fde2e3;
  /* PM #85 공통 토큰(docs/UI_STANDARD.md §1). 숫자는 토큰으로만 쓴다. */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;
  --r-xs: 4px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-2xl: 24px; --r-pill: 999px;
  --fs-caption: 12px; --fs-small: 13px; --fs-label: 14px; --fs-body: 16px; --fs-body-lg: 18px; --fs-title-sm: 20px; --fs-title: 24px; --fs-headline: 28px; --fs-display: 32px;
  --h-sm: 36px; --h-md: 44px; --h-lg: 52px; --h-xl: 56px; --h-choice: 64px; --target-min: 44px; --target-primary: 48px;
  --shadow-1: 0 1px 2px rgba(28, 38, 70, 0.06), 0 2px 8px rgba(28, 38, 70, 0.06);
  --shadow-2: 0 6px 20px rgba(28, 38, 70, 0.10);
  --shadow-3: 0 16px 40px rgba(28, 38, 70, 0.18);
  --shadow: var(--shadow-1);
  --radius: var(--r-lg);
  --tap: var(--h-md);
  --sidebar: 184px;
  --header-h: 64px; --tabs-h: 56px;
  color-scheme: light;
  /* 티어 색 */
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "QOL Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
button, input, select { font: inherit; color: inherit; }
button, input, select { -webkit-appearance: none; appearance: none; }
/* 선택 입력은 전역 초기화에서 제외해 Safari에서도 선택 표시를 보존한다. */
input[type="checkbox"], input[type="radio"] {
  -webkit-appearance: auto; appearance: auto;
  width: 44px; height: 44px; flex: none; accent-color: var(--primary);
}
button, a { -webkit-tap-highlight-color: transparent; }
img, svg { flex-shrink: 0; }
.card, .row > *, .question-layout > *, .contestant { min-width: 0; }
p, strong, td, th, .choice, .who { overflow-wrap: anywhere; }
button { cursor: pointer; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---- 헤더 / 내비 ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  min-height: calc(var(--header-h) + var(--safe-area-top));
  padding: calc(var(--sp-2) + var(--safe-area-top)) max(var(--sp-4), env(safe-area-inset-right)) var(--sp-2) max(var(--sp-4), env(safe-area-inset-left)); background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { min-height: var(--tap); display: flex; align-items: center; gap: var(--sp-2); font-weight: 800; letter-spacing: -0.01em; text-decoration: none; color: var(--text); }
.brand .logo { width: auto; height: 30px; flex-shrink: 0; object-fit: contain; }
.brand small { display: block; font-size: var(--fs-caption); font-weight: 600; color: var(--muted); letter-spacing: 0.06em; }
.who { max-width: 40%; display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-label); color: var(--muted); }
.who strong { color: var(--text); }

.nav {
  position: fixed; left: 0; right: 0; bottom: var(--navigation-bottom,0px); z-index: 10;
  display: grid; grid-template-columns: repeat(var(--nav-columns, 5), 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav > a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-1);
  min-height: var(--tabs-h); font-size: var(--fs-caption); text-decoration: none; color: var(--muted); font-weight: 600;
}
.nav > a .ico { width: 24px; height: 24px; }
.nav > a .ico svg { display: block; width: 100%; height: 100%; }
.nav > a.active { color: var(--primary); }

main { width: 100%; max-width: 1120px; margin: 0 auto; padding: var(--sp-4); }
/* 너비만으로 분류하므로 기기 이름이나 포인터 종류에 영향을 받지 않는다. */
@media (min-width: 768px) {
  body { padding-left: var(--sidebar); padding-bottom: 24px; }
  .nav {
    top: 0; bottom: var(--navigation-bottom,0px); right: auto; width: var(--sidebar);
    display: flex; flex-direction: column; gap: var(--sp-1); padding: var(--sp-6) var(--sp-3);
    border-top: 0; border-right: 1px solid var(--line); overflow-y: auto;
  }
  .nav > a { flex-direction: row; justify-content: flex-start; gap: var(--sp-3); min-height: 48px; padding: var(--sp-3); border-radius: var(--r-md); font-size: var(--fs-body); }
  .nav > a.active { background: var(--primary-soft); }
  main { padding: var(--sp-6); }
}

/* ---- 공통 컴포넌트 ---- */
.card { --card-pad: var(--sp-5); background: var(--surface); border-radius: var(--r-lg); padding: var(--card-pad); box-shadow: var(--shadow-1); margin-bottom: var(--sp-4); }
.card h1 { margin: 0 0 var(--sp-3); font-size: var(--fs-headline); line-height: 1.3; }
.card h2 { margin: 0 0 var(--sp-3); font-size: var(--fs-title-sm); line-height: 1.4; }
.card h3 { margin: var(--sp-4) 0 var(--sp-2); font-size: var(--fs-body); color: var(--muted); font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-small); }
.row { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: var(--sp-3); }

/* 버튼 위계 4단계(주/보조/텍스트/위험)·크기 3단계(sm/md/lg)+xl. 링크(a.btn)도 같은 모양. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--h-md); min-width: var(--target-min, 44px); padding: var(--sp-2) var(--sp-4); border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font-size: var(--fs-body); font-weight: 700; line-height: 1.25;
  text-decoration: none; cursor: pointer; transition: transform .06s ease, background .15s ease, filter .15s ease;
}
.btn svg { width: 20px; height: 20px; flex: none; }
@media (hover: hover) and (pointer: fine) { .btn:not(:disabled):hover { filter: brightness(.96); } }
.btn:active { transform: scale(0.98); filter: brightness(.92); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.accent { background: var(--accent); color: #1b1200; border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn.danger { background: var(--bad); color: #fff; border-color: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: var(--h-sm); padding: 6px var(--sp-3); font-size: var(--fs-label); }
.btn.sm svg { width: 18px; height: 18px; }
.btn.lg, .btn.big { min-height: var(--h-lg); padding: var(--sp-3) var(--sp-5); font-size: var(--fs-body-lg); }
.btn.lg svg, .btn.big svg { width: 24px; height: 24px; }
.btn.xl { min-height: var(--h-xl); font-size: var(--fs-body-lg); }
.btn.icon { width: var(--h-md); min-width: var(--h-md); padding: 0; }
@media not all and (min-width: 768px) { .btn.sm { min-height: var(--h-md); padding: var(--sp-2) var(--sp-4); font-size: var(--fs-body); } }

.field label { display: block; font-size: var(--fs-label); color: var(--muted); margin-bottom: var(--sp-2); font-weight: 700; }
.field + .field { margin-top: var(--sp-4); }
.field .small { margin: var(--sp-1) 0 0; }
.input {
  width: 100%; min-height: var(--h-md); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface-2); font-size: var(--fs-body);
}
.input:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }

select.input { padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%235e6880' stroke-width='2'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }

.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--h-md); min-width: var(--h-md); padding: var(--sp-2) var(--sp-4); border-radius: var(--r-pill); border: 1px solid var(--line);
  background: var(--surface-2); font-size: var(--fs-label); font-weight: 700; line-height: 1.25;
}
/* 고정 값(랭킹게임 티어)은 칩 모양의 정적 표시로 둔다. */
.chips > p[data-fixed-grade] { margin: 0; display: inline-flex; align-items: center; min-height: var(--h-md); padding: var(--sp-2) 14px; border-radius: var(--r-pill); background: var(--primary-soft); font-weight: 700; }
.chip[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.chip:disabled { opacity: .38; cursor: not-allowed; }

.progress { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s ease; }
.progress.opp > span { background: var(--accent); }

.alert { padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--primary-soft); font-weight: 600; }
.alert.bad { background: var(--bad-soft); }
.alert.ok { background: var(--ok-soft); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--sp-4) + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-pill);
  font-weight: 700; box-shadow: var(--shadow-2); z-index: 20; max-width: calc(100vw - var(--sp-8));
}

@media (min-width: 768px) {
  .toast { left: calc(50% + var(--sidebar) / 2); bottom: var(--sp-6); max-width: calc(100vw - var(--sidebar) - 48px); }
}

/* ---- 홈 ---- */
.hero { text-align: center; padding: var(--sp-6) var(--sp-4); background: linear-gradient(135deg, var(--primary) 0%, #7c5cff 100%); color: #fff; }
.hero h1 { margin: 0 0 var(--sp-2); font-size: var(--fs-headline); letter-spacing: -0.02em; }
.hero p { margin: 0; opacity: .9; }
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.mode-grid .btn { flex-direction: column; min-height: 96px; font-size: 18px; }
.mode-grid .btn span.ico { font-size: 30px; }
.mode-grid .btn small { font-weight: 500; font-size: var(--fs-caption); opacity: .85; }

/* ---- 문제 ---- */
.q-head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); font-size: 13px; color: var(--muted); font-weight: 700; }
.q-text { font-size: var(--fs-title-sm); font-weight: 700; line-height: 1.55; margin: var(--sp-2) 0 var(--sp-4); white-space: pre-line; }
.choices { display: grid; gap: max(8px,var(--sp-3)); }
.choice {
  display: flex; align-items: center; gap: 12px; text-align: left;
  --choice-padding-block:var(--sp-3);
  min-height: max(var(--h-xl),var(--choice-min-height)); padding: var(--choice-padding-block) 14px; border-radius: var(--r-lg);
  border: 2px solid var(--line); background: var(--surface-2); font-size: var(--fs-body); font-weight: 600;
}
/* #170: border-box에서 글자 두 줄 공간에 실제 상하 패딩과 2px 테두리를 더한다. */
.choice { --choice-min-height:max(44px,calc(3em + var(--choice-padding-block) + var(--choice-padding-block) + 4px)); }
.home-daily-choices button { --choice-min-height:max(44px,3em); }
@supports (min-height:2lh) {
  .choice { --choice-min-height:max(44px,calc(2lh + var(--choice-padding-block) + var(--choice-padding-block) + 4px)); }
  .home-daily-choices button { --choice-min-height:max(44px,2lh); }
}
.choice .num {
  flex: 0 0 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--line); font-size: 14px; font-weight: 800;
}
/* 터치 후 남는 hover를 새 문항의 선택 표시로 오해하지 않도록 한다. */
@media (hover: hover) and (pointer: fine) {
  .choice:not(:disabled):hover { border-color: var(--primary); }
}
.choice.selected { border-color: var(--primary); }
.choice.correct { border-color: var(--ok); background: var(--ok-soft); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice.opp::after { content: "상대"; margin-left: auto; font-size: var(--fs-caption); color: var(--muted); border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; }
.choice:disabled { cursor: default; }

.feedback { margin-top: var(--sp-4); padding: var(--sp-4); border-radius: var(--r-lg); background: var(--surface-2); }
.feedback .verdict { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.feedback.ok .verdict { color: var(--ok); }
.feedback.bad .verdict { color: var(--bad); }
.feedback .explain { white-space: pre-line; }
.review-note { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.review-note textarea { width: 100%; min-height: 110px; resize: vertical; }
.review-text { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 400px; }
.admin-table { width: 100%; overflow-wrap: anywhere; }
.admin-page [role="tablist"] { margin-bottom: 16px; }

.rate { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.rate button { min-height: var(--tap); padding: 6px var(--sp-3); border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface); font-size: var(--fs-label); font-weight: 600; }
.rate button[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); }

/* 실제 헤더·탭 높이는 layout.js에서 측정한다. dvh 미지원 브라우저도 회전을 반영한다. */
:root { --visible-height: var(--viewport-height, 100vh); }
@supports (height: 100dvh) { :root { --visible-height: min(var(--viewport-height, 100dvh), 100dvh); } }
body.quiz-screen { height: var(--visible-height); min-height: 0; padding-bottom: 0; overflow: hidden; }
.quiz-screen > .sr-only { top: 0; left: 0; }
.quiz-screen .topbar { flex-wrap: nowrap; }
.quiz-screen .topbar .who { flex: 0 1 auto; width: auto; }
.quiz-screen .topbar .account-actions, .quiz-screen .topbar .account-session { display: none; }
.quiz-screen #app {
  height: calc(var(--visible-height) - var(--header-height) - var(--tabs-height));
  display: flex; flex-direction: column; gap: 8px; padding: 10px;
  container-type: size; container-name: quiz;
}
.quiz-screen #qcard { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 12px; margin: 0; }
.quiz-screen .battle-review { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.quiz-screen .q-head { flex: none; margin: 0; flex-wrap: nowrap; font-size: 12px; }
.quiz-screen .q-head > :first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quiz-screen .q-head > :last-child { flex-shrink: 0; }
.quiz-screen #qcard > .progress { flex: 0 0 5px; }
.quiz-screen .question-layout { display: flex; flex-direction: column; flex: 1; min-height: 0; margin: 0; gap: 8px; }
.quiz-screen .question-prompt { display: contents; }
.quiz-screen .q-text { order: 1; }
.quiz-screen .choices { order: 2; flex: none; }
.quiz-screen .feedback { order: 3; }
.quiz-screen .q-text { min-height: 1.55em; flex: 1; margin: 0; overflow-y: auto; font-size: clamp(14px, 2.7cqh, 20px); }
.scroll-hint {
  /* 스크롤 끝에 다다르면 그림자가 사라져 남은 내용을 알 수 있다. */
  background: linear-gradient(var(--surface), var(--surface)) center top / 100% 12px no-repeat local,
    linear-gradient(var(--surface), var(--surface)) center bottom / 100% 12px no-repeat local,
    linear-gradient(rgba(28,38,70,.16), transparent) center top / 100% 8px no-repeat scroll,
    linear-gradient(transparent, rgba(28,38,70,.16)) center bottom / 100% 8px no-repeat scroll;
}
.quiz-screen .keyboard-hint { display: none; flex: none; margin: 0; font-size: 11px; }
.quiz-screen .choices { gap: 8px; }
.quiz-screen .choice { --choice-padding-block:8px; min-height: var(--choice-min-height); padding: var(--choice-padding-block) 10px; gap: 8px; font-size: clamp(13px, 2.3cqh, 16px); }
.quiz-screen .choice .num { flex-basis: 24px; height: 24px; font-size: 12px; }
.quiz-screen .feedback { flex: 0 1 auto; min-height: 76px; max-height: 60%; margin: 0; padding: 6px 8px; display: flex; flex-direction: column; }
.feedback-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; flex-shrink: 0; }
.quiz-screen .feedback .verdict { margin: 0; font-size: 14px; }
.quiz-screen .explain { min-height: 1.5em; max-height: 4.5em; overflow-y: auto; font-size: 13px; }
.quiz-screen .after { flex: none; display: flex; flex-direction: column; gap: 6px; }
.rating-tools { display: flex; align-items: center; gap: var(--sp-2); position: relative; }
.rate { flex-wrap: nowrap; margin: 0; min-width: 0; }
.rate button { min-width: 44px; }
.quiz-screen .rate-label { display: none; }
.question-actions { display: flex; align-items: center; gap: var(--sp-2); }
.question-actions .btn { flex: 1; min-height: 44px; padding: 6px 10px; }
.question-actions a { font-size: 12px; white-space: nowrap; }
.review-exclude { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.lp-note { font-size: var(--fs-caption); }
.review-note { position: relative; margin: 0; padding: 0; border: 0; }
.review-note summary { cursor: pointer; list-style: none; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 12px; }
.review-note summary::-webkit-details-marker { display: none; }
.review-note form { padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-top: 6px; }
.quiz-screen .review-note { position: static; }
.quiz-screen .review-note form { position: absolute; bottom: calc(100% + 6px); right: 0; z-index: 5; width: min(400px, 100%); max-height: calc(var(--visible-height) - var(--header-height) - var(--tabs-height) - 120px); overflow-y: auto; box-shadow: var(--shadow); }
.quiz-screen .battle-status { flex: none; padding: 8px 12px; margin: 0; }
.quiz-screen .battle-status h2 { font-size: 15px; }
.quiz-screen .battle-progress { margin-top: 4px; gap: 6px; }
.quiz-screen .contestant { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 6px; padding: 4px 8px; }
.quiz-screen .contestant > .small { grid-column: 1; grid-row: 1; }
.quiz-screen .contestant strong { grid-column: 2; grid-row: 1; }
.quiz-screen .contestant .row { display: contents; margin: 0; }
.quiz-screen .contestant .row > :first-child { display: none; }
.quiz-screen .contestant .row > :last-child { grid-column: 3; grid-row: 1; }
.quiz-screen .contestant .tier, .quiz-screen .contestant .progress { grid-column: 1 / -1; }
.quiz-screen .contestant .progress { height: 5px; }
.quiz-screen .contestant strong { font-size: 12px; }
@media (min-width: 768px) {
  .quiz-screen .question-layout { display: grid; grid-template-rows: minmax(0, 1fr); align-items: stretch; }
  .quiz-screen .question-prompt { min-height: 0; display: flex; flex-direction: column; gap: 6px; }
  .quiz-screen .keyboard-hint { display: block; }
  .quiz-screen .choices { align-self: start; }
}
@media (min-width: 1100px) {
  .quiz-screen #app[data-quiz-size="large"] .rate-label { display: inline; }
}
/* JS 단계는 컨테이너 쿼리를 지원하지 않는 브라우저에도 같은 축소를 적용한다. */
.quiz-screen #app:not([data-quiz-size="large"]) .choice { --choice-padding-block:4px; min-height: var(--choice-min-height); padding: var(--choice-padding-block) 8px; }
.quiz-screen #app:not([data-quiz-size="large"]) .q-text { font-size: 16px; }
.quiz-screen #app:not([data-quiz-size="large"]) .choice { font-size: 13px; }
.quiz-screen #app[data-quiz-size="medium"] #qcard { gap: var(--sp-1); padding: var(--sp-2); }
.quiz-screen #app[data-quiz-size="small"] .choice { font-size: 12px; line-height: 1.3; }
.quiz-screen #app:not([data-quiz-size="large"]) .lp-note { display: none; }
.quiz-screen #app:not([data-quiz-size="large"]) .battle-progress { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.quiz-screen #app:not([data-quiz-size="large"]) .question-actions > span { display: none; }
.quiz-screen .contestant strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quiz-screen #app[data-quiz-size="small"] #qcard,
.quiz-screen #app[data-quiz-size="tiny"] #qcard { gap: var(--sp-1); padding: var(--sp-1); }
.quiz-screen #app[data-quiz-size="small"] .keyboard-hint,
.quiz-screen #app[data-quiz-size="tiny"] .keyboard-hint { display: none; }
.quiz-screen #app[data-quiz-size="small"] .explain,
.quiz-screen #app[data-quiz-size="tiny"] .explain { max-height: 3em; }
.quiz-screen #app[data-quiz-size="tiny"] { padding: 4px 8px; gap: 4px; }
.quiz-screen #app[data-quiz-size="tiny"] .question-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); align-items: stretch; }
.quiz-screen #app[data-quiz-size="tiny"] .question-prompt { min-height: 0; display: flex; flex-direction: column; gap: 4px; }
.quiz-screen #app[data-quiz-size="tiny"] .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-self: start; }
.quiz-screen #app[data-quiz-size="tiny"] .choice { font-size: 12px; }
.quiz-screen #app[data-quiz-size="tiny"] .choice { line-height: 1.3; }
.quiz-screen #app[data-quiz-size="tiny"] .q-text { font-size: 14px; }
.quiz-screen #app[data-quiz-size="tiny"] .after { flex-direction: row; align-items: center; }
.quiz-screen #app[data-quiz-size="tiny"] .question-actions { flex: 1; }
.quiz-screen #app[data-quiz-size="tiny"] .question-actions a { padding: 4px; }
.quiz-screen #app[data-quiz-size="tiny"] .battle-progress { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.quiz-screen #app[data-quiz-size="tiny"] .contestant > .small,
.quiz-screen #app[data-quiz-size="tiny"] .contestant .tier { display: none; }
.quiz-screen #app[data-quiz-size="tiny"] .battle-status { padding: 4px 8px; }
.quiz-screen #app[data-quiz-size="tiny"] #qcard > .progress { display: none; }
.quiz-screen #app[data-quiz-size="tiny"] .battle-status { display: flex; align-items: center; gap: 8px; }
.quiz-screen #app[data-quiz-size="tiny"] .battle-status > .row { flex: none; gap: 8px; }
.quiz-screen #app[data-quiz-size="tiny"] .battle-progress { flex: 1; margin: 0; }
.quiz-screen #app[data-quiz-size="tiny"] .timer { font-size: 14px; }
.quiz-screen #app[data-quiz-size="tiny"] .contestant { padding: 2px 6px; gap: 2px; }
.quiz-screen #app[data-quiz-size="tiny"] .contestant .row { display: contents; }
.quiz-screen #app[data-quiz-size="tiny"] .contestant .row > :first-child { display: none; }
.quiz-screen #app[data-quiz-size="tiny"] .contestant .progress { grid-column: 1 / -1; }
@media (max-width: 359px) {
  .quiz-screen .rate, .quiz-screen .rating-tools { gap: 2px; }
}
@media (max-width: 767px) {
  .quiz-screen #app[data-quiz-size="tiny"] .question-layout { display: flex; gap: 4px; }
  .quiz-screen #app[data-quiz-size="tiny"] .question-prompt { display: grid; flex: 1; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); }
  .quiz-screen #app[data-quiz-size="tiny"] .q-text { grid-column: 1 / -1; height: 100%; }
  .quiz-screen #app[data-quiz-size="tiny"] .answered .q-text { grid-column: auto; }
  .quiz-screen #app[data-quiz-size="tiny"] .feedback { min-height: 0; height: 100%; max-height: none; }
  .quiz-screen #app[data-quiz-size="tiny"] .choices { width: 100%; }
}

/* ---- 결과 요약 ---- */
.score-big { text-align: center; padding: var(--sp-3) 0; }
.score-big .n { font-size: 48px; font-weight: 900; line-height: 1; letter-spacing: -0.03em; }
.score-big .lp { color: var(--ok); font-weight: 800; margin-top: var(--sp-2); }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; text-align: center; }
.vs .name { font-weight: 800; }
.vs .big { font-size: 34px; font-weight: 900; }
.vs .mid { color: var(--muted); font-weight: 800; }
.outcome { text-align: center; font-size: var(--fs-headline); font-weight: 900; margin: var(--sp-2) 0 var(--sp-1); }
.outcome.win { color: var(--ok); } .outcome.loss { color: var(--bad); } .outcome.draw { color: var(--muted); }

/* ---- 티어 배지 ---- */
.tier { display: inline-flex; align-items: center; gap: var(--sp-2); font-weight: 800; font-size: var(--fs-small); padding: 4px 12px 4px 4px; border-radius: 999px; color: #17213a; background: #f5f7fb; border: 1px solid var(--tier-color, #dce2eb); }
.tier svg { width: 20px; height: 20px; }
.tier.lg { font-size: 18px; padding: 8px 16px 8px 8px; gap: var(--sp-3); }
.tier.lg svg { width: 34px; height: 34px; }

/* ---- 표 / 목록 ---- */
.table-wrap, .tbl-wrap { max-width: 100%; overflow-x: auto; }
.responsive-table { width: 100%; border-collapse: collapse; text-align: left; font-size: var(--fs-label); }
.responsive-table th, .responsive-table td { padding: var(--sp-3) var(--sp-2); border-bottom: 1px solid var(--line); vertical-align: middle; }
.responsive-table thead th { color: var(--muted); font-size: var(--fs-label); font-weight: 700; }
.responsive-table tr.me { background: var(--primary-soft); }
.responsive-table .no, .responsive-table .lp { font-weight: 800; }
.responsive-table .tier { white-space: nowrap; }
.seg { display: inline-flex; max-width: 100%; padding: 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { min-height: var(--tap); padding: 6px 16px; border: 0; border-radius: 999px; background: transparent; font-weight: 700; color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--primary); color: var(--primary-ink); }

.question-layout { display: grid; gap: 16px; margin-top: 16px; }
.choice-option { min-width: 0; }
.choice-option > .choice { width: 100%; height: 100%; }
.choice-figure-grid, .figure-preview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice-figure-grid .choice-option { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.choice-figure-grid .choice { height: auto; flex: 1; border-radius: 0; }
.inline-math { display: inline-block; max-width: 100%; overflow-x: auto; overflow-y: hidden; vertical-align: middle; padding: 3px 1px; }
.inline-math .katex { font-size: 1.1em; }
.block-math { display: block; max-width: 100%; overflow-x: auto; overflow-y: hidden; }
.math-error { color: var(--bad); }
.question-figure { display: block; width: 100%; height: auto; max-height: 35vh; max-height: 35dvh; object-fit: contain; }
.figure-open { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; min-height: 44px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.choice-figure-grid .question-figure { max-height: 16vh; max-height: 16dvh; }
/* 그림도 카드의 남은 높이 안에서 줄인다. 질문·해설 스크롤과 하단 조작을 유지한다. */
.quiz-screen .question-stimulus { order: 1; flex: 1; min-height: 76px; display: flex; flex-direction: column; gap: 4px; }
.quiz-screen .question-stimulus .q-text { flex: 1; }
.quiz-screen .question-stimulus > .figure-open { order: 2; flex: 0 1 auto; min-height: 44px; height: clamp(44px, 12vh, 140px); height: clamp(44px, 12cqh, 140px); }
.quiz-screen .question-stimulus > .figure-open .question-figure { flex: 1; height: 0; }
.quiz-screen .figure-open { padding: 2px; gap: 0; }
.quiz-screen .figure-open .small { font-size: 10px; }
.quiz-screen .question-figure { height: clamp(24px, 12vh, 140px); height: clamp(24px, 12cqh, 140px); min-height: 0; }
.quiz-screen .choice-figure-grid .question-figure { height: clamp(24px, 8vh, 100px); height: clamp(24px, 8cqh, 100px); }
.quiz-screen .choice-figure-grid .choice-option { min-height: 0; }
/* 세로 공간이 부족하면 텍스트 보기 역시 두 줄로 배치해 그림과 조작 공간을 확보한다. */
.quiz-screen #app:not([data-quiz-size="large"]) .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.quiz-screen #app[data-quiz-size="tiny"] .question-stimulus { grid-column: 1 / -1; }
.quiz-screen #app[data-quiz-size="tiny"] .answered .question-stimulus { grid-column: auto; }
.quiz-screen #app[data-quiz-size="tiny"] .question-stimulus .q-text { height: auto; }
.quiz-screen #app[data-quiz-size="tiny"] .question-figure { height: 24px; }
.quiz-screen #app[data-quiz-size="tiny"] .choice-figure-grid .figure-open .small { display: none; }
.quiz-screen #app[data-quiz-size="tiny"] .choice-figure-grid .choice-option { flex-direction: row; }
.quiz-screen #app[data-quiz-size="tiny"] .choice-figure-grid .figure-open { width: auto; min-width: 44px; flex: 1; }
.quiz-screen #app[data-quiz-size="tiny"] .choice-figure-grid .choice { width: auto; height: auto; }
/* 짧은 가로 대결은 진행 상태도 필요하므로 질문 그림과 보기를 나란히 둔다. */
.quiz-screen #app[data-quiz-size="tiny"] .question-layout.has-question-figure { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.quiz-screen #app[data-quiz-size="tiny"] .has-question-figure .question-prompt { display: flex; flex-direction: column; }
.quiz-screen #app[data-quiz-size="tiny"] .has-question-figure .feedback { height: auto; }
/* 대결 종료 예고 등 알림이 하단 다음 버튼을 가리지 않게 헤더 아래에 둔다. */
.quiz-screen .toast { top: calc(var(--header-height) + 4px); bottom: auto; }
.figure-dialog { width: min(92vw, 900px); max-height: 90vh; max-height: 90dvh; border: 1px solid var(--line); border-radius: 16px; padding: 16px; background: var(--surface); color: var(--text); }
.figure-dialog::backdrop { background: rgba(0, 0, 0, .65); }
.figure-dialog .question-figure { max-height: 75vh; max-height: 75dvh; margin-bottom: 12px; }
.figure-dialog .btn { display: block; margin-left: auto; }
/* 현재 기본 UI는 밝은 테마. 어두운 테마에서는 img의 검은 currentColor를 필터로 밝힌다. */
[data-theme="dark"] .question-figure, .theme-dark .question-figure { filter: invert(1) hue-rotate(180deg); }
/* 명도·색상·신호 상태가 자료인 그림은 밝은 바탕에서 원래 색을 보존한다. */
.question-figure.preserve-colors { background: #fff; }
[data-theme="dark"] .question-figure.preserve-colors, .theme-dark .question-figure.preserve-colors { filter: none; }
.keyboard-hint { display: none; }
.battle-progress { display: grid; gap: 12px; margin-top: 16px; }
.contestant { padding: var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-md); }
.contestant .row { margin-top: 10px; margin-bottom: 6px; }
.question-actions a { min-height: var(--tap); display: inline-flex; align-items: center; padding: 8px 16px; }
.mode-grid { margin-bottom: 14px; }
@media (min-width: 768px) {
  .question-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .keyboard-hint { display: block; }
  .battle-progress { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media not all and (min-width: 768px) {
  main { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .nav { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .brand { gap: var(--sp-2); font-size: var(--fs-label); }
  .brand small { letter-spacing: 0; }
  .who { font-size: var(--fs-caption); }
  .card { --card-pad: var(--sp-4); padding: var(--card-pad); }
  .question-layout { gap: 8px; }
  .q-head { flex-wrap: wrap; }
  .q-head > :last-child { margin-left: auto; }
  .after .row > .btn { width: 100%; min-height: 52px; }
  .toast { bottom: calc(var(--tabs-h) + var(--sp-4) + env(safe-area-inset-bottom)); }
  /* 같은 표를 모바일에서는 항목명이 붙은 세로 카드로 표시한다. */
  .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td, .responsive-table th { display: block; }
  .responsive-table thead { display: none; }
  .responsive-table tr { margin-bottom: 12px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
  .responsive-table td, .responsive-table tbody th { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 6px; padding: 6px 0; border: 0; }
  .responsive-table [data-label]::before { content: attr(data-label); font-weight: 600; font-size: 13px; color: var(--muted); }
  .responsive-table td > div { grid-column: 2; }
  .responsive-table .tier { justify-self: start; white-space: normal; }
  .responsive-table tr.me { box-shadow: 0 0 0 2px var(--primary) inset; }
  .admin-page #filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .admin-page #filters .input { width: 100%; }
  .admin-page #qtable, .admin-page #qtable tbody, .admin-page #qtable tr { display: block; }
  .admin-page #qtable thead { display: none; }
  .admin-page #qtable tr { padding: 12px; margin-bottom: 12px; background: var(--surface-2); border-radius: 12px; }
  .admin-page #qtable td { display: block; padding: 6px 0; border: 0; text-align: left; }
  .admin-page #qtable td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
  .admin-page #qtable .qtext { max-width: none; }
  .admin-page .admin-table, .admin-page .admin-table tbody, .admin-page .admin-table tr { display: block; }
  .admin-page .admin-table thead { display: none; }
  .admin-page .admin-table tr { padding: 12px; margin-bottom: 12px; background: var(--surface-2); border-radius: 12px; }
  .admin-page .admin-table td { display: block; padding: 6px 0; border: 0; text-align: left; max-width: none; }
  .admin-page .admin-table td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
  .admin-page #tokenForm { flex-direction: column; align-items: stretch; }
}

.timer { font-variant-numeric: tabular-nums; font-weight: 900; font-size: 20px; }
.timer.hot { color: var(--bad); }
.dots { display: inline-block; width: 1.2em; text-align: left; }
.waiting { text-align: center; padding: 24px 0; }
.waiting .pulse { width: 64px; height: 64px; border-radius: 50%; background: var(--primary); margin: 0 auto 12px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(.9); opacity: .6; } 50% { transform: scale(1.05); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .waiting .pulse { animation: none; } * { transition: none !important; } }

/* ---- 승급 연출 ---- */
.promo {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--promo) 55%, transparent) 0%, rgba(10, 12, 24, .92) 70%);
  color: #fff; text-align: center; cursor: pointer; animation: promo-in .35s ease both; outline: none;
}
@supports not (background: color-mix(in srgb, red 50%, transparent)) {
  .promo { background: rgba(10, 12, 24, .92); }
}
.promo.out { animation: promo-out .3s ease both; }
.promo-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.promo-body { position: relative; padding: 24px; max-width: 90vw; max-height: 100%; overflow-y: auto; }
.promo-emblem {
  position: relative; width: 150px; height: 150px; margin: 0 auto 18px; border-radius: 50%;
  background: var(--promo); display: flex; align-items: center; justify-content: center; overflow: hidden;
  box-shadow: 0 0 0 8px rgba(255,255,255,.12), 0 20px 60px rgba(0,0,0,.45);
  animation: emblem-in .9s cubic-bezier(.2, 1.4, .3, 1) both;
}
.promo-emblem svg { width: 96px; height: 96px; position: relative; z-index: 1; filter: drop-shadow(0 4px 10px rgba(0,0,0,.35)); }
.promo-glow { position: absolute; inset: -30%; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.55), transparent 60%); animation: glow 1.6s ease-in-out .3s infinite alternate; }
.promo-shine { position: absolute; top: -20%; bottom: -20%; left: -60%; width: 40%; background: linear-gradient(100deg, transparent, rgba(255,255,255,.75), transparent); transform: skewX(-20deg); animation: shine 1.4s ease .5s 2; }
.promo-title { margin: 0; font-size: 44px; font-weight: 900; letter-spacing: -0.02em; text-shadow: 0 4px 24px rgba(0,0,0,.4); animation: pop .6s cubic-bezier(.2, 1.4, .3, 1) .25s both; }
.promo-mode { margin: 4px 0 10px; font-weight: 700; opacity: .85; animation: rise .5s ease .4s both; }
.promo-from-to { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 0; font-size: 20px; font-weight: 800; animation: rise .5s ease .55s both; flex-wrap: wrap; }
.promo-from-to .old { opacity: .6; text-decoration: line-through; }
.promo-from-to .new { font-size: 26px; color: #fff; padding: 4px 14px; border-radius: 999px; background: var(--promo); box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.promo-hint { margin-top: 26px; font-size: 13px; opacity: .6; animation: rise .5s ease 1.2s both; }
@keyframes promo-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes promo-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes emblem-in { 0% { transform: scale(.2) rotate(-20deg); opacity: 0; } 60% { opacity: 1; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes glow { from { opacity: .35; transform: scale(.9); } to { opacity: .9; transform: scale(1.1); } }
@keyframes shine { from { left: -60%; } to { left: 120%; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
/* 움직임 줄이기: 페이드만 */
.promo.reduced, .promo.reduced .promo-emblem, .promo.reduced .promo-title, .promo.reduced .promo-mode, .promo.reduced .promo-from-to, .promo.reduced .promo-hint { animation: promo-in .3s ease both; }
.promo.reduced .promo-glow, .promo.reduced .promo-shine { animation: none; display: none; }
.promo.reduced.out { animation: promo-out .3s ease both; }

/* 작은 화면의 승급 크기는 기본 승급 스타일 뒤에서 적용한다. */
@media not all and (min-width: 768px) {
  .promo { overflow-y: auto; padding: max(12px, var(--safe-area-top)) 0 max(12px, env(safe-area-inset-bottom)); }
  .promo-emblem { width: 96px; height: 96px; margin-bottom: 12px; }
  .promo-emblem svg { width: 64px; height: 64px; }
  .promo-title { font-size: 32px; }
  .promo-body { padding: 16px; }
  .promo-hint { margin-top: 12px; }
}

/* 계정 진입점도 768px 기준의 두 분류 안에 배치한다. */
.who-account { min-width: 44px; display: flex; flex-direction: column; justify-content: center; min-height: var(--tap); text-decoration: none; overflow-wrap: anywhere; }
#accountForm, #resetForm { max-width: 440px; }
#resetResult { overflow-wrap: anywhere; }
.account-actions, .account-session { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.player-nickname { min-width: 44px; min-height: var(--tap); display: inline-flex; align-items: center; overflow-wrap: anywhere; }
.account-entry { display: grid; gap: var(--sp-3); }
.account-sidebar { display: none; }
.topbar { flex-wrap: nowrap; }
.who { max-width: 100%; flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; justify-content: flex-end; }
.who .player-nickname { color: var(--text); font-weight: 700; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.who .btn { flex: none; }
/* 길어진 신원 글자는 DOM에 그대로 두고 머리줄 안에서만 말줄임한다. */
.who .who-account { max-width: 100%; }
.who .who-account > span, .who .who-account > strong { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body:not(.quiz-screen) .topbar .brand { flex-shrink: 0; }
@media not all and (min-width: 768px) {
  .player-nickname { max-width: 100%; }
}
@media (min-width: 768px) {
  /* PC 는 사이드바 계정 카드가 로그인 진입점을 맡는다. */
  .topbar .account-actions { display: none; }
}
@media (min-width: 768px) {
  .account-sidebar { display: block; margin-top: auto; padding-top: var(--sp-4); border-top: 1px solid var(--line); }
  .account-sidebar .card { padding: 0; margin: 0; box-shadow: none; background: transparent; }
  .account-sidebar h2 { font-size: var(--fs-body); margin-bottom: var(--sp-2); }
  .account-sidebar .account-actions, .account-sidebar .account-session { flex-direction: column; align-items: stretch; }
  .account-sidebar .who-account { max-width: 100%; }
  /* 남색 사이드바의 신원 보조 글자도 기존 링크 색을 따라 대비를 확보한다. */
  .account-sidebar .who-account .muted { color: inherit; }
}

/* 화면 설정은 풀이 상단과 내 정보에서 같은 값을 사용한다. */
.display-controls { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.display-controls .btn { min-height: 44px; padding: 4px 8px; font-size: 12px; white-space: nowrap; }
.display-controls a { display: none; }
.rating-toggle { display: none; }
.answer-mark:empty { display: none; }
.answer-mark { font-size: 22px; font-weight: 900; flex: none; }
.choice.correct, .choice.wrong { border-width: 3px; }
.choice.selected { box-shadow: inset 0 0 0 2px var(--primary); font-weight: 800; }
.quiz-screen #app .choice-option { min-height: 0; }
.quiz-screen #app .choice { overflow: hidden; }
.quiz-screen #app .choice-text { min-width: 0; min-height: 0; max-height: 100%; overflow-y: auto; scrollbar-width: thin; }
/* 긴 보기의 줄 수가 늘어도 해설과 다음 버튼을 밀어내지 않는다. */
.quiz-screen #app .choices[data-long-choices="true"] { height: 45%; min-height: 96px; grid-auto-rows: minmax(44px, 1fr); }
.tv-mode { --text: #101828; --muted: #344054; --line: #667085; --primary: #2444c4; --ok: #08633c; --bad: #a51624; --ok-soft: #e4f8ed; --bad-soft: #ffebee; }
.tv-mode.quiz-screen #app .q-text { font-size: 22px; line-height: 1.4; }
.tv-mode.quiz-screen #app .choice { font-size: 20px; line-height: 1.4; }
.tv-mode.quiz-screen #app .choice .num { font-size: 16px; }
.tv-mode.quiz-screen #app .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(44px, 1fr)); height: clamp(100px, 30vh, 320px); min-height: 100px; align-self: stretch; }
.tv-mode.quiz-screen #app .choice-option { min-height: 0; }
.tv-mode.quiz-screen #app .choice { height: 100%; overflow: hidden; }
.tv-mode.quiz-screen #app .choice-text { min-width: 0; min-height: 0; max-height: 100%; overflow-y: auto; scrollbar-width: thin; }
.tv-mode.quiz-screen #app .choice-figure-grid .figure-open { flex: 1; min-height: 44px; }
.tv-mode.quiz-screen #app .choice-figure-grid .question-figure { flex: 1; height: 0; }
.tv-mode.quiz-screen #app .choice-figure-grid .choice { flex: 0 0 44px; height: 44px; }
.tv-mode .feedback .verdict { font-size: 18px; }
.tv-mode .choice.selected { border: 3px solid var(--primary); background: #e4e9ff; }
.tv-mode .choice.correct { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.tv-mode .choice.wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }

/* 가로 저높이 판정은 layout.js와 같다. 회전은 DOM을 보존한다. */
@media (orientation: landscape) and (max-height: 500px) {
  body.quiz-screen { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .promo { padding: var(--safe-area-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); overflow-y: auto; }
  .promo-body { padding: 12px; }
  .promo-emblem { width: 80px; height: 80px; margin-bottom: 8px; }
  .promo-emblem svg { width: 52px; height: 52px; }
  .promo-title { font-size: 30px; }
  .promo-hint { margin-top: 8px; }
  .quiz-screen .topbar { display: none; }
  /* 높이 0으로 메뉴를 감추고 풀이 영역을 끝까지 사용한다. */
  .quiz-screen .nav { visibility: hidden; position: fixed; top: auto; bottom: 0; height: 0; min-height: 0; padding: 0; border: 0; overflow: hidden; }
  .quiz-screen #app { margin: 0; width: 100%; max-width: none; padding: max(4px, var(--safe-area-top)) 6px max(4px, var(--safe-area-bottom)); gap: 0; }
  .quiz-screen #app #qcard { padding: 4px 6px; gap: 6px; }
  .quiz-screen #qcard > .progress { display: none; }
  .quiz-screen .q-head { min-height: 44px; gap: 6px; flex-wrap: nowrap; }
  .quiz-screen .q-head > :first-child { display: none; }
  .quiz-screen .question-counter { font-size: 16px; font-weight: 800; white-space: nowrap; }
  .quiz-screen .display-controls a { display: inline-flex; }
  /* 알림이 뜬 동안 위쪽에 한 줄을 확보해 그림·답안·다음 버튼을 가리지 않는다. */
  .quiz-screen:has(.toast:not([hidden])) #app { padding-top: calc(36px + var(--safe-area-top)); }
  .quiz-screen .toast { top: calc(4px + var(--safe-area-top)); left: 50%; bottom: auto; max-width: calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)); padding: 4px 10px; font-size: 14px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .quiz-screen #app .question-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 12px; align-items: stretch; }
  .quiz-screen #app .question-prompt { display: flex; flex-direction: column; min-height: 0; gap: 6px; }
  .quiz-screen #app .q-text { height: auto; min-height: 1.4em; font-size: 18px; line-height: 1.4; flex: 1; }
  .quiz-screen #app .question-stimulus { min-height: 80px; flex: 1; }
  .quiz-screen #app .question-stimulus > .figure-open { flex: 0 1 38%; height: 100px; min-height: 44px; }
  .quiz-screen #app .question-stimulus .question-figure { height: 0; flex: 1; }
  .quiz-screen #app .keyboard-hint { display: none; }
  .quiz-screen #app .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(44px, 1fr)); gap: 6px; align-self: stretch; min-height: 0; }
  .quiz-screen #app .choices.choices-stacked { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(4, minmax(44px, 1fr)); }
  .quiz-screen #app .choices[data-long-choices="true"] { height: auto; min-height: 0; }
  .quiz-screen #app .choice-option { min-height: 0; }
  .quiz-screen #app .choice { --choice-padding-block:6px; min-height: var(--choice-min-height); padding: var(--choice-padding-block); font-size: 16px; line-height: 1.4; overflow: hidden; align-items: center; }
  .quiz-screen #app .choice-text { min-width: 0; min-height: 0; max-height: 100%; overflow-y: auto; }
  .quiz-screen #app .choice-figure-grid .choice-option { flex-direction: column; }
  .quiz-screen #app .choice-figure-grid .figure-open { width: 100%; flex: 1; min-height: 44px; }
  .quiz-screen #app .choice-figure-grid .choice { flex: 0 0 44px; width: 100%; height: 44px; }
  .quiz-screen #app .choice-figure-grid .question-figure { height: 0; flex: 1; }
  .quiz-screen #app .choice-figure-grid .figure-open .small { display: block; }
  .quiz-screen #app .feedback { min-height: 68px; max-height: 50%; height: auto; padding: 2px 6px; }
  .quiz-screen #app .explain { font-size: 15px; line-height: 1.4; max-height: 2.8em; }
  .quiz-screen #app .feedback .verdict { font-size: 15px; }
  .quiz-screen #app .after { display: flex; flex-direction: row; align-items: center; gap: 6px; }
  .quiz-screen #app .rating-toggle { display: block; min-width: 80px; min-height: 44px; padding: 4px 8px; font-size: 13px; }
  .quiz-screen #app .rating-tools { display: none; }
  .quiz-screen #app .ratings-open .rating-tools { display: flex; }
  .quiz-screen #app .question-actions { flex: 1; }
  .quiz-screen #app .question-actions a { display: none; }
  .quiz-screen #app .review-note form { max-height: calc(var(--visible-height) - 110px); }
  .quiz-screen #app .battle-status { display: flex; align-items: center; flex: 1; min-width: 0; padding: 0; border: 0; box-shadow: none; background: transparent; gap: 6px; }
  .quiz-screen #app .battle-status h2 { display: none; }
  .quiz-screen #app .battle-status > .row { flex: none; }
  .quiz-screen #app .timer { font-size: 16px; }
  .quiz-screen #app .battle-progress { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); flex: 1; margin: 0; gap: 4px; }
  .quiz-screen #app .contestant { grid-template-columns: minmax(0, 1fr) auto; padding: 0 4px; border: 0; }
  .quiz-screen #app .contestant strong, .quiz-screen #app .contestant .tier { display: none; }
  .quiz-screen #app .contestant > .small:not(.row) { display: block; grid-column: 1; grid-row: 1; }
  .quiz-screen #app .contestant .row > :last-child { grid-column: 2; grid-row: 1; }
  .quiz-screen #app .contestant .progress { grid-column: 1 / -1; }
  .tv-mode.quiz-screen #app .q-text { font-size: 22px; }
  .tv-mode.quiz-screen #app .choice { font-size: 20px; }
  .tv-mode.quiz-screen #app .choices { height: auto; min-height: 0; }
}

/* PM #47: 공통 풀이 카드. 그림 원본을 바꾸지 않고 실제 내용의 여백만 줄인다. */
html, body, button, .btn, .choice, .card { touch-action: manipulation; }
button, .btn, .choice, .figure-open, .question-layout { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
input, textarea, select { font-size: max(16px, 1em); -webkit-user-select: text; user-select: text; }
body.quiz-screen { padding: 0; }
.quiz-screen .topbar { display: none; }
.quiz-screen .nav { visibility: hidden; position: fixed; bottom: 0; top: auto; height: 0; min-height: 0; padding: 0; border: 0; overflow: hidden; }
.quiz-screen #app { width: 100%; max-width: none; margin: 0; padding: max(4px, var(--safe-area-top)) max(6px, env(safe-area-inset-right)) max(4px, var(--safe-area-bottom)) max(6px, env(safe-area-inset-left)); height: var(--visible-height); gap: 4px; }
.quiz-screen #app #qcard { padding: 6px; gap: 6px; position: relative; }
.quiz-screen #app .q-head { height: 44px; min-height: 44px; gap: 6px; }
.quiz-screen #app .q-head > :first-child { display: none; }
.quiz-screen #app .question-counter { font-size: 16px; white-space: nowrap; }
.quiz-screen #app #qcard > .progress { display: block; flex: 0 0 3px; margin: -4px 0 0; }
.quiz-screen #app .display-controls { position: relative; gap: 4px; }
.quiz-screen #app .display-controls > .btn { padding: 4px 8px; min-height: 44px; font-size: 14px; }
.quiz-screen #app .rating-toggle { display: inline-flex; }
.quiz-screen #app .display-controls .rating-tools { display: none; position: absolute; top: 100%; right: 0; z-index: 20; background: var(--surface); padding: 8px; border: 1px solid var(--line); box-shadow: var(--shadow); max-width: calc(100vw - 30px); }
.quiz-screen #app .display-controls.ratings-open .rating-tools { display: flex; }
.quiz-screen #app .rate-label { display: none; }
.quiz-screen #app .question-layout { display: flex; flex-direction: column; gap: 6px; }
.quiz-screen #app .question-prompt { display: flex; flex-direction: column; min-height: 0; flex: 1; gap: 4px; }
.quiz-screen #app .question-stimulus { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 4px; }
.quiz-screen #app .q-text { flex: 1; min-height: 1.5em; margin: 0; font-size: clamp(16px, 2.8cqh, 24px); line-height: 1.5; }
.quiz-screen #app .has-question-figure .q-text { flex: 0 1 auto; }
.quiz-screen #app .question-stimulus > .figure-open { flex: 1; height: auto; min-height: 35vh; max-height: none; }
.quiz-screen #app .question-figure { height: 100%; width: 100%; max-height: none; min-height: 0; flex: 1; }
.quiz-screen #app .figure-open { padding: 0; }
.quiz-screen #app .figure-open .small { display: none; }
.quiz-screen #app .choices, .tv-mode.quiz-screen #app .choices { flex: 0 0 auto; width: 100%; height: auto; min-height: 0; align-self: stretch; grid-template-columns: repeat(2,minmax(0,1fr)); grid-template-rows: repeat(2,minmax(44px,auto)); gap: 6px; }
.quiz-screen #app .choices[data-long-choices="true"] { grid-template-columns: minmax(0,1fr); grid-template-rows: repeat(4,minmax(44px,auto)); height: auto; min-height: 0; }
.quiz-screen #app .choice { font-size: 16px; min-height: var(--choice-min-height); height: 100%; --choice-padding-block:4px; padding: var(--choice-padding-block) 8px; }
.quiz-screen #app .choice-text { flex: 1; overflow-y: auto; }
.quiz-screen #app .choice-text > .inline-math:only-child { display: block; text-align: center; font-size: 2em; padding: 3px 0; }
.quiz-screen #app .choice-text .katex { font-size: 1.15em; }
.quiz-screen #app .choice-option { min-height: 0; }
.quiz-screen #app .choice-figure-grid { flex: 1; min-height: 180px; grid-template-rows: repeat(2,minmax(0,1fr)); }
.quiz-screen #app .choice-figure-grid .choice-option { display: flex; flex-direction: column; }
.quiz-screen #app .choice-figure-grid .figure-open { width: 100%; flex: 1; min-height: 44px; height: 0; }
.quiz-screen #app .choice-figure-grid .choice { flex: 0 0 44px; width: 100%; height: 44px; }
.quiz-screen #app .feedback { flex: 0 1 84px; min-height: 68px; max-height: 40%; padding: 4px 8px; }
.quiz-screen #app .after { flex: none; display: flex; flex-direction: row; align-items: center; gap: var(--sp-2); }
.quiz-screen #app .after .lp-note { display: none; }
.quiz-screen #app .question-actions { flex: 1; }
.quiz-screen #app .question-actions a { display: none; }
.quiz-screen #app .keyboard-hint { display: none; }
.quiz-screen .toast { top: calc(4px + var(--safe-area-top)); bottom: auto; }
@media (orientation: landscape) {
  .quiz-screen #app .question-layout { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); grid-template-rows: minmax(0,1fr); gap: 12px; }
  .quiz-screen #app .question-layout.has-question-figure { grid-template-columns: minmax(0,58fr) minmax(0,42fr); }
  .quiz-screen #app .question-stimulus > .figure-open { min-height: 0; }
  .quiz-screen #app .choices { align-content: center; }
  .quiz-screen #app .choice-figure-grid { min-height: 0; align-content: stretch; }
  .quiz-screen #app .choice-text > .inline-math:only-child { font-size: 2.2em; }
}
.tv-mode.quiz-screen #app .q-text { font-size: clamp(22px,3.4cqh,38px); }
.tv-mode.quiz-screen #app .choice { font-size: clamp(20px,2.8cqh,30px); }
.tv-mode.quiz-screen #app .display-controls > .btn { font-size: 18px; }
.quiz-screen #app .display-controls > .btn { min-width: 44px; flex-shrink: 0; }
@media (max-width: 450px) { .quiz-screen #app .display-controls > .btn { padding: 4px; font-size: 12px; } }
.quiz-screen #app .display-controls a { display: inline-flex; }
.quiz-screen #app .display-controls .rating-toggle { min-width: 44px; }
@media (max-width: 450px) {
  .quiz-screen #app .display-controls > .btn { max-width: 76px; white-space: normal; text-align: center; }
  .quiz-screen #app .question-counter { font-size: 13px; }
}

.quiz-screen #app .review-actions { gap:4px; }
.quiz-screen #app .review-actions .btn { padding:4px; min-width:44px; font-size:14px; }
.quiz-screen #app .review-actions [data-review-command="previous"] { flex:0 0 68px; }

.rating-memo summary { min-width:44px;min-height:44px;display:grid;place-items:center;cursor:pointer; }
.rating-memo form { position:absolute;top:100%;right:0;width:min(360px,90vw);max-height:65dvh;overflow:auto;padding:12px;background:var(--surface);border:1px solid var(--line);box-shadow:var(--shadow); }
.rating-memo textarea { min-height:80px; }

/* #219: 진행과 메뉴만 남겨 가로 상단 높이를 28px로 제한한다. */
.quiz-screen #app .q-head { height:28px; min-height:28px; gap:6px; }
.quiz-screen #app .q-head > .progress { display:block; flex:1; height:3px; margin:0; min-width:24px; }
.quiz-screen #app .display-controls > .rating-toggle,
.tv-mode.quiz-screen #app .display-controls > .rating-toggle { width:32px; min-width:32px; height:28px; min-height:28px; padding:0; font-size:24px; line-height:1; max-width:32px; }
.quiz-screen #app .display-controls .quiz-menu { width:min(380px,calc(100vw - 24px)); }
.quiz-menu .menu-actions { display:flex; flex-wrap:wrap; gap:var(--sp-2); padding-bottom:6px; }
.quiz-menu .menu-actions .btn { min-height:44px; font-size:16px; }
.tv-mode .quiz-menu .menu-actions .btn { font-size:20px; }

/* 전 학년 선택도 풀이 전 한 화면에서 고른다. */
.picker-screen #app > .card { --card-pad:8px; margin:0; padding:var(--card-pad); }
.picker-screen #app h2 { margin:0 0 4px; font-size:20px; }
.picker-screen #app .card > p { margin:4px 0; }
.picker-screen #picker .chips { gap:4px; }
.picker-screen #picker .chip { min-height:44px; padding:4px 8px; }
.picker-screen #picker .field { margin:0 !important; }
@media (orientation:landscape) and (max-height:500px) {
  .picker-screen #app { padding-top:4px; padding-bottom:4px; margin-top:0; }
  .picker-screen #picker { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
  .picker-screen #picker .chips { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); }
  .picker-screen #picker .chips > p { grid-column:1 / -1; margin:0; }
  .picker-screen #app .card > div:has(>#start), .picker-screen #app .card > div:has(>#queue) { margin-top:4px !important; }
  .picker-screen #app .big { min-height:44px; padding:4px 8px; }
}

@media (orientation:landscape) and (max-height:500px) {
  .picker-screen #app { margin-left:0; width:100%; padding:4px 6px; }
  .picker-screen #picker .chips { grid-template-columns:repeat(4,minmax(0,1fr)); }
  .picker-screen #picker .chip { white-space:nowrap; font-size:13px; }
  .picker-screen #app .card > p { font-size:12px; line-height:1.3; }
}

@media (orientation:landscape) and (max-height:500px) {
  body.picker-screen { padding-bottom:0; }
  .picker-screen #app h2 { line-height:1.15; }
  .picker-screen #picker label { margin-bottom:3px; }
  .picker-screen #picker .field > p { font-size:12px; line-height:1.2; }
}

.quiz-screen #app .review-actions .btn { height:44px; line-height:1.2; }

@media (orientation:landscape) and (max-height:500px) and (max-width:767px) {
  .picker-screen .topbar { display:none; }
  body.picker-screen { padding-bottom:56px; }
  .picker-screen #app .card > p { line-height:1.1; margin:2px 0; }
}

/* 검수 준비 카드는 같은 공통 CSS/뷰포트에서 측정하지만 그려지거나 조작되지 않는다. */
.review-preview #app > .review-preparing { position:absolute !important; inset:4px 6px; width:calc(100% - 12px); height:calc(100% - 8px); visibility:hidden; pointer-events:none; }
.review-preview #app { position:relative; }
.review-preview #app .after:empty { display:none; }

/* 최초 부팅 중에도 검수 iframe에 앱 선택 화면이 노출되지 않도록 한다. */
html.review-embed .topbar, html.review-embed .nav,
html.review-embed #app > .card:not(#qcard) { visibility:hidden; }

/* #54: 해설은 항상 펼쳐 읽는다. 하한 이후에는 영역 내부만 스크롤한다. */
.quiz-screen #app .has-solution .question-prompt { gap:6px; }
.quiz-screen #app .has-solution .question-stimulus > .figure-open { min-height:44px; }
.quiz-screen #app .has-solution .feedback { flex:1 1 0; min-height:0; max-height:none; height:auto; display:flex; flex-direction:column; padding:6px 8px; overflow:hidden; }
.quiz-screen #app .feedback-head { flex:none; }
.quiz-screen #app .feedback .verdict { font-size:20px; line-height:1.3; }
.quiz-screen #app .explain { flex:1; min-height:1.5em; max-height:none; overflow-y:auto; overscroll-behavior:contain; font-size: max(24px,3.4cqh); line-height:1.5; }
.explain .katex { font-size:1em; }
.auto-next { flex:none; font-size:12px; line-height:1.3; padding-top:4px; }
.auto-next-track { height:4px; background:var(--line); border-radius:4px; margin-top:3px; overflow:hidden; }
.auto-next-track > span { display:block; height:100%; width:100%; background:var(--primary); }
.battle-verdict { font-size:24px; font-weight:800; }
.battle-verdict.ok { color:var(--ok); }
.battle-verdict.bad { color:var(--bad); }
.battle-explanations { display:grid; gap:16px; }
.battle-explanation .q-text, .battle-explanation .explain { font-size:24px; line-height:1.5; }
.battle-explanation p { font-size:24px; line-height:1.5; }
.battle-explanation .figure-open { width:100%; max-height:240px; }
.battle-explanation .question-figure { height:220px; }
.battle-explanation .result-answer { color:var(--ok); font-weight:800; }
.quiz-screen #app #qcard .explain { flex:1; max-height:none; min-height:1.5em; }
.quiz-screen #app .study-footer .after { flex:1; display:block; min-width:0; }
.quiz-screen #app .study-footer .question-actions { display:flex; gap:4px; }
.quiz-screen #app .study-footer .question-actions .btn { min-width:44px; white-space:nowrap; }

.quiz-screen #app .study-footer #previousQuestion { flex:0 0 44px; }

/* #247: 문두/보기/조작부를 먼저 확보하고 그림에 남은 높이를 배분한다. */
.quiz-screen #app .question-layout { overflow:visible; }
.quiz-screen #app .question-prompt { justify-content:space-between; }
.quiz-screen #app .question-prompt .q-text { flex:0 0 auto; height:auto; min-height:0; max-height:none; overflow-y:auto; overflow-x:hidden; }
.quiz-screen #app .question-prompt .question-stimulus { flex:0 0 auto; min-height:0; max-height:none; gap:4px; }
.quiz-screen #app .question-stimulus > .figure-open { flex:0 0 auto; min-height:0; max-height:none; height:auto; }
.quiz-screen #app .choices { align-content:end; }
.quiz-screen #app .has-solution .question-prompt .feedback { flex:1; }

/* 삽화도 공통 자료 면에서 질문·보기·조작부를 제외한 가용 공간을 사용한다. */
.question-illustration {flex:none; align-self:center; max-width:100%;}
.question-illustration .figure-open {min-height:44px; padding:0; gap:0;}

/* PM #78: 레이아웃 높이를 추가하지 않고 상태바 빈 띠를 불투명하게 덮는다. */
.status-bar-cover {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--safe-area-top); background: var(--surface);
  z-index: 19; pointer-events: none;
}
body.quiz-screen > .status-bar-cover { background: var(--bg); }
body.home-screen > .status-bar-cover { background: var(--surface); }
@media (orientation: portrait), (orientation: landscape) and (max-height: 500px) {
  body.home-screen > .status-bar-cover { background: #0e1333; }
}
@media (orientation: landscape) and (max-height: 500px) {
  body.home-screen:has(.member-home) > .status-bar-cover {
    background: linear-gradient(to right, #0e1333 300px, #f4f2ec 300px);
    background-color: #0e1333;
  }
}
/* 전체 화면 노트는 top layer에서 같은 색으로 safe-area를 직접 덮는다. */
body:has(.drawing-dialog[open], .note-list-dialog[open]) > .status-bar-cover { background: var(--surface); }
html.review-embed .status-bar-cover { display: none; }

html.review-embed { --safe-area-top:0px; }
/* 안내는 획/보기 입력을 통과시키고 명시적 동작 버튼만 클릭을 받는다. */
#toast { pointer-events:none; }
#toast button { pointer-events:auto; }
body.ink-drawing #toast:not(:has(button)) { opacity:0.15; }


/* ---- PM #85 공통 컴포넌트(docs/UI_STANDARD.md §2·§3) ---- */
/* 버튼 묶음: PC 는 한 줄(주 버튼 오른쪽), 휴대폰은 전폭 세로 쌓임(주 버튼 위). */
.btn-group { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.btn-group.end { justify-content: flex-end; }
.result-actions .btn.primary { order: 1; }
.result-actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); justify-content: center; margin-top: var(--sp-4); }
@media not all and (min-width: 768px) {
  .result-actions { flex-direction: column; align-items: stretch; }
  .result-actions .btn { width: 100%; min-height: var(--h-lg); }
  .result-actions .btn.primary { order: -1; }
}
/* 선택 화면의 주 행동: 휴대폰은 하단 탭 위에 붙는 행동줄, PC 는 내용 아래 왼쪽 정렬. */
.action-bar { margin-top: var(--sp-4); }
@media not all and (min-width: 768px) {
  .action-bar { position: sticky; bottom: calc(var(--sp-2) + env(safe-area-inset-bottom)); z-index: 2; margin: var(--sp-4) calc(-1 * var(--card-pad, var(--sp-4))) calc(-1 * var(--card-pad, var(--sp-4))); padding: var(--sp-3) var(--card-pad, var(--sp-4)); background: var(--surface); border-top: 1px solid var(--line); border-radius: 0 0 var(--r-lg) var(--r-lg); }
  .action-bar .btn { width: 100%; min-height: var(--h-lg); }
}
@media (min-width: 768px) {
  .action-bar .btn.block { width: auto; min-width: 200px; }
}
/* 긴 안내문은 접는다. 제목 → 선택 요소 → 주 버튼 순서를 지킨다. */
details.help { margin: var(--sp-3) 0 0; }
details.help > summary { display: inline-flex; align-items: center; gap: var(--sp-1); min-height: var(--h-md); color: var(--primary); font-size: var(--fs-label); font-weight: 700; cursor: pointer; list-style: none; }
details.help > summary::-webkit-details-marker { display: none; }
details.help > summary::before { content: "▸"; font-size: var(--fs-caption); }
details.help[open] > summary::before { content: "▾"; }
details.help > p { margin: var(--sp-2) 0 0; font-size: var(--fs-label); color: var(--muted); line-height: 1.6; }
/* 정보용 배지 목록(티어 안내 등)은 선택 칩과 모양을 구분한다. */
.badge-list { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.badge-list > * { display: inline-flex; align-items: center; gap: var(--sp-1); min-height: 32px; padding: var(--sp-1) var(--sp-3); border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface); font-size: var(--fs-label); font-weight: 600; }
/* 빈 상태 */
.empty-state { padding: var(--sp-6) var(--sp-4); text-align: center; color: var(--muted); font-size: var(--fs-label); }
.empty-state .btn { margin-top: var(--sp-3); }
/* 폼 카드: 한 열 최대 480, 주 버튼 전폭, 보조는 아래 묶음. */
.account-page { max-width: 480px; }
.account-page h1 { font-size: var(--fs-title); margin-bottom: var(--sp-3); }
.account-page .btn.primary { width: 100%; min-height: var(--h-lg); margin-top: var(--sp-2); }
.account-alt { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-4); }
.account-alt .btn { flex: 1 1 140px; }
/* 머리줄 안 버튼은 md 하나 크기, 검수 진입은 보조 버튼 */
.topbar .btn { min-height: var(--h-md); padding: var(--sp-2) var(--sp-3); font-size: var(--fs-label); flex-shrink: 0; white-space: nowrap; }
/* 대화상자 안 입력도 44 */
dialog input:not([type="checkbox"]):not([type="radio"]), dialog select { min-height: var(--h-md); }
/* 체크박스: 시각 24, 터치 44 는 행(label)에서 확보 */
.check-row { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--h-md); }

/* #835: 모든 스크롤 화면에서 돌출 탭·safe-area를 포함한 실제 하단 레일을 비운다. */
html:not(.review-embed) body:not(.quiz-screen) { padding-bottom:max(var(--navigation-clearance,100px),calc(16px + var(--safe-area-bottom))); }
@media(max-width:767px) { body:not(.quiz-screen) .nav { padding-bottom:max(8px,var(--safe-area-bottom)); } }

/* #978: 자녀 카드의 요약은 항상 보이고 세부 관리만 펼친다. */
.family-child-heading{display:flex;gap:var(--sp-3);align-items:center}
.family-child-heading h2{margin:0;font-size:var(--fs-title-sm)}
.family-child-heading p{margin:var(--sp-2) 0}
.family-page details>summary{min-height:44px;padding:var(--sp-3);cursor:pointer;border-radius:var(--r-md)}
.child-options[open]>summary{margin-bottom:var(--sp-3)}
.registration-card,.child-device{padding:var(--sp-4);border:1px solid var(--line);border-radius:var(--r-lg);margin-block:var(--sp-3)}
.device-code{font-weight:700;overflow-wrap:anywhere}
.registered-child-names{margin-block:var(--sp-4)}
.pending-banner{display:flex;align-items:center;justify-content:space-between;gap:var(--sp-3)}

/* 결과를 읽는 동안 보상을 같은 화면에서 받고, 이동은 확인 후 진행한다. */
.result-rewards { margin-block: var(--sp-4); padding: var(--sp-3); border: 1px solid var(--line); border-radius: 12px; text-align: left; }
.result-rewards > .btn { margin: 4px; }
.result-rewards .growth-page { margin-top: var(--sp-3); }
.result-rewards .growth-rewards { padding: 0; }
.result-rewards .growth-reward { min-width: 0; }

.battle-summary .vs .big { font-size: clamp(18px, 4vw, 28px); line-height: 1.35; overflow-wrap: anywhere; }

/* 오답 유형 연습 버튼과 풀이 카드 사이에 간격을 둔다. */
.same-type-start { margin: 8px 8px 8px 0; min-height: 44px; }
.same-type-notice { margin: 0 0 8px; }

.learning-start { min-height:44px; margin:8px 8px 8px 0; }
.related-learning-panel { width:min(620px,calc(100vw - 24px)); max-height:calc(100dvh - 32px); overflow:auto; border:1px solid var(--line); border-radius:18px; padding:20px; color:var(--text); background:var(--surface); }
.related-learning-panel::backdrop { background:#0008; }
.related-learning-panel p { line-height:1.65; }
