* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

body {
  font-family: "Jua", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  background: linear-gradient(180deg, #ffe3ee 0%, #fff4d6 55%, #e3f6ff 100%);
  color: #5b3a4a;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 8px) 12px calc(env(safe-area-inset-bottom) + 8px);
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- HUD ---------- */
#hud {
  display: flex;
  align-items: stretch;
  gap: 8px;
  height: 92px;
  flex: none;
}
.hud-box {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 3px 0 #f2b8cc;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.score-box { flex: 1; min-width: 0; align-items: flex-start; }
.hud-label { font-size: 17px; color: #d77a9b; }
.hud-value { font-size: 40px; line-height: 1.05; color: #5b3a4a; }
.hud-value.bump { animation: bump .25s ease-out; }
.hud-sub { font-size: 15px; color: #a07c8c; }
.next-box { width: 168px; padding: 4px 6px; }
#next { width: 156px; height: 58px; }
.icon-btn {
  width: 60px;
  border: 0;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 3px 0 #f2b8cc;
  font-size: 28px;
  cursor: pointer;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #f2b8cc; }

@keyframes bump { 0% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* ---------- Stage ---------- */
#stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
}
#game {
  display: block;
  border-radius: 22px;
  border: 5px solid #fff;
  box-shadow: 0 6px 0 #f2b8cc, 0 10px 30px rgba(214, 120, 160, .25);
  background: #fffaf0;
}

/* ---------- Evolution chain ---------- */
#bottom {
  flex: none;
  height: 72px;
  display: flex;
  gap: 8px;
  align-items: center;
}
#chain-wrap {
  flex: 1;
  min-width: 0;
  height: 56px;
  background: rgba(255, 255, 255, .75);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#chain { width: 100%; height: 100%; }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 230, 240, .72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 10;
  padding: 16px;
}
.overlay.show { display: flex; animation: fadein .25s ease-out; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.card {
  background: #fff;
  border-radius: 28px;
  box-shadow: 0 6px 0 #f2b8cc, 0 16px 40px rgba(214, 120, 160, .3);
  padding: 22px 26px 26px;
  text-align: center;
  width: min(360px, 100%);
  animation: pop .35s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes pop { from { transform: scale(.7); } to { transform: scale(1); } }

.card h1 { font-size: 40px; font-weight: 400; color: #e0638d; margin: 4px 0 8px; }
.card h2 { font-size: 36px; font-weight: 400; color: #e0638d; margin-bottom: 8px; }
.card p { font-size: 21px; line-height: 1.45; color: #7a5566; }
.card .hint { font-size: 16px; color: #b08a9b; margin-top: 12px; }
#title-art { width: 190px; height: 190px; }

.big-btn {
  margin-top: 16px;
  border: 0;
  border-radius: 999px;
  padding: 14px 48px;
  font: inherit;
  font-size: 28px;
  color: #fff;
  background: linear-gradient(180deg, #ff8fb3, #f2648f);
  box-shadow: 0 5px 0 #c94671;
  cursor: pointer;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #c94671; }

.badge {
  display: none;
  margin: 0 auto 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #fff1a8;
  color: #b07a00;
  font-size: 20px;
  width: fit-content;
}
.badge.show { display: block; animation: pop .4s cubic-bezier(.2, 1.6, .4, 1); }
.final-label { font-size: 19px; color: #d77a9b; margin-top: 6px; }
.final-score { font-size: 64px; color: #5b3a4a; line-height: 1.1; }
.final-sub { font-size: 19px; color: #8a6677; margin-top: 4px; }

.lang-btn {
  margin-top: 12px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 16px;
  color: #c27a97;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- Bomb button with a ring gauge (--p = 0..100) ---------- */
.bomb-btn {
  --p: 0;
  position: relative;
  flex: none;
  width: 70px;
  height: 70px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: conic-gradient(#ff6b9a calc(var(--p) * 1%), #f3dce6 0);
  box-shadow: 0 4px 0 #f2b8cc;
  cursor: pointer;
}
.bomb-btn::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: #fff;
}
.bomb-btn img {
  position: absolute;
  inset: 6px;
  width: 58px;
  height: 58px;
  filter: grayscale(.85) opacity(.55);
  transition: filter .2s;
}
.bomb-tag {
  position: absolute;
  left: 50%;
  top: -14px;
  transform: translateX(-50%);
  padding: 1px 8px;
  border-radius: 999px;
  background: #ff4d7a;
  color: #fff;
  font-size: 15px;
  white-space: nowrap;
  display: none;
}
.bomb-btn.ready { background: conic-gradient(#ffc93c 0 100%); animation: ready-pulse .8s ease-in-out infinite; }
.bomb-btn.ready img { filter: none; animation: wiggle .5s ease-in-out infinite; }
.bomb-btn.ready .bomb-tag { display: block; }
.bomb-btn:disabled { cursor: default; }
@keyframes ready-pulse { 0%, 100% { box-shadow: 0 4px 0 #e0a100, 0 0 0 0 rgba(255,201,60,.7); } 50% { box-shadow: 0 4px 0 #e0a100, 0 0 0 10px rgba(255,201,60,0); } }
@keyframes wiggle { 0%, 100% { transform: rotate(-8deg) scale(1.05); } 50% { transform: rotate(8deg) scale(1.12); } }

#flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at var(--fx, 50%) var(--fy, 50%), #fff 0, #fff6c8 35%, rgba(255,200,120,.0) 75%);
  opacity: 0;
  z-index: 5;
}
