/* 하이 베이비 — mobile-first styles (iPhone Safari portrait reference 390x844) */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden; background: #000; color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
  touch-action: manipulation; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}
body { position: fixed; inset: 0; }
button { font: inherit; color: inherit; touch-action: manipulation; cursor: pointer; }
.hidden { display: none !important; }

:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

/* App frame: full screen on phones, phone-shaped column on desktop */
#app {
  position: relative; margin: 0 auto; width: 100%; max-width: 520px;
  height: 100vh; height: 100dvh; overflow: hidden; background: #000;
}

/* ---------- World / stage / camera ---------- */
#world { position: absolute; inset: 0; overflow: hidden; transition: filter 1.6s ease; will-change: filter; }
#stage {
  position: absolute; left: 0; top: 0; transform-origin: 0 0;
  transition: transform 3s cubic-bezier(.45,.05,.35,1); will-change: transform;
}
#stage.instant { transition: none; }
#drift { position: absolute; inset: 0; animation: breathe 7s ease-in-out infinite; }
#stageImg { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
@keyframes breathe {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-0.4%, 0.5%) scale(1.012); }
}
#hotspots { position: absolute; inset: 0; }
.hotspot { position: absolute; border-radius: 40%; }
.hotspot.target { animation: targetGlow 2.2s ease-in-out infinite; }
.hotspot.grabbed { box-shadow: 0 0 0 3px rgba(255,240,180,.9), 0 0 40px 14px rgba(255,220,140,.75); background: rgba(255,240,190,.12); transition: box-shadow .2s; }
@keyframes targetGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,236,170,0); background: rgba(255,240,200,0); }
  50% { box-shadow: 0 0 26px 8px rgba(255,236,170,.55); background: rgba(255,240,200,.08); }
}

/* Baby-vision overlays */
#tint { position: absolute; inset: 0; pointer-events: none; background: rgba(255,170,90,.08); mix-blend-mode: soft-light; z-index: 4; }
#vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background: radial-gradient(ellipse 85% 75% at 50% 48%, rgba(0,0,0,0) 55%, rgba(30,15,5,.35) 80%, rgba(0,0,0,.7) 100%);
}
#fx { position: absolute; inset: 0; pointer-events: none; z-index: 20; overflow: hidden; }
#flash { position: absolute; inset: 0; pointer-events: none; z-index: 21; background: #fff; opacity: 0; }
#flash.on { animation: flash .45s ease-out; }
@keyframes flash { 0% { opacity: .75; } 100% { opacity: 0; } }

/* Baby hand + ripple */
.hand {
  position: absolute; left: 0; top: 0; z-index: 6; opacity: 0; pointer-events: none;
  transform-origin: 50% 0; will-change: transform, opacity;
  filter: blur(0.4px) drop-shadow(0 8px 12px rgba(40,20,10,.35));
}
.hand svg { display: block; width: 100%; height: 100%; }
.ripple {
  position: absolute; width: 90px; height: 90px; margin: -45px 0 0 -45px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.85); pointer-events: none; animation: ripple .7s ease-out forwards;
}
@keyframes ripple { from { transform: scale(.2); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
.particle { position: absolute; font-size: 30px; pointer-events: none; will-change: transform, opacity; }

/* ---------- HUD ---------- */
.hud-btn {
  position: absolute; z-index: 30; top: calc(var(--sat) + 10px); left: calc(var(--sal) + 10px);
  width: 56px; height: 56px; border-radius: 50%; border: 0; font-size: 26px;
  background: rgba(0,0,0,.38); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
#hearts {
  position: absolute; z-index: 30; top: calc(var(--sat) + 14px); right: calc(var(--sar) + 12px);
  padding: 8px 16px; border-radius: 28px; font-size: 22px; font-weight: 800;
  background: rgba(0,0,0,.38); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
#hearts.bump { animation: bump .5s ease; }
@keyframes bump { 40% { transform: scale(1.3); } }

/* ---------- Subtitles ---------- */
#subtitle {
  position: absolute; z-index: 25; left: 12px; right: 12px; top: calc(var(--sat) + 76px);
  padding: 12px 16px 14px; border-radius: 20px; text-align: center;
  background: rgba(10,6,4,.42); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  animation: subIn .3s ease;
}
@keyframes subIn { from { opacity: 0; transform: translateY(-8px); } }
#subName {
  display: inline-block; font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 10px; border-radius: 10px; margin-bottom: 4px; background: #888;
}
#subName.mia { background: #e7779a; }
#subName.jake { background: #4f86c9; }
#subName:empty { display: none; }
#subEn { font-size: 24px; font-weight: 800; line-height: 1.25; text-shadow: 0 2px 6px rgba(0,0,0,.85); }
#subEn:empty { display: none; }
#subKo { margin-top: 6px; font-size: 15px; font-style: italic; color: #ffe2c4; opacity: .92; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
#subKo:empty { display: none; }
#subtitle.bubble #subEn { font-size: 30px; }
#subtitle.thought { background: rgba(0,0,0,.25); }
#subtitle.thought #subKo { font-size: 18px; margin: 0; }
#app.no-ko #subKo.ko-sub { display: none; }
/* Dimmed recall of the last parent line during the player's turn */
#subtitle.recall { opacity: .62; padding: 8px 14px 10px; animation: none; }
#subtitle.recall #subEn { font-size: 17px; }
#subtitle.recall #subName { font-size: 11px; }
#subtitle .skip { position: absolute; right: 10px; bottom: 4px; font-size: 11px; opacity: .5; }

/* Tap prompt */
#prompt {
  position: absolute; z-index: 24; left: 50%; bottom: calc(var(--sab) + 22px); transform: translateX(-50%);
  white-space: nowrap; padding: 12px 20px; border-radius: 30px; font-size: 17px; font-weight: 700;
  background: rgba(0,0,0,.5); pointer-events: none; animation: promptPulse 1.8s ease-in-out infinite;
}
@keyframes promptPulse { 50% { opacity: .65; } }

/* Hint card */
#hint {
  position: absolute; z-index: 25; left: 50%; bottom: calc(var(--sab) + 214px); transform: translateX(-50%);
  min-width: 220px; max-width: 88%; padding: 14px 26px; border-radius: 24px; text-align: center;
  background: rgba(255,255,255,.93); color: #2b1d12; box-shadow: 0 10px 30px rgba(0,0,0,.35);
  animation: hintIn .35s cubic-bezier(.2,1.4,.5,1);
}
@keyframes hintIn { from { opacity: 0; transform: translateX(-50%) scale(.7); } }
#hintEn { font-size: 44px; font-weight: 900; line-height: 1.1; }
#hintKo { font-size: 18px; color: #7a5a45; margin-top: 2px; }
#replay {
  position: absolute; top: -14px; right: -14px; width: 44px; height: 44px; border-radius: 50%; border: 0;
  font-size: 20px; line-height: 44px; padding: 0; background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
#replay::before { content: ""; position: absolute; inset: -8px; border-radius: 50%; } /* 60px hit area */
#replay:active { transform: scale(.92); }

/* ---------- Mic controls ---------- */
#controls {
  position: absolute; z-index: 30; left: 0; right: 0; bottom: calc(var(--sab) + 14px);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
#controls > * { pointer-events: auto; }
#mic {
  position: relative; width: 84px; height: 84px; border-radius: 50%; border: 4px solid #fff;
  background: linear-gradient(160deg, #ff8fb1, #e85a85); font-size: 38px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); transition: transform .15s;
}
#mic:active { transform: scale(.94); }
#mic.listening { background: linear-gradient(160deg, #ff5f6d, #d8304a); }
#mic.listening::before, #mic.listening::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 4px solid rgba(255,120,140,.8);
  animation: ring 1.3s ease-out infinite; pointer-events: none;
}
#mic.listening::after { animation-delay: .65s; }
@keyframes ring { from { transform: scale(1); opacity: 1; } to { transform: scale(1.7); opacity: 0; } }
#mic.thinking { background: linear-gradient(160deg, #9fa6ff, #6b72d8); }
#mic.thinking #micIcon { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#micLabel { font-size: 14px; font-weight: 700; text-shadow: 0 1px 4px #000; }
#said {
  min-height: 56px; padding: 0 24px; border-radius: 28px; border: 0; font-size: 18px; font-weight: 800;
  background: rgba(255,255,255,.92); color: #2b1d12; box-shadow: 0 6px 18px rgba(0,0,0,.3);
}
#said:active { transform: scale(.97); }
#recNote {
  max-width: 92%; padding: 6px 12px; border-radius: 12px; font-size: 12.5px; text-align: center;
  background: rgba(0,0,0,.55); color: #ffe2c4;
}
#controls.no-mic #mic, #controls.no-mic #micLabel { display: none; }

/* ---------- Prologue ---------- */
#prologue { position: absolute; inset: 0; z-index: 40; background: #000; display: flex; align-items: center; justify-content: center; }
#laptop {
  position: absolute; left: -20%; right: -20%; bottom: -10%; height: 70%; pointer-events: none;
  background: radial-gradient(ellipse 50% 55% at 50% 100%, rgba(120,170,255,.35), rgba(60,90,160,.12) 50%, rgba(0,0,0,0) 75%);
  animation: flicker 4s ease-in-out infinite; transition: opacity 2s ease;
}
#laptop.off { opacity: 0; }
@keyframes flicker { 50% { opacity: .82; } }
#plText {
  position: relative; padding: 0 28px; font-size: 22px; line-height: 1.6; text-align: center; font-weight: 600;
  color: #e9eefc; text-shadow: 0 0 18px rgba(120,170,255,.4); transition: opacity .6s ease; min-height: 2em;
}
#plText.fade { opacity: 0; }
#plTap {
  position: absolute; left: 0; right: 0; bottom: calc(var(--sab) + 90px); text-align: center; font-size: 18px;
  color: #ccc; animation: promptPulse 1.6s ease-in-out infinite;
}
#plSkip {
  position: absolute; top: calc(var(--sat) + 12px); right: calc(var(--sar) + 12px); min-height: 56px; padding: 0 20px;
  border-radius: 28px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); font-size: 16px; color: #ccc;
}
#prologue.see-through { background: transparent; }

/* ---------- Eyelids ---------- */
.lid {
  position: absolute; left: -10%; right: -10%; height: 56%; z-index: 45; background: #000; pointer-events: none;
  transition: transform .5s cubic-bezier(.5,0,.3,1); transform: translateY(-100%);
}
#lidTop { top: 0; border-radius: 0 0 50% 50% / 0 0 22% 22%; }
#lidBot { bottom: 0; border-radius: 50% 50% 0 0 / 22% 22% 0 0; transform: translateY(100%); }
#app.lids-closed #lidTop, #app.lids-closed #lidBot { transform: translateY(0); }
#app.lids-half #lidTop { transform: translateY(-58%); }
#app.lids-half #lidBot { transform: translateY(58%); }

/* ---------- Title ---------- */
#title {
  position: absolute; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; text-align: center;
  background: radial-gradient(ellipse at 50% 35%, #2b2230 0%, #0c0a10 70%);
  padding: calc(var(--sat) + 20px) 24px calc(var(--sab) + 20px);
}
.title-baby { font-size: 64px; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }
#title h1 { margin: 6px 0 8px; font-size: 46px; font-weight: 900; letter-spacing: -.02em;
  background: linear-gradient(90deg, #ffd1dc, #fff3c4); -webkit-background-clip: text; background-clip: text; color: transparent; }
#title .subtitle { margin: 0 0 22px; font-size: 18px; color: #e8dce8; }
#title .note { margin: 0 0 6px; font-size: 14px; color: #a99fb0; }
#title .note.tiny { margin: 0 0 30px; font-size: 12px; opacity: .85; }
.big-btn {
  display: block; width: 100%; max-width: 320px; margin: 0 auto; min-height: 60px; border: 0; border-radius: 32px;
  font-size: 21px; font-weight: 800; color: #2b1d12; background: linear-gradient(160deg, #ffe3a8, #ffb3c6);
  box-shadow: 0 10px 26px rgba(255,150,180,.3);
}
.big-btn:active { transform: scale(.97); }
.big-btn.secondary { background: rgba(255,255,255,.14); color: #fff; box-shadow: none; }
.link-btn { margin-top: 16px; min-height: 56px; padding: 0 18px; background: none; border: 0; color: #a99fb0; font-size: 15px; text-decoration: underline; }
.best { font-size: 14px; color: #c9b8c9; margin: 10px 0 0; min-height: 1em; }

/* ---------- Result ---------- */
#result { position: absolute; inset: 0; z-index: 55; background: rgba(20,10,8,.5); }
.result-inner {
  position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  padding: calc(var(--sat) + 72px) 20px calc(var(--sab) + 24px); text-align: center; animation: subIn .6s ease;
}
#result h2 { margin: 6px 0 4px; font-size: 32px; font-weight: 900; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
#result h3 { margin: 18px 0 10px; font-size: 17px; }
#result .total { font-size: 44px; font-weight: 900; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
.polaroid {
  width: 210px; margin: 14px auto 0; padding: 10px 10px 0; background: #fbf8f1; border-radius: 4px;
  transform: rotate(-3deg); box-shadow: 0 12px 30px rgba(0,0,0,.45);
}
#polaroidImg { width: 190px; height: 190px; background: #ccc url(assets/kitchen.jpg) no-repeat; }
#polaroidCap { padding: 10px 0 12px; font-family: "Marker Felt", "Comic Sans MS", "Segoe Print", cursive; font-size: 18px; color: #333; }
#chips { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; max-width: 420px; margin: 0 auto; }
.chip {
  padding: 8px 10px; border-radius: 16px; background: rgba(255,255,255,.9); color: #2b1d12; text-align: left;
  display: flex; flex-direction: column;
}
.chip b { font-size: 18px; }
.chip span { font-size: 12px; color: #7a5a45; }
.chip i { font-style: normal; font-size: 14px; letter-spacing: 1px; }
.thought { margin: 18px 6px; font-size: 16px; font-style: italic; color: #ffe2c4; text-shadow: 0 1px 4px #000; }
.res-btns { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Settings ---------- */
#settings { position: absolute; inset: 0; z-index: 70; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; }
.settings-card { width: 86%; max-width: 340px; padding: 20px; border-radius: 24px; background: #2a2230; }
.settings-card h3 { margin: 0 0 12px; text-align: center; }
.settings-card .row { display: flex; align-items: center; justify-content: space-between; min-height: 56px; font-size: 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.settings-card input { width: 28px; height: 28px; accent-color: #ff8fb1; }
.settings-card .big-btn { margin-top: 16px; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  #drift, .title-baby, #laptop, .hotspot.target { animation: none !important; }
  #stage { transition-duration: 1.2s !important; }
  .hotspot.target { box-shadow: 0 0 22px 6px rgba(255,236,170,.5); }
}
