:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #f6f2ff;
  background: #0d0919;
  --muted: #b9adcf;
  --gold: #ffd16a;
  --edge: #342747;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  min-height: 100svh;
  margin: 0;
  background: radial-gradient(ellipse at 50% -10%, #251442, transparent 73%), #0d0919;
}

button { font: inherit; cursor: pointer; }
button:focus-visible, canvas:focus-visible { outline: 3px solid #c4afff; outline-offset: 4px; }
.arcade { width: min(100% - 64px, 1280px); margin-inline: auto; padding: 22px 0 16px; }
.topbar, .brand, .tools, .hud, .stat, .guide, .guide p, .guide-items > span, .keys {
  display: flex;
  align-items: center;
}
.topbar { justify-content: space-between; margin-bottom: 16px; }
.brand {
  gap: 11px;
  font-size: 1.27rem;
  font-weight: 900;
  letter-spacing: -.025em;
}
.brand-icon {
  display: grid;
  place-items: center;
  height: 38px;
  width: 38px;
  border-radius: 11px;
  background: linear-gradient(150deg, #b47bff, #7441de);
  color: white;
  font-size: 1.53rem;
  line-height: 1;
  box-shadow: 0 3px 15px #a263ff44, inset 0 1px #ffffff38;
}
.brand-sub { color: #b7a1d2; margin-left: 4px; font-size: .74rem; letter-spacing: .15em; }
.tools { gap: 8px; }
.tool {
  width: 44px;
  height: 42px;
  display: grid;
  place-content: center;
  border: 1px solid var(--edge);
  color: #eee0ff;
  border-radius: 10px;
  background: #211631;
  font-weight: 800;
  font-size: 1.1rem;
}
.tool:hover:not(:disabled) { background: #36234e; }
.tool:disabled { opacity: .44; cursor: default; }
.sound { grid-auto-flow: column; gap: 2px; align-items: center; }
.speaker { display: block; width: 11px; height: 14px; background: currentColor; clip-path: polygon(0 32%, 38% 32%, 100% 0, 100% 100%, 38% 68%, 0 68%); }
.sound-waves { font-size: .72rem; letter-spacing: -.17em; padding-right: .17em; }
.sound[aria-pressed="true"] .sound-waves { opacity: .4; }
.corners {
  width: 15px;
  height: 15px;
  display: block;
  background: currentColor;
  clip-path: polygon(0 0, 40% 0, 40% 13%, 13% 13%, 13% 40%, 0 40%, 0 0, 60% 0, 100% 0, 100% 40%, 87% 40%, 87% 13%, 60% 13%, 60% 0, 0 0, 0 60%, 13% 60%, 13% 87%, 40% 87%, 40% 100%, 0 100%, 0 60%, 100% 60%, 100% 100%, 60% 100%, 60% 87%, 87% 87%, 87% 60%, 100% 60%, 0 60%);
}
.frame {
  border: 1px solid var(--edge);
  border-radius: 21px;
  overflow: hidden;
  box-shadow: 0 22px 70px #06040e91;
}
.hud {
  position: relative;
  z-index: 1;
  padding: 11px clamp(12px, 2.1vw, 26px);
  gap: 13px clamp(16px, 2.8vw, 37px);
  min-height: 62px;
  background: #1b122b;
  border-bottom: 1px solid #483461;
}
.stat { gap: 8px; min-width: 0; }
.stat > div:not(.hearts) { display: grid; }
.star-symbol { color: var(--gold); font-size: 1.35rem; line-height: 1; }
.best-symbol, .gem-symbol { color: #c2a1ff; font-size: 1.2rem; line-height: 1; }
.label { color: var(--muted); font-size: .82rem; font-weight: 700; line-height: 1.1; }
.hud output { margin-top: 3px; color: #f8f3ff; font-size: 1.12rem; font-weight: 850; line-height: 1; font-variant-numeric: tabular-nums; }
.wave { margin-left: auto; padding: 6px 10px; border: 1px solid #4c3867; border-radius: 8px; }
.wave output { margin-top: 0; color: #d5beff; font-size: .95rem; }
.hearts { display: flex; gap: 4px; font-size: 1.33rem; color: #ff80a5; line-height: 1; }
.hearts .lost { color: #574162; }
.stage {
  position: relative;
  isolation: isolate;
  height: clamp(390px, calc(100svh - 194px), 730px);
  background: radial-gradient(ellipse at 58% 28%, #282149, #0a0920 76%);
}
.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(0deg, #110c26a0, #100d2358 35%, #0b0a1c19), url("./nebula.png") center 52% / cover no-repeat;
}
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
canvas:focus-visible { outline-offset: -5px; }
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2.4vh, 25px);
  padding: 16px 18px;
  text-align: center;
  background: radial-gradient(ellipse at center, #120b2799 0%, #18112550 55%, transparent 85%);
}
.pilot-badge {
  width: clamp(114px, 24vh, 200px);
  height: clamp(114px, 24vh, 200px);
  object-fit: contain;
  filter: drop-shadow(0 9px 28px #9a7cff6b);
  animation: float 3.8s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-8px); } }
h1, h2, p { margin: 0; }
h1, h2 {
  font-family: "Segoe UI Black", "Arial Black", "Segoe UI", sans-serif;
  font-weight: 950;
  line-height: .92;
  letter-spacing: -.048em;
  filter: drop-shadow(0 6px 0 #2a194c) drop-shadow(0 8px 25px #0b061fcd);
}
h1 { font-size: clamp(3.15rem, 8vw, 7.4rem); }
h1 span { color: #fff9ea; }
h1 strong { color: #d2adff; }
h2 { font-size: clamp(2.8rem, 7vw, 6rem); }
.welcome p, #result p {
  margin-top: 21px;
  color: #f0e4ff;
  font-size: clamp(1rem, 2vw, 1.25rem);
  text-shadow: 0 2px 8px #0a0617;
}
.launch {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  min-height: 53px;
  padding: 10px 30px;
  border-radius: 12px;
  border: 1px solid #ffdf99;
  box-shadow: 0 4px 0 #a9662e, 0 6px 25px #ffa7483d;
  background: linear-gradient(180deg, #ffde88, #ffbd54);
  color: #2b172e;
  font-weight: 900;
  font-size: 1.06rem;
}
.launch:hover { background: #ffe09a; }
.launch:active { transform: translateY(2px); box-shadow: 0 2px 0 #a9662e; }
.play-icon { width: 12px; height: 14px; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.wave-toast {
  position: absolute;
  top: 9%;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border: 1px solid #a778ef;
  border-radius: 99px;
  background: #20113aeb;
  color: #f0defe;
  font-weight: 850;
  pointer-events: none;
}
.guide {
  padding: 14px 2px 0;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  color: #c9bfd9;
  font-size: .88rem;
}
.guide p, .guide-items > span { gap: 8px; }
.guide .guide-items { gap: 9px 19px; flex-wrap: wrap; }
.keys { display: grid; grid-template-columns: repeat(3, 22px); grid-template-rows: repeat(2, 19px); gap: 2px; }
.keys kbd { display: grid; place-items: center; background: #251933; border: 1px solid #48355e; border-radius: 5px; color: white; font: inherit; line-height: 1; }
.keys kbd:nth-child(1) { grid-area: 1 / 2; }
.keys kbd:nth-child(2) { grid-area: 2 / 1; }
.keys kbd:nth-child(3) { grid-area: 2 / 2; }
.keys kbd:nth-child(4) { grid-area: 2 / 3; }
.meteor-symbol { width: .91rem; height: .91rem; background: #f59a71; border: 3px solid #8d3e59; border-radius: 43% 51% 45% 40%; }
.touch-only { display: none; }
#arcade:fullscreen { width: 100%; padding: 10px 16px; overflow: auto; background: #0d0919; }
#arcade:fullscreen .stage { height: max(270px, calc(100dvh - 154px)); }

@media (max-width: 680px) {
  .arcade { width: calc(100% - 22px); padding-top: 11px; }
  .topbar { margin-bottom: 10px; }
  .frame { border-radius: 14px; }
  .hud { gap: 10px; min-height: 57px; }
  .stat { gap: 5px; }
  .wave { padding-inline: 6px; }
  .hull { flex-direction: column; gap: 2px; }
  .hearts { gap: 2px; font-size: 1.15rem; }
  .stage { height: clamp(390px, calc(100svh - 209px), 640px); }
  .stage::before { background-position: 72% center; }
  h1 span, h1 strong { display: block; }
  .welcome p, #result p { margin-top: 13px; }
  .guide { gap: 8px; }
}
@media (pointer: coarse) {
  .keyboard-only, .keys { display: none; }
  .touch-only { display: inline; }
}
@media (max-width: 355px) {
  .hud { gap: 8px; padding-inline: 8px; }
  .stat .star-symbol, .stat .best-symbol { display: none; }
}
@media (max-height: 620px) and (min-width: 681px) {
  .pilot-badge { width: 108px; height: 108px; }
  h1 { font-size: clamp(2.8rem, 8vw, 5.6rem); }
}
@media (max-height: 480px) and (orientation: landscape) {
  .arcade { padding-top: 8px; }
  .topbar { margin-bottom: 8px; }
  .stage { height: max(230px, calc(100svh - 146px)); }
  .pilot-badge { width: 78px; height: 78px; }
  .overlay { gap: 8px; }
  h1, h2 { font-size: clamp(2.2rem, 6vw, 4.2rem); }
  .welcome p, #result p { margin-top: 8px; }
  .launch { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .pilot-badge { animation: none; }
}
