/* Bricks — matches the games hub palette. Dark by default, light via prefers-color-scheme.
   game.js reads the --field, --paddle, --ball, --b1..--b5 and --steel colours for the canvas. */

:root {
  color-scheme: dark;
  --font-display: 'Bricolage Grotesque', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-body: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --bg: #0d0d10;
  --surface: #17171c;
  --surface-2: #222229;
  --text: #f5f5f7;
  --muted: #a1a1aa;
  --line: #2a2a31;
  --accent: #b18cff;
  --warn: #ffd23f;
  --danger: #ff5d5d;
  --focus: #ffd23f;

  /* Canvas */
  --field: #111116;
  --field-line: #1b1b21;
  --paddle: #b18cff;
  --ball: #f5f5f7;
  --flash: #ffffff;
  --scrim: rgba(13, 13, 16, 0.74);
  --steel: #4a4a55;
  --steel-hi: #6b6b78;

  /* Brick colours by hit points left */
  --b1: #5aa9ff;
  --b2: #2fbf71;
  --b3: #ffd23f;
  --b4: #ffa94d;
  --b5: #ff5d5d;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f6f6f3;
    --surface: #ffffff;
    --surface-2: #ececea;
    --text: #141416;
    --muted: #55555e;
    --line: #dcdcd6;
    --accent: #6b46c1;
    --focus: #141416;

    --field: #fbfbf9;
    --field-line: #efefea;
    --paddle: #6b46c1;
    --ball: #141416;
    --flash: #ffffff;
    --scrim: rgba(246, 246, 243, 0.8);
    --steel: #9d9da6;
    --steel-hi: #bdbdc4;

    --b1: #1f6fd1;
    --b2: #1d8a50;
    --b3: #d9a300;
    --b4: #e07a1f;
    --b5: #d63c3c;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background:
    radial-gradient(60rem 30rem at 15% -10%, rgba(177, 140, 255, 0.14), transparent 60%),
    radial-gradient(50rem 28rem at 110% 0%, rgba(255, 169, 77, 0.10), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.topbar {
  width: 100%;
  max-width: 560px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.back {
  justify-self: start;
  display: inline-flex; align-items: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.95rem;
  padding: 6px 8px 6px 2px; border-radius: 10px;
}
.back:hover { color: var(--text); }
.back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.5rem, 6vw, 2rem);
  letter-spacing: -0.03em;
  margin: 0;
}

.hud {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: min(100%, 480px);
}
.stat {
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px;
  padding: 0 12px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
  font: 800 1.1rem var(--font-display);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat.score { flex: 1 1 auto; min-width: 96px; max-width: 150px; }
.stat svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linejoin: round; }
.stat-label { color: var(--muted); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.lives { gap: 6px; }
.life {
  width: 12px; height: 12px; border-radius: 4px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.life.on { background: var(--accent); box-shadow: none; }
.reset {
  width: 44px; height: 44px; flex: none; border-radius: 12px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line);
  display: grid; place-items: center; padding: 0;
  transition: transform 120ms ease;
}
.reset svg { width: 22px; height: 22px; fill: none; stroke: var(--text); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.reset:hover { border-color: var(--muted); }
.reset:active { transform: scale(0.94); }

.field-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}
.field {
  display: block;
  width: 300px; height: 400px; /* game.js sets the real size */
  border-radius: 14px;
  background: var(--field);
  box-shadow: 0 0 0 1px var(--line);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.status {
  margin: 0; min-height: 1.6em;
  font: 800 1.25rem var(--font-display); letter-spacing: -0.01em;
  text-align: center;
}
.status.win { color: var(--accent); }
.status.lose { color: var(--danger); }
.best { margin: -10px 0 0; color: var(--muted); font-size: 0.9rem; min-height: 1.4em; text-align: center; }

@media (max-width: 360px) {
  .stat { padding: 0 9px; font-size: 1rem; }
  .stat.score { min-width: 80px; }
}
@media (prefers-reduced-motion: reduce) { .reset { transition: none; } }
