/* Bonk Burst page — keeps the site header, gives the game the rest of the screen */
html:has(body.game-page), body.game-page { overscroll-behavior: none; }
/* While a level is being played: the page can't scroll or pull-to-refresh, and the stage swallows touch gestures */
html.bb-playing, html.bb-playing body { overflow: hidden; overscroll-behavior: none; }
html.bb-playing .bb-stage, html.bb-playing .bb-frame { touch-action: none; -webkit-user-select: none; user-select: none; }
body.game-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow-x: hidden; }
.game-page .site-header { padding-bottom: 6px; }
.bb-main { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; position: relative; z-index: 1; }
.bb-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: min(560px, calc(100% - 16px)); padding: 2px 0 8px;
}
.bb-back {
  display: inline-flex; align-items: center; gap: 4px; min-height: 38px; padding: 4px 12px 4px 8px;
  border-radius: 999px; background: var(--chip); border: 1.5px solid var(--line); box-shadow: var(--shadow-sm);
  font-weight: 800; font-size: 0.9rem; color: var(--ink);
}
.bb-back svg { width: 18px; height: 18px; }
.bb-title {
  margin: 0; font-family: var(--display); font-weight: 700; font-size: 1.35rem; letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--brand), var(--cartoons)); -webkit-background-clip: text; background-clip: text; color: transparent;
  white-space: nowrap;
}
.bb-tools { display: flex; gap: 8px; }
.bb-btn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--chip); color: var(--ink); border: 1.5px solid var(--line); box-shadow: var(--shadow-sm);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: transform 0.25s var(--spring);
}
.bb-btn:active { transform: scale(0.9); }
.bb-btn svg { width: 20px; height: 20px; grid-area: 1 / 1; }
.bb-btn[data-state="on"] .i-off, .bb-btn[data-state="off"] .i-on { display: none; }
.bb-btn[data-state="playing"] .i-play, .bb-btn[data-state="paused"] .i-pause { display: none; }
.bb-back:focus-visible, .bb-btn:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.bb-stage {
  flex: 1 1 auto; min-height: 0; width: min(560px, 100%); margin: 0 auto;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 0 8px max(10px, env(safe-area-inset-bottom));
}
#bb-canvas {
  display: block; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  border-radius: 22px; border: 1.5px solid var(--line); box-shadow: var(--shadow);
  background: var(--bg-soft); cursor: crosshair;
}
@media (max-width: 620px) {
  .bb-bar { padding-bottom: 6px; }
  .bb-title { font-size: 1.2rem; }
  .bb-stage { padding: 0 6px max(6px, env(safe-area-inset-bottom)); }
  #bb-canvas { border-radius: 18px; }
}

/* ---------- frame + HTML menus over the canvas (scaled with the canvas via --u) ---------- */
.bb-frame { position: relative; flex: none; --u: 1; }
.bb-frame #bb-canvas { width: 100%; height: 100%; }
.bb-ui {
  position: absolute; inset: 0; z-index: 2; border-radius: 22px; overflow: hidden;
  font-size: calc(var(--u) * 16px); font-family: var(--sans); color: var(--ink);
}
.bb-ui[hidden] { display: none; }
@media (max-width: 620px) { .bb-ui { border-radius: 18px; } }
.bb-scr { position: absolute; inset: 0; display: flex; flex-direction: column; animation: bb-fade 0.25s var(--ease); }
@keyframes bb-fade { from { opacity: 0; } }

/* Title */
.bb-title-scr { justify-content: flex-start; }
.bb-topline { display: flex; justify-content: flex-end; padding: 1em 1em 0; }
.bb-acct.ng-chip { font-size: max(0.82em, 12px); min-height: 2.5em; max-width: 12em; }
.bb-menu { position: absolute; left: 0; right: 0; top: 47%; display: flex; flex-direction: column; align-items: center; gap: 0.85em; padding: 0 1.5em; }
.bb-play {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35em; padding: 0 1.1em 0 0.8em;
  border: 0; border-radius: 999px; cursor: pointer; color: #fff; font: 700 1.75em var(--display); letter-spacing: 0.01em;
  background: linear-gradient(90deg, var(--brand), var(--gaming) 60%, var(--cartoons)); background-size: 100% 100%;
  box-shadow: 0 0.22em 0 var(--brand-deep), 0 0.6em 1.2em rgba(107, 77, 255, 0.35);
  animation: bb-breathe 2.2s ease-in-out infinite; -webkit-tap-highlight-color: transparent;
  font-size: 1.75em; height: 2.3em; min-width: 6.4em;
}
[data-theme="dark"] .bb-play { box-shadow: 0 0.22em 0 #4a3bb8, 0 0.6em 1.2em rgba(0, 0, 0, 0.4); }
.bb-play:active { transform: translateY(0.15em); animation: none; }
.bb-play-i svg { width: 1em; height: 1em; display: block; }
@keyframes bb-breathe { 50% { transform: scale(1.045); } }
.bb-prog { margin: 0; font-weight: 800; color: var(--muted); font-size: 1em; text-align: center; }
.bb-row { display: flex; gap: 0.6em; justify-content: center; flex-wrap: wrap; }
.bb-pill {
  display: inline-flex; align-items: center; gap: 0.45em; height: 2.9em; padding: 0 1.15em 0 0.6em; border-radius: 999px; cursor: pointer;
  background: var(--card); color: var(--ink); border: 0.1em solid var(--line); box-shadow: 0 0.2em 0 var(--line), var(--shadow-sm);
  font: 800 1em var(--sans); -webkit-tap-highlight-color: transparent; transition: transform 0.2s var(--spring);
}
.bb-pill:active { transform: translateY(0.15em); }
.bb-pill-i { width: 1.9em; height: 1.9em; border-radius: 0.7em; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--hardware), var(--games)); font: 700 1.15em/1 var(--display); }
.bb-pill:nth-child(2) .bb-pill-i { background: linear-gradient(135deg, #ffc24d, var(--cartoons-2)); }
.bb-pill-i svg { width: 1.15em; height: 1.15em; display: block; }
.bb-pill.locked { color: var(--muted); }
.bb-pill.locked .bb-pill-i { background: var(--bg-soft); color: var(--muted); box-shadow: inset 0 0 0 0.1em var(--line); }
.bb-pill-sm { height: 2.5em; font-size: 0.9em; }
.bb-guest { margin: 0.3em 0 0; max-width: 24em; text-align: center; color: var(--muted); font-weight: 700; font-size: 0.86em; line-height: 1.45; }
.bb-linkbtn { border: 0; padding: 0; background: none; color: var(--brand); font: inherit; font-weight: 800; text-decoration: underline; text-underline-offset: 0.15em; cursor: pointer; }
.bb-pill:focus-visible, .bb-play:focus-visible, .bb-round:focus-visible, .bb-endless:focus-visible, .bb-linkbtn:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* Level select */
.bb-levels-scr { background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.bb-lv-head { display: flex; align-items: center; gap: 0.7em; padding: 1em 1.1em 0.6em; }
.bb-lv-head h2 { margin: 0; flex: 1; font: 700 1.55em var(--display); letter-spacing: -0.02em; }
.bb-lv-head .ng-stars-pill { font-size: 0.95em; }
.bb-round { width: 2.6em; height: 2.6em; border-radius: 50%; display: grid; place-items: center; border: 0.1em solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; flex: none; }
.bb-round svg { width: 1.3em; height: 1.3em; }
.bb-lv-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0.6em 1.1em 1em; scrollbar-width: thin; font-size: 1.05em; }
.bb-lv-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.6em; padding: 0.7em 1.1em 0.9em; border-top: 0.1em solid var(--line); background: color-mix(in srgb, var(--card) 70%, transparent); }
.bb-endless {
  width: 100%; display: flex; align-items: center; gap: 0.8em; margin-top: 0.3em; padding: 0.8em 1em; border-radius: 1.2em; cursor: pointer; text-align: left;
  border: 0.12em dashed color-mix(in srgb, var(--brand) 55%, transparent); background: linear-gradient(110deg, var(--brand-soft), var(--cartoons-soft)); color: var(--ink);
}
.bb-endless-i { width: 2.4em; height: 2.4em; border-radius: 0.9em; display: grid; place-items: center; flex: none; color: #fff; font: 700 1.5em/1 var(--display); background: linear-gradient(135deg, var(--brand), var(--cartoons)); }
.bb-endless-i svg { width: 0.8em; height: 0.8em; }
.bb-endless-t { display: flex; flex-direction: column; }
.bb-endless-t b { font: 700 1.2em var(--display); }
.bb-endless-t small { color: var(--muted); font-weight: 700; font-size: 0.85em; }
.bb-endless.locked { cursor: not-allowed; background: var(--bg-soft); border-color: var(--line); }
.bb-endless.locked .bb-endless-i { background: var(--line); color: var(--muted); }

/* Result cards */
.bb-card-scr { align-items: center; justify-content: center; padding: 1.2em; background: color-mix(in srgb, var(--bg) 45%, transparent); }
.bb-card {
  width: min(23em, 100%); display: flex; flex-direction: column; align-items: stretch; gap: 0.7em; padding: 1.6em 1.4em 1.3em; text-align: center;
  background: var(--card); border: 0.1em solid var(--line); border-radius: 1.8em; box-shadow: 0 1.4em 3em rgba(0, 0, 0, 0.22);
  animation: bb-pop 0.5s var(--spring);
}
.bb-card .ng-primary { font-size: 1.15em; min-height: 2.9em; margin-top: 0.2em; }
.bb-card .bb-row .bb-pill { flex: 1; justify-content: center; }
@keyframes bb-pop { from { transform: scale(0.7) translateY(1em); opacity: 0; } }
.bb-kicker { margin: 0; color: var(--muted); font-weight: 800; font-size: 0.9em; letter-spacing: 0.02em; }
.bb-big {
  margin: 0; font: 700 2.6em/1.05 var(--display); letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--brand), var(--cartoons)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.bb-big-over { background-image: linear-gradient(90deg, var(--cartoons), var(--cartoons-2)); }
.bb-stars { display: flex; justify-content: center; align-items: flex-end; gap: 0.3em; margin: 0.1em 0 0.2em; }
.bb-star { width: 3.2em; height: 3.2em; color: var(--line); animation: bb-star 0.55s var(--spring) both; animation-delay: var(--d); }
.bb-star:nth-child(2) { width: 4em; height: 4em; }
.bb-star svg { width: 100%; height: 100%; display: block; }
.bb-star.on { color: #ffcc33; filter: drop-shadow(0 0.18em 0 #e09a00) drop-shadow(0 0.4em 0.6em rgba(255, 170, 0, 0.35)); }
@keyframes bb-star { from { transform: scale(0) rotate(-40deg); opacity: 0; } }
.bb-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6em; }
.bb-stats div, .bb-score { display: flex; flex-direction: column; padding: 0.6em; border-radius: 1em; background: var(--bg-soft); }
.bb-stats small, .bb-score small { color: var(--muted); font-weight: 800; font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.06em; }
.bb-stats b { font: 700 1.45em var(--display); }
.bb-score b { font: 700 2.4em var(--display); color: var(--ink); }
.bb-bonus { margin: 0; color: var(--games); font-weight: 800; font-size: 0.88em; }
.bb-save { margin: 0; color: var(--muted); font-weight: 700; font-size: 0.85em; min-height: 1.2em; }
.bb-save:empty { display: none; }
.bb-rank { display: flex; flex-wrap: wrap; gap: 0.4em; justify-content: center; align-items: center; color: var(--muted); font-weight: 700; font-size: 0.9em; min-height: 2em; }
.bb-rank-chip { padding: 0.3em 0.8em; border-radius: 999px; background: var(--brand-soft); color: var(--brand-deep); }
.bb-rank-chip b { font-family: var(--display); font-size: 1.15em; }
.bb-newbest { padding: 0.3em 0.8em; border-radius: 999px; background: linear-gradient(90deg, #ffc24d, var(--cartoons-2)); color: #fff; font-weight: 800; animation: bb-pop 0.6s var(--spring); }
.bb-card-sm { width: min(19em, 100%); }
.bb-pause { background: transparent; }
@media (prefers-reduced-motion: reduce) { .bb-play, .bb-card, .bb-star, .bb-scr { animation: none; } }
