/* quiz by quiz — 3단계 스타일
   모바일 우선. 320px 폭까지 깨지지 않게 맞췄다. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c1f24;
  /* 상태 색은 WCAG AA(4.5:1)를 제 배경과 흰 배경 양쪽에서 넘긴다.
     이 색들은 12~13px 이나 상속 크기로만 쓰여 «큰 글자» 예외에 드는 곳이 없다.
     기호(✓ ✗)와 글자가 뜻을 지고 색은 거들 뿐이지만(FR-4.1, FR-4.2),
     거드는 것도 보여야 거든다. 밝기만 낮추고 색상·채도는 그대로 두었다. */
  --text-muted: #69707e;
  --accent: #3b5bdb;
  --accent-soft: #edf0fd;
  --correct: #268037;
  --correct-soft: #ebfbee;
  --wrong: #db2121;
  --wrong-soft: #fff5f5;
  --warning: #bf490a;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

/* flex·grid 요소에도 hidden 속성이 먹도록 (JS가 hidden으로 여닫는다) */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard',
    'Malgun Gothic', system-ui, sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* 스크린리더 전용. 화면에서는 보이지 않지만 낭독은 된다 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* 키보드로 이동할 때만 테두리를 보여준다. 마우스 클릭에는 뜨지 않는다 */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── 부팅 상태 ──
   스크립트가 실행되지 못하면 .is-booted가 붙지 않아 앱이 계속 숨겨진다.
   3초 뒤 인라인 스크립트가 .is-boot-failed를 붙여 이유를 알린다. */
.app {
  display: none;
  max-width: 560px;
  margin: 0 auto;
  /* 아래 여백은 피드백 시트 높이만큼 늘어난다. 시트가 fixed 라 문서 흐름에서
     빠져 있어, 이게 없으면 마지막 보기가 시트에 가려 보이지 않는다.
     실제 높이는 해설 길이에 따라 달라지므로 quiz.js 가 재서 넣는다. */
  padding: 8px 16px calc(48px + var(--feedback-h, 0px));
}

body.is-booted .app {
  display: block;
}

.boot {
  max-width: 560px;
  margin: 0 auto;
  padding: 48px 16px;
}

body.is-booted .boot {
  display: none;
}

.boot__loading {
  margin: 0;
  color: var(--text-muted);
  text-align: center;
}

.boot__error {
  display: none;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

body.is-boot-failed .boot__loading {
  display: none;
}

body.is-boot-failed .boot__error {
  display: block;
}

.boot__title {
  margin: 0 0 10px;
  font-size: 19px;
}

.boot__body {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--text-muted);
  word-break: keep-all;
}

.boot__code {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #1c1f24;
  color: #e8eaed;
  font-size: 13px;
  overflow-x: auto;
}

.boot code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg);
  font-size: 0.92em;
}

/* ── 상단 바 (소리 토글) ── */
.app-bar {
  display: none;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px 0;
  justify-content: flex-end;
}

body.is-booted .app-bar {
  display: flex;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--border);
  color: var(--text);
}

.icon-button__icon {
  font-size: 15px;
  line-height: 1;
}

.screen[hidden] {
  display: none;
}

.screen:focus {
  outline: none; /* 화면 전환용 포커스라 테두리를 그리지 않는다 */
}

/* ── 버튼 공통 ── */
.button {
  font: inherit;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid transparent;
  /* 손가락으로 누를 수 있는 크기 (3-B 반응형) */
  min-height: 44px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

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

.button--primary {
  background: var(--accent);
  color: #fff;
}

.button--primary:hover {
  background: #364fc7;
}

.button--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.button--ghost:hover {
  border-color: #c8ccd4;
  color: var(--text);
}

.button--danger {
  background: var(--wrong);
  color: #fff;
}

.button--danger:hover {
  background: #c92a2a;
}

/* ── 홈 ── */
.home-header {
  margin-bottom: 28px;
  text-align: center;
}

.home-title {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.home-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

/* 카테고리가 홀수 개면 마지막 카드가 한 칸만 채워 오른쪽이 빈다.
   개수를 세지 않고 «홀수 번째이면서 마지막» 인 카드만 두 칸으로 늘린다.
   카테고리를 더하거나 빼도 이 규칙 그대로 맞는다. */
.category-card:nth-child(odd):last-child {
  grid-column: 1 / -1;
}

.category-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 16px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font: inherit;
  text-align: left;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.category-card:hover:not(:disabled) {
  border-color: var(--accent);
}

.category-card:active:not(:disabled) {
  transform: scale(0.99);
}

.category-card:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.category-card__icon {
  font-size: 20px;
  line-height: 1.2;
}

.category-card__name {
  font-size: 16px;
  font-weight: 700;
}

.category-card__desc {
  font-size: 12px;
  color: var(--text-muted);
}

.category-card__count {
  margin-top: 2px;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

.category-card:disabled .category-card__count {
  color: var(--wrong);
}

/* 최고 점수 (FR-2.3). 기록이 없으면 아예 그리지 않는다 */
.category-card__best {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ── 전체 도전 (FR-2.2) ── */
.challenge-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font: inherit;
  text-align: left;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.challenge-card:hover:not(:disabled) {
  border-color: var(--accent);
}

.challenge-card:active:not(:disabled) {
  transform: scale(0.99);
}

.challenge-card:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.challenge-card__icon {
  font-size: 24px;
  line-height: 1;
}

.challenge-card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.challenge-card__name {
  font-size: 16px;
  font-weight: 700;
}

.challenge-card__desc {
  font-size: 12px;
  color: var(--text-muted);
}

.challenge-card__meta {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-align: right;
}

.home-actions {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.home-note {
  margin-top: 20px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--wrong-soft);
  color: var(--wrong);
  font-size: 13px;
}

/* ── 퀴즈 헤더 ── */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.quiz-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.quiz-category {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.quiz-position {
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.progress {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 20px;
}

.progress__fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease;
}

/* ── 타이머 ── */
.timer {
  margin-bottom: 20px;
}

.timer__track {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.timer__fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  border-radius: 999px;
  transform-origin: left center;
}

.timer__label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* 경고 상태: 색상만이 아니라 아이콘과 문구도 함께 바뀐다 (FR-3.9) */
.timer--warning .timer__fill {
  background: var(--warning);
}

.timer--warning .timer__label {
  color: var(--warning);
}

.timer--warning .timer__icon {
  animation: pulse 0.8s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

/* ── 문제와 보기 ── */
.question {
  margin: 0 0 18px;
  font-size: 20px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  word-break: keep-all;
}

.choices {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font: inherit;
  text-align: left;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.choice:hover:not(:disabled) {
  border-color: var(--accent);
}

.choice:disabled {
  cursor: default;
}

.choice__key {
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.choice__text {
  flex: 1;
  word-break: keep-all;
}

/* 정답·오답 표시는 색상에 더해 아이콘으로도 구분한다 (FR-4.1, FR-4.2) */
.choice__mark {
  flex: none;
  font-size: 14px;
  font-weight: 700;
}

.choice--correct {
  border-color: var(--correct);
  background: var(--correct-soft);
}

.choice--correct .choice__key {
  background: var(--correct);
  color: #fff;
}

.choice--correct .choice__mark {
  color: var(--correct);
}

.choice--wrong {
  border-color: var(--wrong);
  background: var(--wrong-soft);
}

.choice--wrong .choice__key {
  background: var(--wrong);
  color: #fff;
}

.choice--wrong .choice__mark {
  color: var(--wrong);
}

.choice--muted {
  opacity: 0.55;
}

/* ── 피드백 ── */
/* 화면 맨 아래에 붙는 시트.
   답을 고른 뒤 스크롤을 내려 찾지 않아도 되고, 엄지가 닿는 자리에 버튼이 온다.

   z-index 를 주지 않는다 — 이 프로젝트에는 하나도 없고 DOM 순서가 곧 겹치는
   순서다. 그래서 이 요소는 <main> 밖, 대화상자들 앞에 있다.
   .app 은 --feedback-h 만큼 아래 여백을 더 두어 시트가 마지막 보기를 가리지 않는다. */
.feedback {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
  /* 노치가 있는 기기에서 홈 인디케이터에 눌리지 않게 */
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  /* 그림자를 위로 드리워 «떠 있는 것»으로 읽히게 한다 */
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.14);
  /* 해설이 길어도 화면을 다 먹지 않는다 */
  max-height: 60vh;
  overflow-y: auto;
}

.feedback__verdict {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
}

.feedback--correct .feedback__verdict {
  color: var(--correct);
}

.feedback--wrong .feedback__verdict {
  color: var(--wrong);
}

.feedback__explanation {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--text-muted);
  word-break: keep-all;
}

.feedback .button {
  width: 100%;
  /* 키 표시를 오른쪽 끝에 붙이기 위한 기준. 글자는 가운데에 그대로 둔다 */
  position: relative;
}

/* ── 키 표시 ──
   게임 모드에서는 손이 방향키에 있으므로, 마우스로 옮겨 가지 않아도
   Enter 로 이어갈 수 있다는 것을 버튼에서 바로 알린다.
   키보드가 없는 기기에는 쓸모가 없어 pointer: fine 에서만 그린다. */
.key-hint {
  display: none;
  position: absolute;
  top: 50%;
  right: 12px;
  translate: 0 -50%;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0.75;
}

.key-hint__key {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 3px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.24);
  font: inherit;
  font-size: 12px;
  line-height: 1;
}

@media (pointer: fine) {
  .quiz--game .key-hint {
    display: inline-flex;
  }
}

/* 좁으면 버튼 글자와 부딪힌다. 키 표시는 부가 정보라 접는다 —
   조작법은 ? 대화상자에 그대로 있다. 뒤에 와야 위 규칙을 이긴다. */
@media (max-width: 400px) {
  .quiz--game .key-hint {
    display: none;
  }
}

/* ── 나가기 확인 다이얼로그 ── */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.45);
}

.dialog-backdrop[hidden] {
  display: none;
}

.dialog {
  width: 100%;
  max-width: 340px;
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.2);
}

.dialog__title {
  margin: 0 0 6px;
  font-size: 17px;
}

.dialog__body {
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--text-muted);
}

.dialog__actions {
  display: flex;
  gap: 8px;
}

.dialog__actions .button {
  flex: 1;
}

/* ── 결과 ── */
.result-header {
  margin-bottom: 20px;
  padding: 24px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.result-mode {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.result-score {
  margin: 4px 0 8px;
  font-size: 16px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.result-score strong {
  font-size: 44px;
  line-height: 1.1;
  color: var(--text);
  letter-spacing: -0.03em;
}

.result-score__max {
  margin-left: 2px;
}

.result-grade {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.result-grade-message {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  word-break: keep-all;
}

/* 최고 기록 비교 (FR-5.7) */
.result-best {
  margin: 14px 0 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg);
  font-size: 13px;
  color: var(--text-muted);
  word-break: keep-all;
}

.result-best--new {
  background: var(--correct-soft);
  color: var(--correct);
  font-weight: 600;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 20px;
  padding: 14px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.result-stats__item {
  text-align: center;
  min-width: 0;
}

.result-stats dt {
  font-size: 12px;
  color: var(--text-muted);
}

.result-stats dd {
  margin: 2px 0 0;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.result-block {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.result-block__title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
}

/* 카테고리별 정답 개수 (FR-5.6) */
.category-score {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.category-score__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
}

.category-score__count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* 틀린 문제 다시 보기 (FR-5.4) */
.review {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.review__item {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.review__item:first-child {
  padding-top: 0;
  border-top: none;
}

.review__question {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
  word-break: keep-all;
}

/* 정답·오답을 색상만이 아니라 앞의 기호와 글자로도 구분한다 */
.review__row {
  display: flex;
  gap: 8px;
  margin: 0 0 4px;
  font-size: 14px;
  word-break: keep-all;
}

.review__tag {
  flex: none;
  font-weight: 700;
}

.review__row--mine .review__tag {
  color: var(--wrong);
}

.review__row--answer .review__tag {
  color: var(--correct);
}

.review__explanation {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  word-break: keep-all;
}

/* 랭킹 등록 (FR-6.1) */
.register__row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
}

.register__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.register__input {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  color: inherit;
}

.register__input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.register__input:disabled {
  background: var(--bg);
  color: var(--text-muted);
}

.register__message {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  word-break: keep-all;
}

.register__message--error {
  color: var(--wrong);
}

.register__message--done {
  color: var(--correct);
  font-weight: 600;
}

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

.result-actions .button {
  flex: 1 1 30%;
  min-width: 96px;
}

/* ── 랭킹 ── */
.ranking-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.ranking-title {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

/* 저장 범위 안내 (FR-6.10) */
.ranking-scope {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  word-break: keep-all;
}

.ranking-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  padding-bottom: 4px;
  overflow-x: auto;
}

.ranking-tab {
  flex: none;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.ranking-tab:hover {
  border-color: var(--accent);
}

.ranking-tab--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.ranking-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ranking-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  grid-template-areas:
    'rank nickname score'
    'rank date date';
  align-items: center;
  column-gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

/* 방금 등록한 기록 (FR-6.5) */
.ranking-item--mine {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ranking-item__rank {
  grid-area: rank;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.ranking-item--mine .ranking-item__rank {
  color: var(--accent);
}

.ranking-item__nickname {
  grid-area: nickname;
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
}

.ranking-item__badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
}

.ranking-item__score {
  grid-area: score;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* 몇 문제 중 몇 개인지. 점수보다 작게 붙여 순위는 점수로 읽히게 둔다 */
.ranking-item__hits {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.ranking-item__date {
  grid-area: date;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* 빈 상태 (FR-6.12) */
.ranking-empty {
  margin: 0;
  padding: 32px 16px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  word-break: keep-all;
}

.ranking-footer {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

/* ── 출제 수보다 문제가 적을 때 ── */
.category-card__count--short {
  color: var(--warning);
}

/* ── 애니메이션 ──
   정답·오답을 눈으로도 짚어 준다. 색상 대신이 아니라 색상에 더하는 것이다. */
@keyframes pop {
  40% {
    transform: scale(1.03);
  }
}

@keyframes shake {
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.choice--correct {
  animation: pop 0.32s ease;
}

.choice--wrong {
  animation: shake 0.3s ease;
}

.feedback:not([hidden]) {
  animation: sheet-up 0.22s ease-out;
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}
/* ── 게임 모드 무대 ──
   바닥을 십자로 나눈 2×2 칸 위에서 캐릭터를 8방향으로 움직여 보기를 고른다.
   조작의 실체는 위 보기 버튼이고 여기는 그 버튼을 부르는 시각적 조작부다.
   그래서 게임 모드를 꺼도 잃는 기능이 없다. */

/* 게임 모드에서는 위 패널이 «문제 + 보기» 창 노릇을 하므로 촘촘하게 줄인다.
   무대와 조작부가 한 화면에 함께 들어와야 게임처럼 읽힌다. */
.quiz--game .choices {
  gap: 6px;
  margin-bottom: 14px;
}

.quiz--game .choice {
  min-height: 40px;
  padding: 7px 12px;
  font-size: 14px;
  box-shadow: none;
}

.quiz--game .choice__key {
  width: 20px;
  height: 20px;
  font-size: 11px;
}

/* 방향 조작부는 두지 않는다. 바닥을 직접 누르면 건너가서 골라지므로
   손가락·마우스로는 그것으로 충분하고, 키보드는 방향키가 있다.
   덕분에 바닥이 폭을 다 쓰고 세로도 바닥 높이만 차지한다. */
.arena {
  margin: 0 0 20px;
}

.arena__stage {
  position: relative;
  min-width: 0;
}

/* ── 바닥 ──
   칸 사이의 틈으로 컨테이너 배경이 비쳐 십자선이 된다.
   선을 따로 그리지 않으므로 칸 수가 바뀌어도 그대로 맞는다. */
/* 칸 사이 틈이 곧 십자선이자 «아무 칸도 아닌 자리»다.
   캐릭터는 여기 한가운데에서 시작하므로 눈에 보일 만큼 넓혀 둔다. */
.arena__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 7px;
  /* --border 는 페이지 배경과 가까워 십자선이 묻힌다. 한 단계 진한 값을 쓴다 */
  background: #ccd2dd;
  border-radius: 16px;
}

.arena-tile {
  position: relative;
  min-width: 0;
  height: 72px;
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.18s, box-shadow 0.18s, color 0.18s;
}

/* 번호와 채점 표시는 칸 «위쪽» 양 끝에 붙이고 캐릭터는 아래쪽에 세운다.
   위아래로 나눠 두면 칸이 좁아져도 가로로 겹칠 일이 없다.
   조작부를 옆에 두면서 칸 폭이 줄어 이 배치가 필요해졌다. */
.arena-tile__number {
  position: absolute;
  top: 5px;
  left: 9px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1;
  transition: color 0.18s;
}

.arena-tile__mark {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

/* 캐릭터가 서 있는 칸. 불이 들어온 것처럼 보이게 한다.
   클래스 이름은 워커가 붙이는 is-standing 하나로 통일했다 —
   홈이든 무대든 «발밑»을 나타내는 것은 같은 개념이다. */
.arena-tile.is-standing {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent), 0 0 18px rgba(59, 91, 219, 0.45);
}

.arena-tile.is-standing .arena-tile__number {
  color: var(--accent);
}

/* 채점 뒤. 색만이 아니라 표시로도 구분한다 (FR-4.1, FR-4.2) */
.arena-tile--correct {
  background: var(--correct-soft);
  box-shadow: inset 0 0 0 2px var(--correct);
}

.arena-tile--correct .arena-tile__number,
.arena-tile--correct .arena-tile__mark {
  color: var(--correct);
}

.arena-tile--correct .arena-tile__mark::after {
  content: '✓';
}

.arena-tile--wrong {
  background: var(--wrong-soft);
  box-shadow: inset 0 0 0 2px var(--wrong);
}

.arena-tile--wrong .arena-tile__number,
.arena-tile--wrong .arena-tile__mark {
  color: var(--wrong);
}

.arena-tile--wrong .arena-tile__mark::after {
  content: '✗';
}

.arena-tile--muted {
  opacity: 0.55;
}

.arena--locked .arena-tile {
  cursor: default;
}

/* ── 걸어 다니는 캐릭터 ──
   퀴즈 무대·홈·캐릭터 화면이 같은 조각을 쓴다.

     .walker          위치. JS가 transform 으로만 옮긴다
     .walker__body    뛰고 눌리는 몸통 (슬라임은 눈, 도트는 스프라이트를 품는다)
     .walker__shadow  땅에 남는 그림자

   몸통을 ::before 로 그리면 눈이 따로 놀고 그림자가 몸을 따라 떠올라
   튀는 것으로 보이지 않는다. 그래서 실제 요소로 나눴다. */
/* 캐릭터는 페이지가 아니라 «화면»에 붙는다. 스크롤해도 제자리에 있고
   그 아래로 내용이 흘러간다.
   z-index 를 주지 말 것 — 뒤에 오는 다이얼로그가 DOM 순서로 위에 와야 한다. */
.walker {
  position: fixed;
  top: 0;
  left: 0;
  width: 34px;
  height: 42px;
  pointer-events: none;
  will-change: transform;
}

/* 홈과 캐릭터 화면은 무대가 넓어 조금 크게 그린다 */
.walker--home {
  width: 40px;
  height: 48px;
}

.walker__body {
  position: absolute;
  inset: 0;
  border-radius: 46% 46% 38% 38%;
  box-shadow: inset 0 -6px 0 rgba(15, 23, 42, 0.16), 0 3px 8px rgba(15, 23, 42, 0.3);
  /* 발밑 기준으로 눌린다. 가운데 기준이면 땅으로 꺼져 보인다 */
  transform-origin: 50% 100%;
}

/* 도트 몬스터는 덩어리가 아니라 스프라이트다. 배경과 그림자를 지운다 */
.walker__body--pixel {
  background: none;
  border-radius: 0;
  box-shadow: none;
  display: grid;
  place-items: center;
}

/* 1px 요소 하나에 box-shadow 로 픽셀을 찍는다 (ui/sprite.js).
   요소가 하나라 scale·translate 가 스프라이트 전체에 통째로 먹는다. */
.walker__dot {
  /* 점 크기와 간격이 같아야 픽셀이 빈틈없이 붙는다 */
  width: var(--pixel-unit);
  height: var(--pixel-unit);
  /* box-shadow 는 오른쪽·아래로만 퍼지므로 왼쪽 위로 당겨 가운데를 맞춘다 */
  translate: var(--sprite-shift-x) var(--sprite-shift-y);
}

/* 발밑 그림자. 몸이 튀어 올라도 여기 남아야 «튀는» 것으로 읽힌다 */
.walker__shadow {
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 26px;
  height: 7px;
  translate: -50% 0;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.22);
  filter: blur(1px);
}

.walker--home .walker__shadow {
  width: 30px;
}

/* 슬라임의 눈 둘 */
.walker__face,
.walker__face::after {
  position: absolute;
  top: 14px;
  width: 6px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
}

.walker__face {
  left: 8px;
}

.walker__face::after {
  content: '';
  top: 0;
  left: 12px;
}

.walker--home .walker__face {
  top: 16px;
  left: 10px;
}

/* ── 움직임 ──
   공이 튀듯 — 땅에 닿는 순간 납작하게 눌리고, 솟아오르며 길쭉해진다.
   솟는 구간은 점점 느려지고(ease-out) 떨어지는 구간은 점점 빨라진다(ease-in).
   rotate 를 넣지 말 것. 좌우로 흔들면 튀는 게 아니라 떠다니는 것으로 보인다. */
.walker--walking .walker__body {
  animation: walker-bounce 0.3s infinite;
}

.walker--walking .walker__shadow {
  animation: walker-bounce-shadow 0.3s infinite;
}

/* 서 있을 때도 제자리에서 가만히 뛴다. «움직일 수 있다»를 눈으로 알린다 */
.walker--idle .walker__body {
  animation: walker-idle 1.1s infinite;
}

.walker--idle .walker__shadow {
  animation: walker-idle-shadow 1.1s infinite;
}

/* 고를 때 한 번 크게 뛴다. --walking·--idle 뒤에 두어야 겹칠 때 이쪽이 이긴다 */
.walker--hop .walker__body {
  animation: walker-land 0.42s;
}

.walker--hop .walker__shadow {
  animation: walker-land-shadow 0.42s;
}

/* 틀렸을 때. 색을 뺀다 */
.walker--sad .walker__body {
  background: linear-gradient(160deg, #b4bcc9, #808a9b);
}

.walker--sad .walker__body--pixel {
  background: none;
  filter: grayscale(1);
}

@keyframes walker-bounce {
  0% {
    translate: 0 0;
    scale: 1.22 0.78;
    animation-timing-function: cubic-bezier(0.15, 0.75, 0.4, 1);
  }
  20% { translate: 0 -8px; scale: 0.9 1.12; }
  50% {
    translate: 0 -13px;
    scale: 1 1;
    animation-timing-function: cubic-bezier(0.6, 0, 0.85, 0.4);
  }
  85% { translate: 0 -3px; scale: 0.95 1.06; }
  100% { translate: 0 0; scale: 1.22 0.78; }
}

@keyframes walker-bounce-shadow {
  0% {
    scale: 1.15 1;
    opacity: 1;
    animation-timing-function: cubic-bezier(0.15, 0.75, 0.4, 1);
  }
  50% {
    scale: 0.6 0.8;
    opacity: 0.45;
    animation-timing-function: cubic-bezier(0.6, 0, 0.85, 0.4);
  }
  100% { scale: 1.15 1; opacity: 1; }
}

/* 제자리 뛰기. 걷기보다 낮고 느긋하다 — 서 있다는 느낌은 남기되 살아 있게 한다 */
@keyframes walker-idle {
  0% {
    translate: 0 0;
    scale: 1.12 0.88;
    animation-timing-function: cubic-bezier(0.2, 0.7, 0.4, 1);
  }
  35% {
    translate: 0 -7px;
    scale: 0.96 1.04;
    animation-timing-function: cubic-bezier(0.6, 0, 0.85, 0.4);
  }
  70% { translate: 0 0; scale: 1.12 0.88; }
  100% { translate: 0 0; scale: 1.12 0.88; }
}

@keyframes walker-idle-shadow {
  0% { scale: 1.08 1; opacity: 1; animation-timing-function: cubic-bezier(0.2, 0.7, 0.4, 1); }
  35% { scale: 0.78 0.9; opacity: 0.65; animation-timing-function: cubic-bezier(0.6, 0, 0.85, 0.4); }
  70% { scale: 1.08 1; opacity: 1; }
  100% { scale: 1.08 1; opacity: 1; }
}

@keyframes walker-land {
  0% { translate: 0 0; scale: 1 1; animation-timing-function: cubic-bezier(0.15, 0.8, 0.4, 1); }
  28% { translate: 0 -22px; scale: 0.86 1.2; animation-timing-function: cubic-bezier(0.6, 0, 0.9, 0.5); }
  58% { translate: 0 0; scale: 1.3 0.72; }
  78% { translate: 0 -5px; scale: 0.96 1.05; }
  100% { translate: 0 0; scale: 1 1; }
}

@keyframes walker-land-shadow {
  0% { scale: 1 1; opacity: 1; }
  28% { scale: 0.5 0.7; opacity: 0.35; }
  58% { scale: 1.25 1; opacity: 1; }
  100% { scale: 1 1; opacity: 1; }
}

/* ── 무대 아래 한 줄 안내 ── */
.arena__hint,
.home-hint {
  margin: 9px 0 0;
  text-align: center;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-muted);
}

.home-hint {
  margin-top: 14px;
}

.arena__hint-touch,
.home-hint-touch {
  display: none;
}

/* ── 이동 스틱 ──
   손가락 입력이 있는 기기에서, 걸어 다닐 수 있는 화면에서만 그린다.
   화면에 띄워 세로 자리를 차지하지 않는다.
   z-index 를 주지 않는다 — 주면 뒤에 오는 다이얼로그보다 위로 올라온다. */
.walk-stick {
  display: none;
  position: fixed;
  left: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(226, 229, 234, 0.72);
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.14);
  /* 스틱을 밀 때 화면이 함께 스크롤되지 않게 막는다 */
  touch-action: none;
  user-select: none;
}

@media (pointer: coarse) {
  .arena__hint-key,
  .home-hint-key {
    display: none;
  }

  .arena__hint-touch,
  .home-hint-touch {
    display: inline;
  }

  /* 걸어 다닐 수 있는 화면에서만 켠다 (walker.js 가 붙이는 클래스) */
  .walk-stick--on {
    display: block;
  }
}

/* 화면이 짧으면 무대와 겹칠 수 있다. 줄여서 가리는 넓이를 좁힌다 */
@media (max-height: 700px) {
  .walk-stick {
    width: 130px;
    height: 130px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    left: 10px;
  }

  .walk-stick__knob {
    width: 54px;
    height: 54px;
    margin: -27px 0 0 -27px;
  }

  .walk-confirm {
    width: 76px;
    height: 76px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    font-size: 14px;
  }
}

/* 확정 버튼. 스틱의 반대편에 두어 두 엄지로 잡는다.
   손가락에는 Enter가 없어, 이게 없으면 스틱으로 걸어가도 칸을 직접 눌러야 한다.
   답을 낸 뒤에는 walker.js 가 --on 을 떼어 치운다 — 그대로 두면 «다음 문제»를 가린다. */
.walk-confirm {
  display: none;
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.25);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  touch-action: manipulation;
  user-select: none;
}

.walk-confirm:active {
  translate: 0 2px;
  background: #2c46ad;
}

@media (pointer: coarse) {
  .walk-confirm--on {
    display: block;
  }
}

.walk-stick__knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 66px;
  height: 66px;
  margin: -33px 0 0 -33px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.3);
}

/* ── 홈 무대 ──
   캐릭터가 이 안을 걸어 다닌다. 좌표 기준이므로 position 이 필요하다. */
.home-stage {
  position: relative;
}

/* 카테고리보다 위에 둔다. 첫 화면에 보여야 캐릭터가 서 있는 것이 눈에 들어온다 */
.home-menu {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

/* 메뉴가 홀수 개면 마지막 카드가 한 칸만 채워 오른쪽이 빈다.
   카테고리 카드와 같은 규칙이라 메뉴를 더하거나 빼도 그대로 맞는다. */
.menu-card:nth-child(odd):last-child {
  grid-column: 1 / -1;
}

.menu-card {
  display: flex;
  align-items: center;
  gap: 10px;
  /* 오른쪽은 캐릭터가 설 자리로 비워 둔다. 글자를 덜 가린다 */
  padding: 14px 44px 14px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font: inherit;
  text-align: left;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s;
}

/* 닉네임 카드는 메뉴 줄 위에 홀로 놓여 폭을 다 쓴다 */
.menu-card--wide {
  width: 100%;
  margin-bottom: 12px;
}

.menu-card:hover:not(:disabled) {
  border-color: var(--accent);
}

.menu-card:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* 미리보기 자리. 슬라임·도트가 여기 들어간다 */
.menu-card__figure {
  position: relative;
  flex: none;
  width: 34px;
  height: 40px;
  font-size: 22px;
  line-height: 40px;
  text-align: center;
}

.menu-card__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.menu-card__name {
  font-size: 15px;
  font-weight: 700;
}

.menu-card__desc {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 캐릭터가 보기 버튼 위에 섰을 때. 바닥 칸과 같은 뜻이라 같은 결로 칠한다 */
.choice.is-standing:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* 카드처럼 제 표시가 따로 없는 버튼들. 걸어 올라서면 눌릴 수 있다고 알린다.
   focus 테두리와 같은 모양을 쓴다 — 「지금 이걸 누르면 된다」는 뜻이 같다.

   글자를 적는 칸도 같은 표시를 쓴다. 밟으면 «누르는» 대신 커서가 들어가지만,
   보는 쪽에서는 둘 다 「지금 여기서 Enter」라 표시를 나눌 이유가 없다. */
.button.is-standing,
.icon-button.is-standing,
.ranking-tab.is-standing,
.character-card.is-standing,
.arena__help.is-standing,
input.is-standing,
textarea.is-standing,
select.is-standing {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* 캐릭터가 올라선 칸. 눌러서 고를 수 있다는 표시다 */
.category-card.is-standing,
.challenge-card.is-standing,
.menu-card.is-standing {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-soft), 0 0 18px rgba(59, 91, 219, 0.28);
}

/* ── 내 캐릭터 화면 ── */
.screen-title {
  margin: 0;
  font-size: 20px;
}

.screen-lead {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.character-stage {
  position: relative;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.character-card {
  display: grid;
  place-items: center;
  /* 이름이 없으니 그림만 들어간다. 여백을 넉넉히 줘 누르기 편하게 한다 */
  padding: 16px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

/* 미리보기는 정지 그림이다. 뛰는 것은 걸어 다니는 캐릭터 하나뿐이라
   목록이 어수선해지지 않는다. 이름을 붙이지 않으므로 칸에는 그림만 들어간다. */
.character-card__figure {
  position: relative;
  width: 40px;
  height: 48px;
}

/* 지금 쓰고 있는 캐릭터 */
.character-card--on {
  border-color: var(--accent);
  background: var(--accent-soft);
}

@media (max-width: 360px) {
  .character-grid {
    gap: 8px;
  }

  .character-card {
    padding: 12px 4px;
  }
}


/* 조작법 대화상자를 여는 버튼. 퀴즈 헤더의 «나가기» 옆에 붙는다.
   무대 안에 두면 무대 세로를 먹으므로 헤더로 뺐다.
   게임 모드가 아니면 쓸모가 없으므로 아예 그리지 않는다. */
.arena__help {
  display: none;
  flex: none;
  /* 「나가기」 옆에 붙는다. 헤더가 space-between이라 이게 없으면 가운데로 뜬다 */
  margin-left: auto;
  width: 32px;
  height: 32px;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  touch-action: manipulation;
}

.quiz--game .arena__help {
  display: grid;
}

.arena__help:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── 조작법 목록 ── */
.help-list {
  margin: 0 0 18px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
  font-size: 14px;
}

.help-list dt {
  font-weight: 700;
  white-space: nowrap;
}

.help-list dd {
  margin: 0;
  color: var(--text-muted);
  word-break: keep-all;
}

.help-list kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

/* 움직임에 민감한 사용자를 위해 OS 설정을 따른다 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* 화면 전환·문제 이동용 포커스라 테두리를 그리지 않는다 */
.question:focus {
  outline: none;
}

/* ── 좁은 화면 (320px까지) ── */
@media (max-width: 360px) {
  .app,
  .app-bar,
  .boot {
    padding-left: 12px;
    padding-right: 12px;
  }

  .home-title {
    font-size: 24px;
  }

  .category-grid {
    gap: 10px;
  }

  .category-card {
    padding: 10px 12px 12px;
  }

  .challenge-card {
    gap: 10px;
    padding: 14px 12px;
  }

  .question {
    font-size: 18px;
  }

  .arena-tile {
    height: 64px;
  }

  .result-score strong {
    font-size: 36px;
  }

  .result-stats {
    padding: 12px 4px;
    gap: 4px;
  }

  .result-stats dd {
    font-size: 14px;
  }

  .result-stats dt {
    font-size: 11px;
  }

  .result-block {
    padding: 14px 12px;
  }

  /* 닉네임 칸이 너무 좁아지지 않게 라벨을 윗줄로 뺀다 */
  .register__row {
    grid-template-columns: 1fr auto;
  }

  .register__label {
    grid-column: 1 / -1;
  }

  .result-actions .button {
    flex-basis: 100%;
  }

  .ranking-item {
    grid-template-columns: 24px 1fr auto;
    padding: 10px 12px;
  }
}


/* ── 온라인 로비 ──
   방을 어디에 두는지는 어댑터가 정한다. 여기는 그리는 일만 한다. */
.online-note {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  word-break: keep-all;
}

.online-block {
  margin-bottom: 20px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.online-block__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.online-block__title {
  margin: 0 0 10px;
  font-size: 15px;
}

.online-block__head .online-block__title {
  margin-bottom: 10px;
}

/* 목록과 폼에서 함께 쓰는 작은 버튼 */
.button--small {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
}

.room-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.room-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.room-item__actions {
  display: flex;
  flex: none;
  gap: 6px;
}

.room-item__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.room-item__name {
  font-size: 14px;
  font-weight: 700;
}

.room-item__meta {
  font-size: 12px;
  color: var(--text-muted);
}

.room-empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.room-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.room-form__row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.room-form__row--check {
  font-size: 13px;
  color: var(--text-muted);
}

.room-form__label {
  flex: none;
  width: 68px;
  font-size: 13px;
  font-weight: 600;
}

.room-form__input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font: inherit;
  font-size: 15px;
  color: inherit;
}

.room-form__input:focus-visible {
  border-color: var(--accent);
}

.room-message {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--correct);
  word-break: keep-all;
}

.room-message--bad {
  color: var(--wrong);
}

/* 좁은 화면에서는 라벨을 위로 올린다. 68px 라벨이 입력칸을 너무 좁힌다 */
@media (max-width: 380px) {
  .room-form__row:not(.room-form__row--check) {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  .room-form__label {
    width: auto;
  }
}

/* ── 대기실 ──
   방에 들어오면 오는 곳. 참가자가 바닥에 서 있고 내 캐릭터가 그 사이를 걷는다. */
.waiting-settings {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

/* 누르면 다음 값으로 도는 버튼. select 로 두면 캐릭터가 밟아도 목록이 열리지 않는다 */
.setting-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font: inherit;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

.setting-card:hover:not(:disabled) {
  border-color: var(--accent);
}

.setting-card:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.setting-card__label {
  font-size: 12px;
  color: var(--text-muted);
}

.setting-card__value {
  font-size: 15px;
  font-weight: 700;
}

.waiting-start {
  width: 100%;
  margin-bottom: 12px;
}

/* 간단한 배경. 위는 벽, 아래는 바닥이다 — 이미지 파일을 쓰지 않는다 */
.lounge {
  position: relative;
  min-height: 190px;
  padding: 16px 14px 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: flex-end;
  background:
    linear-gradient(#eef1f7 0 66%, #d9dfea 66% 67.5%, #e7ebf3 67.5% 100%);
  overflow: hidden;
}

.lounge__players {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lounge__player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 56px;
}

.lounge__figure {
  position: relative;
  width: 34px;
  height: 42px;
}

.lounge__name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: var(--text-muted);
}

/* 캐릭터 위에 뜨는 말풍선. .walker 안에 있어 캐릭터를 따라다닌다.
   몸통 애니메이션은 .walker__body 에 걸려 있어 말풍선은 흔들리지 않는다. */
.walker__bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  translate: -50% 0;
  max-width: 190px;
  width: max-content;
  padding: 6px 10px;
  border-radius: 12px;
  background: var(--text);
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  word-break: keep-all;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25);
}

.walker__bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  translate: -50% 0;
  border: 6px solid transparent;
  border-top-color: var(--text);
}

.chat {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.chat__input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font: inherit;
  font-size: 15px;
  color: inherit;
}

.chat__input:focus-visible {
  border-color: var(--accent);
}

/* 말풍선이 화면 위로 넘칠 때는 캐릭터 아래에 띄운다. 꼬리도 함께 뒤집는다 */
.walker__bubble--below {
  bottom: auto;
  top: calc(100% + 8px);
}

.walker__bubble--below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: var(--text);
}

/* 말풍선은 몇 초 뒤 사라진다. 놓친 말을 다시 볼 수 있게 최근 몇 줄을 남긴다 */
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.chat-log__line {
  font-size: 13px;
  color: var(--text);
  word-break: keep-all;
}

.chat-log__who {
  font-weight: 700;
  color: var(--accent);
}

.chat-log__line--notice {
  color: var(--warning);
  font-size: 12px;
}

.chat__hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.chat__hint kbd {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  font: inherit;
  font-size: 11px;
}

@media (max-width: 380px) {
  .waiting-settings {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 닉네임 다이얼로그. 입력칸과 버튼 줄 사이를 띄운다 */
#nickname-form .room-form__input {
  width: 100%;
  margin-bottom: 8px;
}
