/* ===== 삼색이의 대모험 스타일 =====
   분위기: 따뜻한 만화 판타지. 남색 상단 바, 나무·금테 패널과 버튼, 양피지 카드, 둥근 글꼴(Jua) */
:root {
  --ink: #4a2f1c; --soft: #8a6a50;
  --parch: #fff7e4; --parch-2: #f5e0b4;
  --gold: #f2c35b; --gold-light: #ffe08a; --gold-dark: #b9822e;
  --wood: #c07f45; --wood-light: #dc9d5f; --wood-dark: #6e4322;
  --navy: #1d2f55; --navy-2: #2d4a82; --navy-dark: #101b36;
  --orange: #f5a23a; --orange-dark: #c26a17; --green: #6cc04a; --green-dark: #3f8a2c;
  --sea: #3fb4e0; --grey: #c9c3bd; --red: #e5534b; --sky: #cdeaff;
  --frame: 0 0 0 3px var(--wood-dark), 0 8px 0 3px rgba(40, 20, 5, .25);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { color: var(--ink); font-family: "Jua", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  background:
    radial-gradient(ellipse 60% 40% at 15% 0%, rgba(255,255,255,.35), transparent 70%),
    radial-gradient(ellipse 50% 35% at 90% 100%, rgba(255,255,255,.18), transparent 70%),
    repeating-radial-gradient(circle at 50% 120%, rgba(255,255,255,.05) 0 14px, transparent 14px 34px),
    linear-gradient(#63cdf0, #2a8fcd 60%, #1f74b3);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
h1, h2, h3 { font-weight: normal; }
/* --app-h: 화면 키보드를 뺀 실제 보이는 높이 (js/core/mobile.js가 채워 줘요) */
#app { --pad: 16px; max-width: 1000px; margin: 0 auto; min-height: var(--app-h, 100vh); touch-action: manipulation;
  padding: calc(var(--pad) + env(safe-area-inset-top)) calc(var(--pad) + env(safe-area-inset-right)) calc(var(--pad) + env(safe-area-inset-bottom)) calc(var(--pad) + env(safe-area-inset-left)); }
.scene { min-height: calc(var(--app-h, 100vh) - 2 * var(--pad) - env(safe-area-inset-top) - env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
button { touch-action: manipulation; font-family: inherit; }
.scene.center { align-items: center; justify-content: center; text-align: center; }
.scene-title { margin: 0; }
.sub, .hint { color: var(--soft); margin: 0; }
.hint { font-size: 14px; text-align: center; color: #eaf6ff; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.card .hint { color: var(--soft); text-shadow: none; }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }

/* 양피지 패널 (나무 테두리 + 금테) */
.card { background: linear-gradient(#fffbf0, var(--parch-2)); border: 4px solid var(--gold); border-radius: 22px; box-shadow: var(--frame), inset 0 2px 0 #fff;
  padding: 24px; max-width: 560px; width: 100%; position: relative; }
.card label { display: flex; align-items: center; gap: 8px; text-align: left; padding: 6px 0; font-size: 18px; }
.card input[type=radio], .card input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--orange); }
.card h3 { text-align: left; margin: 16px 0 4px; color: var(--wood-dark); }
.card h2 { margin: 6px 0 10px; }
.card-title, .plaque { display: inline-block; align-self: center; margin: 0 auto 8px; padding: 6px 22px; color: #fff; font-size: 24px;
  background: linear-gradient(var(--navy-2), var(--navy)); border: 3px solid var(--gold); border-radius: 14px; box-shadow: 0 0 0 3px var(--navy-dark), 0 5px 0 3px rgba(0,0,0,.2);
  text-shadow: 0 2px 0 var(--navy-dark); }
.card > .card-title { margin-top: -44px; }
.big-icon { font-size: 64px; filter: drop-shadow(0 4px 0 rgba(0,0,0,.15)); }

/* 버튼: 금색(기본), 양피지(ghost), 나무(wood) */
.btn { font: inherit; font-size: 19px; color: #fff; border: 3px solid var(--wood-dark); border-radius: 16px; padding: 11px 20px; cursor: pointer;
  background: linear-gradient(#ffd977, var(--orange)); text-shadow: 0 2px 0 var(--orange-dark);
  box-shadow: inset 0 3px 0 rgba(255,255,255,.6), inset 0 -4px 0 rgba(0,0,0,.12), 0 5px 0 var(--wood-dark), 0 8px 8px rgba(0,0,0,.18);
  transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translateY(3px); box-shadow: inset 0 3px 0 rgba(255,255,255,.6), inset 0 -4px 0 rgba(0,0,0,.12), 0 2px 0 var(--wood-dark); }
@media (hover: hover) { .btn:hover { filter: brightness(1.06); } }
.btn.ghost { background: linear-gradient(#fffbf0, var(--parch-2)); color: var(--ink); text-shadow: none; }
.btn.wood { background: linear-gradient(var(--wood-light), var(--wood)); color: #fff8e6; text-shadow: 0 2px 0 var(--wood-dark);
  border-color: var(--wood-dark); outline: 2px solid var(--gold); outline-offset: -6px; }
.btn.big { font-size: 28px; padding: 18px 36px; display: flex; flex-direction: column; align-items: center; }
.btn small { font-size: 14px; opacity: .9; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; font-size: 22px; cursor: pointer; padding: 0; display: grid; place-items: center;
  background: linear-gradient(var(--navy-2), var(--navy)); border: 3px solid var(--gold); box-shadow: 0 3px 0 var(--navy-dark); }
.icon-btn:active { transform: translateY(2px); }

/* 남색 상태 바 (전투, 미션, 퀴즈) */
.hud { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 18px; color: #fff;
  background: linear-gradient(var(--navy-2), var(--navy)); border: 3px solid var(--gold); border-radius: 16px; padding: 8px 14px;
  box-shadow: 0 0 0 3px var(--navy-dark), 0 5px 0 3px rgba(0,0,0,.2); text-shadow: 0 2px 0 var(--navy-dark); }
.hud .title { color: var(--gold-light); }

/* ===== 시작 화면 ===== */
.title-scene { gap: 14px; }
.title-scene .logo { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; font-size: 92px;
  background: radial-gradient(circle at 40% 35%, #fff8df, #ffd98a); border: 6px solid var(--gold); box-shadow: 0 0 0 5px var(--wood-dark), 0 12px 0 5px rgba(0,0,0,.2); }
.title-scene .logo span { animation: bob 2s ease-in-out infinite; display: block; }
.title-scene h1 { font-size: 56px; margin: 6px 0 0; color: var(--gold-light); letter-spacing: 1px;
  text-shadow: 3px 0 var(--wood-dark), -3px 0 var(--wood-dark), 0 3px var(--wood-dark), 0 -3px var(--wood-dark), 2px 2px var(--wood-dark), -2px -2px var(--wood-dark), 2px -2px var(--wood-dark), -2px 2px var(--wood-dark), 0 8px 0 rgba(0,0,0,.25); }
.ribbon { background: linear-gradient(var(--navy-2), var(--navy)); color: #fff; padding: 8px 22px; border-radius: 999px; border: 3px solid var(--gold); box-shadow: 0 4px 0 var(--navy-dark); font-size: 17px; }
.toast { min-height: 24px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.35); font-size: 18px; }
@keyframes bob { 50% { transform: translateY(-8px); } }

/* ===== 대화 ===== */
.dialog-scene { justify-content: flex-end; cursor: pointer; border-radius: 22px; padding: 16px; border: 4px solid var(--gold); box-shadow: var(--frame);
  background: radial-gradient(ellipse 70% 30% at 50% 100%, #9fd87a 0 98%, transparent 100%), linear-gradient(#d9d3cc, #f2ece4); }
.dialog-scene.sky { background: radial-gradient(ellipse 70% 30% at 50% 100%, #fff 0 98%, transparent 100%), linear-gradient(#a8d6ff, #eaf5ff); }
.dialog-box { position: relative; display: flex; gap: 16px; align-items: center; margin-top: 24px; padding: 26px 20px 20px;
  background: linear-gradient(#fffbf0, var(--parch-2)); border: 4px solid var(--gold); border-radius: 20px; box-shadow: var(--frame); }
.dialog-box .face { font-size: 64px; width: 92px; height: 92px; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff, #ffe6b0); border: 4px solid var(--gold); box-shadow: 0 0 0 3px var(--wood-dark); }
.dialog-box .who { position: absolute; top: -20px; left: 24px; font-size: 18px; color: #fff; padding: 4px 16px; border-radius: 12px;
  border: 3px solid var(--gold); box-shadow: 0 0 0 2px var(--wood-dark); text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.dialog-box .text { font-size: 24px; line-height: 1.5; }
.dialog-scene .hint { margin-top: 10px; color: var(--soft); text-shadow: none; }

/* ===== 단어 카드 ===== */
.scene > .sub { color: #fff; text-align: center; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.word-card { background: linear-gradient(#fffbf0, var(--parch-2)); border: 3px solid var(--gold); border-radius: 18px; padding: 12px; text-align: center; cursor: pointer;
  box-shadow: 0 0 0 2px var(--wood-dark), 0 5px 0 2px rgba(0,0,0,.18); transition: transform .1s; }
@media (hover: hover) { .word-card:hover { transform: translateY(-3px) rotate(-1deg); } }
.word-card .emo { font-size: 42px; }
.word-card .en { font-size: 24px; font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: bold; color: var(--navy); }
.word-card .ko { color: var(--soft); }
.cards .sub { color: #fff; }

/* ===== 타이핑 글자 ===== */
.label { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 22px; font-weight: bold; letter-spacing: 1px; color: var(--navy);
  background: #fff; border: 2px solid var(--wood-dark); border-radius: 10px; padding: 2px 8px; white-space: pre; box-shadow: 0 3px 0 rgba(0,0,0,.2); }
.label .typed { color: var(--orange-dark); }
.label .next { text-decoration: underline; text-decoration-color: var(--orange); text-decoration-thickness: 3px; text-underline-offset: 4px; }
.locked .label { outline: 3px solid var(--gold); background: #fff6d6; }
.shake { animation: shake .25s; }
.shake .label { color: var(--red); }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ===== 섬 지도 ===== */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; color: #fff; position: relative;
  background: linear-gradient(var(--navy-2), var(--navy)); border: 3px solid var(--gold); border-radius: 16px; box-shadow: 0 0 0 3px var(--navy-dark), 0 5px 0 3px rgba(0,0,0,.2); }
.tb-title { position: absolute; left: 50%; top: -6px; transform: translateX(-50%); font-size: 24px; padding: 6px 26px 8px; white-space: nowrap;
  background: linear-gradient(#35558f, var(--navy)); border: 3px solid var(--gold); border-radius: 0 0 18px 18px; border-top: 0;
  text-shadow: 0 2px 0 var(--navy-dark); box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.chip.lv { display: flex; flex-direction: column; line-height: 1.1; font-size: 17px; }
.chip.lv small { font-size: 12px; color: var(--gold-light); }
.tb-right { display: flex; align-items: center; gap: 8px; }
.coin { display: flex; align-items: center; gap: 4px; padding: 3px 12px 3px 6px; border-radius: 999px; font-size: 17px;
  background: rgba(0,0,0,.35); border: 2px solid var(--navy-dark); box-shadow: inset 0 2px 3px rgba(0,0,0,.4); }
.coin b { font-weight: normal; min-width: 1.2em; text-align: right; }
.coin small { opacity: .7; font-size: 12px; }

.island { position: relative; flex: 1; min-height: 460px; border-radius: 22px; overflow: hidden; border: 4px solid var(--gold); box-shadow: var(--frame);
  background:
    radial-gradient(ellipse 8% 4% at 12% 80%, rgba(255,255,255,.35), transparent 70%),
    radial-gradient(ellipse 10% 3% at 88% 20%, rgba(255,255,255,.3), transparent 70%),
    repeating-linear-gradient(170deg, rgba(255,255,255,.06) 0 6px, transparent 6px 26px),
    radial-gradient(ellipse at 50% 50%, #5fd0ee, #2c9ad2 70%, #1f7fbd); }
.island .land { position: absolute; inset: 3% 2% 2% 2%; background: url("../img/island.svg?v=1") center / 100% 100% no-repeat; pointer-events: none; }
.deco { position: absolute; transform: translate(-50%, -70%); pointer-events: none; min-width: 26px; }
.deco svg { display: block; width: 100%; height: auto; overflow: visible; }
.deco.castle { animation: bob 4s ease-in-out infinite; }

/* 지역 말풍선 */
.region { position: absolute; transform: translate(-50%, -50%); font: inherit; color: var(--ink); cursor: pointer; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 104px; padding: 6px 12px 7px;
  background: linear-gradient(#fffdf6, #f8e9c6); border: 3px solid var(--gold); border-radius: 16px;
  box-shadow: 0 0 0 2px var(--wood-dark), 0 6px 0 2px rgba(40,20,5,.25); transition: transform .12s; }
.region::after { content: ""; position: absolute; left: 50%; bottom: -13px; width: 16px; height: 16px; transform: translateX(-50%) rotate(45deg);
  background: #f8e9c6; border-right: 3px solid var(--gold); border-bottom: 3px solid var(--gold); box-shadow: 3px 3px 0 0 var(--wood-dark); z-index: -1; }
@media (hover: hover) { .region:hover { transform: translate(-50%, -56%) scale(1.04); } }
.region:active { transform: translate(-50%, -48%); }
.region .ico { font-size: 26px; width: 40px; height: 40px; display: grid; place-items: center; margin-top: -26px; border-radius: 12px;
  background: radial-gradient(circle at 40% 35%, #fff, #ffe7b5); border: 3px solid var(--gold); box-shadow: 0 0 0 2px var(--wood-dark), 0 3px 0 2px rgba(0,0,0,.2); }
.region .nm { font-size: 17px; white-space: nowrap; margin-top: 2px; }
.region .th { font-size: 13px; color: var(--soft); }
.region.cleared { background: linear-gradient(#fffbe0, #ffe59a); }
.region.cleared::after { background: #ffe59a; }
.region .rec { position: absolute; top: -48px; white-space: nowrap; color: #fff; font-size: 12px; border-radius: 10px; padding: 3px 8px;
  background: linear-gradient(#ff9a52, #e5622b); border: 2px solid #fff; box-shadow: 0 2px 0 rgba(0,0,0,.25); animation: bob 1.6s ease-in-out infinite; }
.region.hidden-ch { background: linear-gradient(135deg, #ffe0ef, #dfe6ff); border-color: #b49cff; }
.region.hidden-ch::after { background: #dfe6ff; border-color: #b49cff; }

.lighthouse { position: absolute; right: 2%; top: 3%; width: 11%; min-width: 48px; display: flex; flex-direction: column; align-items: center; gap: 4px; z-index: 1; }
.lighthouse svg { width: 70%; height: auto; display: block; filter: drop-shadow(0 4px 0 rgba(0,0,0,.2)); }
.slots8 { display: grid; grid-template-columns: repeat(4, 10px); gap: 3px; padding: 4px 5px; border-radius: 8px; background: var(--navy); border: 2px solid var(--gold); }
.slots8 i { width: 10px; height: 10px; border-radius: 50%; background: #3b4f7a; }
.slots8 i.on { background: var(--gold-light); box-shadow: 0 0 6px var(--gold-light); }
.menu-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ===== 전투 ===== */
.arena { position: relative; flex: 1; min-height: 380px; border-radius: 22px; overflow: hidden; border: 4px solid var(--gold); box-shadow: var(--frame);
  background:
    radial-gradient(ellipse 12% 6% at 20% 18%, #fff 60%, transparent 62%),
    radial-gradient(ellipse 9% 5% at 72% 12%, #fff 60%, transparent 62%),
    linear-gradient(#9fdcff, #e3f5ff 58%, #a7dc7e 58.5%, #7cc457 75%, #69b04a); }
.cat { position: absolute; left: 6%; top: 55%; font-size: 64px; transform: translateY(-50%); transition: filter .2s; filter: drop-shadow(0 6px 0 rgba(0,0,0,.18)); }
.cat.ouch { filter: drop-shadow(0 0 10px var(--red)); }
.cat .shield-bubble { display: none; position: absolute; inset: -10px; border-radius: 50%; border: 4px solid #7fc3ff; background: rgba(127,195,255,.25); }
.cat.shielded .shield-bubble { display: block; }
.enemy, .food, .final-word { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 2px; transform: translate(-50%, -50%); }
.enemy .body { font-size: 44px; filter: drop-shadow(0 4px 0 rgba(0,0,0,.18)); }
.enemy.sandbag { top: 58%; }
.enemy.sandbag .body { font-size: 72px; }
.food { top: 45%; }
.food .body { font-size: 48px; }
.food small { color: var(--ink); background: rgba(255,255,255,.8); border-radius: 8px; padding: 0 6px; }
.final-word { left: 60%; top: 45%; }
.final-word .label { font-size: 44px; }
.final-word small { color: var(--navy); }
.poof { animation: poof .3s forwards; }
@keyframes poof { to { opacity: 0; transform: translate(-50%, -50%) scale(1.6); } }
.shot { position: absolute; font-size: 28px; transform: translate(-50%, -50%); pointer-events: none; }
.pop { position: absolute; font-size: 22px; color: #fff; text-shadow: 0 2px 0 var(--orange-dark), 0 0 4px var(--orange-dark); animation: rise .8s forwards; }
@keyframes rise { to { transform: translateY(-40px); opacity: 0; } }
.boss { position: absolute; right: 4%; top: 6%; text-align: center; padding: 6px 10px; border-radius: 16px; background: rgba(29,47,85,.75); border: 3px solid var(--gold); color: #fff; }
.boss-face { font-size: 64px; }
.boss-name { font-size: 14px; max-width: 170px; }
.boss .bar { width: 160px; height: 14px; margin-top: 4px; background: var(--navy-dark); border: 2px solid var(--gold); border-radius: 8px; overflow: hidden; }
.boss .bar div { height: 100%; width: 100%; background: linear-gradient(#ff8a7a, var(--red)); transition: width .3s; }
.heal-banner { display: none; position: absolute; top: 12px; left: 50%; transform: translateX(-50%); white-space: nowrap; color: #fff; padding: 8px 16px; border-radius: 14px; font-size: 18px;
  background: linear-gradient(#8fd96a, var(--green-dark)); border: 3px solid var(--gold); box-shadow: 0 0 0 2px var(--wood-dark); text-shadow: 0 2px 0 var(--green-dark); }
.healing .heal-banner { display: block; }
.healing .arena { background: linear-gradient(#ffe9b8, #fff3d6 58%, #f5c98a 58.5%, #e8b06a); }
.weapon-bar { display: flex; gap: 12px; justify-content: center; }
.weapon { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 12px; border-radius: 14px;
  background: linear-gradient(#fffbf0, var(--parch-2)); border: 3px solid var(--gold); box-shadow: 0 0 0 2px var(--wood-dark), 0 4px 0 2px rgba(0,0,0,.2); }
.weapon.on { background: linear-gradient(#ffe99a, var(--gold)); }
.weapon small { color: var(--soft); }
.weapon.on small { color: var(--wood-dark); }

/* ===== 미션 ===== */
.slots { flex: 1; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; align-content: center; }
.slot { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px; border-radius: 20px; transition: .3s;
  background: linear-gradient(#fffbf0, var(--parch-2)); border: 3px solid var(--gold); box-shadow: 0 0 0 2px var(--wood-dark), 0 6px 0 2px rgba(0,0,0,.2); }
.slot .emo { font-size: 56px; transition: .3s; }
.slot.grey { background: linear-gradient(#f1eee9, #ddd6cc); border-color: #c9bfae; }
.slot.grey .emo { filter: grayscale(1) opacity(.5); }
.slot.alive { border-color: var(--green); transform: scale(1.05); box-shadow: 0 0 0 2px var(--green-dark), 0 0 18px 4px rgba(255,240,140,.9); }
.slot small { color: var(--soft); }
.rival { align-self: flex-end; color: #fff; border-radius: 12px; padding: 6px 12px; background: linear-gradient(#444, #222); border: 3px solid var(--gold); }

/* ===== 퀴즈 ===== */
.quiz .q-ko { font-size: 32px; margin: 8px 0 16px; }
.quiz .answer { font: inherit; font-size: 28px; -webkit-appearance: none; appearance: none; text-align: center; width: 100%; padding: 10px; color: var(--navy);
  background: #fff; border: 3px solid var(--wood); border-radius: 14px; font-family: ui-monospace, Menlo, Consolas, monospace; box-shadow: inset 0 3px 0 rgba(0,0,0,.08); }
.quiz .answer:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--gold-light); }
.quiz .feedback { min-height: 32px; font-size: 20px; margin-top: 10px; }
.quiz .hud { margin-bottom: 8px; }

/* ===== 휴대폰·태블릿 ===== */

/* 숨은 입력칸: 화면 키보드를 띄우는 용도. 글자 크기 16px 이상이라 아이폰이 화면을 확대하지 않아요 */
#kb { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; font-size: 16px; border: 0; padding: 0; caret-color: transparent; pointer-events: none; }

/* 타이핑 장면(전투, 미션)은 키보드 위 공간에 딱 맞게. 스크롤 없이 */
body.typing-scene { overflow: hidden; }
body.typing-scene #app { height: var(--app-h, 100vh); min-height: 0; overflow: hidden; }
body.typing-scene .scene { height: 100%; min-height: 0; }
.scene.battle .arena { min-height: 0; }
.scene.mission .slots { min-height: 0; overflow: auto; padding: 6px; }

/* 키보드가 닫혀서 잠깐 멈춤 */
.kb-pause { display: none; position: fixed; inset: 0; z-index: 20; border: 0; font: inherit; color: #fff; background: rgba(16,27,54,.82);
  flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 24px; text-shadow: 0 2px 0 var(--navy-dark); }
.kb-pause .big { font-size: 64px; }
.kb-pause small { color: var(--gold-light); font-size: 16px; }
body.kb-paused .kb-pause { display: flex; }
.kb-pill { display: none; position: fixed; z-index: 15; right: calc(10px + env(safe-area-inset-right)); bottom: calc(10px + env(safe-area-inset-bottom));
  font-size: 24px; width: 50px; height: 50px; border-radius: 50%; border: 3px solid var(--gold); background: linear-gradient(var(--navy-2), var(--navy)); box-shadow: 0 0 0 2px var(--navy-dark), 0 4px 6px rgba(0,0,0,.25); }
body.touch.typing-scene:not(.kb-up):not(.kb-paused) .kb-pill { display: block; }
.kb-toast { position: fixed; z-index: 30; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  background: var(--navy); color: #fff; border: 2px solid var(--gold); padding: 10px 16px; border-radius: 12px; font-size: 16px; transition: .2s; white-space: nowrap; }
.kb-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* 터치 화면에서는 키보드 전용 안내 숨기기 */
body.touch .desk-only { display: none; }

@media (max-width: 600px) {
  #app { --pad: 8px; }
  .scene { gap: 8px; }
  .hud { font-size: 15px; padding: 6px 10px; gap: 6px; }
  .btn { font-size: 17px; padding: 10px 14px; }
  .btn.big { font-size: 24px; padding: 14px 24px; }
  .card { padding: 18px; }
  .title-scene .logo { width: 120px; height: 120px; font-size: 72px; }
  .title-scene h1 { font-size: 38px; }
  .ribbon { font-size: 14px; padding: 6px 14px; }
  .topbar { padding: 4px 6px; }
  .tb-title { position: static; transform: none; font-size: 16px; padding: 2px 8px; border: 0; background: none; box-shadow: none; }
  .chip.lv { font-size: 14px; }
  .chip.lv small { font-size: 10px; }
  .coin { font-size: 14px; padding: 2px 8px 2px 4px; }
  .coin small { display: none; }
  .tb-right { gap: 4px; }
  .icon-btn { width: 36px; height: 36px; font-size: 18px; }
  .island { min-height: 62vh; }
  .region { min-width: 0; padding: 4px 7px 5px; border-radius: 12px; }
  .region::after { width: 10px; height: 10px; bottom: -9px; }
  .region .ico { font-size: 18px; width: 28px; height: 28px; margin-top: -18px; border-radius: 9px; }
  .region .nm { font-size: 12px; }
  .region .th { font-size: 10px; }
  .region .rec { font-size: 10px; top: -34px; padding: 2px 5px; }
  .menu-row { gap: 8px; }
  .menu-row .btn { flex: 1 1 28%; font-size: 15px; padding: 10px 6px; }
  .dialog-box { padding: 22px 14px 14px; gap: 10px; }
  .dialog-box .face { font-size: 40px; width: 60px; height: 60px; }
  .dialog-box .text { font-size: 19px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
  .word-card .en { font-size: 20px; }
  .label { font-size: 19px; padding: 2px 6px; letter-spacing: 0; }
  .cat { font-size: 48px; left: 3%; }
  .enemy .body { font-size: 34px; }
  .boss-face { font-size: 44px; }
  .boss .bar { width: 110px; }
  .final-word .label { font-size: 34px; }
  .weapon-bar { gap: 6px; }
  .weapon { padding: 4px 8px; }
  .slots { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .slot { padding: 8px; border-radius: 14px; }
  .slot .emo { font-size: 40px; }
  .quiz .q-ko { font-size: 26px; }
  .card-title, .plaque { font-size: 20px; }
}

/* 키보드가 열려 화면이 낮을 때(세로 휴대폰 + 키보드, 가로 휴대폰): 꼭 필요한 것만 */
@media (max-height: 520px) {
  #app { --pad: 6px; }
  .scene { gap: 6px; }
  body.typing-scene .hint { display: none; }
  .hud { font-size: 14px; padding: 3px 8px; border-radius: 10px; border-width: 2px; }
  .arena { border-width: 3px; }
  .scene.battle .weapon small { display: none; }
  .cat { font-size: 40px; }
  .enemy .body, .food .body { font-size: 28px; }
  .enemy.sandbag .body { font-size: 48px; }
  .boss { top: 2%; padding: 2px 6px; }
  .boss-face { font-size: 30px; }
  .boss-name { font-size: 11px; }
  .heal-banner { font-size: 14px; padding: 4px 10px; top: 6px; }
  .slots { gap: 6px; }
  .slot { padding: 4px 6px; gap: 2px; }
  .slot .emo { font-size: 28px; }
  .slot small { font-size: 12px; }
  .rival { padding: 2px 8px; }
  .scene.battle .label, .scene.mission .label { font-size: 18px; }
  .dialog-box .face { font-size: 32px; width: 50px; height: 50px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .slots { grid-template-columns: repeat(4, 1fr); }
  .island { min-height: 440px; }
}
