:root {
  --pink-bg: #ffe3ef;
  --pink-deep: #ff7eb3;
  --pink-soft: #ffb6d2;
  --cream: #fff7fb;
  --ink: #5a3b49;
  --danger: #ff4d6d;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
  background: linear-gradient(180deg, #fff0f6 0%, var(--pink-bg) 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 8px 8px;
}

#topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 4px 4px;
}

#title {
  font-size: clamp(13px, 4vw, 18px);
  margin: 0;
  text-align: center;
  font-weight: 800;
  color: var(--pink-deep);
  text-shadow: 0 1px 0 #fff;
  flex: 1;
}

.score-box {
  background: #fff;
  border-radius: 14px;
  padding: 6px 12px;
  min-width: 64px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(255, 126, 179, 0.25);
  line-height: 1.1;
}
.score-box .label { display: block; font-size: 10px; color: var(--pink-soft); font-weight: 700; }
.score-box span:last-child { font-size: 18px; font-weight: 800; }
.score-box.best { color: #b07; }

#next-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 6px 6px;
}
.next-label { font-size: 12px; font-weight: 700; color: var(--pink-deep); }
#next-canvas { background: #fff; border-radius: 12px; box-shadow: inset 0 0 0 2px var(--pink-soft); }
#evolution-hint { font-size: 11px; color: #c98aa6; margin-left: auto; }

#stage-wrap {
  position: relative;
  flex: 1;
  width: 100%;
  display: flex;
  justify-content: center;
  min-height: 0;
}

#game-canvas {
  background: var(--cream);
  border-radius: 18px;
  box-shadow: 0 6px 20px rgba(255, 126, 179, 0.3), inset 0 0 0 3px #fff;
  touch-action: none;
  display: block;
}

/* 게임오버 오버레이 */
#overlay {
  position: absolute;
  inset: 0;
  background: rgba(90, 59, 73, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  z-index: 10;
}
#overlay.hidden { display: none; }

#confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

#result-card {
  position: relative;
  z-index: 2;
  background: #fff;
  border-radius: 24px;
  padding: 14px 14px 16px;
  width: min(86%, 330px);
  text-align: center;
  box-shadow: 0 18px 40px rgba(120, 40, 80, 0.35);
  animation: pop 0.3s cubic-bezier(.2,1.3,.4,1);
}
@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

#card-canvas {
  width: 100%;
  max-width: 302px;
  display: block;
  border-radius: 18px;
}

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.card-actions button {
  flex: 1;
  border: none;
  border-radius: 14px;
  padding: 14px 8px;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  transition: transform 0.05s;
}
.card-actions button:active { transform: translateY(2px); }
#btn-retry { background: var(--pink-deep); box-shadow: 0 4px 0 #d65f93; }
#btn-retry:active { box-shadow: 0 1px 0 #d65f93; }
#btn-share { background: #111; box-shadow: 0 4px 0 #000; }
#btn-share:active { box-shadow: 0 1px 0 #000; }
#share-msg { font-size: 12px; color: #c98aa6; margin-top: 10px; min-height: 16px; line-height: 1.4; }
