/* Hungry Hungry Hippos — playful arcade styling */
@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/fredoka-400.woff2") format("woff2");
}
@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/fredoka-600.woff2") format("woff2");
}
@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/fredoka-700.woff2") format("woff2");
}

:root {
  --font-playful: "Fredoka", "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Marker Felt", system-ui, sans-serif;
  --panel-bg: rgba(255, 255, 255, 0.94);
  --ink: #2b3a4a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-playful);
  color: var(--ink);
  background: #1d6f8a;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app { position: fixed; inset: 0; }

#game-canvas, #confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#confetti-canvas { pointer-events: none; z-index: 40; }
#game-canvas { z-index: 1; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  right: max(8px, env(safe-area-inset-right));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  z-index: 20;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }

#score-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 46vw;
}
.chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--panel-bg);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  font-size: clamp(12px, 2.2vmin, 17px);
  font-weight: 700;
  line-height: 1;
}
.chip .dot {
  width: 0.85em;
  height: 0.85em;
  border-radius: 50%;
  box-shadow: inset -1px -2px 2px rgba(0,0,0,0.3);
}
.chip .chip-score { min-width: 1.4em; text-align: right; font-variant-numeric: tabular-nums; }
.chip.bump { animation: chip-bump 0.25s ease; }
@keyframes chip-bump {
  40% { transform: scale(1.18) rotate(-2deg); }
}

#hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
#timer {
  background: var(--panel-bg);
  border-radius: 14px;
  padding: 4px 14px;
  font-size: clamp(16px, 3.4vmin, 26px);
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  font-variant-numeric: tabular-nums;
}
#timer.urgent { color: #d33; animation: timer-pulse 0.5s infinite alternate; }
@keyframes timer-pulse { to { transform: scale(1.1); } }
#marble-count {
  background: rgba(0, 30, 50, 0.55);
  color: #fff;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: clamp(11px, 2vmin, 15px);
  font-weight: 700;
}

.icon-btn {
  border: none;
  background: var(--panel-bg);
  border-radius: 12px;
  font-size: clamp(15px, 3vmin, 22px);
  padding: 6px 10px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.icon-btn:active { transform: scale(0.92); }

/* ---------- Announcements ---------- */
#announce {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  font-size: clamp(20px, 5vmin, 44px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,0.3), 0 0 24px rgba(255, 215, 0, 0.8);
  pointer-events: none;
  animation: announce-pop 1.6s ease forwards;
  white-space: nowrap;
}
@keyframes announce-pop {
  0% { opacity: 0; transform: translateX(-50%) scale(0.4); }
  15% { opacity: 1; transform: translateX(-50%) scale(1.15); }
  25% { transform: translateX(-50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(1.05) translateY(-14px); }
}

/* ---------- Countdown ---------- */
#countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  font-size: clamp(80px, 26vmin, 220px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 6px 0 rgba(0,0,0,0.25), 0 0 40px rgba(255,255,255,0.5);
  pointer-events: none;
}
#countdown.pop { animation: count-pop 0.9s ease; }
@keyframes count-pop {
  0% { transform: scale(1.6); opacity: 0; }
  20% { transform: scale(1); opacity: 1; }
  85% { opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.2; }
}

/* ---------- Overlays (title / results) ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 35;
  background: rgba(10, 40, 60, 0.35);
  backdrop-filter: blur(2px);
  padding: 12px;
}
.panel {
  background: var(--panel-bg);
  border-radius: 26px;
  padding: clamp(16px, 4vmin, 36px) clamp(20px, 5vmin, 48px);
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), inset 0 -6px 0 rgba(0,0,0,0.06);
  max-width: min(92vw, 560px);
  max-height: 92vh;
  overflow-y: auto;
  animation: panel-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes panel-in {
  from { transform: scale(0.7) translateY(30px); opacity: 0; }
}

.game-title {
  display: flex;
  flex-direction: column;
  line-height: 0.95;
  font-size: clamp(34px, 9vmin, 64px);
  font-weight: 900;
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.game-title span:nth-child(1) { color: #ff9f2e; text-shadow: 0 3px 0 #c96f00; }
.game-title span:nth-child(2) { color: #ff6fa5; text-shadow: 0 3px 0 #c74b7e; }
.game-title .hippo-word { color: #58b368; text-shadow: 0 3px 0 #3a8245; }

.tagline { font-size: clamp(13px, 2.6vmin, 18px); margin-bottom: 16px; }
.tagline kbd {
  background: #2b3a4a;
  color: #fff;
  border-radius: 6px;
  padding: 1px 8px;
  font-family: inherit;
  box-shadow: 0 2px 0 #10181f;
}
.hint { font-size: clamp(11px, 2.1vmin, 14px); opacity: 0.75; margin-top: 10px; }
.stats-line { font-size: clamp(12px, 2.2vmin, 15px); font-weight: 700; margin-top: 10px; opacity: 0.85; }

.big-btn {
  font-family: var(--font-playful);
  font-size: clamp(20px, 4.4vmin, 30px);
  font-weight: 900;
  color: #fff;
  background: linear-gradient(180deg, #6fd67f, #3d9e50);
  border: none;
  border-radius: 999px;
  padding: 12px 44px;
  cursor: pointer;
  box-shadow: 0 6px 0 #2b7a3a, 0 10px 18px rgba(0,0,0,0.3);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.big-btn:hover { transform: scale(1.05); }
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #2b7a3a, 0 4px 8px rgba(0,0,0,0.3); }

.small-btn {
  font-family: var(--font-playful);
  margin-top: 12px;
  font-size: clamp(12px, 2.2vmin, 15px);
  font-weight: 700;
  color: var(--ink);
  background: #e8eef2;
  border: none;
  border-radius: 999px;
  padding: 6px 16px;
  cursor: pointer;
  box-shadow: 0 3px 0 #b9c6cf;
}
.small-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #b9c6cf; }

/* ---------- Results ---------- */
#winner-banner {
  font-size: clamp(28px, 7vmin, 52px);
  font-weight: 900;
  margin-bottom: 14px;
  color: #3d9e50;
  text-shadow: 0 3px 0 rgba(0,0,0,0.12);
}
#winner-banner.lost { color: #e0643c; }
#winner-banner.tie { color: #7c6fd0; }

#tallies { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.tally-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f2f6f9;
  border-radius: 14px;
  padding: 8px 14px;
  font-size: clamp(14px, 2.8vmin, 19px);
  font-weight: 800;
}
.tally-row.first { background: #fff4c9; box-shadow: 0 0 0 3px #ffd93b inset; }
.tally-row .dot { width: 1em; height: 1em; border-radius: 50%; box-shadow: inset -1px -2px 2px rgba(0,0,0,0.3); }
.tally-row .tally-name { flex: 1; text-align: left; }
.tally-row .tally-score { font-variant-numeric: tabular-nums; }
.tally-row .crown { font-size: 1.2em; }

/* Landscape phones: tighten panels */
@media (max-height: 500px) {
  .panel { padding: 12px 24px; }
  .game-title { font-size: clamp(26px, 8vmin, 40px); flex-direction: row; gap: 10px; justify-content: center; }
  .tagline { margin-bottom: 8px; }
  .big-btn { padding: 8px 32px; }
}
