* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: linear-gradient(180deg, #f6e3c9 0%, #efd0a8 45%, #e2b888 100%);
  color: #4a2e1a;
  font-family: 'Fredoka', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  overflow: hidden;
}

#game {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
  touch-action: none;
  cursor: crosshair;
}

#ui {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  pointer-events: none;
  z-index: 2;
}

#scoreboard {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.score-item {
  pointer-events: auto;
  background: rgba(255, 248, 238, 0.9);
  color: #4a2e1a;
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: 0 8px 24px rgba(90, 40, 10, 0.16);
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.score-item .label { opacity: 0.7; font-size: 13px; }
.score-item span:last-child { font-weight: 700; font-size: 20px; }

#meters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.meter {
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 248, 238, 0.9);
  border-radius: 999px;
  padding: 7px 14px 7px 10px;
  box-shadow: 0 8px 24px rgba(90, 40, 10, 0.16);
}
.meter-icon { font-size: 18px; line-height: 1; }
.meter-track {
  display: block;
  width: 92px;
  height: 12px;
  border-radius: 999px;
  background: rgba(74, 46, 26, 0.14);
  overflow: hidden;
}
.meter-tag {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0.6;
  white-space: nowrap;
}
.meter-tag.is-on { color: #d00000; opacity: 1; }
.meter-tag.is-stalled { color: #0e7490; opacity: 1; }
.meter-fill {
  display: block;
  height: 100%;
  width: 30%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7ec8ff, #ffd166 55%, #ff6b3d);
  transition: width 120ms linear;
}
.meter.is-hot .meter-fill { background: linear-gradient(90deg, #ffb347, #ff5a3d); }
.meter.is-hot { animation: meterPanic 620ms ease-in-out infinite; }
@keyframes meterPanic {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.hearts {
  pointer-events: none;
  background: rgba(255, 248, 238, 0.9);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 17px;
  letter-spacing: 2px;
  line-height: 1;
  box-shadow: 0 8px 24px rgba(90, 40, 10, 0.16);
}

.mood-chip {
  pointer-events: none;
  background: rgba(255, 248, 238, 0.9);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(90, 40, 10, 0.16);
  white-space: nowrap;
}
.mood-chip.is-zoomies {
  background: linear-gradient(180deg, #ffe566, #ffb347);
  animation: zoomPulse 380ms ease-in-out infinite;
}
.mood-chip.is-sleepy { opacity: 0.92; }
.mood-chip.is-cross {
  background: linear-gradient(180deg, #ffb3a7, #ef7462);
  color: #5c1c10;
}
@keyframes zoomPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.combo-chip {
  pointer-events: none;
  background: linear-gradient(180deg, #ffd166, #f0a04a);
  color: #4a2e1a;
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(200, 130, 30, 0.28);
  animation: comboPop 220ms ease;
}
.combo-chip.is-hidden { display: none; }
@keyframes comboPop {
  from { transform: scale(0.75); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

#controls { pointer-events: auto; display: flex; gap: 8px; align-items: center; }
#restart, #play, #homeBtn, #mute, .home-link {
  cursor: pointer;
  border: none;
  background: linear-gradient(180deg, #f0a04a, #d97828);
  color: white;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 15px;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  box-shadow: 0 8px 24px rgba(180, 90, 20, 0.35);
}
#mute { padding: 10px 12px; }
#homeBtn, .home-link {
  background: linear-gradient(180deg, #ff7eb6, #e85a9a);
  box-shadow: 0 8px 24px rgba(200, 60, 120, 0.28);
}
#restart:hover, #play:hover, #homeBtn:hover, #mute:hover, .home-link:hover { filter: brightness(1.08); }
#restart:active, #play:active, #homeBtn:active, #mute:active, .home-link:active { filter: brightness(0.94); }

#weeAlert {
  position: absolute;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd166, #f0a04a);
  color: #4a2e1a;
  font-weight: 700;
  font-size: 18px;
  white-space: nowrap;
  box-shadow: 0 12px 34px rgba(200, 120, 20, 0.4);
  animation: weePulse 520ms ease-in-out infinite;
  pointer-events: none;
}
#weeAlert.hidden { display: none; }
#weeAlert.is-urgent {
  background: linear-gradient(180deg, #ff8a5c, #e03c2f);
  color: #fff;
  box-shadow: 0 12px 34px rgba(220, 60, 30, 0.45);
}
.wee-emoji { font-size: 22px; }
@keyframes weePulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.05); }
}

#overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(74, 40, 16, 0.42);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 4;
  padding: 16px;
}
#overlay.show { opacity: 1; pointer-events: auto; }
#overlay .panel {
  background: #fffaf3;
  color: #4a2e1a;
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 24px 70px rgba(90, 40, 10, 0.35);
}
#overlay h1 { margin: 0 0 8px; font-size: 30px; }
#overlay p { opacity: 0.88; line-height: 1.45; margin: 0 0 10px; }
#overlay .hint { font-size: 14px; opacity: 0.72; margin-bottom: 16px; }
#overlay .legend {
  display: grid;
  gap: 6px;
  margin: 12px 0 16px;
  font-size: 15px;
}
#overlay .legend.hidden { display: none; }
#overlay .legend span { opacity: 0.92; }
.overlay-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

@media (max-width: 560px) {
  #ui { gap: 6px; top: 8px; left: 8px; right: 8px; }
  #meters { gap: 6px; }
  .meter { padding: 5px 10px 5px 8px; gap: 6px; }
  .meter-track { width: 62px; height: 10px; }
  .meter-icon { font-size: 15px; }
  .hearts { padding: 5px 9px; font-size: 14px; letter-spacing: 1px; }
  .mood-chip { padding: 5px 9px; font-size: 12px; }
  .combo-chip { padding: 5px 9px; font-size: 12px; }
  .meter-tag { display: none; }
  .score-item { padding: 5px 9px; gap: 5px; }
  .score-item .label { font-size: 11px; }
  .score-item span:last-child { font-size: 15px; }
  #weeAlert { font-size: 14px; padding: 9px 14px; top: 76px; }
  #controls { gap: 6px; }
  #restart, #play, #homeBtn, #mute, .home-link { padding: 8px 11px; font-size: 13px; border-radius: 10px; }
  #overlay .panel { padding: 18px; }
  #overlay h1 { font-size: 24px; }
  #overlay .legend { font-size: 13.5px; }
}
