/* Ice Cream Pop — full-screen 3D canvas with a 2D HTML overlay UI.
   Kid-friendly ice-cream-parlor pinks + sunny yellow. Self-contained: system
   fonts, no network dependencies, so it runs offline in the desktop/mobile
   shells like the other games in this portfolio. */

:root {
  --pink: #ff7bb0;
  --pink-deep: #d63a82;
  --yellow: #ffd23f;
  --mint: #6fcf97;
  --cream: #fff6fb;
  --ink: #3a2435;
  --ui-font: "Baloo 2", "Comic Sans MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--ui-font);
  color: var(--ink);
  background: #fff0f7;
  user-select: none;
}

#game-shell { position: fixed; inset: 0; }
#game-canvas { display: block; width: 100%; height: 100%; touch-action: manipulation; }

/* ===================== HUD ===================== */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px 14px;
  pointer-events: none;
}
#hud .hud-left, #hud .hud-right { display: flex; gap: 8px; align-items: center; }

.pill {
  display: inline-flex;
  align-items: center;
  font-weight: 800;
  font-size: clamp(0.9rem, 3.4vw, 1.2rem);
  padding: 0.32em 0.78em;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
  color: var(--ink);
}
.pill.danger {
  background: #ffdede;
  color: var(--pink-deep);
  animation: messPulse 0.5s ease-in-out infinite alternate;
}
@keyframes messPulse {
  from { box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12); }
  to   { box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12), 0 0 0 7px rgba(214, 58, 130, 0); }
}

#timer-bar {
  flex: 1 0 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 2px;
}
#timer-fill {
  height: 100%;
  width: 100%;
  background: #7bd86f;
  border-radius: 999px;
  transition: width 0.1s linear, background 0.2s;
}
#timer-bar.timer-flash { animation: timerFlash 0.45s ease; }
@keyframes timerFlash {
  0%, 100% { background: rgba(255, 255, 255, 0.55); }
  50% { background: rgba(255, 90, 90, 0.85); }
}

/* ===================== ORDER LIST ===================== */
#list {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  width: min(680px, 96vw);
  pointer-events: none;
}
.list-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
  font-weight: 800;
  font-size: clamp(0.78rem, 3vw, 1rem);
  transition: opacity 0.2s, filter 0.2s;
}
.li-scoop {
  width: 1.1em; height: 1.1em;
  border-radius: 50%;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}
.li-emoji { font-size: 1.05em; }
.li-check { display: none; color: var(--mint); font-size: 1.1em; }
.list-item.done {
  opacity: 0.5;
  filter: grayscale(0.7);
}
.list-item.done .li-label { text-decoration: line-through; }
.list-item.done .li-check { display: inline; }
.list-item.done .li-emoji { display: none; }

/* ===================== TOAST ===================== */
.toast {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  pointer-events: none;
  font-size: clamp(1.3rem, 5.5vw, 2.2rem);
  font-weight: 800;
  padding: 0.3em 0.8em;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  transition: transform 0.22s cubic-bezier(0.2, 1.6, 0.4, 1), opacity 0.22s;
}
.toast-show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.toast-good { color: var(--mint); }
.toast-bad { color: var(--pink-deep); }

/* ===================== OVERLAY SCREENS ===================== */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: radial-gradient(circle at 50% 30%, rgba(255, 233, 245, 0.7), rgba(255, 123, 176, 0.5));
  backdrop-filter: blur(2px);
}
.card {
  background: #fffdf9;
  border: 5px solid var(--pink);
  border-radius: 28px;
  padding: clamp(20px, 5vw, 36px);
  max-width: 540px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(214, 58, 130, 0.3);
}
.card-emoji { font-size: clamp(2.6rem, 12vw, 4rem); }
.card h1 {
  margin: 0.2em 0 0.3em;
  font-size: clamp(1.6rem, 6.6vw, 2.5rem);
  color: var(--pink-deep);
  line-height: 1.05;
}
.card p {
  margin: 0.5em 0;
  font-size: clamp(1rem, 3.6vw, 1.18rem);
  line-height: 1.5;
}
.card .sub { color: #8a7d92; font-size: 1rem; }

.big-btn {
  font-family: inherit;
  cursor: pointer;
  border: none;
  font-weight: 800;
  margin-top: 14px;
  padding: 0.7em 2em;
  font-size: clamp(1.15rem, 4.4vw, 1.5rem);
  color: #fff;
  background: var(--pink);
  border-radius: 999px;
  box-shadow: 0 7px 0 var(--pink-deep);
  transition: transform 0.07s ease, box-shadow 0.07s ease;
}
.big-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--pink-deep); }

/* ===================== LOADING ===================== */
.loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--pink-deep);
  background: #fff0f7;
}

@media (prefers-reduced-motion: reduce) {
  .pill.danger, #timer-bar.timer-flash { animation: none; }
}
