:root {
  color-scheme: dark;
  --bg: #080b18;
  --panel: rgba(15, 20, 43, 0.88);
  --panel-strong: #111833;
  --line: rgba(134, 151, 255, 0.22);
  --text: #f4f6ff;
  --muted: #aeb7d8;
  --violet: #8d7bff;
  --cyan: #50e6ff;
  --danger: #ff547a;
  --focus: #ffe66b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 78% 14%, rgba(91, 70, 255, 0.24), transparent 34rem),
    radial-gradient(circle at 5% 90%, rgba(27, 202, 255, 0.13), transparent 30rem),
    var(--bg);
}

button, a { -webkit-tap-highlight-color: transparent; }

button { font: inherit; }

.shell {
  width: min(1180px, calc(100% - 2rem));
  min-height: 100svh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 1.25rem;
  padding: 1.25rem 0 1rem;
}

.masthead, footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.brand-mark {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border: 1px solid rgba(141, 123, 255, 0.7);
  border-radius: 0.7rem;
  color: var(--cyan);
  background: linear-gradient(145deg, rgba(80, 230, 255, 0.12), rgba(141, 123, 255, 0.18));
  box-shadow: inset 0 0 1.2rem rgba(80, 230, 255, 0.08);
  letter-spacing: 0;
}

.system-state {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.system-state span {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0.85rem rgba(80, 230, 255, 0.9);
}

.game-panel {
  align-self: center;
  display: grid;
  grid-template-columns: minmax(17rem, 0.74fr) minmax(30rem, 1.45fr);
  gap: clamp(1rem, 3vw, 2.5rem);
  padding: clamp(1.1rem, 3vw, 2.25rem);
  border: 1px solid var(--line);
  border-radius: 1.6rem;
  background: linear-gradient(145deg, rgba(17, 24, 51, 0.96), rgba(10, 14, 31, 0.9));
  box-shadow: 0 2rem 7rem rgba(0, 0, 0, 0.42);
  overflow: hidden;
}

.game-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
}

.eyebrow {
  margin: 0 0 0.8rem;
  color: var(--cyan);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.65rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.instructions {
  max-width: 37rem;
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

kbd {
  display: inline-grid;
  min-width: 1.7rem;
  min-height: 1.7rem;
  place-items: center;
  margin: 0 0.08rem;
  padding: 0 0.35rem;
  border: 1px solid rgba(174, 183, 216, 0.4);
  border-bottom-width: 2px;
  border-radius: 0.35rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  font: 700 0.8rem/1 ui-monospace, monospace;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 1.4rem;
}

.scoreboard div {
  min-width: 0;
  padding: 0.75rem 0.6rem;
  border: 1px solid rgba(134, 151, 255, 0.16);
  border-radius: 0.8rem;
  background: rgba(7, 10, 24, 0.46);
}

.scoreboard span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scoreboard strong {
  display: block;
  margin-top: 0.2rem;
  font-size: 1.35rem;
  line-height: 1;
}

.actions {
  display: flex;
  gap: 0.7rem;
  margin-top: 1.2rem;
}

.actions button {
  min-height: 3rem;
  padding: 0.65rem 1rem;
  border-radius: 0.8rem;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  flex: 1;
  border: 1px solid transparent;
  color: #07111d;
  background: linear-gradient(110deg, var(--cyan), #9af2ff);
  box-shadow: 0 0.7rem 2.2rem rgba(80, 230, 255, 0.16);
}

.quiet-button {
  border: 1px solid rgba(174, 183, 216, 0.28);
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.actions button:hover:not(:disabled) { filter: brightness(1.08); }
.actions button:active:not(:disabled) { transform: translateY(1px); }
.actions button:disabled { cursor: not-allowed; opacity: 0.45; }

button:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.game-status {
  min-height: 1.5rem;
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.playfield-wrap {
  position: relative;
  align-self: center;
  min-width: 0;
  border: 1px solid rgba(80, 230, 255, 0.2);
  border-radius: 1.15rem;
  background: #070b1b;
  box-shadow: inset 0 0 4rem rgba(33, 40, 94, 0.34);
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 45 / 26;
  touch-action: none;
}

.scanline {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 4px, rgba(129, 150, 255, 0.025) 4px 5px);
  mix-blend-mode: screen;
}

.touch-controls {
  position: absolute;
  right: 0.8rem;
  bottom: 0.8rem;
  display: none;
  gap: 0.6rem;
}

.touch-controls button {
  width: 3.6rem;
  height: 3.6rem;
  border: 1px solid rgba(80, 230, 255, 0.4);
  border-radius: 50%;
  color: var(--text);
  background: rgba(9, 15, 37, 0.82);
  backdrop-filter: blur(8px);
  font-size: 1.4rem;
  font-weight: 800;
  touch-action: none;
}

footer {
  color: rgba(174, 183, 216, 0.72);
  font-size: 0.75rem;
  line-height: 1.4;
  letter-spacing: 0.04em;
}

footer span:first-child { font-weight: 800; letter-spacing: 0.14em; }
.noscript { margin: 1rem; color: var(--danger); }

@media (max-width: 860px) {
  .shell { width: min(100% - 1rem, 46rem); padding-top: 0.75rem; }
  .game-panel { grid-template-columns: 1fr; }
  .game-copy { order: 2; }
  .playfield-wrap { order: 1; }
  h1 br { display: none; }
  .instructions { margin-top: 0.9rem; }
  .touch-controls { display: flex; }
}

@media (max-width: 520px) {
  .system-state { font-size: 0; }
  .system-state span { width: 0.65rem; height: 0.65rem; }
  .game-panel { padding: 0.8rem; border-radius: 1.15rem; }
  .scoreboard { grid-template-columns: repeat(2, 1fr); }
  .actions { flex-direction: column; }
  .quiet-button { width: 100%; }
  footer { align-items: flex-start; flex-direction: column; gap: 0.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
