/* ================================================================
   NEON BREAKER — retro arcade design tokens
   Palette: neon red + electric blue on deep slate, score green
   Type: Press Start 2P (display) / VT323 (UI + numerals)
   ================================================================ */
:root {
  --primary: #dc2626;
  --primary-soft: #ff5a5a;
  --secondary: #2563eb;
  --secondary-soft: #60a5fa;
  --accent: #22c55e;
  --accent-soft: #6ee7a0;
  --gold: #f59e0b;
  --violet: #a855f7;

  --background: #0f172a;
  --surface: #131c33;
  --surface-2: #1b2540;
  --foreground: #ffffff;
  --muted: #1f1829;
  --text-dim: #93a0bd;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --glass: rgba(255, 255, 255, 0.045);

  --font-display: "Press Start 2P", "Courier New", monospace;
  --font-ui: "VT323", "Courier New", monospace;

  --glow-red: 0 0 12px rgba(220, 38, 38, 0.75);
  --glow-blue: 0 0 12px rgba(37, 99, 235, 0.7);
  --glow-green: 0 0 12px rgba(34, 197, 94, 0.65);

  --radius: 14px;
  --radius-sm: 8px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  padding: clamp(8px, 2vw, 28px);
  display: grid;
  place-items: center;
  background:
    radial-gradient(1100px 620px at 50% -10%, rgba(37, 99, 235, 0.22), transparent 62%),
    radial-gradient(900px 560px at 12% 108%, rgba(220, 38, 38, 0.16), transparent 60%),
    var(--background);
  color: var(--foreground);
  font-family: var(--font-ui);
  font-size: 20px;
  line-height: 1.35;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* --- full-page CRT effects ------------------------------------- */
.fx-scanlines,
.fx-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}
.fx-scanlines {
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.035) 0 1px,
    transparent 1px 3px
  );
  mix-blend-mode: overlay;
  opacity: 0.55;
}
.fx-vignette {
  background: radial-gradient(130% 100% at 50% 45%, transparent 52%, rgba(0, 0, 0, 0.62) 100%);
}

/* --- cabinet shell --------------------------------------------- */
.cabinet {
  position: relative;
  z-index: 10;
  width: min(1020px, 100%);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(8px, 1.4vw, 14px);
  padding: clamp(10px, 1.6vw, 18px);
  background: linear-gradient(180deg, rgba(19, 28, 51, 0.92), rgba(15, 23, 42, 0.96));
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  box-shadow:
    0 34px 70px -30px rgba(0, 0, 0, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 0 0 6px rgba(255, 255, 255, 0.02);
}

/* --- HUD ------------------------------------------------------- */
.hud {
  display: flex;
  align-items: center;
  gap: clamp(10px, 2vw, 22px);
  flex-wrap: wrap;
  padding: 4px 6px 10px;
  border-bottom: 1px dashed var(--border);
}
.hud-brand { display: flex; align-items: center; gap: 10px; }
.hud-brand__name {
  font-family: var(--font-display);
  font-size: clamp(8px, 1.15vw, 11px);
  line-height: 1.5;
  letter-spacing: 0.06em;
  color: var(--foreground);
  text-shadow: var(--glow-blue);
}
.hud-brand__logo { display: grid; grid-template-columns: repeat(3, 7px); gap: 3px; }
.blk { height: 7px; display: block; }
.blk--red { background: var(--primary); box-shadow: var(--glow-red); }
.blk--blue { background: var(--secondary); box-shadow: var(--glow-blue); }
.blk--green { background: var(--accent); box-shadow: var(--glow-green); }

.hud-stats {
  display: flex;
  gap: clamp(10px, 2.2vw, 26px);
  margin: 0;
  margin-inline-start: auto;
  flex-wrap: wrap;
}
.stat { text-align: center; min-width: 62px; }
.stat dt {
  font-size: 15px;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  text-transform: uppercase;
}
.stat dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(11px, 1.5vw, 15px);
  color: var(--accent);
  text-shadow: var(--glow-green);
}
.stat--hi dd { color: var(--gold); text-shadow: 0 0 12px rgba(245, 158, 11, 0.6); }
.stat__of { color: var(--text-dim); font-size: 0.7em; }

.hud-actions { display: flex; align-items: center; gap: 10px; }

.lives { display: flex; gap: 5px; }
.life { width: 20px; height: 20px; color: var(--primary); filter: drop-shadow(0 0 6px rgba(220, 38, 38, 0.8)); }
.life.is-off { color: rgba(255, 255, 255, 0.16); filter: none; }

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--foreground);
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { transform: translateY(-2px); border-color: var(--secondary-soft); background: rgba(37, 99, 235, 0.16); }
.icon-btn.is-muted { color: var(--text-dim); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- stage / canvas -------------------------------------------- */
.stage {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: #060a14;
  box-shadow: inset 0 0 70px rgba(37, 99, 235, 0.14);
  touch-action: none;
}
#game {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  cursor: none;
}
.stage.is-touch #game { cursor: default; }

/* --- power-up indicator bar ------------------------------------ */
.powerbar {
  position: absolute;
  inset-inline: 10px;
  bottom: 10px;
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  pointer-events: none;
  z-index: 12;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 16px;
  letter-spacing: 0.06em;
  border-radius: 999px;
  background: rgba(6, 10, 20, 0.76);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(8px);
  color: var(--accent-soft);
  animation: chipIn 0.24s var(--ease);
}
.chip svg { width: 15px; height: 15px; }
.chip--warn { color: var(--gold); }
@keyframes chipIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* --- overlay panels -------------------------------------------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(circle at 50% 40%, rgba(6, 10, 20, 0.72), rgba(6, 10, 20, 0.94));
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s var(--ease), visibility 0.22s;
}
.overlay.is-open { opacity: 1; visibility: visible; }

.panel {
  width: min(560px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: clamp(18px, 3vw, 30px);
  text-align: center;
  background: rgba(19, 28, 51, 0.82);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  backdrop-filter: blur(14px);
  box-shadow: 0 26px 60px -26px rgba(0, 0, 0, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  animation: panelIn 0.3s var(--ease);
}
@keyframes panelIn { from { opacity: 0; transform: translateY(16px) scale(0.97); } to { opacity: 1; transform: none; } }

.panel__kicker {
  font-size: 17px;
  letter-spacing: 0.34em;
  color: var(--secondary-soft);
  text-transform: uppercase;
  margin: 0 0 10px;
}
.panel__title {
  font-family: var(--font-display);
  font-size: clamp(15px, 2.9vw, 26px);
  line-height: 1.45;
  margin: 0 0 12px;
  color: var(--foreground);
  text-shadow: 0 0 10px rgba(96, 165, 250, 0.75), 0 0 26px rgba(37, 99, 235, 0.4);
}
.panel__title--red { text-shadow: 0 0 10px rgba(220, 38, 38, 0.8), 0 0 26px rgba(220, 38, 38, 0.45); }
.panel__title--green { text-shadow: 0 0 10px rgba(34, 197, 94, 0.8), 0 0 26px rgba(34, 197, 94, 0.4); }
.panel__text { margin: 0 0 16px; color: var(--text-dim); font-size: 19px; line-height: 1.5; }
.panel__text b { color: var(--accent-soft); }

/* --- buttons --------------------------------------------------- */
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 4px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 20px;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--foreground);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease), border-color 0.16s var(--ease);
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { transform: translateY(-2px); border-color: var(--foreground); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn--primary {
  background: linear-gradient(180deg, var(--primary-soft), var(--primary));
  border-color: rgba(255, 255, 255, 0.24);
  box-shadow: var(--glow-red);
}
.btn--primary:hover { box-shadow: 0 0 20px rgba(220, 38, 38, 0.85); }
.btn--accent {
  background: linear-gradient(180deg, var(--accent-soft), var(--accent));
  color: #04160c;
  border-color: rgba(255, 255, 255, 0.26);
  box-shadow: var(--glow-green);
}

/* --- legend (power-ups) ---------------------------------------- */
.legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 16px;
  text-align: start;
}
.legend__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 16px;
  color: var(--text-dim);
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.legend__item svg { width: 17px; height: 17px; flex: none; }
.legend__item b { color: var(--foreground); font-weight: 400; }

/* --- scoreboard (game over / clear) ---------------------------- */
.scoreboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin: 6px 0 18px;
}
.scoreboard__cell {
  padding: 12px 8px;
  background: rgba(6, 10, 20, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.scoreboard__label { display: block; font-size: 15px; letter-spacing: 0.16em; color: var(--text-dim); }
.scoreboard__value {
  font-family: var(--font-display);
  font-size: clamp(13px, 2vw, 18px);
  color: var(--accent);
  text-shadow: var(--glow-green);
}
.scoreboard__value--gold { color: var(--gold); text-shadow: 0 0 12px rgba(245, 158, 11, 0.6); }
.new-record {
  display: inline-block;
  margin-bottom: 12px;
  padding: 6px 14px;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: #04160c;
  background: linear-gradient(180deg, var(--gold), #d97706);
  border-radius: 999px;
  animation: blink 1.1s steps(2, end) infinite;
}
@keyframes blink { 50% { opacity: 0.35; } }

/* --- footer strip --------------------------------------------- */
.strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 6px 2px;
  border-top: 1px dashed var(--border);
  color: var(--text-dim);
  font-size: 17px;
  letter-spacing: 0.04em;
}
.strip__keys { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.key {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  padding: 2px 8px;
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--foreground);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-bottom-width: 3px;
  border-radius: 6px;
}
.key--wide { padding-inline: 12px; }
.strip__hint { color: var(--secondary-soft); }
.strip__hint.is-visible { animation: blink 1.4s steps(2, end) infinite; }

/* --- responsive ------------------------------------------------- */
@media (max-width: 720px) {
  body { font-size: 18px; padding: 6px; }
  .cabinet { border-radius: 16px; padding: 8px; }
  .hud { gap: 8px; }
  .hud-stats { gap: 8px; margin-inline-start: 0; width: 100%; justify-content: space-between; }
  .stat { min-width: 0; flex: 1; }
  .hud-actions { margin-inline-start: auto; }
  .icon-btn { width: 38px; height: 38px; }
  .strip__keys { display: none; }
  .strip { justify-content: center; }
  .legend { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 420px) {
  .panel { padding: 16px 12px; }
  .legend { grid-template-columns: 1fr; }
  .btn { font-size: 10px; padding: 11px 14px; }
}

@media (hover: none) {
  #game { cursor: default; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  .fx-scanlines { display: none; }
}

/* --- icon fallback: keep button/legend layout stable if the
       icon font fails to load (offline / blocked CDN) ----------- */
.btn i, .icon-btn i, .legend__item i, .chip i, .life i {
  display: inline-block;
  width: 1em;
  height: 1em;
  min-width: 14px;
}
.life svg { width: 20px; height: 20px; }
