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

:root {
  --bg: #FFF7EC;
  --text: #3D2C2E;
  --text-muted: #8B7E80;
  --card: #ffffff;
  --accent-red: #FF6B6B;
  --accent-teal: #4ECDC4;
  --accent-yellow: #FFD93D;
  --accent-purple: #6C5CE7;
  --shadow-sm: 0 4px 12px rgba(61, 44, 46, 0.08);
  --shadow-md: 0 8px 28px rgba(61, 44, 46, 0.12);
  --radius: 20px;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.blob { position: fixed; border-radius: 50%; filter: blur(90px); opacity: 0.25; z-index: 0; animation: blobFloat 14s ease-in-out infinite alternate; pointer-events: none; }
.blob-1 { width: 380px; height: 380px; background: var(--accent-red); top: -140px; left: -80px; }
.blob-2 { width: 340px; height: 340px; background: var(--accent-teal); bottom: -100px; right: -60px; animation-delay: -5s; }
.blob-3 { width: 280px; height: 280px; background: var(--accent-yellow); top: 35%; left: 55%; animation-delay: -9s; }
@keyframes blobFloat {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(24px, -32px) scale(1.06); }
}

.top-bar { position: relative; z-index: 2; padding: 16px 20px; }
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'Nunito', sans-serif; font-weight: 700; font-size: 0.95rem;
  color: var(--text-muted); text-decoration: none;
  padding: 8px 14px; border-radius: 14px;
  background: rgba(255,255,255,0.6); backdrop-filter: blur(8px);
  transition: background 0.2s, color 0.2s;
}
.back-btn:hover { background: rgba(255,255,255,0.9); color: var(--text); }

.game-wrapper {
  position: relative; z-index: 1; flex: 1;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 20px 40px; max-width: 480px; margin: 0 auto; width: 100%;
}

.game-header { text-align: center; margin-bottom: 20px; animation: fadeDown 0.5s ease both; }
.game-header h1 {
  font-family: 'Baloo 2', cursive; font-weight: 800;
  font-size: clamp(2rem, 5vw, 2.8rem);
  background: linear-gradient(135deg, var(--accent-red), var(--accent-purple));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.emoji-bounce {
  display: inline-block; -webkit-text-fill-color: initial;
  animation: emojiBounce 2s ease-in-out infinite;
}
@keyframes emojiBounce {
  0%, 100% { transform: translateY(0) rotate(0); }
  25%  { transform: translateY(-6px) rotate(-8deg); }
  75%  { transform: translateY(-3px) rotate(6deg); }
}
.subtitle { font-size: 1rem; font-weight: 600; color: var(--text-muted); margin-top: 2px; }
@keyframes fadeDown {
  0% { opacity: 0; transform: translateY(-18px); }
  100% { opacity: 1; transform: translateY(0); }
}

.palette {
  display: flex; gap: 14px; flex-wrap: wrap; justify-content: center;
  margin-bottom: 24px; animation: fadeDown 0.5s 0.15s ease both;
}
.color-orb {
  width: 62px; height: 62px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.8);
  box-shadow: var(--shadow-sm); cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  position: relative;
}
.color-orb::after {
  content: '+'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 800; color: rgba(255,255,255,0.75);
  opacity: 0; transition: opacity 0.2s;
}
.color-orb:hover::after { opacity: 1; }
.color-orb:hover { transform: scale(1.18); box-shadow: var(--shadow-md); }
.color-orb:active { transform: scale(0.92); }
.color-orb.used { opacity: 0.35; transform: scale(0.88); pointer-events: none; box-shadow: none; }
.color-orb.pop-in { animation: orbPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes orbPop {
  0% { opacity: 0; transform: scale(0); }
  100% { opacity: 1; transform: scale(1); }
}

.color-orb .color-name {
  position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%);
  font-family: 'Nunito', sans-serif; font-size: 0.72rem; font-weight: 700;
  color: var(--text-muted); white-space: nowrap; pointer-events: none;
}

.bottle-stage {
  display: flex; justify-content: center; align-items: center;
  margin-bottom: 14px; animation: fadeDown 0.5s 0.25s ease both;
}
.bottle-wrapper { position: relative; width: 180px; }
.bottle-svg {
  width: 100%; height: auto;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.08));
  transition: transform 0.3s ease;
}
.bottle-svg.shaking { animation: bottleShake 0.6s ease-in-out 3; }
@keyframes bottleShake {
  0%, 100% { transform: rotate(0); }
  15% { transform: rotate(12deg) translateX(4px); }
  30% { transform: rotate(-10deg) translateX(-4px); }
  45% { transform: rotate(8deg) translateX(3px); }
  60% { transform: rotate(-6deg) translateX(-2px); }
  75% { transform: rotate(4deg) translateX(1px); }
  90% { transform: rotate(-2deg); }
}
.color-layer { transition: y 0.4s cubic-bezier(0.34,1.56,0.64,1), height 0.4s cubic-bezier(0.34,1.56,0.64,1); }
.color-layer.pouring { animation: pourIn 0.5s ease-out both; }
@keyframes pourIn { 0% { opacity: 0.3; } 100% { opacity: 1; } }

.empty-label {
  position: absolute; top: 63%; left: 50%; transform: translate(-50%, -50%);
  font-family: 'Baloo 2', cursive; font-size: 1rem; font-weight: 700;
  color: var(--text-muted); pointer-events: none; opacity: 0.7; transition: opacity 0.3s;
  text-align: center; width: 80px;
}
.empty-label.hidden { opacity: 0; }

.result-swatch {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; background: var(--card); border-radius: 50px;
  box-shadow: var(--shadow-sm); margin-bottom: 20px;
  opacity: 0; transform: translateY(10px) scale(0.9);
  transition: opacity 0.4s, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.result-swatch.visible { opacity: 1; transform: translateY(0) scale(1); }
.swatch-circle {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid rgba(0,0,0,0.06); flex-shrink: 0;
}
.swatch-name { font-family: 'Baloo 2', cursive; font-weight: 700; font-size: 1rem; color: var(--text); }

.actions {
  display: flex; gap: 12px; flex-wrap: wrap; justify-content: center;
  animation: fadeDown 0.5s 0.4s ease both;
}
.btn {
  font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 1rem;
  border: none; border-radius: 16px; padding: 14px 24px; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.25s, opacity 0.3s;
}
.btn:active { transform: scale(0.93); }
.btn:disabled { opacity: 0.35; pointer-events: none; }
.btn-icon { font-size: 1.2rem; display: inline-block; }

.btn-shake {
  background: linear-gradient(135deg, var(--accent-purple), #a78bfa);
  color: #fff; box-shadow: 0 4px 16px rgba(108,92,231,0.35);
}
.btn-shake:hover:not(:disabled) { box-shadow: 0 8px 28px rgba(108,92,231,0.45); transform: translateY(-2px); }

.btn-clear { background: var(--card); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-clear:hover:not(:disabled) { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.btn-new {
  background: linear-gradient(135deg, var(--accent-teal), #38b2ac);
  color: #fff; box-shadow: 0 4px 16px rgba(78,205,196,0.35);
}
.btn-new:hover { box-shadow: 0 8px 28px rgba(78,205,196,0.45); transform: translateY(-2px); }

.sparkle {
  position: absolute; width: 8px; height: 8px; border-radius: 50%;
  pointer-events: none; animation: sparklePop 0.7s ease-out forwards;
}
@keyframes sparklePop {
  0%   { opacity: 1; transform: translate(0,0) scale(1); }
  100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0); }
}

@media (max-width: 400px) {
  .color-orb { width: 52px; height: 52px; }
  .bottle-wrapper { width: 150px; }
  .btn { padding: 12px 18px; font-size: 0.92rem; }
}
