*, *::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;
}

/* blobs */
.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-yellow); top: -140px; left: -80px; }
.blob-2 { width: 340px; height: 340px; background: var(--accent-red); bottom: -100px; right: -60px; animation-delay: -5s; }
.blob-3 { width: 280px; height: 280px; background: var(--accent-teal); 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 */
.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 */
.game-wrapper {
  position: relative; z-index: 1; flex: 1;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 20px 40px; max-width: 520px; margin: 0 auto; width: 100%;
}

/* header */
.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-yellow), var(--accent-red));
  -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); }
}

/* color tray */
.color-tray {
  display: flex; gap: 16px; flex-wrap: wrap; justify-content: center;
  margin-bottom: 28px; animation: fadeDown 0.5s 0.15s ease both;
}

.color-box {
  width: 80px; height: 80px; border-radius: 16px;
  border: 4px solid rgba(255,255,255,0.8);
  box-shadow: var(--shadow-sm); cursor: grab;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  position: relative;
}
.color-box:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-md);
}
.color-box:active, .color-box.dragging {
  cursor: grabbing;
  transform: scale(0.95);
  opacity: 0.7;
}
.color-box.pop-in { animation: boxPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes boxPop {
  0% { opacity: 0; transform: scale(0) rotate(-8deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

.color-box .color-name {
  position: absolute; bottom: -20px; 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;
}

/* mixing zone */
.mix-zone-wrapper {
  margin-bottom: 20px; animation: fadeDown 0.5s 0.25s ease both;
}

.mix-zone {
  width: 220px; height: 180px;
  background: var(--card);
  border: 3px dashed #D1C9CA;
  border-radius: 24px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.5s ease, border-color 0.3s, transform 0.2s;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.mix-zone.drag-over {
  border-color: var(--accent-purple);
  transform: scale(1.04);
  box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.15), var(--shadow-md);
}
.mix-zone.has-color {
  border-style: solid;
  border-color: rgba(255,255,255,0.4);
}

.mix-label {
  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; padding: 0 20px;
}
.mix-label.hidden { opacity: 0; }

/* result swatch */
.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); }

/* buttons */
.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-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); }

/* sparkles */
.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-box { width: 66px; height: 66px; border-radius: 14px; }
  .mix-zone { width: 190px; height: 150px; }
  .btn { padding: 12px 18px; font-size: 0.92rem; }
}
