:root {
  --c-sun: #ffd23f;
  --c-orange: #ff7b00;
  --c-pink: #ff2e63;
  --c-leaf: #2bd576;
  --c-deep: #06281f;
  --c-ink: #06281f;
  --glass: rgba(255, 255, 255, 0.14);
  --glass-line: rgba(255, 255, 255, 0.35);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --font-display: 'Baloo 2', system-ui, sans-serif;
  --font-body: 'Fredoka', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  color: #fff;
  background: #0a1f1a;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

/* ---------- HUD ---------- */
.hud {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: clamp(14px, 3vw, 32px);
  pointer-events: none;
}
.hud > * { pointer-events: auto; }

.topbar {
  width: min(960px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: clamp(28px, 5vw, 44px);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
  animation: spinBall 6s linear infinite;
}
@keyframes spinBall { to { transform: rotate(360deg); } }

.brand-text h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(22px, 4.4vw, 40px);
  line-height: 1;
  letter-spacing: 0.5px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.18), 0 10px 24px rgba(0, 0, 0, 0.35);
}
.brand-text p {
  margin: 4px 0 0;
  font-size: clamp(11px, 2.4vw, 15px);
  opacity: 0.92;
  font-weight: 500;
}

.live-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: clamp(11px, 2.2vw, 14px);
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.live-pill .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #4dff9b;
  box-shadow: 0 0 0 0 rgba(77, 255, 155, 0.7);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(77, 255, 155, 0.6); }
  100% { box-shadow: 0 0 0 14px rgba(77, 255, 155, 0); }
}

/* ---------- Meter ---------- */
.meter-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(16px, 3vw, 26px);
}

.ring-wrap {
  position: relative;
  width: clamp(240px, 64vw, 360px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.4));
}

.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.16);
  stroke-width: 16;
}
.ring-progress {
  fill: none;
  stroke: url(#ringGrad);
  stroke-width: 16;
  stroke-linecap: round;
  stroke-dasharray: 603.18; /* 2*pi*96 */
  stroke-dashoffset: 603.18;
  transition: stroke-dashoffset 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  filter: drop-shadow(0 0 10px rgba(255, 123, 0, 0.6));
}

.readout {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
}
.value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(54px, 15vw, 96px);
  line-height: 0.9;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.18), 0 14px 30px rgba(0, 0, 0, 0.4);
}
.value .pct { font-size: 0.42em; margin-left: 2px; opacity: 0.9; }
.value.bump { animation: bump 0.35s cubic-bezier(0.3, 1.4, 0.5, 1); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.16); } 100% { transform: scale(1); } }

.label {
  font-weight: 600;
  font-size: clamp(12px, 2.8vw, 17px);
  max-width: 80%;
  opacity: 0.95;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* ---------- Boost button ---------- */
.boost-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 16px 42px;
  border: none;
  cursor: pointer;
  font-family: var(--font-display);
  color: #3a1500;
  border-radius: 28px;
  background: linear-gradient(180deg, #ffe98a 0%, var(--c-sun) 40%, var(--c-orange) 100%);
  box-shadow: 0 10px 0 #c95a00, 0 22px 40px rgba(0, 0, 0, 0.4), inset 0 2px 6px rgba(255, 255, 255, 0.6);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.boost-btn:active {
  transform: translateY(7px);
  box-shadow: 0 3px 0 #c95a00, 0 10px 20px rgba(0, 0, 0, 0.4), inset 0 2px 6px rgba(255, 255, 255, 0.6);
}
.boost-emoji { font-size: clamp(24px, 6vw, 34px); line-height: 1; }
.boost-label { font-weight: 800; font-size: clamp(16px, 3.6vw, 22px); }
.boost-sub { font-family: var(--font-body); font-weight: 600; font-size: 11px; opacity: 0.7; text-transform: uppercase; letter-spacing: 1px; }
.boost-btn:disabled { filter: grayscale(0.5) brightness(0.9); cursor: default; }

/* ---------- Stats ---------- */
.stats { display: flex; gap: 14px; }
.stat {
  min-width: 110px;
  text-align: center;
  padding: 10px 16px;
  border-radius: 16px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.stat-num { display: block; font-family: var(--font-display); font-weight: 800; font-size: clamp(18px, 4vw, 26px); }
.stat-cap { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.8; }

/* ---------- Milestones ---------- */
.bottombar { width: min(960px, 100%); display: flex; justify-content: center; min-height: 28px; }
.milestones { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.milestone {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.2);
  animation: slideUp 0.5s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Floating "+%" pops ---------- */
.pop-layer { position: fixed; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
.pop {
  position: absolute;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(18px, 4vw, 30px);
  color: #fff;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
  animation: floatPop 1s ease-out forwards;
}
@keyframes floatPop {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, -10px) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -90px) scale(0.9); }
}
.pop.pop-neg { color: #9fb6c9; }

/* ---------- Llama speech bubble ---------- */
.llama-bubble {
  position: fixed;
  z-index: 4;
  left: -999px;
  top: -999px;
  transform: translate(-50%, -100%);
  max-width: 260px;
  padding: 12px 16px;
  border-radius: 18px;
  background: #fffdf6;
  color: #3a2a14;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(13px, 2.2vw, 18px);
  line-height: 1.25;
  text-align: center;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  border: 3px solid #ffd23f;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.llama-bubble.show { opacity: 1; visibility: visible; }
.llama-bubble::after {
  content: '';
  position: absolute;
  left: 28px;
  bottom: -14px;
  border-width: 14px 12px 0 0;
  border-style: solid;
  border-color: #ffd23f transparent transparent transparent;
}
.llama-bubble.pop { animation: bubblePop 0.4s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes bubblePop {
  0% { transform: translate(-50%, -100%) scale(0.4); }
  60% { transform: translate(-50%, -100%) scale(1.12); }
  100% { transform: translate(-50%, -100%) scale(1); }
}

/* ---------- Celebration ---------- */
.celebration {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 40%, rgba(255, 200, 60, 0.35), rgba(0, 0, 0, 0.7));
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease;
  text-align: center;
  padding: 24px;
}
.celebration.show { opacity: 1; visibility: visible; }
.celebration-inner { transform: scale(0.8); transition: transform 0.6s cubic-bezier(0.2, 1.5, 0.4, 1); }
.celebration.show .celebration-inner { transform: scale(1); }
.cel-emoji { font-size: clamp(48px, 14vw, 110px); animation: wobble 1.2s ease-in-out infinite; }
@keyframes wobble { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
.celebration h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(30px, 8vw, 64px);
  margin: 8px 0;
  background: linear-gradient(90deg, #ffd23f, #ff7b00, #ff2e63, #ffd23f);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 3s linear infinite;
}
@keyframes shimmer { to { background-position: 300% 0; } }
.celebration p { font-size: clamp(14px, 3.4vw, 22px); font-weight: 600; }

@media (max-width: 480px) {
  .stat { min-width: 90px; }
  .hud { justify-content: space-around; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
}

/* ===================== Control panel ===================== */
.control-body {
  overflow: auto;
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 123, 0, 0.35), transparent 55%),
    radial-gradient(circle at 90% 10%, rgba(255, 46, 99, 0.3), transparent 50%),
    linear-gradient(180deg, #0d3326 0%, #07221b 100%);
}
.control {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: clamp(18px, 5vw, 34px) clamp(16px, 5vw, 28px) 40px;
}
.control-head h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(24px, 6vw, 34px);
  margin: 0;
}
.control-head p { margin: 6px 0 0; opacity: 0.85; font-weight: 500; }

.control-readout {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 22px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  text-align: center;
}
.cr-value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(38px, 12vw, 60px);
  line-height: 1;
}
.cr-value small { font-size: 0.4em; font-weight: 700; opacity: 0.7; }
.cr-bar {
  height: 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  overflow: hidden;
  margin: 14px 0 10px;
}
.cr-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffd23f, #ff7b00, #ff2e63);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.cr-mood { font-weight: 600; opacity: 0.92; }

.entry { display: flex; gap: 10px; }
.entry input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  padding: 16px 18px;
  border-radius: 16px;
  border: 2px solid var(--glass-line);
  background: rgba(255, 255, 255, 0.95);
  color: #1c1208;
  text-align: center;
}
.entry input:focus { outline: 3px solid #ffd23f; }
.add-btn {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  color: #3a1500;
  white-space: nowrap;
  padding: 0 20px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  background: linear-gradient(180deg, #ffe98a, var(--c-orange));
  box-shadow: 0 6px 0 #c95a00, 0 12px 22px rgba(0, 0, 0, 0.35);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.add-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #c95a00, 0 6px 12px rgba(0, 0, 0, 0.35); }

.quick { display: flex; flex-wrap: wrap; gap: 10px; }
.quick-btn {
  flex: 1 1 28%;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  padding: 14px 0;
  border-radius: 14px;
  cursor: pointer;
  color: #fff;
  border: 1px solid var(--glass-line);
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px);
  transition: transform 0.08s ease, background 0.2s ease;
}
.quick-btn:hover { background: rgba(255, 255, 255, 0.24); }
.quick-btn:active { transform: scale(0.95); }
.quick-btn.neg { color: #ffb3c0; }

.reset-btn {
  margin-top: 4px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 12px;
  border-radius: 14px;
  cursor: pointer;
  color: #ffd9d9;
  background: rgba(255, 60, 90, 0.18);
  border: 1px solid rgba(255, 120, 140, 0.4);
}
.reset-btn:hover { background: rgba(255, 60, 90, 0.3); }
.hint { text-align: center; font-size: 13px; opacity: 0.7; }

