/* 웹툰 재생 화면 — 문제를 보는 동안 화면에서 움직이는 것이 없어야 한다(설계서 04 §2) */

:root {
  --bg: #0b1020;
  --card: #161d36;
  --ink: #f4f7ff;
  --dim: #93a0c4;
  --hit: #3ddc97;
  --miss: #ff7a7a;
  --byeol: #8fd0ff;   /* 배우는 쪽 · 왼쪽 */
  --pita: #ffd48f;    /* 되묻는 쪽 · 오른쪽 */
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.6 system-ui, -apple-system, "Noto Sans KR", sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    env(safe-area-inset-top)
    max(14px, env(safe-area-inset-right))
    env(safe-area-inset-bottom)
    max(14px, env(safe-area-inset-left));
}

button { touch-action: manipulation; font-family: inherit; }

/* ── 편 고르기 ─────────────────────────────────────────── */

.list { flex: 1; overflow-y: auto; padding: 8px 0 24px; }
.list-title { margin: 12px 4px 16px; font-size: 22px; }
.cards { display: grid; gap: 10px; }

.card {
  display: block;
  width: 100%;
  min-height: 72px;
  padding: 14px 16px;
  border: 0;
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  text-align: left;
}
.card .t { font-size: 19px; font-weight: 700; }
.card .s { display: block; margin-top: 4px; color: var(--dim); font-size: 14px; }
.card:active { transform: scale(0.985); }

/* ── 무대 ──────────────────────────────────────────────── */

.stage { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.scene {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  background: #0f1428;
  overflow: hidden;
}

.art { width: 100%; height: 100%; object-fit: contain; }

/* 그려지는 도형 — 선 색은 캐릭터 색과 같은 계열로 둔다 */
.fig {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--byeol);
  padding: 16px;
}
.fig svg { width: 100%; height: 100%; max-height: 100%; }

/* 그림이 아직 안 옮겨진 편에서 뜬다. 실패 화면이 아니라 「글만 있는 컷」이다 */
.scene-text {
  margin: 0;
  padding: 24px;
  max-width: 30ch;
  text-align: center;
  color: var(--dim);
  font-size: 17px;
}

/* ── 캐릭터 ────────────────────────────────────────────
   말하는 쪽이 앞으로 나오고 듣는 쪽은 물러난다. 둘 다 같은 밝기면 누가 말하는지 모른다 */

.cast {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  height: 96px;
  margin-top: -18px;          /* 씬 아래에 살짝 걸치게 */
  pointer-events: none;
}

.cast-one {
  width: 92px;
  height: 92px;
  opacity: 0.45;
  filter: saturate(0.6);
  transform: translateY(6px) scale(0.9);
  transition: opacity 180ms ease, transform 180ms ease, filter 180ms ease;
}
.cast-one[data-who="pita"] { margin-left: auto; }

.cast-one.on {
  opacity: 1;
  filter: none;
  transform: translateY(0) scale(1);
}

.cast-one img {
  width: 100%; height: 100%;
  object-fit: contain;
  -webkit-user-drag: none;
}

/* 숨쉬기 — 말 안 할 때도 살아 있어야 한다 */
.cast-one.on img { animation: breathe 3.2s ease-in-out infinite; }
@keyframes breathe { 50% { transform: translateY(-3px) scale(1.02); } }

/* 말할 때 한 번 튄다 */
.fx-say img { animation: say 260ms ease; }
@keyframes say { 40% { transform: translateY(-7px) rotate(-1.5deg); } }

/* 맞혔을 때 — 판정 뒤에만 돈다 */
.fx-joy img { animation: joy 520ms cubic-bezier(.34,1.56,.64,1); }
@keyframes joy {
  30% { transform: translateY(-16px) scale(1.06); }
  60% { transform: translateY(0) scale(0.98); }
}

/* 틀렸을 때 — 흔들되 작게. 혼내는 연출이 아니다 */
.fx-oops img { animation: oops 420ms ease; }
@keyframes oops {
  20% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  80% { transform: translateX(-2px); }
}

/* ── 말풍선 ────────────────────────────────────────────── */

.bubble-wrap { min-height: 132px; display: flex; align-items: flex-start; padding: 12px 2px 0; }

.bubble {
  position: relative;
  max-width: 88%;
  padding: 12px 16px 14px;
  border-radius: 18px;
  background: var(--card);
}
.bubble.left { align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.right { margin-left: auto; border-bottom-right-radius: 4px; }

.who { font-size: 13px; font-weight: 700; letter-spacing: 0.02em; }
.bubble.left .who { color: var(--byeol); }
.bubble.right .who { color: var(--pita); }

.line { margin: 2px 0 0; font-size: 20px; }

/* ── 문항 ──────────────────────────────────────────────── */

.quiz { padding: 4px 2px 8px; }
.q { margin: 0 0 12px; font-size: 19px; font-weight: 700; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.opt {
  min-height: 64px;              /* A밴드 손가락 규격(설계서 04 §3) */
  border: 0;
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  font: 700 20px/1.2 inherit;
  padding: 8px;
}
.opt:active { transform: scale(0.97); }
.opt.hit { background: var(--hit); color: #05240f; }
.opt.miss { background: var(--miss); color: #2a0505; }

/* ── 감정 체크인 ────────────────────────────────────────
   **점수처럼 보이면 안 된다.** 등급을 매기는 화면으로 읽히는 순간 아이는
   「정답인 감정」을 고른다. 그래서 넷을 나란히 같은 크기로 놓고, 색으로
   좋고 나쁨을 가르지 않는다. 건너뛰기를 나란히 두는 것도 같은 이유다 —
   대답을 강제하면 그것도 거짓말을 만든다. */
.checkin {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 60vh;
  padding: 24px 16px;
}
.checkin-q { margin: 0; color: var(--ink); font-size: 20px; font-weight: 600; }
.moods { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; width: 100%; max-width: 420px; }
.mood {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  min-height: 44px;
}
.mood .face { font-size: 30px; line-height: 1; }
.mood:active { transform: scale(0.97); }
.checkin .skip { margin-top: 4px; }

/* 정서 문구는 설명(.why)보다 «앞이고 위»다 — 틀린 직후에 먼저 닿는 것이 안심이어야
   한다(ver1.7 편도체 안정화). 색을 경고색으로 쓰지 않는 것이 요점이다. */
.care {
  margin: 10px 0 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}
.care.show { animation: careIn 320ms ease both; }
@keyframes careIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .care.show { animation: none; } }

/* ── 전략 고르기 (감정코칭 5단계의 네 번째) ────────────────
   오답 뒤에 «무엇을 할지 내가 고른다». 실패가 아니라 선택으로 바꾸는 자리다.
   셋을 같은 무게로 놓는다 — 「힌트」가 작아 보이면 도움 요청이 부끄러운 일이 된다. */
.strats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.strat {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
}
.strat:active { transform: scale(0.97); }

/* 자기설명은 «쓰는» 것이 아니라 «고르는» 것이다 — 자판이 벽이 되면 안 된다 */
.explain { margin-top: 12px; }
.explain-q { margin: 0 0 8px; color: var(--ink); font-size: 15px; }
.explain-opts { display: grid; gap: 8px; }
.explain-opts .strat { flex: none; text-align: left; }

.why { margin: 10px 0 0; min-height: 26px; color: var(--dim); font-size: 15px; }

/* 힌트는 눈에 띄되 선택지보다 앞서지 않는다 — 먼저 생각할 자리를 뺏지 않는다 */
.hint { margin: 12px 0 0; color: var(--ink); font-size: 16px; line-height: 1.5; }
.hintBtn { margin-top: 10px; }
.hintBtn[disabled] { opacity: 0.45; }

.stars { margin-left: auto; color: var(--ink); font-size: 14px; font-variant-numeric: tabular-nums; }
.stars.pop { animation: starPop 1.2s ease; }
@keyframes starPop { 0% { transform: scale(1); } 25% { transform: scale(1.35); } 100% { transform: scale(1); } }

/* ── 진행 ──────────────────────────────────────────────── */

.dots { display: flex; gap: 5px; justify-content: center; padding: 8px 0 4px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: #2b3557; }
.dot.on { background: var(--dim); }
.dot.cur { background: var(--ink); transform: scale(1.4); }

.bar { display: flex; align-items: center; gap: 8px; padding: 8px 0 12px; }

.ghost {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #2b3557;
  border-radius: 12px;
  background: transparent;
  color: var(--dim);
  font-size: 15px;
}
.ghost[aria-pressed="true"] { border-color: var(--hit); color: var(--hit); }

.pos { color: var(--dim); font-size: 14px; font-variant-numeric: tabular-nums; }

.fail { margin: 32px 16px; color: var(--miss); font-size: 16px; }

/* 연출만 멈춘다. 이야기 진행은 그대로다 */
@media (prefers-reduced-motion: reduce) {
  .card:active, .opt:active { transform: none; }
  .dot.cur { transform: none; }
  /* 캐릭터는 그대로 서 있되 움직이지 않는다. 누가 말하는지는 밝기로만 구분한다 */
  .cast-one, .cast-one img, .fx-say img, .fx-joy img, .fx-oops img { animation: none; }
  .cast-one { transition: opacity 120ms linear; transform: none; }
}
