/* Scenes overlay */
.scene {
  position: absolute; inset: 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  padding-top: calc(20px + env(safe-area-inset-top));
  display: none;
  flex-direction: column;
  gap: 14px;
}
.scene.visible { display: flex; }
.scene.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.scene.modal {
  background: rgba(33,19,48,0.55);
  align-items: center; justify-content: center;
}

/* Boot */
.scene-boot {
  align-items: center; justify-content: center; text-align: center;
  background: linear-gradient(180deg,#FFE8F1 0%, #A987E8 100%);
}
.logo { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.logo-title { font-size: 34px; margin: 0; font-weight: 900; letter-spacing: -0.5px; color: var(--plum-950); }
.logo-sub   { margin: 0; opacity: 0.85; font-weight: 700; }
.logo-jelly {
  width: 96px; height: 96px;
  background:
    radial-gradient(circle at 35% 35%, #FFC0CE 0 24%, #FF5F7E 32%, #C93358 78%);
  border: 3px solid var(--plum-800);
  border-radius: 50% 50% 46% 54% / 60% 60% 40% 40%;
  box-shadow: 0 10px 24px rgba(59,35,90,.35), inset -8px -12px 0 rgba(0,0,0,.08);
  position: relative;
  animation: bounce 1.4s var(--ease-out) infinite alternate;
}
.logo-jelly::before, .logo-jelly::after {
  content: ''; position: absolute; top: 32%;
  width: 10px; height: 14px; background: #211330; border-radius: 50%;
}
.logo-jelly::before { left: 28%; } .logo-jelly::after { right: 28%; }
@keyframes bounce { from { transform: translateY(0) scaleY(1);} to { transform: translateY(-8px) scaleY(0.94);} }

.hint { opacity: 0.75; font-weight: 700; }

/* Buttons */
.btn {
  appearance: none; border: none; font: inherit; font-weight: 800;
  border-radius: var(--r-btn);
  min-height: 48px;
  padding: 14px 20px;
  cursor: pointer;
  transition: transform 120ms var(--ease-out-back), box-shadow 120ms;
  color: var(--plum-950);
}
.btn:active { transform: translateY(3px); }
.btn-primary {
  background: var(--strawberry-500);
  color: #fff;
  box-shadow: 0 4px 0 var(--strawberry-700), 0 10px 24px rgba(201,51,88,.35);
  min-height: 56px;
}
.btn-primary.big { font-size: 20px; }
.btn-primary.danger { background: var(--danger); box-shadow: 0 4px 0 #8f2626, 0 10px 24px rgba(228,71,71,.35); }
.btn-primary:active { box-shadow: 0 1px 0 var(--strawberry-700), 0 4px 10px rgba(201,51,88,.2); }
.btn-secondary {
  background: var(--cream-050);
  color: var(--plum-800);
  border: 2px solid var(--plum-800);
}
.btn-secondary.danger { color: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.icon-btn {
  appearance: none; border: none;
  background: rgba(255,255,255,0.85);
  color: var(--plum-800);
  width: 44px; height: 44px; border-radius: 12px;
  font-size: 20px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.topbar-title { margin: 0; font-size: 20px; font-weight: 800; color: var(--plum-950); }
.stars-chip {
  background: var(--lemon-400); color: var(--lemon-700); font-weight: 900;
  padding: 6px 12px; border-radius: 999px;
  box-shadow: 0 2px 0 rgba(0,0,0,.1);
}

/* Home */
.home-hero { text-align: center; margin-top: 4px; }
.home-jelly {
  width: 120px; height: 120px; margin: 0 auto;
  background: radial-gradient(circle at 35% 35%, #FFC0CE 0 24%, #FF5F7E 32%, #C93358 78%);
  border: 3px solid var(--plum-800);
  border-radius: 50% 50% 46% 54% / 60% 60% 40% 40%;
  box-shadow: 0 10px 30px rgba(59,35,90,.3);
  position: relative;
  animation: bounce 1.6s var(--ease-out) infinite alternate;
}
.home-jelly::before, .home-jelly::after {
  content: ''; position: absolute; top: 32%;
  width: 12px; height: 16px; background: #211330; border-radius: 50%;
}
.home-jelly::before { left: 28%; } .home-jelly::after { right: 28%; }

.home-title { margin: 12px 0 0; font-size: 26px; font-weight: 900; color: var(--plum-950); }
.home-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: auto; }
.home-cards > :nth-child(1) { grid-column: 1 / span 2; }
.home-card {
  appearance: none; border: none;
  background: var(--cream-050);
  border-radius: var(--r-card);
  padding: 16px;
  min-height: 96px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  font: inherit; font-weight: 800; color: var(--plum-800);
  box-shadow: 0 6px 18px rgba(59,35,90,.15);
  cursor: pointer;
  position: relative;
}
.home-card:active { transform: translateY(2px); }
.card-icon { font-size: 26px; }
.card-label { font-size: 18px; }
.card-lock {
  font-size: 12px; font-weight: 700; color: var(--locked);
}
.home-card[data-locked="true"] .card-icon { opacity: 0.5; }
.home-card[data-locked="true"] { filter: saturate(0.4); }
.home-card[data-locked="false"] .card-lock { display: none; }

/* Scene titles */
.scene-title { margin: 8px 0 0; font-size: 24px; font-weight: 900; color: var(--plum-950); text-align: center; }
.scene-sub   { margin: 0; text-align: center; opacity: .8; }

/* Skin grid */
.skin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding-bottom: 20px;
}
.first-skin-grid { justify-items: center; margin-top: 8px; }

.skin-card {
  background: var(--cream-050);
  border-radius: var(--r-card);
  padding: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-weight: 800;
  border: 3px solid transparent;
  cursor: pointer;
  transition: border-color 120ms, transform 120ms;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  position: relative;
  min-height: 120px;
}
.skin-card.selected { border-color: var(--strawberry-500); }
.skin-card.locked   { filter: grayscale(0.9) brightness(0.9); cursor: not-allowed; }
.skin-card .skin-preview { width: 64px; height: 56px; }
.skin-card .name { font-size: 14px; }
.skin-card .req  { font-size: 11px; opacity: 0.75; font-weight: 700; }

.skin-preview {
  border: 3px solid var(--plum-800);
  border-radius: 50% 50% 46% 54% / 60% 60% 40% 40%;
  background: var(--strawberry-500);
  position: relative;
}
.skin-preview::before, .skin-preview::after {
  content:''; position:absolute; top:32%;
  width:22%; height:26%; background:#211330; border-radius:50%;
}
.skin-preview::before { left: 22%; } .skin-preview::after { right: 22%; }

/* World map */
.map-worlds { display: flex; flex-direction: column; gap: 16px; padding-bottom: 30px; }
.map-world  {
  background: var(--cream-050);
  border-radius: var(--r-card);
  padding: 14px;
  box-shadow: 0 6px 18px rgba(59,35,90,.15);
}
.map-world h3 { margin: 0 0 8px; }
.stage-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px;
}
.stage-node {
  appearance:none; border: none; font: inherit;
  background: var(--cream-200); color: var(--plum-800); font-weight: 800;
  aspect-ratio: 1/1;
  border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; cursor: pointer; position: relative;
  border: 2px solid var(--plum-800);
}
.stage-node.locked {
  background: #E9E4EE; color: var(--locked); border-color: var(--locked); cursor: not-allowed;
}
.stage-node.unlocked { background: var(--cream-050); }
.stage-node.recommended {
  animation: pulse 1.6s var(--ease-in-out) infinite;
  box-shadow: 0 0 0 3px var(--strawberry-500);
}
@keyframes pulse { 50% { transform: scale(1.05); } }
.stage-node .num { font-size: 18px; font-weight: 900; }
.stage-node .starline { font-size: 10px; letter-spacing: 1px; color: var(--lemon-700); }

/* HUD */
/* base.css의 `.ui-root .scene { pointer-events: auto }` 보다 특이도가 높아야
   인게임 오버레이가 캔버스의 드래그·탭 입력을 가로채지 않는다. */
.ui-root .scene.game-scene {
  padding-top: calc(env(safe-area-inset-top) + 10px);
  pointer-events: none;
  gap: 0;
}
.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 4px 8px;
}
.hud-hearts .heart { font-size: 22px; color: var(--danger); text-shadow: 0 2px 0 rgba(0,0,0,.15); }
.hud-hearts .heart.empty { color: #d9c9d1; }
.hud-score { text-align: center; font-weight: 900; font-size: 22px; color: var(--plum-950);
             background: rgba(255,255,255,0.85); border-radius: 999px; padding: 4px 14px; }
.hud-time { text-align: center; font-weight: 900; font-size: 18px; color: var(--plum-800);
             background: rgba(255,255,255,0.85); border-radius: 999px; padding: 4px 10px; }
.hud-pause { pointer-events: auto; }

.tutorial-hint {
  margin-top: auto;
  align-self: center;
  background: rgba(33,19,48,0.75);
  color: #fff; padding: 10px 16px; border-radius: 999px;
  font-weight: 800; font-size: 14px;
}
.countdown {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 96px; font-weight: 900; color: #fff;
  text-shadow: 0 6px 20px rgba(0,0,0,.5);
  pointer-events: none;
}

/* Modal / Result cards */
.modal-card, .result-card {
  background: var(--cream-050);
  border-radius: var(--r-card);
  padding: 20px;
  max-width: 320px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  display: flex; flex-direction: column; gap: 10px; align-items: center;
  margin: auto;
}
.modal-card h2, .result-card h2 { margin: 0; font-size: 22px; font-weight: 900; color: var(--plum-950); }
.modal-card h3 { margin: 0; font-size: 18px; font-weight: 900; }
.modal-card p  { margin: 0; opacity: .85; text-align: center; }
.modal-card .btn, .result-card .btn { width: 100%; }

.result-stars {
  display: flex; gap: 8px; font-size: 36px; color: var(--lemon-400);
}
.result-stars .star.empty { color: #ddd6df; }
.result-score { font-size: 40px; font-weight: 900; color: var(--plum-950); }
.result-breakdown { list-style: none; padding: 0; margin: 0; width: 100%; }
.result-breakdown li {
  display: flex; justify-content: space-between; padding: 4px 0;
  font-weight: 700;
}
.result-breakdown li b { font-weight: 900; }

.badge {
  background: var(--lemon-400); color: var(--lemon-700); font-weight: 900;
  padding: 4px 12px; border-radius: 999px;
}
.skin-unlock { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.skin-unlock .skin-preview { width: 40px; height: 36px; }

.result-actions { display: flex; flex-direction: column; gap: 8px; width: 100%; }

.fail-cause { font-weight: 800; opacity: 0.9; }

/* Settings */
.settings-list { display: flex; flex-direction: column; gap: 12px; }
.settings-row {
  background: var(--cream-050); border-radius: 14px; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-weight: 700;
}
.settings-controls { display: flex; align-items: center; gap: 10px; }
.settings-row input[type="range"] { width: 120px; }
.settings-row select {
  font: inherit; font-weight: 700;
  border: 2px solid var(--plum-800); border-radius: 8px; padding: 6px 8px;
  background: #fff;
}

/* Toast */
.toast {
  position: absolute; left: 50%; bottom: 24px;
  transform: translateX(-50%);
  background: rgba(33,19,48,0.9); color: #fff;
  padding: 10px 16px; border-radius: 999px;
  font-weight: 700; font-size: 14px;
  z-index: 20;
}
