/* ==========================================================================
   style.css — HUD and menus. Glassy, high contrast, and out of the way of
   the garden.
   ========================================================================== */

:root {
  --ink: #eaf2fb;
  --ink-dim: #9fb2c8;
  --accent: #4fb3ff;
  --accent-2: #7cff9d;
  --warn: #ffd23d;
  --bad: #ff5470;
  --glass: rgba(10, 16, 28, 0.62);
  --glass-2: rgba(16, 24, 40, 0.82);
  --stroke: rgba(160, 200, 255, 0.22);
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  --ui: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --num: 'Segoe UI', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: #05080f;
  color: var(--ink);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

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

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

body[data-state='menu'] #game-canvas,
body[data-state='loading'] #game-canvas,
body[data-state='paused'] #game-canvas,
body[data-state='over'] #game-canvas {
  cursor: default;
}

.hidden {
  display: none !important;
}

/* --------------------------------------------------------------------------
   Overlays and cards
   -------------------------------------------------------------------------- */

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(120% 90% at 50% 40%, rgba(4, 8, 16, 0.55), rgba(3, 6, 12, 0.9));
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  z-index: 40;
  animation: fadeIn 0.28s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

.card {
  width: min(460px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 30px 30px 26px;
  border-radius: 22px;
  background: linear-gradient(180deg, var(--glass-2), var(--glass));
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  text-align: center;
  animation: rise 0.34s cubic-bezier(0.2, 1.1, 0.4, 1);
}

.card.wide {
  width: min(600px, 100%);
}

@keyframes rise {
  from {
    transform: translateY(22px) scale(0.97);
    opacity: 0;
  }
}

.logo {
  display: flex;
  flex-direction: column;
  line-height: 0.88;
  margin-bottom: 18px;
}

.logo-k {
  font-size: clamp(30px, 6vw, 46px);
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--ink);
  text-shadow: 0 2px 20px rgba(79, 179, 255, 0.35);
}

.logo-b {
  font-size: clamp(42px, 9vw, 72px);
  font-weight: 900;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #9fe0ff, var(--accent) 55%, #2a6fd6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 22px rgba(79, 179, 255, 0.5));
}

h2 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.16em;
  margin-bottom: 16px;
}

.tagline {
  color: var(--ink-dim);
  font-size: 14.5px;
  line-height: 1.55;
  margin-bottom: 20px;
}

.muted {
  color: var(--ink-dim);
  font-size: 14px;
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.1em;
  font-size: 13px;
  padding: 12px 18px;
  border-radius: 13px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px) scale(0.985);
}

.btn.primary {
  background: linear-gradient(180deg, #63c1ff, #2a7fd6);
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: 0 10px 30px rgba(42, 127, 214, 0.45);
  color: #04101f;
}

.btn.primary:hover {
  box-shadow: 0 14px 38px rgba(42, 127, 214, 0.6);
}

.btn.danger {
  background: rgba(255, 84, 112, 0.18);
  border-color: rgba(255, 84, 112, 0.45);
}

.btn.big {
  width: 100%;
  font-size: 17px;
  padding: 16px;
  margin-top: 6px;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn-row .btn {
  flex: 1;
}

/* Stats */
.stat-row {
  display: flex;
  gap: 10px;
  margin: 18px 0;
}

.stat {
  flex: 1;
  padding: 12px 6px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.stat span {
  display: block;
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
}

.stat small {
  display: block;
  margin-top: 3px;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  color: var(--ink-dim);
}

.big-score {
  font-size: 60px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--warn);
  text-shadow: 0 6px 30px rgba(255, 210, 61, 0.4);
  line-height: 1;
  margin: 8px 0 6px;
}

.new-best {
  margin: 10px auto 0;
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(124, 255, 157, 0.16);
  border: 1px solid rgba(124, 255, 157, 0.4);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  animation: pulseBadge 1.1s ease-in-out infinite;
}

@keyframes pulseBadge {
  50% {
    transform: scale(1.06);
  }
}

/* Settings rows */
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.row:last-of-type {
  border-bottom: none;
}

.range-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-wrap em {
  font-style: normal;
  font-size: 12px;
  color: var(--ink-dim);
  min-width: 42px;
  text-align: right;
}

input[type='range'] {
  width: 150px;
  accent-color: var(--accent);
}

input[type='checkbox'] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

select {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  border: 1px solid var(--stroke);
  border-radius: 9px;
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
}

.help-list {
  text-align: left;
  list-style: none;
  display: grid;
  gap: 11px;
  margin-bottom: 18px;
}

.help-list li {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-dim);
  padding-left: 18px;
  position: relative;
}

.help-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--accent);
}

.help-list b {
  color: var(--ink);
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
}

.controls-grid > div {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  padding: 9px 6px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.04);
}

.key {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.controls-grid span:last-child {
  font-size: 11.5px;
  color: var(--ink-dim);
}

/* Loader */
.loader-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  margin: 8px 0 12px;
}

#loader-fill {
  height: 100%;
  width: 4%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.35s ease;
}

/* --------------------------------------------------------------------------
   HUD
   -------------------------------------------------------------------------- */

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(180deg, rgba(3, 7, 14, 0.55), transparent);
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hud-right {
  justify-content: flex-end;
}

.hud-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding-top: 2px;
}

.score-block {
  display: flex;
  flex-direction: column;
}

.score-label {
  font-size: 9px;
  letter-spacing: 0.28em;
  color: var(--ink-dim);
  margin-top: -2px;
}

/* The odometer. Each column is exactly 1em tall and clips a rolling strip. */
.score {
  font-size: 40px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.01em;
  color: #fff;
  text-shadow: 0 3px 18px rgba(79, 179, 255, 0.55), 0 1px 0 rgba(0, 0, 0, 0.4);
  transform-origin: left center;
}

.odo {
  display: inline-flex;
  font-variant-numeric: tabular-nums;
}

.odo-col {
  display: block;
  height: 1em;
  width: 0.62em;
  overflow: hidden;
  transition: opacity 0.3s ease;
}

.odo-col.dim {
  opacity: 0.18;
}

.odo-strip {
  display: block;
  will-change: transform;
}

.odo-strip span {
  display: block;
  height: 1em;
  line-height: 1em;
  text-align: center;
}

.score.punch {
  animation: scorePunch 0.24s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes scorePunch {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.13);
    filter: brightness(1.5);
  }
  100% {
    transform: scale(1);
  }
}

/* Lives */
.lives {
  display: flex;
  gap: 6px;
  padding-top: 4px;
}

.life {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #ffe9a8, #ffb03d 55%, #d9781a);
  box-shadow: 0 0 12px rgba(255, 176, 61, 0.65), inset 0 -2px 3px rgba(0, 0, 0, 0.25);
  animation: lifeIn 0.3s cubic-bezier(0.2, 1.5, 0.4, 1);
}

@keyframes lifeIn {
  from {
    transform: scale(0);
  }
}

.life.lost {
  animation: lifeOut 0.66s ease-in forwards;
}

@keyframes lifeOut {
  0% {
    transform: scale(1.5);
    background: radial-gradient(circle at 32% 30%, #fff, var(--bad));
  }
  100% {
    transform: scale(0) translateY(26px) rotate(140deg);
    opacity: 0;
  }
}

/* Chips */
.level-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(8, 14, 26, 0.6);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#level-num {
  font-size: 12px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 0.05em;
}

#level-name {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.22em;
}

.bricks-chip,
.best-chip {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--ink-dim);
  font-weight: 700;
}

.bricks-chip span,
.best-chip span {
  color: var(--ink);
}

.fps {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: rgba(159, 178, 200, 0.55);
  min-width: 52px;
  text-align: right;
}

.icon-btn {
  pointer-events: auto;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  border: 1px solid var(--stroke);
  background: rgba(8, 14, 26, 0.6);
  color: var(--ink);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* Combo */
.combo {
  position: absolute;
  left: 50%;
  top: 96px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

#combo-mult {
  font-size: 34px;
  font-weight: 900;
  color: var(--warn);
  text-shadow: 0 0 26px rgba(255, 210, 61, 0.75);
  line-height: 1;
}

.combo-track {
  width: 92px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

#combo-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--warn), #ff8b3d);
  transform-origin: left center;
}

.combo-label {
  font-size: 8.5px;
  letter-spacing: 0.3em;
  color: var(--ink-dim);
}

.combo.bump {
  animation: comboBump 0.26s cubic-bezier(0.2, 1.5, 0.4, 1);
}

@keyframes comboBump {
  0% {
    transform: translateX(-50%) scale(1);
  }
  40% {
    transform: translateX(-50%) scale(1.22);
  }
  100% {
    transform: translateX(-50%) scale(1);
  }
}

/* Powerup pills */
.power-row {
  position: absolute;
  left: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.pill {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(8, 14, 26, 0.7);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: pillIn 0.28s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes pillIn {
  from {
    transform: translateX(-30px);
    opacity: 0;
  }
}

.pill-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  box-shadow: 0 0 10px currentColor;
}

.pill-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.pill-track {
  width: 54px;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.pill-fill {
  display: block;
  height: 100%;
  background: #fff;
  transform-origin: left center;
}

.pill.expiring {
  animation: pillFlash 0.5s ease-in-out infinite;
}

@keyframes pillFlash {
  50% {
    opacity: 0.45;
  }
}

.pill.bump {
  animation: pillIn 0.28s cubic-bezier(0.2, 1.4, 0.4, 1);
}

/* Banner */
.banner {
  position: absolute;
  left: 50%;
  top: 34%;
  transform: translate(-50%, -50%) scale(0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
}

.banner.show {
  animation: bannerIn 2.4s ease-out forwards;
}

.banner-main {
  font-size: clamp(30px, 5.4vw, 56px);
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #fff;
  text-shadow: 0 4px 34px rgba(79, 179, 255, 0.85), 0 2px 0 rgba(0, 0, 0, 0.35);
}

.banner-sub {
  font-size: 13px;
  letter-spacing: 0.24em;
  color: var(--ink-dim);
  text-transform: uppercase;
}

@keyframes bannerIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
    filter: blur(8px);
  }
  12% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.04);
    filter: blur(0);
  }
  20% {
    transform: translate(-50%, -50%) scale(1);
  }
  78% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -56%) scale(0.96);
  }
}

/* Score popups */
.pops {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.pop {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.75), 0 0 22px currentColor;
  will-change: transform, opacity;
}

/* Full-screen effects */
.flash {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  mix-blend-mode: screen;
}

.wipe {
  position: absolute;
  inset: 0;
  background: #05080f;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 35;
}

.wipe.on {
  opacity: 1;
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  background: radial-gradient(125% 105% at 50% 45%, transparent 52%, rgba(0, 0, 0, 0.42) 100%);
}

/* --------------------------------------------------------------------------
   Small screens
   -------------------------------------------------------------------------- */

@media (max-width: 720px) {
  .score {
    font-size: 28px;
  }
  .hud-top {
    padding: 12px 14px;
  }
  .hud-mid {
    display: none;
  }
  .fps {
    display: none;
  }
  .controls-grid {
    grid-template-columns: 1fr;
  }
}
