/* Hungry Hungry Hippos — toy-box bounce styling */

@font-face {
  font-family: 'Fredoka';
  src: url('../assets/fonts/fredoka-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --pond-deep: #1899b8;
  --pond-mid: #35c0cf;
  --pond-lite: #7ed6c9;
  --cream: #fff7e8;
  --ink: #4a3728;
  --c-orange: #ff8c42;
  --c-green: #6fcf5f;
  --c-pink: #ff6fa5;
  --c-yellow: #ffd23f;
  --panel: rgba(255, 250, 238, 0.92);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: 'Fredoka', 'Comic Sans MS', 'Chalkboard SE', 'Segoe UI', sans-serif;
  background:
    radial-gradient(120% 120% at 50% 0%, #b8f0e4 0%, #7ed6c9 42%, #58c4c4 78%, #3faebd 100%);
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

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

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

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

.chip {
  background: var(--panel);
  border: 3px solid #fff;
  border-radius: 999px;
  box-shadow: 0 3px 0 rgba(74,55,40,.25), 0 6px 14px rgba(20,80,90,.18);
  padding: 6px 16px;
  font-weight: 700;
  font-size: clamp(16px, 2.4vmin, 22px);
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.timer-chip { min-width: 4.2em; justify-content: center; font-variant-numeric: tabular-nums; }
.timer-chip.urgent { color: #e5383b; animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.12); } }

.mini-marble {
  width: 1em; height: 1em; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #fff 0%, #ffd9e8 18%, #ff6fa5 55%, #c9457c 100%);
  box-shadow: inset -1px -2px 3px rgba(0,0,0,.25);
  display: inline-block;
}
.marble-chip { font-variant-numeric: tabular-nums; }

.icon-btn {
  pointer-events: auto;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: var(--panel);
  font-size: 19px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(74,55,40,.25), 0 6px 14px rgba(20,80,90,.18);
  display: flex; align-items: center; justify-content: center;
  transition: transform .08s ease;
  color: var(--ink);
}
.icon-btn:active { transform: scale(.9); }
.icon-btn.off { opacity: .55; filter: grayscale(.6); }

/* tap hint */
#tapHint {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex; gap: 8px; align-items: center;
  font-weight: 700;
  font-size: clamp(13px, 2vmin, 17px);
  color: #fff;
  text-shadow: 0 2px 4px rgba(20,70,80,.5);
  opacity: .95;
  transition: opacity .4s ease;
  pointer-events: none;
}
#tapHint .tap-key, #tapHint .tap-tap {
  background: rgba(255,255,255,.22);
  border: 2px solid rgba(255,255,255,.65);
  padding: 3px 10px; border-radius: 10px;
  backdrop-filter: blur(2px);
}
#tapHint .tap-or { font-weight: 500; font-style: italic; }
#tapHint.faded { opacity: 0; }

/* ---------- Score chips ---------- */
#scoreboard { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.score-chip {
  position: absolute;
  display: flex; align-items: center; gap: 8px;
  padding: 5px 14px 5px 8px;
  border-radius: 999px;
  border: 3px solid #fff;
  font-weight: 700;
  font-size: clamp(14px, 2.2vmin, 20px);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
  box-shadow: 0 3px 0 rgba(74,55,40,.3), 0 6px 14px rgba(20,80,90,.2);
  transition: transform .12s ease;
}
.score-chip.bump { transform: scale(1.18); }
.score-chip .chip-name { letter-spacing: .02em; }
.score-chip .chip-score {
  background: rgba(255,255,255,.92);
  color: var(--ink);
  border-radius: 999px;
  min-width: 1.9em;
  text-align: center;
  padding: 1px 8px;
  font-variant-numeric: tabular-nums;
}
.score-chip.pos-bottom { left: 50%; bottom: max(46px, calc(env(safe-area-inset-bottom) + 40px)); transform: translateX(-50%); }
.score-chip.pos-bottom.bump { transform: translateX(-50%) scale(1.18); }
.score-chip.pos-top { left: 50%; top: max(56px, calc(env(safe-area-inset-top) + 50px)); transform: translateX(-50%); }
.score-chip.pos-top.bump { transform: translateX(-50%) scale(1.18); }
.score-chip.pos-left { left: max(8px, env(safe-area-inset-left)); top: 50%; transform: translateY(-50%) rotate(-90deg); transform-origin: left center; left: max(38px, calc(env(safe-area-inset-left) + 34px)); }
.score-chip.pos-left.bump { transform: translateY(-50%) rotate(-90deg) scale(1.18); }
.score-chip.pos-right { right: max(8px, env(safe-area-inset-right)); top: 50%; transform: translateY(-50%) rotate(90deg); transform-origin: right center; right: max(38px, calc(env(safe-area-inset-right) + 34px)); }
.score-chip.pos-right.bump { transform: translateY(-50%) rotate(90deg) scale(1.18); }
.score-chip.you { border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.35), 0 3px 0 rgba(74,55,40,.3), 0 6px 16px rgba(20,80,90,.3); }

/* ---------- Center callouts ---------- */
.center-callout {
  position: absolute; left: 50%; top: 42%;
  transform: translate(-50%,-50%);
  font-size: clamp(64px, 16vmin, 150px);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 4px 0 rgba(74,55,40,.35), 0 10px 30px rgba(20,80,90,.4);
  z-index: 8;
  pointer-events: none;
}
.center-callout.pop { animation: calloutPop .55s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes calloutPop {
  0% { transform: translate(-50%,-50%) scale(.2); opacity: 0; }
  60% { transform: translate(-50%,-50%) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(1); opacity: 1; }
}
.center-callout.go { color: var(--c-yellow); }

.banner {
  position: absolute; left: 50%; top: 20%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #ffe27a, #ffb347);
  border: 3px solid #fff;
  border-radius: 18px;
  padding: 10px 26px;
  font-size: clamp(20px, 4.4vmin, 34px);
  font-weight: 700;
  color: #7a3c00;
  text-shadow: 0 1px 0 rgba(255,255,255,.6);
  box-shadow: 0 4px 0 rgba(74,55,40,.3), 0 10px 26px rgba(20,80,90,.3);
  z-index: 8;
  pointer-events: none;
  white-space: nowrap;
}
.banner.pop { animation: bannerPop .5s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes bannerPop {
  0% { transform: translateX(-50%) scale(.3) rotate(-6deg); opacity: 0; }
  70% { transform: translateX(-50%) scale(1.08) rotate(2deg); opacity: 1; }
  100% { transform: translateX(-50%) scale(1) rotate(0); opacity: 1; }
}
.banner.blue { background: linear-gradient(180deg, #b5ecff, #5cc3ea); color: #0c4d6b; }

/* ---------- Screens ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
  padding: 14px;
  background: radial-gradient(80% 80% at 50% 45%, rgba(20,90,105,.12), rgba(15,70,85,.34));
}
.panel {
  background: var(--panel);
  border: 4px solid #fff;
  border-radius: 28px;
  box-shadow: 0 6px 0 rgba(74,55,40,.25), 0 20px 50px rgba(10,60,75,.35);
  padding: clamp(18px, 3.4vmin, 34px) clamp(20px, 4vmin, 44px);
  text-align: center;
  max-width: min(560px, 94vw);
  max-height: calc(100vh - 28px);
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  backdrop-filter: blur(3px);
}

.logo {
  display: flex; flex-direction: column;
  font-size: clamp(40px, 9vmin, 74px);
  line-height: .95;
  letter-spacing: .01em;
  color: var(--c-orange);
  text-shadow: 0 3px 0 #fff, 0 6px 0 rgba(74,55,40,.25);
  animation: logoBob 2.2s ease-in-out infinite;
}
.logo span:nth-child(2) { color: var(--c-pink); }
.logo .logo-hippos { color: var(--c-green); font-size: 1.14em; }
@keyframes logoBob {
  0%,100% { transform: rotate(-1.2deg) scale(1); }
  50% { transform: rotate(1.2deg) scale(1.03); }
}
.tagline { font-size: clamp(14px, 2.6vmin, 19px); font-weight: 600; opacity: .75; margin: 10px 0 18px; }

.big-btn {
  font-family: inherit;
  font-size: clamp(22px, 4.6vmin, 34px);
  font-weight: 700;
  letter-spacing: .03em;
  color: #fff;
  background: linear-gradient(180deg, #ff9d5c, #ff7a2f);
  border: 4px solid #fff;
  border-radius: 999px;
  padding: 12px 46px;
  cursor: pointer;
  box-shadow: 0 5px 0 #c25a17, 0 10px 24px rgba(20,80,90,.3);
  transition: transform .1s ease, box-shadow .1s ease;
  text-shadow: 0 2px 0 rgba(0,0,0,.18);
}
.big-btn:hover { transform: translateY(-2px) scale(1.03); }
.big-btn:active { transform: translateY(3px) scale(.97); box-shadow: 0 2px 0 #c25a17, 0 6px 14px rgba(20,80,90,.3); }

.title-row { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.small-btn {
  font-family: inherit;
  font-size: clamp(14px, 2.4vmin, 17px);
  font-weight: 600;
  color: var(--ink);
  background: #fff;
  border: 3px solid #e8dcc8;
  border-radius: 999px;
  padding: 8px 20px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(74,55,40,.18);
  transition: transform .08s ease;
}
.small-btn:hover { transform: translateY(-1px); }
.small-btn:active { transform: translateY(2px); }
.small-btn.off { opacity: .6; }

.how-panel {
  margin-top: 14px;
  background: rgba(255,255,255,.65);
  border: 2px dashed #d9c9a8;
  border-radius: 16px;
  padding: 12px 16px;
  font-size: clamp(13px, 2.2vmin, 16px);
  line-height: 1.45;
  text-align: left;
}
.how-panel p + p { margin-top: 8px; }
.how-panel kbd {
  background: #fff; border: 2px solid #d9c9a8; border-bottom-width: 3px;
  border-radius: 6px; padding: 0 7px; font-family: inherit; font-weight: 700;
}
.c-orange { color: var(--c-orange); }

.stats-row {
  margin-top: 16px;
  display: flex; gap: 18px; justify-content: center;
  font-size: clamp(13px, 2.2vmin, 16px);
  font-weight: 600; opacity: .8;
  flex-wrap: wrap;
}
.stats-row b { font-size: 1.15em; }

/* results */
.result-title {
  font-size: clamp(34px, 7.5vmin, 60px);
  color: var(--c-green);
  text-shadow: 0 3px 0 #fff, 0 5px 0 rgba(74,55,40,.2);
  animation: resultIn .6s cubic-bezier(.2,1.5,.4,1) both;
}
.result-title.lose { color: var(--c-pink); }
@keyframes resultIn {
  0% { transform: scale(.3) rotate(-8deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.result-sub { font-size: clamp(14px, 2.6vmin, 18px); font-weight: 600; opacity: .75; margin: 8px 0 16px; }

.tally-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.tally-row {
  display: flex; align-items: center; gap: 10px;
  font-size: clamp(15px, 2.6vmin, 19px); font-weight: 700;
}
.tally-row .t-name { width: 5.5em; text-align: right; }
.tally-row .t-bar-wrap { flex: 1; height: 1.35em; background: rgba(74,55,40,.12); border-radius: 999px; overflow: hidden; }
.tally-row .t-bar { height: 100%; border-radius: 999px; width: 0; transition: width .9s cubic-bezier(.2,.9,.3,1); }
.tally-row .t-score { width: 2.4em; text-align: left; font-variant-numeric: tabular-nums; }
.tally-row.winner .t-name::after { content: ' \1F451'; }
.tally-row.you .t-name::after { content: ' (you)'; font-size: .8em; font-weight: 500; }
.tally-row.you.winner .t-name::after { content: ' (you) \1F451'; font-size: .8em; font-weight: 500; }

.pause-panel h2 { font-size: clamp(30px, 6vmin, 48px); color: var(--pond-deep); }

/* thin screens: shrink panels a bit */
@media (max-height: 480px) {
  .panel { padding: 14px 20px; border-radius: 20px; }
  .logo { font-size: clamp(30px, 10vmin, 46px); }
  .tagline { margin: 6px 0 10px; }
  .big-btn { padding: 8px 34px; }
  .title-row { margin-top: 8px; }
  .stats-row { margin-top: 8px; }
}
