/* 탱글로 서비스 화면 — 탱글은 귤(탠저린)을 닮은 주황색, 글씨는 따뜻한 갈색 */
@font-face { font-family: "Tanglo Sans"; font-weight: 400; font-display: swap; src: url("../assets/fonts/NanumGothic-Regular.woff") format("woff"); }
@font-face { font-family: "Tanglo Sans"; font-weight: 700; font-display: swap; src: url("../assets/fonts/NanumGothic-Bold.woff") format("woff"); }

:root {
  --cream: #fff8ee;
  --paper: #ffffff;
  --ink: #4a3426;
  --soft: #8a7060;
  --mint: #ffb35c;
  --mint-d: #e0680f;
  --mint-bg: #fff0dc;
  --sun: #ffd36b;
  --peach: #ffb5a0;
  --lav: #dcd7f5;
  --red: #d0453a;
  --line: #f0dfc8;
  --shadow: 0 10px 28px rgba(120, 60, 10, .13);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--cream); color: var(--ink); }
body {
  font-family: "Tanglo Sans", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  background:
    radial-gradient(circle at 12% -4%, #ffdca8 0, transparent 38%),
    radial-gradient(circle at 98% 8%, #e4f1cf 0, transparent 34%),
    var(--cream);
  min-height: 100dvh;
}
.defs { position: absolute; }
.app {
  max-width: 520px; margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 18px calc(96px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px; min-height: 100dvh;
}
.stack { display: flex; flex-direction: column; gap: 14px; }

/* 머리말 */
.top { display: flex; align-items: center; gap: 10px; }
.brand { font-weight: 700; font-size: 22px; letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 14px; height: 14px; border-radius: 50%; background: linear-gradient(180deg, #ffc680, var(--mint-d)); box-shadow: 0 2px 6px rgba(224, 104, 15, .45); }
.cam-label { margin-left: auto; font-size: 12px; color: var(--soft); }
.badge { margin-left: auto; font-size: 12px; font-weight: 700; color: #8a5a00; background: #ffe9b0; padding: 4px 10px; border-radius: 999px; }
.cam-label:not(:empty) + .badge { margin-left: 0; }

/* 화면 공통 */
.screen { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; animation: rise .35s ease both; }
.screen.play { align-items: stretch; text-align: left; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.hero-title { margin: 4px 0 0; font-size: 26px; line-height: 1.35; letter-spacing: -.03em; font-weight: 700; }
.hero-title.small { font-size: 22px; }
.hero-sub { margin: 0; color: var(--soft); font-size: 15px; line-height: 1.6; }
.fine { margin: 0; color: var(--soft); font-size: 12.5px; line-height: 1.6; }
.fine.center { text-align: center; }
.msg { margin: 0; min-height: 1.4em; color: var(--red); font-size: 14px; }
.notice { margin: 0; padding: 10px 14px; border-radius: 14px; background: #fff0c9; color: #7a5200; font-size: 13px; line-height: 1.5; }
.status { margin: 0; text-align: center; color: var(--soft); font-size: 13px; min-height: 1.3em; }
.privacy { margin: auto 0 0; text-align: center; font-size: 12px; color: var(--soft); }

/* 버튼 */
.btn {
  appearance: none; border: 2px solid var(--line); background: var(--paper); color: var(--ink);
  font: inherit; font-weight: 700; font-size: 16px; padding: 14px 22px; border-radius: 999px; cursor: pointer;
  box-shadow: 0 4px 0 var(--line); transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.btn:disabled { opacity: .5; }
.btn.primary { background: var(--mint-d); border-color: var(--mint-d); color: #fff; box-shadow: 0 5px 0 #a84a05; }
.btn.primary:active { box-shadow: 0 1px 0 #a84a05; }
.btn.xl { font-size: 19px; padding: 18px 28px; width: 100%; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--soft); }
.actions { display: flex; gap: 10px; width: 100%; }
.actions.center { justify-content: center; }
.actions.col { flex-direction: column; }
.btn.guardian {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 30;
  background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 5px 0 #a3322a, var(--shadow); padding: 14px 20px;
}
.gate-form { display: flex; flex-direction: column; gap: 12px; width: 100%; }
input[type="password"], select { font: inherit; font-size: 17px; padding: 14px 16px; border-radius: 16px; border: 2px solid var(--line); background: var(--paper); color: var(--ink); width: 100%; text-align: center; }
input[type="password"]:focus { outline: none; border-color: var(--mint-d); }

/* 마스코트 탱글 */
.mascot { width: 120px; margin: 0 auto; }
.mascot.big { width: 190px; }
.mascot svg { width: 100%; height: auto; overflow: visible; }
.mascot .body { fill: url(#jelly); stroke: #e0780f; stroke-width: 3; }
.mascot .shine { fill: #fff; opacity: .6; }
.mascot .eye { fill: var(--ink); }
.mascot .glint { fill: #fff; }
.mascot .leaf { fill: #7cb342; stroke: #5b8f2c; stroke-width: 2.5; stroke-linejoin: round; }
.mascot .stem { fill: none; stroke: #6b8f3a; stroke-width: 5; stroke-linecap: round; }
.mascot .dot { fill: #e0780f; opacity: .35; }
.mascot .cheek { fill: #ff8f78; opacity: .7; }
.mascot .mouth { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; transform-origin: 100px 108px; }
.mascot .shadow { fill: rgba(120, 60, 10, .13); }
.mascot svg { animation: bob 3.2s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes bob { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.03, .97); } }
.orb.speaking .mascot svg { animation: talk .45s ease-in-out infinite; }
.orb.speaking .mascot .mouth { animation: mouth .3s ease-in-out infinite alternate; }
.orb.listening .mascot svg { animation: bob 2.2s ease-in-out infinite; }
.orb.connecting .mascot svg { animation: bob 1s ease-in-out infinite; }
@keyframes talk { 0%, 100% { transform: translateY(0) scale(1.02, .98); } 50% { transform: translateY(-6px) scale(.98, 1.03); } }
@keyframes mouth { from { transform: scaleY(1); } to { transform: scaleY(1.7); } }

/* 처음 화면 */
.animal-row { display: flex; justify-content: center; gap: 4px; }
.animal-row img { width: 52px; height: 52px; object-fit: contain; }
.animal-row img:nth-child(odd) { transform: rotate(-6deg); }
.animal-row img:nth-child(even) { transform: rotate(6deg) translateY(4px); }
.checklist { list-style: none; margin: 0; padding: 14px 16px; width: 100%; background: var(--paper); border-radius: 22px; box-shadow: var(--shadow); text-align: left; display: flex; flex-direction: column; gap: 10px; font-size: 14px; line-height: 1.5; }
.checklist li { display: flex; gap: 10px; }
.checklist li span { flex: none; }

/* 놀이 화면 */
.stage-wrap { position: relative; }
.stage { position: relative; width: 100%; aspect-ratio: 4 / 3; background: #2b2018; border-radius: 28px; overflow: hidden; border: 4px solid var(--paper); box-shadow: var(--shadow); }
.stage video, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: #f0dccb; padding: 20px; font-size: 15px; }
.empty p { margin: 0; }
.switch { position: absolute; right: 10px; bottom: 10px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .85); font-size: 20px; box-shadow: var(--shadow); }
.cardnow { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; min-height: 56px; padding: 8px 12px; border-radius: 20px; background: var(--paper); font-size: 16px; font-weight: 700; box-shadow: var(--shadow); }
.cardnow.idle { color: var(--soft); font-weight: 400; font-size: 15px; }
.cardnow.ok { color: var(--mint-d); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 6px; border-radius: 999px; background: var(--mint-bg); font-size: 15px; }
.chip img { width: 34px; height: 34px; object-fit: contain; }
.orb { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 0 2px; }
.orb-text { font-size: 17px; font-weight: 700; color: var(--ink); min-height: 1.4em; }
.orb.speaking .orb-text { color: var(--mint-d); }
.meter { width: 160px; height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--mint), var(--sun)); transition: width .08s; }
.friends { background: var(--paper); border-radius: 22px; padding: 12px 14px; box-shadow: var(--shadow); }
.friends-label { font-size: 13px; color: var(--soft); font-weight: 700; }
.friends-list { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.friends-list img { width: 52px; height: 52px; object-fit: contain; border-radius: 16px; background: var(--mint-bg); padding: 4px; animation: pop .4s ease both; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }

/* 끝·동화책 */
.end-note { margin: 0; padding: 16px 18px; border-radius: 22px; background: var(--paper); box-shadow: var(--shadow); font-size: 18px; font-weight: 700; line-height: 1.5; width: 100%; }
.offer { background: var(--paper); border-radius: 26px; padding: 20px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; width: 100%; }
.offer h2 { margin: 0; font-size: 19px; line-height: 1.4; }
.offer p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--ink); }
.offer .fine { color: var(--soft); }
.book-pages { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; width: calc(100% + 36px); margin: 0 -18px; padding: 6px 18px 14px; -webkit-overflow-scrolling: touch; }
.book-pages img { flex: none; width: 78%; max-width: 380px; scroll-snap-align: center; border-radius: 22px; box-shadow: var(--shadow); background: var(--paper); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid var(--mint-bg); border-top-color: var(--mint-d); animation: spin .9s linear infinite; margin: 6px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 개발 도구 */
.dev { background: #fff; border: 2px dashed var(--line); border-radius: 18px; padding: 12px; display: flex; flex-direction: column; gap: 10px; text-align: left; font-size: 13px; }
.dev h2 { margin: 0; font-size: 14px; }
.dev label { display: flex; flex-direction: column; gap: 4px; }
.dev select { font-size: 14px; padding: 8px; text-align: left; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--cream); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; }
.stat .k { font-size: 11px; color: var(--soft); }
.stat .v { font-size: 16px; font-weight: 700; }
.debug { margin: 0; font-size: 11px; color: var(--soft); word-break: break-all; }
.log { max-height: 220px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.line { padding: 6px 10px; border-radius: 12px; font-size: 13px; line-height: 1.4; }
.line.ai { background: var(--mint-bg); }
.line.you { background: #fff0c9; align-self: flex-end; }
.line.sys { color: var(--soft); font-size: 12px; }
.links { margin: 0; }
.links a { color: var(--mint-d); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
