/* Balla Bites — shared design tokens and game shell.
   Look: the candy bag. Sky blue foil, white swoosh, navy sticker outlines, red buttons, bear yellow rewards. */
:root {
  --sky: #00A6E0;
  --sky-deep: #0086C4;
  --sky-light: #6FD3F7;
  --sky-pale: #D9F3FD;
  --navy: #2A2466;
  --navy-soft: #4B4592;
  --red: #E0241A;
  --red-deep: #A91710;
  --yellow: #FCE600;
  --yellow-deep: #E0A800;
  --white: #FFFFFF;
  --pink: #FFB3D1;
  --green: #3DAA35;
  --orange: #F58A1F;

  --font: "M PLUS Rounded 1c", "VAG Rounded", "Arial Rounded MT Bold", system-ui, sans-serif;
  --outline: 4px solid var(--navy);
  --sticker: 0 6px 0 var(--navy);
  --r-lg: 28px;
  --r-md: 20px;
  --r-sm: 14px;
  --bar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-weight: 800;
  color: var(--navy);
  background: var(--sky);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  overflow: hidden;
}
img { -webkit-user-drag: none; user-drag: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
button:focus-visible, a:focus-visible { outline: 4px solid var(--yellow); outline-offset: 3px; }

/* Bag background: foil blue with the white swoosh and soft light bands */
.bb-bg {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background:
    radial-gradient(120% 70% at 85% -10%, rgba(255,255,255,.55) 0 38%, transparent 38.4%),
    radial-gradient(90% 60% at -10% 110%, rgba(255,255,255,.28) 0 40%, transparent 40.4%),
    linear-gradient(160deg, var(--sky-light) 0%, var(--sky) 38%, var(--sky-deep) 100%);
}
/* crimped bag seal, top and bottom */
.bb-crimp {
  position: fixed; left: 0; right: 0; height: 12px; z-index: 5; pointer-events: none;
  background:
    linear-gradient(135deg, var(--white) 25%, transparent 25%) -8px 0 / 16px 12px,
    linear-gradient(225deg, var(--white) 25%, transparent 25%) -8px 0 / 16px 12px;
  opacity: .9;
}
.bb-crimp.top { top: 0; }
.bb-crimp.bottom { bottom: 0; transform: scaleY(-1); }

/* ---------- Buttons ---------- */
.bb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 60px; padding: 10px 28px;
  font-size: 22px; font-weight: 900; line-height: 1.1; color: var(--white);
  background: var(--red); border: var(--outline); border-radius: 999px;
  box-shadow: 0 6px 0 var(--navy);
  transition: transform .08s ease, box-shadow .08s ease;
}
.bb-btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--navy); }
.bb-btn.alt { background: var(--white); color: var(--navy); }
.bb-btn.sun { background: var(--yellow); color: var(--navy); }

.bb-icon-btn {
  width: 52px; height: 52px; flex: none;
  display: grid; place-items: center;
  background: var(--white); border: var(--outline); border-radius: 50%;
  box-shadow: 0 4px 0 var(--navy);
  transition: transform .08s ease, box-shadow .08s ease;
}
.bb-icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--navy); }
.bb-icon-btn svg { width: 28px; height: 28px; display: block; }

/* ---------- Game shell ---------- */
.bb-game { position: fixed; inset: 0; display: flex; flex-direction: column; padding: 16px 0 12px; }
.bb-bar {
  flex: none; height: var(--bar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
}
.bb-title {
  flex: 1; min-width: 0; margin: 0;
  font-size: clamp(17px, 4.8vw, 26px); font-weight: 900; line-height: 1.05;
  color: var(--white);
  text-shadow: 0 3px 0 var(--navy), 2px 0 0 var(--navy), -2px 0 0 var(--navy), 0 -2px 0 var(--navy);
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; text-wrap: balance;
}
.bb-pill {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 46px; padding: 0 14px;
  background: var(--white); border: var(--outline); border-radius: 999px;
  box-shadow: 0 4px 0 var(--navy);
  font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums;
}
.bb-pill .bb-star { width: 24px; height: 24px; }
.bb-pill.bump { animation: bb-bump .28s ease; }
@keyframes bb-bump { 40% { transform: scale(1.22) rotate(-4deg); } }

.bb-stage { position: relative; flex: 1; min-height: 0; touch-action: none; overflow: hidden; }

/* ---------- Overlays (age gate, end screen) ---------- */
.bb-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 20px;
  background: rgba(42, 36, 102, .55);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: bb-fade .2s ease both;
}
@keyframes bb-fade { from { opacity: 0; } }
.bb-card {
  width: min(100%, 440px);
  background: var(--white); border: var(--outline); border-radius: var(--r-lg);
  box-shadow: 0 10px 0 var(--navy);
  padding: 26px 22px 24px; text-align: center;
  animation: bb-pop .42s cubic-bezier(.2, 1.5, .4, 1) both;
}
@keyframes bb-pop { from { transform: scale(.6) rotate(-4deg); opacity: 0; } }
.bb-card h2 { margin: 0 0 6px; font-size: clamp(28px, 8vw, 38px); font-weight: 900; line-height: 1.05; }
.bb-card p { margin: 0 0 16px; font-size: 20px; font-weight: 800; color: var(--navy-soft); }
.bb-card .bb-actions { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }

.bb-age { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin-top: 16px; }
.bb-age button {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px;
  min-height: 170px; padding: 14px 8px 12px;
  background: var(--sky-pale); border: var(--outline); border-radius: var(--r-md);
  box-shadow: 0 6px 0 var(--navy);
  font-size: 34px; font-weight: 900; line-height: 1;
  transition: transform .08s ease, box-shadow .08s ease;
}
.bb-age button:nth-child(2) { background: #FFF3A8; }
.bb-age button:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--navy); }
.bb-age .bb-age-art { flex: 1; display: flex; align-items: center; justify-content: center; }
.bb-age .bb-age-art img { width: 56px; height: 56px; margin: 0 -12px; }
.bb-age button:first-child .bb-age-art img { width: 84px; height: 84px; }
.bb-age small { font-size: 16px; font-weight: 800; color: var(--navy-soft); }

.bb-stars { display: flex; justify-content: center; gap: 8px; margin: 10px 0 4px; }
.bb-stars svg { width: 64px; height: 64px; opacity: .22; filter: grayscale(1); }
.bb-stars svg.on { opacity: 1; filter: none; animation: bb-star-in .5s cubic-bezier(.2, 1.6, .4, 1) both; }
.bb-stars svg.on:nth-child(2) { animation-delay: .18s; }
.bb-stars svg.on:nth-child(3) { animation-delay: .36s; }
@keyframes bb-star-in { from { transform: scale(0) rotate(-90deg); } }
.bb-end-score { font-size: 56px; font-weight: 900; line-height: 1; margin: 8px 0 2px; font-variant-numeric: tabular-nums; }
.bb-end-best { font-size: 18px; color: var(--navy-soft); }
.bb-end-candy { width: 120px; height: 120px; margin: 0 auto; display: block; animation: bb-wobble 1.2s ease-in-out infinite; }
@keyframes bb-wobble { 0%, 100% { transform: rotate(-8deg) scale(1); } 50% { transform: rotate(8deg) scale(1.08); } }

/* ---------- FX layer ---------- */
.bb-fx { position: fixed; inset: 0; z-index: 80; pointer-events: none; width: 100%; height: 100%; }
.bb-float {
  position: fixed; z-index: 81; pointer-events: none;
  font-size: 34px; font-weight: 900; color: var(--yellow); white-space: nowrap;
  text-shadow: 0 3px 0 var(--navy), 3px 0 0 var(--navy), -3px 0 0 var(--navy), 0 -3px 0 var(--navy), 2px 2px 0 var(--navy), -2px 2px 0 var(--navy);
  transform: translate(-50%, -50%);
  animation: bb-float 1s cubic-bezier(.2, .8, .3, 1) forwards;
}
.bb-float.big { font-size: 54px; animation-duration: 1.5s; }
@keyframes bb-float {
  0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; }
  20% { transform: translate(-50%, -70%) scale(1.25); opacity: 1; }
  40% { transform: translate(-50%, -90%) scale(1); }
  100% { transform: translate(-50%, -190%) scale(1); opacity: 0; }
}
.bb-shake { animation: bb-shake .36s ease; }
@keyframes bb-shake {
  15% { transform: translate(-7px, 3px) rotate(-1deg); } 30% { transform: translate(6px, -4px) rotate(1deg); }
  45% { transform: translate(-5px, 2px); } 60% { transform: translate(4px, -2px); } 80% { transform: translate(-2px, 1px); }
}
.bb-hand {
  position: fixed; z-index: 70; pointer-events: none; width: 76px; height: 76px;
  margin: -8px 0 0 -22px;
  filter: drop-shadow(0 4px 0 rgba(42,36,102,.45));
  transition: opacity .25s ease;
}

@media (prefers-reduced-motion: reduce) {
  .bb-card, .bb-overlay, .bb-stars svg.on, .bb-end-candy, .bb-shake, .bb-pill.bump { animation: none; }
}
