/* ===== Kevin's Island — full-viewport 3D HUD ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --sand: #f3dfa8;
  --sand-dark: #e0c583;
  --ink: #4a3b28;
  --accent: #2a9d8f;
  --accent-dark: #1d6f65;

  /* Overlay-on-3D surfaces: dark, glassy, warm-tinted */
  --glass-bg: rgba(28, 34, 40, 0.55);
  --glass-bg-strong: rgba(24, 30, 36, 0.72);
  --glass-border: rgba(243, 223, 168, 0.28);
  --glass-text: #f7efdd;
  --glass-muted: rgba(247, 239, 221, 0.62);
  --glass-shadow: 0 8px 28px rgba(0, 20, 30, 0.38);
}

html, body {
  height: 100%;
}
body {
  margin: 0;
  overflow: hidden;
  height: 100dvh;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--glass-text);
  background: linear-gradient(#183c56, #1d6fa5); /* fallback behind the 3D canvas */
}

/* ===== Full-viewport scene ===== */
#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  z-index: 0;
}
/* The 3D renderer injects a <canvas>; make sure it fills. */
#scene canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Rain: subtle vignette darkening (rain itself is rendered in 3D) */
#scene.rainy::after {
  content: "";
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 35%, transparent 45%, rgba(20, 34, 54, 0.42) 100%);
  z-index: 1;
}

/* Status pill — floating overlay, bottom-center */
#scene-caption {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--glass-bg-strong);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 8px 18px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--glass-text);
  box-shadow: var(--glass-shadow);
  max-width: min(70vw, 480px);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 6;
}

/* ===== HUD layer ===== */
#hud {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none; /* let clicks fall through to the 3D world except on real controls */
}
#hud > * { pointer-events: auto; }

/* TOP-LEFT: title */
#title-tag {
  position: absolute;
  top: 14px; left: 16px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--glass-text);
  background: var(--glass-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 5px 12px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  box-shadow: var(--glass-shadow);
}

/* TOP-RIGHT: clock pill */
#clock {
  position: absolute;
  top: 14px; right: 16px;
  display: flex; gap: 10px; align-items: center;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 7px 16px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--glass-text);
  box-shadow: var(--glass-shadow);
}
#clock #weather-label { font-size: 1.15rem; }

/* Mobile-only drawer toggle */
#panel-toggle {
  position: absolute;
  top: 58px; right: 16px;
  display: none;
  width: 44px; height: 44px;
  font-size: 1.3rem;
  align-items: center; justify-content: center;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  color: var(--glass-text);
  cursor: pointer;
  box-shadow: var(--glass-shadow);
}

/* ===== RIGHT SIDE panel ===== */
#side-panel {
  position: absolute;
  top: 62px;
  right: 16px;
  bottom: 16px;
  width: 320px;
  display: flex;
  z-index: 12; /* lift above the journal (esp. the mobile bottom sheet) */
  transition: transform 0.28s ease, opacity 0.2s ease;
}
/* Collapse tab/chevron */
#side-collapse {
  align-self: flex-start;
  margin-top: 6px;
  width: 26px; height: 44px;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-right: none;
  border-radius: 10px 0 0 10px;
  color: var(--glass-text);
  cursor: pointer;
  box-shadow: var(--glass-shadow);
}
#side-collapse .chev { transition: transform 0.25s ease; font-size: 1.2rem; line-height: 1; }
#side-panel.collapsed #side-collapse .chev { transform: rotate(180deg); }

.side-scroll {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--glass-border) transparent;
}
.side-scroll::-webkit-scrollbar { width: 8px; }
.side-scroll::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 8px; }

/* Collapsed state: slide the scroll area away, keep the tab reachable */
#side-panel.collapsed { transform: translateX(calc(100% - 26px)); }

/* ===== Glassy panels ===== */
.panel {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 13px 15px;
  box-shadow: var(--glass-shadow);
  color: var(--glass-text);
}
.panel h2 {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px;
  opacity: 0.8; margin-bottom: 10px; color: var(--sand);
}

.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.bar-row label { width: 84px; font-size: 0.88rem; }
.bar {
  flex: 1; height: 13px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.32); overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.bar-fill { height: 100%; border-radius: 999px; transition: width 1s ease, background 1s; width: 50%; }
.bar-fill.food   { background: linear-gradient(90deg, #e76f51, #f4a261); }
.bar-fill.energy { background: linear-gradient(90deg, #e9c46a, #ffe08a); }
.bar-fill.mood   { background: linear-gradient(90deg, #2a9d8f, #7fd8c9); }
.bar-fill.house  { background: linear-gradient(90deg, #b5651d, #e2a253); }
.bar-fill.low    { background: #ff5a5a !important; }

#wave-btn, #reset-btn, #away-close {
  margin-top: 8px;
  background: var(--accent);
  color: #fff; border: none;
  padding: 8px 14px; border-radius: 10px;
  font-weight: 700; font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--accent-dark);
  transition: transform 0.1s;
}
#wave-btn { width: 100%; }
#wave-btn:active, #reset-btn:active, #away-close:active { transform: translateY(2px); box-shadow: none; }

.inv-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.inv-item {
  display: flex; align-items: center; gap: 6px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px; padding: 6px 12px;
  font-weight: 700; font-size: 1.05rem;
}
.inv-icon { font-size: 1.3rem; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 0.82rem; }
.stats-grid b { color: var(--sand); }

#house-stage-name { font-weight: 800; font-size: 1.1rem; margin-bottom: 6px; }
#house-detail { font-size: 0.82rem; margin-top: 8px; color: var(--glass-muted); }
#house-milestones { margin-top: 10px; font-size: 1.15rem; letter-spacing: 4px; }
#house-milestones .done { filter: none; }
#house-milestones .todo { filter: grayscale(1) opacity(0.3); }

/* Panel footer (reset + hint) */
.panel-footer {
  display: flex; flex-direction: column; gap: 8px;
  padding: 4px 4px 2px;
}
.panel-footer .hint {
  font-size: 0.72rem;
  color: var(--glass-muted);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
#reset-btn {
  background: rgba(200, 107, 74, 0.85);
  box-shadow: 0 3px 0 #8f4a31;
  font-size: 0.8rem;
  padding: 6px 12px;
  align-self: flex-start;
}

/* ===== BOTTOM-LEFT: Journal ===== */
#panel-log {
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: min(370px, calc(100vw - 32px));
  max-height: 40vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
#log-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 15px;
  cursor: pointer;
  user-select: none;
}
#log-header h2 {
  margin: 0;
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px;
  opacity: 0.85; color: var(--sand);
}
#log-header .chev { transition: transform 0.25s ease; opacity: 0.75; }
#panel-log.collapsed #log-header .chev { transform: rotate(-90deg); }

#log-list {
  list-style: none;
  overflow-y: auto;
  padding: 0 12px 12px;
  display: flex; flex-direction: column; gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--glass-border) transparent;
}
#log-list::-webkit-scrollbar { width: 8px; }
#log-list::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 8px; }
#panel-log.collapsed #log-list { display: none; }

#log-list li {
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.26);
  font-size: 0.86rem;
  display: flex; gap: 10px;
}
#log-list li .log-time { color: var(--glass-muted); font-size: 0.78rem; white-space: nowrap; min-width: 74px; }
#log-list li.milestone { background: rgba(233, 196, 106, 0.22); font-weight: 700; }

/* ===== Modal ===== */
.modal {
  position: fixed; inset: 0;
  background: rgba(10, 22, 34, 0.62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--glass-bg-strong);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 26px 30px;
  max-width: 440px; width: 90%;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  color: var(--glass-text);
}
.modal-card h2 { margin-bottom: 8px; color: var(--sand); }
#away-duration { font-weight: 600; margin-bottom: 12px; }
#away-summary { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
#away-summary li { background: rgba(0, 0, 0, 0.28); border-radius: 8px; padding: 6px 10px; }
#away-highlights { font-size: 0.9rem; margin-bottom: 6px; }
#away-highlights div { padding: 4px 0; font-weight: 700; color: #ffcf7a; }

/* ===== Responsive: narrow screens (<700px) ===== */
@media (max-width: 700px) {
  #panel-toggle { display: flex; }

  #side-panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 72vh;
    transform: translateY(100%); /* hidden bottom sheet by default */
    transition: transform 0.3s ease;
  }
  #side-panel.open { transform: translateY(0); }
  #side-panel.collapsed { transform: translateY(100%); } /* collapse == close on mobile */

  #side-collapse {
    align-self: center;
    margin: 0 auto;
    width: 46px; height: 22px;
    border: 1px solid var(--glass-border);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    transform: translateY(-100%);
    position: absolute;
    left: 50%;
    margin-left: -23px;
  }
  #side-collapse .chev { transform: rotate(90deg); }
  #side-panel.collapsed #side-collapse .chev,
  #side-panel.open #side-collapse .chev { transform: rotate(90deg); }

  .side-scroll {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--glass-border);
    border-radius: 16px 16px 0 0;
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    max-height: 72vh;
  }

  #panel-log {
    width: calc(100vw - 32px);
    max-height: 34vh;
    bottom: 16px;
  }

  #title-tag { font-size: 0.9rem; padding: 4px 9px; }
  #clock { padding: 6px 12px; font-size: 0.85rem; }
}

/* Extra-short viewports: keep journal from swallowing the screen */
@media (max-height: 520px) {
  #panel-log { max-height: 46vh; }
  #side-panel { top: 58px; }
}

/* =====================================================
   UI POLISH PASS — toasts, progress, dial, mood, micro-interactions
   ===================================================== */

/* ---- Slightly stronger glass so text stays legible over bright daytime sea ---- */
:root {
  --glass-bg: rgba(26, 32, 38, 0.62);
  --glass-bg-strong: rgba(22, 28, 34, 0.78);
  --gold: #ffcf7a;
  --gold-deep: #e9a53f;
}

/* Consistent focus-visible + cursor feedback on every control */
button { cursor: pointer; }
button:focus-visible,
#log-header:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ===== Caption progress bar (inside the bottom-center pill) ===== */
#scene-caption {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  white-space: normal;
}
#caption-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
#caption-progress {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
  transition: opacity 0.3s ease, height 0.3s ease;
}
#caption-progress.hidden { opacity: 0; height: 0; }
#caption-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #7fd8c9);
  transition: width 0.9s linear;
}

/* ===== Clock dial (sun/moon arc) ===== */
#clock { gap: 9px; }
#clock-dial { width: 40px; height: 24px; flex: 0 0 auto; display: block; }
#dial-arc { stroke: rgba(247, 239, 221, 0.4); stroke-width: 1.4; stroke-dasharray: 2.2 2.6; stroke-linecap: round; }
#dial-horizon { stroke: rgba(247, 239, 221, 0.28); stroke-width: 1; }
#dial-body { fill: #ffd76b; filter: drop-shadow(0 0 3px rgba(255, 208, 90, 0.8)); transition: fill 0.6s ease; }
#clock-dial.night #dial-body { fill: #dce6f2; filter: drop-shadow(0 0 3px rgba(200, 220, 255, 0.7)); }
.clock-labels { display: flex; flex-direction: column; line-height: 1.15; }
.clock-labels #day-label { font-size: 0.7rem; opacity: 0.72; font-weight: 700; letter-spacing: 0.3px; }
.clock-labels #time-label { font-size: 0.98rem; font-weight: 800; }

/* ===== Kevin mood face + activity chip ===== */
#kevin-status { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
#kevin-face {
  font-size: 1.9rem; line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}
#kevin-activity-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 4px 12px 4px 9px;
  font-size: 0.82rem; font-weight: 700;
  color: var(--glass-text);
}
#kevin-activity-icon { font-size: 1.05rem; }

/* ===== Wave button: squash/pop + floating hand ===== */
#wave-btn { position: relative; overflow: visible; }
#wave-btn.wave-pop .wave-btn-label { display: inline-block; }
.wave-float {
  position: absolute;
  left: 50%; top: 8px;
  transform: translateX(-50%);
  font-size: 1.4rem;
  pointer-events: none;
  opacity: 0;
}

/* ===== Journal filter toggle ===== */
#log-header { gap: 8px; }
#log-header h2 { margin-right: auto; }
#log-filter { display: flex; gap: 4px; }
#log-filter button {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--glass-muted);
  font-size: 0.68rem; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#log-filter button.active {
  background: rgba(233, 196, 106, 0.24);
  border-color: rgba(233, 196, 106, 0.5);
  color: var(--gold);
}
#panel-log.filter-milestones #log-list li:not(.milestone) { display: none; }
#log-list li.log-empty { justify-content: center; color: var(--glass-muted); font-style: italic; }

/* ===== Live event toasts ===== */
#toast-stack {
  position: fixed;
  left: 50%;
  bottom: 74px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 40;
  pointer-events: none;
  width: max-content;
  max-width: min(86vw, 440px);
}
.toast {
  pointer-events: auto;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 9px 15px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--glass-text);
  box-shadow: var(--glass-shadow);
  text-align: center;
  max-width: 100%;
  opacity: 0;
  transform: translateY(14px);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.leaving { opacity: 0; transform: translateY(10px) scale(0.96); }
.toast.milestone {
  background: linear-gradient(135deg, rgba(233, 165, 63, 0.9), rgba(180, 110, 30, 0.88));
  border: 1px solid var(--gold);
  color: #fff5e0;
  font-size: 0.98rem;
  font-weight: 800;
  padding: 13px 22px;
  box-shadow: 0 10px 34px rgba(180, 120, 30, 0.5), 0 0 0 1px rgba(255, 207, 122, 0.3) inset;
}
.toast .toast-spark {
  position: absolute;
  top: -6px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
}

/* ===== Critically-low bar pulse ===== */
.bar-fill.low { background: #ff5a5a !important; }

/* ===== Island projects panel ===== */
#projects-list { display: flex; flex-direction: column; gap: 8px; }
.proj {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 5px;
}
.proj-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.proj-name { font-weight: 700; font-size: 0.88rem; }
.proj-hint { font-size: 0.76rem; color: var(--glass-muted); line-height: 1.35; }
.proj-check { color: #8fe3b0; font-weight: 800; }
.proj.built { border-color: rgba(143, 227, 176, 0.35); background: rgba(60, 120, 90, 0.14); }
.proj.locked { opacity: 0.55; }
.proj .bar { height: 9px; }
.focus-btn {
  background: none;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--sand);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 3px 8px;
  flex: 0 0 auto;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}
.focus-btn:hover { background: rgba(233, 196, 106, 0.16); transform: scale(1.08); }
.focus-btn.on { background: rgba(233, 196, 106, 0.32); border-color: #e9c46a; }

/* ===== Welcome-back modal polish ===== */
.modal { animation: none; }
.modal-card { position: relative; overflow: hidden; }
.modal-card h2 { font-size: 1.35rem; }
#away-summary li { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; }
#away-summary li b { color: var(--sand); }
#away-highlights:not(:empty) {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(233, 165, 63, 0.16);
  border: 1px solid rgba(255, 207, 122, 0.4);
}
#away-highlights:not(:empty)::before {
  content: "✨ While you were away";
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gold);
  margin-bottom: 6px;
  font-weight: 800;
}
#away-highlights div {
  padding: 5px 0;
  font-weight: 800;
  font-size: 0.98rem;
  color: #ffe1ad;
}

/* ===== Mobile tweaks ===== */
@media (max-width: 700px) {
  #toast-stack { bottom: 68px; max-width: 90vw; }
  .toast { font-size: 0.8rem; padding: 8px 13px; }
  .toast.milestone { font-size: 0.9rem; padding: 11px 16px; }
  #clock-dial { width: 34px; height: 20px; }
  #log-filter button { font-size: 0.64rem; padding: 3px 6px; }
  #kevin-face { font-size: 1.7rem; }
}

/* =====================================================
   Motion — everything animated lives behind this guard
   ===================================================== */
@media (prefers-reduced-motion: no-preference) {

  /* Panel entrance — staggered, once on load */
  #title-tag, #clock, #side-panel, #panel-log, #scene-caption {
    animation: hud-in 0.55s cubic-bezier(0.2, 0.8, 0.25, 1) both;
  }
  #title-tag { animation-delay: 0.05s; }
  #clock     { animation-delay: 0.12s; }
  #scene-caption { animation-delay: 0.2s; }
  #side-panel { animation-delay: 0.18s; }
  #panel-log  { animation-delay: 0.26s; }
  @keyframes hud-in {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  /* side-panel & log slide from their own edges */
  #side-panel { animation-name: hud-in-right; }
  #panel-log  { animation-name: hud-in-left; }
  @keyframes hud-in-right { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
  @keyframes hud-in-left  { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: translateX(0); } }

  /* Toast slide-in transition */
  .toast { transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
  .toast.milestone.show { animation: toast-pop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.3); }
  @keyframes toast-pop {
    0% { transform: translateY(14px) scale(0.9); }
    60% { transform: translateY(0) scale(1.05); }
    100% { transform: translateY(0) scale(1); }
  }
  /* Milestone sparkle burst */
  .toast .toast-spark { animation: spark-burst 1.1s ease-out forwards; }
  @keyframes spark-burst {
    0%   { opacity: 0; transform: translate(0, 0) scale(0.4) rotate(0deg); }
    30%  { opacity: 1; }
    100% { opacity: 0; transform: translate(var(--sx, 0), var(--sy, -22px)) scale(1.1) rotate(var(--sr, 40deg)); }
  }

  /* Critically-low bar: soft pulse */
  .bar-fill.low { animation: bar-pulse 1.1s ease-in-out infinite; }
  @keyframes bar-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 90, 90, 0); filter: brightness(1); }
    50%      { box-shadow: 0 0 10px 1px rgba(255, 90, 90, 0.7); filter: brightness(1.25); }
  }

  /* Wave button squash/pop */
  #wave-btn.wave-pop { animation: wave-squash 0.4s ease; }
  @keyframes wave-squash {
    0% { transform: scale(1); }
    35% { transform: scale(0.9, 1.08) translateY(2px); }
    70% { transform: scale(1.05, 0.95); }
    100% { transform: scale(1); }
  }
  /* Floating hand rising from the wave button */
  .wave-float { animation: wave-rise 0.9s ease-out forwards; }
  @keyframes wave-rise {
    0%   { opacity: 0; transform: translateX(-50%) translateY(0) scale(0.7); }
    20%  { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) translateY(-46px) scale(1.2) rotate(18deg); }
  }

  /* Fresh journal entry highlight */
  #log-list li.new-entry { animation: entry-in 0.9s ease; }
  @keyframes entry-in {
    0%   { background: rgba(233, 196, 106, 0.5); transform: translateY(-4px); opacity: 0.4; }
    100% { opacity: 1; }
  }

  /* Mood face gets a tiny bounce when it changes */
  #kevin-face.mood-change { animation: face-bounce 0.5s ease; }
  @keyframes face-bounce {
    0%, 100% { transform: scale(1); }
    45% { transform: scale(1.28) rotate(-6deg); }
  }
}
