:root {
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #14161c;
  color: #e6e6ec;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#app {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.2rem 1.6rem;
  gap: 0.8rem;
}

.top-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.title-group { display: flex; align-items: baseline; gap: 0.6rem; }

.page-title {
  font-size: clamp(1.2rem, 2.6vw, 1.7rem);
  font-weight: 700;
  color: #ffb84d;
  letter-spacing: 0.02em;
}

.page-sub {
  font-size: 0.85rem;
  color: #9a9aa8;
}

.back-link {
  color: #7fbfff;
  text-decoration: none;
  font-size: 0.9rem;
  opacity: 0.8;
}
.back-link:hover { opacity: 1; text-decoration: underline; }

.stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 5vw, 4rem);
  min-height: 0;
  background: radial-gradient(ellipse at 50% 30%, #1d2130 0%, #14161c 70%);
  border-radius: 1rem;
  border: 1px solid #23273a;
  overflow: hidden;
}

.pepe-wrap {
  width: min(38vh, 34vw, 320px);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}
.pepe-wrap.bounce { animation: pepe-bounce 0.4s ease; }
.pepe-wrap.max-cheer { animation: pepe-cheer 0.6s ease infinite; }

@keyframes pepe-bounce {
  0% { transform: scale(1); }
  35% { transform: scale(1.06) translateY(-4px); }
  100% { transform: scale(1); }
}
@keyframes pepe-cheer {
  0%, 100% { transform: rotate(-3deg) scale(1.03); }
  50% { transform: rotate(3deg) scale(1.08); }
}

#pepe-svg { width: 100%; height: 100%; overflow: visible; }

.pupil { transition: cy 0.2s ease; }
.blush { transition: opacity 0.3s ease; }

.wing { transition: transform 0.2s ease; transform-box: fill-box; }
#pepe-wing-l { transform-origin: 100% 30%; }
#pepe-wing-r { transform-origin: 0% 30%; }

.carton-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
}

#carton {
  width: clamp(70px, 12vw, 110px);
  cursor: pointer;
  transform-origin: 20% 90%;
  transition: transform 0.18s cubic-bezier(.34,1.56,.64,1);
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.4));
}
#carton:active,
#carton.pouring {
  transform: rotate(-55deg) translate(6px, -6px);
}
#carton:focus { outline: 2px solid #ffb84d; outline-offset: 4px; border-radius: 8px; }

.carton-hint {
  font-size: 0.78rem;
  color: #8b8b9a;
}

#splash-layer, #confetti-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.drip {
  position: absolute;
  width: 6px;
  height: 12px;
  background: #ff9f1c;
  border-radius: 50% 50% 60% 60%;
  top: 0;
  animation: drip-fall linear forwards;
}
@keyframes drip-fall {
  to { transform: translateY(220px); opacity: 0.2; }
}

.confetti-piece {
  position: absolute;
  top: -10px;
  width: 8px;
  height: 8px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(120vh) rotate(540deg); opacity: 0.3; }
}

.meter-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.meter-label {
  font-size: 0.85rem;
  color: #b0b0bd;
  min-width: 5.5rem;
}

.meter-bg {
  flex: 1;
  height: 1rem;
  background: #23273a;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #2f3448;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffb84d, #ff9f1c, #ff7a1c);
  transition: width 0.15s ease;
}

.meter-pct {
  font-size: 0.85rem;
  color: #ffb84d;
  min-width: 3rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stats-row {
  display: flex;
  gap: 2rem;
  justify-content: center;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-num {
  font-size: clamp(1.1rem, 2.2vw, 1.5rem);
  font-weight: 700;
  color: #7fe0a0;
  font-variant-numeric: tabular-nums;
}

.stat-name {
  font-size: 0.75rem;
  color: #8b8b9a;
}

#banner {
  position: absolute;
  left: 50%;
  top: 12%;
  transform: translate(-50%, -12px);
  font-size: clamp(1.1rem, 3vw, 1.8rem);
  font-weight: 800;
  color: #ffe08a;
  text-shadow: 0 2px 12px rgba(255, 159, 28, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
}
#banner.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
