/*! Copyright (c) 2026 BamByte (bambyte.net). All rights reserved.
 * Proprietary code: no copying, redistribution, or use to train or prompt
 * AI / machine-learning systems without written permission from BamByte. */
/* Brick Blast -- game page (game.html).
   The playfield on the left, the site's sidebar on the right: HUD panel with
   the round controls on top (js/sidebarLayout.js), the same shell, frame and
   sizes Boom Boats uses, so every game reads the same. Single player only, so
   none of the online chat / lobby chrome is here.

   --game-accent is the electric blue of the BamByte skin's paddle and walls;
   keep it in step with --bkb-accent in menu.css. */

:root {
  --game-accent: #1e88ff;
  --game-accent-rgb: 30, 136, 255;
  --panel: #0e1630;
  --text: #f4f7fb;
  --muted: #a9b5cc;
  --bkb-sidebar-w: clamp(220px, 24vw, 340px);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 50% 35%, #182452, #070b1c 72%);
  overflow: hidden;
}

/* Full-height flex + dvh, same as the rest of the site. */
.bkb-shell {
  display: flex;
  gap: 16px;
  height: var(--bb-vh, 100vh);
  height: var(--bb-vh, 100dvh);
  padding: 16px;
}

/* The stage takes the slack; the 4:3 board is the biggest that fits in it
   (container query units, so no resize JS). */
.bkb-stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
  order: 2;
}

.bkb-board {
  position: relative;
  width: min(100cqw, 100cqh * 4 / 3);
  height: min(100cqh, 100cqw * 3 / 4);
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 3px rgba(var(--game-accent-rgb), 0.85), 0 12px 30px rgba(0, 0, 0, 0.5);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#screen {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  outline: none;
}
/* Hi-res skins: smooth scaling instead of crisp pixels. */
#screen.bkb-smooth { image-rendering: auto; }

/* Cheat / game messages, bottom-left of the board. */
.bkb-stage-msg {
  position: absolute;
  left: 4%;
  bottom: 3%;
  margin: 0;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-weight: 800;
  font-size: clamp(12px, 2.4cqw, 18px);
  pointer-events: none;
}
.bkb-stage-msg[hidden] { display: none; }

/* Pause cover. */
.bkb-pause {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 8, 20, 0.55);
  cursor: pointer;
  z-index: 5;
}
.bkb-pause[hidden] { display: none; }
.bkb-pause__card {
  padding: 18px 34px;
  border-radius: 16px;
  background: #1c1c1c;
  border: 2px solid rgba(var(--game-accent-rgb), 0.8);
  box-shadow: 0 0 18px rgba(var(--game-accent-rgb), 0.45), 0 14px 34px rgba(0, 0, 0, 0.6);
  text-align: center;
}
.bkb-pause__card h2 {
  margin: 0 0 4px;
  font: 900 clamp(22px, 5cqw, 40px)/1.1 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 0 14px rgba(var(--game-accent-rgb), 0.9);
}
.bkb-pause__card p { margin: 0; color: var(--muted); font-weight: 600; font-size: clamp(12px, 2cqw, 15px); }

/* ---- Round controls (moved into the sidebar HUD by sidebarLayout.js) ------ */
.bkb-side { display: none; }
.bb-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  /* One row whatever the sidebar width: the buttons shrink (to 26px) instead. */
  flex-wrap: nowrap;
  gap: 8px;
  margin: 0 0 8px;
  padding: 6px 10px;
  border-radius: 16px;
  background: #4a4a4a;
  border: 2px solid #6d6d6d;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 6px rgba(0, 0, 0, 0.45);
}
.bb-icon-btn {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}
/* Up to 40px, shrinking together on a narrow sidebar. Also sizes the shared
   HUD menu button (/net/offline_hud_menu.js) appended to this row. */
.bb-toolbar .bb-icon-btn,
.bb-toolbar .bb-offline-hud-menu-btn {
  flex: 0 1 40px;
  width: auto;
  height: auto;
  min-width: 26px;
  aspect-ratio: 1;
}
.bb-icon-btn img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.bb-icon-btn:hover { transform: translateY(-1px) scale(1.08); filter: brightness(1.15); }
.bb-icon-btn:active { transform: scale(0.94); }
.bb-icon-btn:focus-visible { outline: 2px solid var(--game-accent); outline-offset: 2px; }
.bb-icon-btn--gear { color: #111; background: #d9d9d9; width: 32px; height: 32px; padding: 5px; }
.bb-icon-btn--gear svg { width: 100%; height: 100%; display: block; }
/* The shared HUD menu's Settings item clicks this hidden gear; it only shows
   when that menu could not load (this folder served without the site root). */
#btn-settings { display: none; }
body.bkb-no-hud-menu #btn-settings { display: grid; }

/* ---- Sidebar -------------------------------------------------------------- */
#rightPanel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 var(--bkb-sidebar-w);
  width: var(--bkb-sidebar-w);
  max-height: 100%;
  min-width: 0;
  padding: 8px;
  overflow: hidden;
  position: relative;
  order: 4;
}
/* No room, no chat: the chat mount stays hidden in single player. */
#sb-content { display: none; }

body.bkb-dock-left #rightPanel { order: 1; }
body.bkb-dock-left .bkb-resize-handle { order: 2; }
body.bkb-dock-left .bkb-stage { order: 3; }

/* The grab strip between the board and the sidebar: the 10px strip is the
   hit area, the 2px line down its middle is what you see. */
.bkb-resize-handle {
  display: block;
  position: relative;
  flex: 0 0 10px;
  align-self: stretch;
  cursor: col-resize;
  background: transparent;
  order: 3;
}
.bkb-resize-handle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--game-accent);
  opacity: 0.35;
  border-radius: 2px;
  transition: opacity 0.18s ease, width 0.18s ease;
}
.bkb-resize-handle:hover::before,
.bkb-resize-handle.bkb-resizing::before { opacity: 1; width: 4px; }
body.bkb-resizing-cursor { cursor: col-resize; user-select: none; }

/* ---- HUD panel -------------------------------------------------------------- */
.hud-panel { display: none; }
#rightPanel > .hud-panel {
  display: flex;
  flex-direction: column;
  position: relative;          /* the settings popover is placed against it */
  width: 100%;
  flex: 0 1 auto;
  min-height: 0;
  overflow: hidden;            /* the body below scrolls; controls + logo stay put */
  border: 3px solid var(--game-accent);
  border-radius: 8px;
  background-color: rgba(12, 16, 24, 0.4);
  padding: 8px;
}
.hud-panel[hidden] { display: none !important; }

.hud-panel__title {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.hud-panel__logo-card { width: 100%; padding: 4px 6px; }
.hud-panel__logo {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.45));
}
.hud-panel__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 4px 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--game-accent-rgb), 0.6) transparent;
}

/* "Hide HUD": just the control strip stays. */
#rightPanel .hud-collapsed > *:not(.bb-toolbar) { display: none; }
#rightPanel .hud-collapsed {
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}

/* Score / level / paddles / best. */
.bkb-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.bkb-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-width: 0;
}
.bkb-stat--score { grid-column: 1 / -1; align-items: center; }
.bkb-stat__label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--game-accent);
}
.bkb-stat__value {
  font-size: 18px;
  font-weight: 900;
  color: #fff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bkb-stat--score .bkb-stat__value {
  font-size: 30px;
  text-shadow: 0 0 12px rgba(var(--game-accent-rgb), 0.7);
}

/* One pill per paddle: the lit one is in play, the rest are spares. */
.bkb-lives { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 24px; }
.bkb-lives i {
  display: block;
  width: 20px;
  height: 7px;
  border-radius: 4px;
  background: linear-gradient(#7fc0ff, var(--game-accent));
  box-shadow: 0 0 6px rgba(var(--game-accent-rgb), 0.6);
}
.bkb-lives i.is-live { background: linear-gradient(#fff, #9fd0ff); }

/* Active power-ups. */
.bkb-effects { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.bkb-effects:empty { display: none; }
.bkb-chip {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: rgba(var(--game-accent-rgb), 0.25);
  border: 1px solid rgba(var(--game-accent-rgb), 0.7);
}

.bkb-hint { margin: 10px 0 0; font-size: 12px; line-height: 1.45; color: var(--muted); text-align: center; }
.bkb-hint b { color: #fff; }

/* Portrait power-up legend under the hint (assets/powerup_legend_portrait.webp,
   rendered from assets/skins/legend.html?layout=portrait). Opens the wide
   sheet full size. */
.bkb-hud-legend { display: block; margin-top: 10px; border-radius: 14px; }
.bkb-hud-legend img { display: block; width: 100%; height: auto; }
.bkb-hud-legend:hover img, .bkb-hud-legend:focus-visible img { filter: brightness(1.08); }
.bkb-hud-legend:focus-visible { outline: 2px solid var(--game-accent); outline-offset: 2px; }

/* ---- Settings popover ----------------------------------------------------------- */
.settings-menu {
  position: absolute;
  right: 8px;
  top: 64px;
  z-index: 40;
  width: min(280px, calc(100% - 16px));
  max-height: calc(var(--bb-vh, 100dvh) - 120px);
  overflow-y: auto;
  padding: 12px;
  border-radius: 14px;
  background: #2b2a2a;
  border: 2px solid rgba(var(--game-accent-rgb), 0.55);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
}
.settings-menu[hidden] { display: none; }
/* In the sidebar it opens like BAMO's / Boom Boats': a full-width panel inside
   the side panel. Brick Blast's HUD box runs the whole height of the sidebar
   (there's no chat under it), so instead of hanging below it, the panel fills
   the HUD box from just under the control bar and its Game Settings button
   down to the bottom, and scrolls. The small-screen rule further down still
   floats it centred instead. */
#hud-panel > #settings-menu {
  top: 132px;
  bottom: 10px;
  left: 10px;
  right: 10px;
  width: auto;
  max-height: none;
  padding: 14px 16px 12px;
  background: rgba(22, 22, 22, 0.97);
  border: 2px solid var(--game-accent);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55), 0 0 18px rgba(var(--game-accent-rgb), 0.22);
  text-align: left;
}
.settings-note { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); }
.settings-group { margin-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.12); padding-top: 10px; }
.settings-title { margin: 0 0 8px; font-size: 13px; color: var(--game-accent); }

.bkb-set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  margin: 6px 0;
}
.bkb-set-row input[type="range"] { flex: 1 1 auto; max-width: 140px; accent-color: var(--game-accent); }
.bkb-toggle-row input { width: 18px; height: 18px; accent-color: var(--game-accent); }

/* Level editor: Picture to level settings (sidebar, under the hint). */
.bkb-picture { margin-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.12); padding-top: 10px; text-align: left; }
.bkb-picture__name { margin: -4px 0 6px; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bkb-picture output { min-width: 2ch; text-align: right; font-variant-numeric: tabular-nums; }
.bkb-picture--float {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  width: min(240px, 60%);
  margin: 0;
  padding: 10px 12px;
  border: 2px solid var(--game-accent);
  border-radius: 12px;
  background: rgba(22, 22, 22, 0.95);
}
.bkb-select {
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid rgba(var(--game-accent-rgb), 0.6);
  background: var(--panel);
  color: #fff;
  font: inherit;
}
.bkb-set-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }

.bkb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border: 0;
  border-radius: 999px;
  font: 800 12.5px/1.1 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #fff;
  text-decoration: none;
  text-align: center;
  background: #3a3a3a;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.16);
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
}
.bkb-btn:hover, .bkb-btn:focus-visible { filter: brightness(1.18); transform: translateY(-1px); }
.bkb-btn--go {
  background: #1f7a3d;
  box-shadow: 0 0 0 2px rgba(70, 220, 120, 0.75), 0 0 10px 2px rgba(70, 220, 120, 0.45);
}

.rules { margin: 0; }
.rules dt { margin-top: 8px; font-weight: 800; font-size: 12.5px; color: var(--game-accent); }
.rules dd { margin: 2px 0 6px; font-size: 12px; line-height: 1.45; color: #fff; }
.bkb-legend { display: block; margin-top: 10px; color: var(--muted); font-size: 11.5px; text-decoration: none; text-align: center; }
.bkb-legend img { display: block; width: 100%; height: auto; border-radius: 8px; margin-bottom: 4px; }
.bkb-legend:hover span { color: #fff; }

/* ---- Dialogs (high scores, name entry) ---------------------------------------- */
.bkb-modal {
  position: fixed;
  inset: 0;
  z-index: 4100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(0, 0, 0, 0.6);
}
.bkb-modal__card {
  width: min(360px, 92vw);
  max-height: calc(var(--bb-vh, 100dvh) - 24px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 22px;
  border-radius: 20px;
  background: #1c1c1c;
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6);
}
.bkb-modal__title {
  margin: 0;
  text-align: center;
  font: 900 clamp(18px, 4vw, 24px)/1.1 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #fff;
}
.bkb-modal__score {
  margin: 0;
  text-align: center;
  font-size: 34px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 14px rgba(var(--game-accent-rgb), 0.8);
}
.bkb-modal__label { font-size: 13px; font-weight: 700; color: var(--muted); text-align: center; }
/* The signed-in name the high score is saved under (no name box to fill in). */
.bkb-modal__name {
  margin: -6px 0 0;
  text-align: center;
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  overflow-wrap: anywhere;
  text-shadow: 0 0 10px rgba(var(--game-accent-rgb), 0.6);
}
.bkb-input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid rgba(var(--game-accent-rgb), 0.7);
  background: #0e1220;
  color: #fff;
  font: 700 16px system-ui, sans-serif;
  text-align: center;
}
.bkb-modal .bkb-btn { padding: 12px 0; font-size: 14px; text-transform: uppercase; }

.bkb-scores-wrap { overflow-y: auto; min-height: 0; }
.bkb-scores { width: 100%; border-collapse: collapse; font-size: 14px; }
.bkb-scores th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--game-accent);
  padding: 4px 8px;
}
.bkb-scores td { padding: 6px 8px; border-top: 1px solid rgba(255, 255, 255, 0.07); color: #fff; }
.bkb-scores td:first-child { width: 2.5em; color: var(--muted); }
.bkb-scores td:last-child, .bkb-scores th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.bkb-scores tr.is-me td { background: rgba(var(--game-accent-rgb), 0.22); font-weight: 800; }
.bkb-empty { text-align: center; color: var(--muted) !important; }

/* ==== Phones and tablets ====================================================
   Desktop is untouched: everything below is gated on a portrait viewport no
   wider than 1024px (stacked) or a landscape one no taller than 500px. */

/* Portrait: board on top at full width, sidebar under it. */
@media (orientation: portrait) and (max-width: 1024px) {
  html, body { height: auto; min-height: 100%; }
  body { overflow-x: hidden; overflow-y: auto; }

  .bkb-shell {
    flex-direction: column;
    height: auto;
    min-height: var(--bb-vh, 100dvh);
    padding: 8px;
    gap: 8px;
  }
  .bkb-stage,
  body.bkb-dock-left .bkb-stage {
    order: 1;
    flex: 0 0 auto;
    width: 100%;
    height: calc((100vw - 16px) * 3 / 4);
  }
  #rightPanel,
  body.bkb-dock-left #rightPanel {
    order: 2;
    flex: 0 0 auto;
    width: 100%;
    max-height: none;
    padding: 0;
    overflow: visible;
  }
  #rightPanel > .hud-panel,
  .hud-panel__body { overflow: visible; }
  .bkb-hud-legend { max-width: 420px; margin: 10px auto 0; }
  .bkb-resize-handle { display: none; }
  .hud-panel__logo { max-width: 320px; margin: 0 auto; }
}

/* Phones on their side: keep side by side, narrower sidebar. */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --bkb-phone-side-w: clamp(180px, 26vw, 240px); }
  .bkb-shell { padding: 6px; gap: 6px; }
  #rightPanel {
    flex: 0 0 var(--bkb-phone-side-w);
    width: var(--bkb-phone-side-w);
    padding: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .bkb-resize-handle { display: none; }
  /* Tighter control row in the narrow sidebar (the buttons shrink to fit). */
  .bb-toolbar { gap: 5px; padding: 4px 6px; }
  .hud-panel__logo { max-height: 48px; width: auto; margin: 0 auto; }
  .hud-panel__title { padding: 4px 6px; }
  #rightPanel > .hud-panel { padding: 6px; }
  .bkb-stat { padding: 5px 8px; }
  .bkb-stat--score .bkb-stat__value { font-size: 22px; }
  .bkb-hint { display: none; }
}

/* Settings popover on small screens: floats over the viewport, centred. */
@media (orientation: portrait) and (max-width: 1024px), (orientation: landscape) and (max-height: 500px) {
  #rightPanel #settings-menu {
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    bottom: auto;
    width: min(320px, calc(100vw - 24px));
    max-height: calc(var(--bb-vh, 100dvh) - 24px);
    z-index: 900;
  }
}
p.bkb-modal__label { margin: 0; }
