/* 리딩 게임(GM) — Blendium Reading 게임 유형 화면. public/js/reading-game.js 가 그린다(형아 2026-11-12).
   초1~3 이 손가락으로 누르는 화면이라 누를 자리는 64px 이상, 영어는 크게. 모든 이름은 rg- 로 시작한다. */
.rg {
    --rg-ink: #1e293b;
    --rg-sub: #64748b;
    --rg-line: #cbd5e1;
    --rg-soft: #f8fafc;
    --rg-accent: #f97316;
    --rg-accent-soft: #fff4e8;
    --rg-ok: #16a34a;
    --rg-ok-soft: #eafaf0;
    --rg-no: #e11d48;
    --rg-key: #fde68a;
    --rg-radius: 18px;
    container-type: inline-size;
    color: var(--rg-ink);
    max-width: 1080px;
    margin: 0 auto;
    display: grid;
    gap: 14px;
    -webkit-tap-highlight-color: transparent;
}
.rg *, .rg *::before, .rg *::after { box-sizing: border-box; }
/* :where 로 힘을 0 으로 — 안 그러면 .rg-tile · .rg-btn 의 글자 크기를 이 줄이 덮는다 */
:where(.rg) button { font: inherit; color: inherit; cursor: pointer; }
.rg button:focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }
.rg .rg-en { font-family: "Andika", "Nunito", "Segoe UI", system-ui, sans-serif; letter-spacing: .01em; }

/* ── 머리: 미션 다섯 칸 + 찾은 물건 수 ─────────────────────────── */
.rg-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; justify-content: space-between; }
.rg-chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.rg-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: 999px; border: 2px solid var(--rg-line);
    background: #fff; color: var(--rg-sub); font-size: .9rem; font-weight: 600; line-height: 1.2;
}
.rg-chip .rg-chip-n {
    width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center;
    background: var(--rg-soft); font-size: .75rem; font-weight: 700;
}
.rg-chip.is-now { border-color: var(--rg-accent); background: var(--rg-accent-soft); color: #9a3412; }
.rg-chip.is-now .rg-chip-n { background: var(--rg-accent); color: #fff; }
.rg-chip.is-done { border-color: #bbf7d0; color: #166534; background: var(--rg-ok-soft); }
.rg-chip.is-done .rg-chip-n { background: var(--rg-ok); color: #fff; }
/* 한 판을 끝내면 칩을 눌러 그 단계만 다시 한다(형아 2026-11-13) — 누를 수 있는 모양으로 */
.rg-chip.is-free { cursor: pointer; min-height: 40px; box-shadow: 0 2px 0 rgba(15, 23, 42, .10); transition: transform .12s, box-shadow .12s; user-select: none; }
.rg-chip.is-free:hover { transform: translateY(-1px); box-shadow: 0 3px 0 rgba(15, 23, 42, .14); }
.rg-chip.is-free:active { transform: translateY(1px); box-shadow: none; }
.rg-chip.is-free:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }
.rg-free-note { margin: 0; color: var(--rg-sub); font-size: .92rem; text-align: center; }
/* 폰 — 지금 미션만 이름을 쓰고 나머지는 번호만 */
@container (max-width: 560px) {
    .rg-chip:not(.is-now) .rg-chip-t { display: none; }
    .rg-chip:not(.is-now) { padding: 5px; }
    .rg-chip.is-free:not(.is-now) { padding: 5px 10px; }
    .rg-count { font-size: .9rem; padding: 5px 12px; }
}
.rg-count {
    font-weight: 700; font-size: 1rem; padding: 6px 14px; border-radius: 999px;
    background: var(--rg-ink); color: #fff; white-space: nowrap;
}
.rg-count b { color: #fdba74; font-variant-numeric: tabular-nums; }

/* ── 본판: 위 장면, 아래 과제 (넓으면 나란히) ─────────────────── */
.rg-board { display: grid; gap: 14px; }
@container (min-width: 860px) {
    .rg-board { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
}
.rg-left { display: grid; gap: 10px; }

.rg-scene {
    position: relative; border-radius: var(--rg-radius); overflow: hidden;
    border: 2px solid var(--rg-line); background: #fff; aspect-ratio: 1280 / 853;
}
.rg-scene > img { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.rg-spot { position: absolute; }
.rg-cover {
    position: absolute; inset: 0; display: grid; place-items: center;
    border-radius: 16px; background: #fff;
    border: 3px dashed #94a3b8; color: #94a3b8;
    font-weight: 800; font-size: clamp(18px, 4cqw, 40px);
    transition: transform .45s cubic-bezier(.5, -0.5, .5, 1.5), opacity .45s ease;
}
.rg-spot.is-hint .rg-cover { border-color: var(--rg-accent); color: var(--rg-accent); animation: rg-pulse 1.1s ease-in-out infinite; }
.rg-spot.is-found .rg-cover { transform: scale(0); opacity: 0; pointer-events: none; }
.rg-crop {
    position: absolute; inset: 0; background-repeat: no-repeat; border-radius: 12px;
    opacity: 0; pointer-events: none;
}
.rg-spot.is-wiggle .rg-crop { opacity: 1; animation: rg-wiggle .9s ease-in-out 2; box-shadow: 0 0 0 4px rgba(249, 115, 22, .6); }
.rg-spot.is-glow::after {
    content: ""; position: absolute; inset: -6px; border-radius: 18px;
    box-shadow: 0 0 0 4px rgba(249, 115, 22, .75); animation: rg-pulse 1s ease-in-out 2;
}
/* 스티커판 — 낱말이 한 인물의 성질이라 장면에서 자리를 못 나누는 유닛. 찾은 낱말 그림을 여기 모은다(형아 2026-11-12) */
.rg-stickers { display: grid; grid-template-columns: repeat(var(--rg-n, 5), minmax(0, 1fr)); gap: 8px; }
.rg-spot.rg-sticker {
    position: relative; aspect-ratio: 1 / 1.2; border-radius: 16px; background: #fff;
    border: 2px solid var(--rg-line); display: grid; grid-template-rows: minmax(0, 1fr) auto;
    justify-items: center; align-items: center; padding: 6px 4px 6px; gap: 2px;
}
.rg-sticker img { width: 100%; height: 100%; object-fit: contain; min-height: 0; }
.rg-sticker b { font-size: clamp(12px, 2.6cqw, 20px); font-weight: 700; line-height: 1.2; color: var(--rg-ink); }
.rg-sticker .rg-cover { border-radius: 14px; font-size: clamp(18px, 3.4cqw, 30px); }
.rg-spot.rg-sticker.is-found { border-color: #bbf7d0; background: var(--rg-ok-soft); }
.rg-spot.rg-sticker.is-wiggle { animation: rg-wiggle .9s ease-in-out 2; box-shadow: 0 0 0 4px rgba(249, 115, 22, .6); }
.rg-sparkle { position: absolute; inset: 0; pointer-events: none; }
.rg-sparkle i {
    position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; border-radius: 50%;
    background: #fbbf24; animation: rg-burst .7s ease-out forwards;
}

/* 민아 말풍선 */
.rg-mina { display: flex; align-items: flex-start; gap: 12px; min-height: 72px; }
.rg-mina img { width: 64px; height: 64px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--rg-line); flex: 0 0 auto; object-fit: cover; }
/* 말풍선 — 아이가 읽는 안내라 크게(형아 2026-11-12). 문장마다 줄을 바꾼다(say) */
.rg-bubble {
    position: relative; flex: 1 1 auto; background: #fff; border: 2px solid var(--rg-line);
    border-radius: 16px; padding: 12px 16px; font-size: 1.3rem; font-weight: 500; line-height: 1.5; min-height: 56px;
}
.rg-bubble::before {
    content: ""; position: absolute; left: -9px; top: 22px; width: 14px; height: 14px; background: #fff;
    border-left: 2px solid var(--rg-line); border-bottom: 2px solid var(--rg-line); transform: rotate(45deg);
}
.rg-bubble .rg-en { font-size: 1.5rem; font-weight: 700; }
@container (max-width: 560px) {
    .rg-bubble { font-size: 1.15rem; padding: 10px 14px; }
    .rg-bubble .rg-en { font-size: 1.3rem; }
    .rg-mina img { width: 52px; height: 52px; }
}

/* ── 과제 칸 ─────────────────────────────────────────────── */
.rg-task {
    background: #fff; border: 2px solid var(--rg-line); border-radius: var(--rg-radius);
    padding: 18px; display: grid; gap: 16px; align-content: start;
}
.rg-ask { font-size: 1.1rem; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rg-ask small { font-weight: 500; color: var(--rg-sub); font-size: .9rem; }
.rg-word { font-size: clamp(44px, 9cqw, 64px); font-weight: 700; text-align: center; line-height: 1.1; }
.rg-sent { font-size: clamp(28px, 5.4cqw, 40px); font-weight: 700; text-align: center; line-height: 1.25; }
.rg-mark { border-radius: 8px; padding: 0 .14em; margin: 0 -.14em; transition: background-color .3s; }
.rg-mark.is-on { background: var(--rg-key); }

.rg-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.rg-card {
    position: relative; border: 3px solid var(--rg-line); border-radius: var(--rg-radius); background: #fff;
    padding: 8px; aspect-ratio: 1; display: grid; place-items: center;
    transition: border-color .2s, transform .15s, opacity .2s, background-color .2s;
}
.rg-card:hover { border-color: #94a3b8; }
.rg-card:active { transform: scale(.97); }
.rg-card img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; }
.rg-card.is-ok { border-color: var(--rg-ok); background: var(--rg-ok-soft); }
.rg-card.is-no { border-color: var(--rg-no); opacity: .4; animation: rg-shake .4s; pointer-events: none; }
.rg-card.is-point { border-color: var(--rg-accent); box-shadow: 0 0 0 4px rgba(249, 115, 22, .25); }
.rg-pointer {
    position: absolute; left: 50%; top: -30px; width: 34px; height: 34px; margin-left: -17px;
    color: var(--rg-accent); animation: rg-bob .8s ease-in-out infinite; pointer-events: none;
}

/* 버튼 — 한 단계 줄임(형아 2026-11-12 「버튼 크기를 좀 줄여」). 손가락 칸 44px 은 지킨다 */
.rg-tools { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.rg-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 44px; padding: 0 16px; border-radius: 999px; border: 2px solid var(--rg-line);
    background: #fff; font-weight: 700; font-size: .95rem;
}
.rg-btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.rg-btn:hover { border-color: #94a3b8; }
.rg-btn.is-main { background: var(--rg-accent); border-color: var(--rg-accent); color: #fff; }
.rg-btn.is-main:hover { background: #ea580c; border-color: #ea580c; }
.rg-btn.is-go { background: var(--rg-ok); border-color: var(--rg-ok); color: #fff; }
.rg-btn.is-rec { background: var(--rg-no); border-color: var(--rg-no); color: #fff; }
.rg-btn[disabled] { opacity: .45; cursor: default; }
.rg-btn.is-big { min-height: 52px; padding: 0 24px; font-size: 1.05rem; }

/* 이야기 읽기 */
.rg-story { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rg-story li {
    font-size: clamp(20px, 3.6cqw, 26px); font-weight: 600; line-height: 1.35;
    padding: 8px 12px; border-radius: 12px; border: 2px solid transparent; color: #94a3b8;
    transition: background-color .25s, border-color .25s, color .25s;
}
.rg-story li.is-read { color: var(--rg-ink); }
.rg-story li.is-now { color: var(--rg-ink); background: var(--rg-accent-soft); border-color: #fdba74; }
.rg-echo { height: 8px; border-radius: 999px; background: var(--rg-soft); overflow: hidden; }
.rg-echo i { display: block; height: 100%; width: 0; background: var(--rg-accent); border-radius: inherit; }
.rg-echo-tip { text-align: center; font-weight: 700; color: #9a3412; min-height: 1.4em; }

/* 문장 만들기 */
.rg-slots { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; min-height: 72px; }
.rg-slot {
    min-width: 96px; min-height: 64px; padding: 6px 14px; border-radius: 14px; border: 3px dashed var(--rg-line);
    display: grid; place-items: center; font-size: clamp(22px, 4cqw, 30px); font-weight: 700; color: var(--rg-ink);
}
.rg-slot.is-full { border-style: solid; border-color: var(--rg-ok); background: var(--rg-ok-soft); }
.rg-tiles { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.rg-tile {
    min-width: 96px; min-height: 64px; padding: 6px 18px; border-radius: 14px; border: 3px solid #93c5fd;
    background: #eff6ff; font-size: clamp(22px, 4cqw, 30px); font-weight: 700;
    box-shadow: 0 4px 0 #bfdbfe; transition: transform .12s, opacity .2s;
}
.rg-tile:active { transform: translateY(3px); box-shadow: 0 1px 0 #bfdbfe; }
.rg-tile.is-used { visibility: hidden; }
.rg-tile.is-no { animation: rg-shake .4s; border-color: var(--rg-no); }
.rg-tile.is-point { border-color: var(--rg-accent); box-shadow: 0 0 0 4px rgba(249, 115, 22, .3), 0 4px 0 #fdba74; }

/* 소개하기 */
.rg-picks { display: grid; grid-template-columns: repeat(var(--rg-n, 5), minmax(0, 1fr)); gap: 8px; }
.rg-picks .rg-card { padding: 4px; border-width: 2px; border-radius: 14px; }
.rg-picks .rg-card.is-pick { border-color: var(--rg-accent); background: var(--rg-accent-soft); }
.rg-meter { height: 10px; border-radius: 999px; background: var(--rg-soft); overflow: hidden; }
.rg-meter i { display: block; height: 100%; width: 0; background: var(--rg-ok); transition: width .08s linear; }
.rg-note { text-align: center; color: var(--rg-sub); font-size: .95rem; }

/* 완성 */
.rg-done { text-align: center; display: grid; gap: 12px; }
.rg-done h3 { margin: 0; font-size: 1.5rem; }
.rg-stars { display: flex; gap: 6px; justify-content: center; color: #e2e8f0; }
.rg-stars svg { width: 44px; height: 44px; }
.rg-stars .is-on { color: #f59e0b; }
.rg-sum { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.rg-sum span { padding: 6px 12px; border-radius: 999px; background: var(--rg-soft); border: 2px solid var(--rg-line); font-weight: 700; font-variant-numeric: tabular-nums; }
.rg-review { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; color: var(--rg-sub); }
.rg-review b { color: var(--rg-ink); background: var(--rg-key); border-radius: 8px; padding: 2px 8px; font-size: 1.15rem; }
.rg-scene.is-party .rg-crop { opacity: 1; animation: rg-wiggle 1s ease-in-out 2; }
.rg-stickers.is-party .rg-sticker { animation: rg-wiggle 1s ease-in-out 2; }
.rg-stickers.is-party .rg-sticker:nth-child(even) { animation-delay: .15s; }

/* 시작 화면 */
.rg-start { text-align: center; display: grid; gap: 14px; justify-items: center; }
.rg-start h3 { margin: 0; font-size: 1.35rem; }
.rg-start p { margin: 0; color: var(--rg-sub); }
/* 지난번에 멈춘 판 — 「…까지 했어요」 + [처음부터] [이어서 하기] (형아 2026-11-13) */
.rg-start .rg-resume { color: var(--rg-ink); font-weight: 600; padding: 8px 14px; border-radius: 12px; background: var(--rg-accent-soft); }
.rg-start .rg-resume b { color: #9a3412; }

@keyframes rg-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes rg-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@keyframes rg-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes rg-wiggle {
    0%, 100% { transform: rotate(0) scale(1); }
    25% { transform: rotate(-6deg) scale(1.08); }
    50% { transform: rotate(5deg) scale(1.1) translateY(-4%); }
    75% { transform: rotate(-3deg) scale(1.05); }
}
@keyframes rg-burst { from { transform: translate(-50%, -50%) scale(1); opacity: 1; } to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.3); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    .rg *, .rg *::before, .rg *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 420px) {
    .rg-task { padding: 14px; }
    .rg-choices { gap: 8px; }
    .rg-chip { padding: 5px 9px; font-size: .82rem; }
    .rg-picks { grid-template-columns: repeat(var(--rg-n, 5), minmax(0, 1fr)); gap: 5px; }
}

/* ── 이야기 순서(4레벨, 형아 2026-11-13) — game.mode = 'sequence' ───────────────
   왼쪽 위 「이야기 칸」 줄(필름)에 장면 칸이 차례로 놓인다. 칸 그림은 3:4. */
.rg-film { display: grid; grid-template-columns: repeat(var(--rg-n, 5), minmax(0, 1fr)); gap: 8px; list-style: none; margin: 0; padding: 0; }
.rg-frame {
    position: relative; aspect-ratio: 3 / 4; border-radius: 14px; overflow: hidden;
    border: 2px solid var(--rg-line); background: #fff;
    transition: border-color .2s, box-shadow .2s;
}
.rg-frame > img { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.rg-frame > img:not([src]) { visibility: hidden; }
.rg-frame-n {
    position: absolute; left: 6px; top: 6px; z-index: 2; width: 24px; height: 24px; border-radius: 50%;
    display: grid; place-items: center; background: var(--rg-ink); color: #fff; font-size: .8rem; font-weight: 800;
}
.rg-frame .rg-cover { border-radius: 12px; font-size: clamp(18px, 3.4cqw, 30px); }
.rg-frame.is-found .rg-cover { transform: scale(0); opacity: 0; pointer-events: none; }
.rg-frame.is-target .rg-cover { border-color: var(--rg-accent); color: var(--rg-accent); animation: rg-pulse 1.1s ease-in-out infinite; }
.rg-frame.is-now { border-color: var(--rg-accent); box-shadow: 0 0 0 3px rgba(249, 115, 22, .35); }
.rg-frame.is-wiggle { animation: rg-wiggle .9s ease-in-out 2; box-shadow: 0 0 0 4px rgba(249, 115, 22, .6); }
.rg-film.is-party .rg-frame { animation: rg-wiggle 1s ease-in-out 2; }
.rg-film.is-party .rg-frame:nth-child(even) { animation-delay: .15s; }

/* 4레벨 문장은 길다 — 한 단계 작게 */
.rg-seq .rg-sent { font-size: clamp(22px, 4.4cqw, 32px); }
.rg-seq .rg-story li { font-size: clamp(18px, 3.2cqw, 23px); }
.rg-panel-big {
    display: block; justify-self: center; height: clamp(150px, 36cqw, 380px); aspect-ratio: 3 / 4;
    object-fit: cover; border-radius: 16px; border: 2px solid var(--rg-line);
}

/* 칸 그림 보기 — 세로 3:4. 순서 맞히기는 칸을 한 줄에 다 놓는다(좁으면 세 칸씩) */
.rg-choices.is-tall .rg-card, .rg-picks.is-tall .rg-card { aspect-ratio: 3 / 4; padding: 4px; }
.rg-choices.is-tall .rg-card img, .rg-picks.is-tall .rg-card img { object-fit: cover; border-radius: 12px; }
.rg-choices.is-many { grid-template-columns: repeat(var(--rg-n, 5), minmax(0, 1fr)); gap: 8px; }
@container (max-width: 560px) {
    .rg-choices.is-many { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .rg-film { gap: 5px; }
    .rg-frame-n { width: 20px; height: 20px; left: 4px; top: 4px; font-size: .72rem; }
}
.rg-card.is-used { pointer-events: none; border-style: dashed; }
.rg-card.is-used img { opacity: .3; filter: grayscale(1); }
.rg-card-n {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center; background: var(--rg-ink); color: #fff; font-weight: 800; font-size: 1rem;
}
.rg-card.is-miss { animation: rg-shake .4s; border-color: var(--rg-no); }
.rg-hint {
    text-align: center; font-size: clamp(19px, 3.4cqw, 24px); font-weight: 700; line-height: 1.35;
    background: var(--rg-accent-soft); border: 2px solid #fdba74; border-radius: 12px; padding: 8px 12px;
}
.rg-done-scene { display: block; width: 100%; border-radius: 14px; border: 2px solid var(--rg-line); }

/* 빈칸 채우기(6·7레벨 ①) — 본책 문장 · 우리말 뜻 힌트 · 낱말 셋 (형아 2026-11-13) */
.rg-seq .rg-gap-sent { font-size: clamp(20px, 3.8cqw, 28px); line-height: 1.45; }
.rg-gap {
    display: inline-block; min-width: 3.4em; height: .95em; margin: 0 .1em; vertical-align: -.08em;
    border-bottom: 3px solid var(--rg-accent);
}
.rg-gap.is-filled {
    min-width: 0; height: auto; vertical-align: baseline; padding: 0 .14em;
    color: var(--rg-ok); background: var(--rg-ok-soft); border-bottom-color: var(--rg-ok); border-radius: 6px 6px 0 0;
}
.rg-gap-hint {
    justify-self: center; display: inline-flex; align-items: baseline; gap: 10px; max-width: 100%;
    padding: 6px 16px; border-radius: 999px; background: var(--rg-accent-soft); font-size: 1.05rem;
}
.rg-gap-hint span { color: #9a3412; font-size: .85rem; font-weight: 700; }
.rg-choices.is-words .rg-card {
    aspect-ratio: auto; min-height: 60px; padding: 10px 6px;
    font-size: clamp(19px, 3.4cqw, 25px); font-weight: 700; line-height: 1.15; overflow-wrap: anywhere;
}
