/* ============================================================================
   Rooftop Breakout — style.css
   Mobile-first, dark-nebula theme for the HTML shell + DOM HUD.
   System fonts only; no external assets/CDNs.
   ========================================================================== */

/* ---------- 1. Reset & base ---------------------------------------------- */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  background: #0b1026;
  color: #eef2ff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- 2. Layout: fullscreen playfield ------------------------------ */
.game-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  /* dark nebula backdrop */
  background:
    radial-gradient(120% 90% at 50% 0%, #1b2350 0%, transparent 60%),
    radial-gradient(140% 120% at 85% 100%, #3c1f5e 0%, transparent 55%),
    radial-gradient(120% 120% at 10% 100%, #123a4d 0%, transparent 50%),
    #0b1026;
}

/* ---------- 3. Canvas ----------------------------------------------------- */
/* The canvas element is 480x880; this scales it to fit the viewport while
   keeping the ratio. image-rendering stays at the browser default (smooth). */
#game {
  display: block;
  width: auto;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  aspect-ratio: 480 / 880;
  border-radius: 16px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 24px 60px rgba(0, 0, 0, 0.65),
    0 0 44px rgba(120, 160, 255, 0.16),
    0 0 120px rgba(180, 120, 255, 0.10);
}

/* ---------- 4. HUD container + shared text -------------------------------- */
/* #hud is a canvas-sized box centered the same way as the canvas, so HUD
   coordinates always land on the playfield (ui.js toggles .active on it). */
#hud {
  position: absolute;
  inset: 0;
  margin: auto;
  width: auto;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  aspect-ratio: 480 / 880;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#hud.active {
  opacity: 1;
}

.hud-blk,
#hud-chips {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  position: absolute;
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.65), 0 0 18px rgba(0, 0, 0, 0.4);
  user-select: none;
}

/* ---------- 5. Score / multiplier / combo (top-left) ---------------------- */
#hud-score {
  top: 12px;
  left: 14px;
  font-size: clamp(20px, 4.5vw, 34px);
  font-weight: 700;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  line-height: 1;
}

#hud-mult {
  top: 60px;
  left: 16px;
  font-size: clamp(26px, 6vw, 46px);
  font-weight: 800;
  line-height: 1;
  /* default colour; hud.js rewrites it inline per multiplier level */
  color: #7ef0a6;
  transition: color 0.25s ease, filter 0.25s ease;
}
#hud-mult.pop {
  /* brief gradient flash on multiplier change */
  background: linear-gradient(180deg, #ffffff, #7ef0a6);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 0 14px rgba(126, 240, 166, 0.6));
}

#hud-combo {
  top: 104px;
  left: 16px;
  font-size: clamp(14px, 3.2vw, 18px);
  font-weight: 700;
  color: #ffb74d;
  letter-spacing: 0.5px;
}

/* ---------- 6. Lives (hearts, top-right under the buttons) ---------------- */
#hud-lives {
  top: 62px;
  right: 14px;
  font-size: clamp(16px, 3.6vw, 24px);
  line-height: 1;
  color: #ff5d6c;
  letter-spacing: 3px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7), 0 0 14px rgba(255, 60, 90, 0.5);
}

/* ---------- 7. Rooftop streak + power chips (top center) ------------------ */
#hud-streak {
  top: 128px;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(13px, 3vw, 17px);
  font-weight: 700;
  color: #ffd700;
  letter-spacing: 1px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7), 0 0 16px rgba(255, 215, 0, 0.45);
  white-space: nowrap;
}

/* gold shimmer when a streak is active (element has text) */
#hud-streak:not(:empty) {
  animation: streak-shimmer 2.4s ease-in-out infinite;
}

#hud-chips {
  top: 152px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-width: 92%;
}

/* ---------- 8. Control buttons (top-right) -------------------------------- */
#pause-btn-wrap {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
/* ui.js toggles .active while playing */
#pause-btn-wrap.active {
  opacity: 1;
  pointer-events: auto;
}

#btn-mute,
#btn-pause {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
  pointer-events: auto;
  padding: 0;
  touch-action: manipulation;
  transition: background 0.15s ease, transform 0.1s ease;
}
#btn-mute:hover,
#btn-pause:hover {
  background: rgba(255, 255, 255, 0.16);
}
#btn-mute:active,
#btn-pause:active {
  transform: scale(0.9);
}

/* ---------- 9. Virtual thumbstick ----------------------------------------- */
#stick {
  position: absolute;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  border: 2px solid rgba(255, 255, 255, 0.25);
  z-index: 15;
  pointer-events: none;
  display: none; /* input.js flips to block while a touch is active */
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.35) inset, 0 0 18px rgba(120, 160, 255, 0.12);
  transform: scale(1);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#stick .knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, #d9e4ff 40%, rgba(150, 180, 255, 0.55) 100%);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.45),
    0 0 18px rgba(160, 200, 255, 0.35);
  /* no transform transition: the knob must track the finger 1:1 while
     dragging; the container fade covers the release animation */
}

/* ---------- 10. Screens --------------------------------------------------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 12, 30, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}

/* Flex centering + overflow-y: auto can clip content on short screens;
   use auto-ish margins inside instead so tall menu content stays reachable. */
.screen-inner {
  margin: auto;
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* ---------- 11. Buttons --------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 0 34px;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: clamp(16px, 3.6vw, 18px);
  font-weight: 800;
  letter-spacing: 3px;
  color: #04060f;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

/* primary: neon gradient + glow */
.btn-primary {
  background: linear-gradient(135deg, #ff6ec7 0%, #a78bfa 55%, #4facfe 100%);
  min-height: 64px;
  padding: 0 48px;
  box-shadow:
    0 8px 26px rgba(160, 90, 250, 0.5),
    0 0 34px rgba(79, 172, 254, 0.35);
  animation: btn-pulse 2.4s ease-in-out infinite;
}
.btn-primary:hover {
  transform: translateY(-2px) scale(1.03);
  filter: brightness(1.1);
}
.btn-primary:active {
  transform: translateY(1px) scale(0.96);
}

/* ghost: outline style, used for secondary actions */
.btn-ghost {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #e8ecff;
  letter-spacing: 2px;
  min-height: 52px;
  padding: 0 28px;
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}
.btn-ghost:active {
  transform: scale(0.96);
}

/* ---------- 12. Menu screen ----------------------------------------------- */
.menu-title {
  margin: 0 0 6px;
  font-size: clamp(34px, 9vw, 62px);
  font-weight: 900;
  line-height: 1.04;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: linear-gradient(100deg, #58c7ff 0%, #b06cff 45%, #ff5ec7 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 6px 22px rgba(160, 90, 250, 0.5));
  animation: title-float 3.5s ease-in-out infinite;
}

.tagline {
  margin: 0 0 22px;
  font-size: clamp(14px, 3.4vw, 16px);
  font-style: italic;
  font-weight: 500;
  color: #a9b6e8;
  max-width: 340px;
  line-height: 1.45;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  width: 100%;
}

.howto {
  margin: 0 0 22px;
  max-width: 360px;
  font-size: clamp(12px, 3vw, 14px);
  line-height: 1.55;
  color: #9aa7d5;
}
.howto em {
  color: #ffd54f;
  font-style: normal;
  font-weight: 700;
}

/* ---------- 13. Brick legend ---------------------------------------------- */
.legend {
  width: 100%;
  max-width: 420px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  text-align: left;
}

.legend-row {
  display: grid;
  grid-template-columns: 14px 1fr;
  grid-template-rows: auto auto;
  column-gap: 7px;
  align-items: center;
}

.brick-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  grid-row: 1 / span 2;
  align-self: center;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.25), 0 1px 3px rgba(0, 0, 0, 0.6);
}

.legend-name {
  font-size: clamp(12px, 2.9vw, 13px);
  font-weight: 700;
  color: #e6ebff;
  letter-spacing: 0.4px;
  line-height: 1.2;
}

.legend-desc {
  font-size: 10.5px;
  line-height: 1.3;
  color: #8d9ac6;
}

/* ---------- 14. Pause / level clear / game over --------------------------- */
.screen-title {
  margin: 0 0 18px;
  font-size: clamp(30px, 8vw, 48px);
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(100deg, #58c7ff, #ff5ec7);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 4px 16px rgba(160, 90, 250, 0.4));
}

.gameover-title {
  background: linear-gradient(100deg, #ff9a5e, #ff5ec7);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.screen-bonus,
.screen-score,
.screen-streak {
  margin: 0 0 8px;
  font-size: clamp(14px, 3.4vw, 17px);
  font-weight: 700;
  letter-spacing: 1.5px;
}

.screen-bonus {
  color: #ffd54f;
}
.screen-score {
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}
.screen-streak {
  color: #ffd700;
  font-variant-numeric: tabular-nums;
}

.screen-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
  width: 100%;
}

/* ---------- 15. Footer ---------------------------------------------------- */
.credit {
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.28);
  pointer-events: none;
  z-index: 1;
}

/* ---------- 16. Animations ------------------------------------------------ */
@keyframes pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}
.pop {
  display: inline-block;
  animation: pop 0.3s ease;
}

@keyframes btn-pulse {
  0%, 100% { box-shadow: 0 8px 26px rgba(160, 90, 250, 0.5), 0 0 34px rgba(79, 172, 254, 0.35); }
  50%      { box-shadow: 0 8px 34px rgba(160, 90, 250, 0.75), 0 0 54px rgba(79, 172, 254, 0.55); }
}

@keyframes streak-shimmer {
  0%, 100% { opacity: 1; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7), 0 0 12px rgba(255, 215, 0, 0.45); }
  50%      { opacity: 0.85; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7), 0 0 26px rgba(255, 215, 0, 0.95); }
}

@keyframes title-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}

/* ---------- 17. Power-up chips -------------------------------------------- */
.chip {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #04060f;
  background: #69f0ae;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.25);
  white-space: nowrap;
}
.chip-wide    { background: #69f0ae; }
.chip-laser   { background: #40c4ff; }
.chip-slow    { background: #b388ff; }
.chip-fire    { background: #ff6e40; }
.chip-shield  { background: #80d8ff; }

/* ---------- 18. Narrow / landscape tweaks --------------------------------- */
@media (max-width: 360px) {
  .screen { padding: 14px; }
  .legend { gap: 6px 10px; }
  #hud-score { top: 10px; left: 10px; }
  #hud-mult  { top: 54px; left: 12px; }
  #hud-combo { top: 96px; left: 12px; }
  #hud-lives { top: 56px; right: 12px; }
  #hud-streak { top: 122px; }
  #hud-chips  { top: 146px; }
  .menu-title { font-size: clamp(28px, 8vw, 40px); }
}

/* short/landscape phones: keep the title compact so the menu still fits */
@media (max-height: 560px) {
  .menu-title { font-size: clamp(22px, 6vw, 34px); }
  .tagline { margin-bottom: 12px; }
  .howto { margin-bottom: 12px; font-size: 11.5px; }
  .legend-name { font-size: 11px; }
  .credit { display: none; }
}
