:root {
  color-scheme: dark;
  --black: #030207;
  --ink: #090811;
  --panel: rgba(14, 12, 25, 0.92);
  --white: #f8faff;
  --silver: #b9c4d5;
  --green: #43ff72;
  --green-hot: #adff4d;
  --purple: #be46ff;
  --violet: #742cff;
  --cyan: #35e8ff;
  --pink: #ff45c7;
  --warning: #ffcf4a;
  --cabinet-width: min(100vw, 760px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--black);
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -20%, rgba(108, 26, 196, 0.34), transparent 42rem),
    radial-gradient(circle at 10% 35%, rgba(36, 255, 106, 0.08), transparent 26rem),
    #030207;
  color: var(--white);
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
  font: inherit;
}

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

.game-shell {
  display: grid;
  min-height: 100svh;
  place-items: start center;
  padding: max(10px, env(safe-area-inset-top)) 8px max(14px, env(safe-area-inset-bottom));
}

.cabinet {
  position: relative;
  width: var(--cabinet-width);
  overflow: hidden;
  border: 1px solid rgba(196, 216, 255, 0.22);
  border-radius: 26px;
  background:
    linear-gradient(130deg, rgba(255,255,255,0.11), transparent 16%, transparent 78%, rgba(255,255,255,0.06)),
    #09080e;
  box-shadow:
    0 0 0 4px #020104,
    0 0 0 6px rgba(89, 255, 120, 0.16),
    0 26px 80px rgba(0, 0, 0, 0.72),
    0 0 70px rgba(153, 44, 255, 0.13);
  isolation: isolate;
}

.cabinet::before {
  position: absolute;
  inset: 0;
  z-index: 10;
  border-radius: inherit;
  box-shadow: inset 0 0 32px rgba(190, 70, 255, 0.12);
  content: "";
  pointer-events: none;
}

.topper {
  position: relative;
  display: grid;
  min-height: 100px;
  grid-template-columns: 100px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(112, 255, 144, 0.28);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), transparent),
    radial-gradient(circle at 18% 50%, rgba(63, 255, 111, 0.12), transparent 36%),
    #08070d;
}

.brand-logo {
  width: 94px;
  height: 94px;
  object-fit: contain;
  filter: drop-shadow(0 0 14px rgba(72, 255, 111, 0.42));
  user-select: none;
}

.title-lockup {
  display: flex;
  min-width: 0;
  flex-direction: column;
  line-height: 0.9;
  text-transform: uppercase;
}

.title-lockup > span {
  color: var(--green);
  font-size: clamp(0.68rem, 2vw, 0.82rem);
  font-weight: 900;
  letter-spacing: 0.28em;
}

.title-lockup > strong {
  margin-top: 5px;
  color: var(--white);
  font-size: clamp(1.75rem, 6vw, 3rem);
  font-weight: 1000;
  letter-spacing: -0.07em;
  text-shadow: 0 0 24px rgba(190, 70, 255, 0.45);
}

.title-lockup > small {
  margin-top: 8px;
  color: #acb5c7;
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1.2;
}

.icon-button {
  min-width: 76px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid rgba(217, 228, 255, 0.24);
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  color: #b9c4d5;
  cursor: pointer;
  font-size: 0.67rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.icon-button[aria-pressed="true"] {
  border-color: rgba(67, 255, 114, 0.6);
  color: var(--green);
  box-shadow: inset 0 0 15px rgba(67,255,114,0.08), 0 0 18px rgba(67,255,114,0.08);
}

.hud {
  display: grid;
  grid-template-columns: 1.45fr repeat(3, 1fr);
  border-bottom: 1px solid rgba(216, 227, 255, 0.16);
  background: rgba(4, 3, 8, 0.98);
}

.hud-cell {
  min-width: 0;
  padding: 9px 10px 8px;
  border-right: 1px solid rgba(216, 227, 255, 0.12);
}

.hud-cell:last-child {
  border-right: 0;
}

.hud-cell span,
.mission-copy span,
.hyper-meter > span {
  display: block;
  color: #8f98aa;
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.hud-cell strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--white);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(0.78rem, 2.8vw, 1.08rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-cell strong {
  color: var(--green);
  text-shadow: 0 0 12px rgba(67,255,114,0.35);
}

.mission-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 42%);
  align-items: center;
  gap: 14px;
  padding: 9px 14px;
  border-bottom: 1px solid rgba(190, 70, 255, 0.26);
  background: linear-gradient(90deg, rgba(93, 32, 145, 0.2), rgba(21, 255, 92, 0.055));
}

.mission-copy strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  font-size: 0.84rem;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hyper-meter {
  min-width: 0;
}

.hyper-meter > span {
  margin-bottom: 5px;
  text-align: right;
}

.hyper-meter i {
  display: block;
  height: 7px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
}

.hyper-meter b {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--purple), var(--cyan), var(--green));
  box-shadow: 0 0 14px var(--green);
  transition: width 180ms ease;
}

.playfield-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #030207;
  touch-action: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 720 / 1120;
  background: #030207;
}

.playfield-logo {
  position: absolute;
  top: 25.8%;
  left: 50%;
  z-index: 2;
  width: 27%;
  height: auto;
  opacity: 0.13;
  filter: grayscale(0.3) drop-shadow(0 0 16px rgba(76, 255, 126, 0.7));
  mix-blend-mode: screen;
  pointer-events: none;
  transform: translateX(-50%);
  user-select: none;
}

.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 32px 28px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 34%, rgba(75, 255, 123, 0.1), transparent 20%),
    radial-gradient(circle at 50% 52%, rgba(132, 41, 220, 0.3), transparent 45%),
    rgba(2, 1, 6, 0.92);
  text-align: center;
  transition: opacity 320ms ease, visibility 320ms ease;
}

.game-overlay[hidden],
.controls-modal[hidden] {
  display: none;
}

.game-overlay:not(.is-visible) {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay-scan {
  position: absolute;
  inset: -100% 0;
  background: linear-gradient(180deg, transparent 45%, rgba(81,255,125,0.12) 50%, transparent 55%);
  animation: scan 5.8s linear infinite;
}

.overlay-logo {
  z-index: 1;
  width: min(46%, 300px);
  height: auto;
  margin: -20px 0 -18px;
  filter: drop-shadow(0 0 24px rgba(63, 255, 111, 0.35));
  animation: float-logo 4s ease-in-out infinite;
  user-select: none;
}

.kicker {
  position: relative;
  z-index: 1;
  margin: 0 0 8px;
  color: var(--green);
  font-size: clamp(0.65rem, 2vw, 0.8rem);
  font-weight: 1000;
  letter-spacing: 0.2em;
}

.game-overlay h1,
.game-overlay h2,
.controls-card h2 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: clamp(2.2rem, 9vw, 4.5rem);
  font-weight: 1000;
  letter-spacing: -0.075em;
  line-height: 0.83;
}

.game-overlay h1 em {
  color: transparent;
  font-style: normal;
  -webkit-text-stroke: 1px var(--purple);
  text-shadow: 0 0 28px rgba(190,70,255,0.7);
}

.briefing {
  position: relative;
  z-index: 1;
  max-width: 450px;
  margin: 18px auto 20px;
  color: #c8cfdd;
  font-size: clamp(0.9rem, 2.6vw, 1.05rem);
  line-height: 1.45;
}

.primary-button {
  position: relative;
  z-index: 1;
  min-width: min(100%, 280px);
  min-height: 54px;
  padding: 13px 22px;
  border: 1px solid rgba(210,255,218,0.6);
  border-radius: 14px;
  background: linear-gradient(135deg, #60ff82, #16c759);
  box-shadow: 0 8px 30px rgba(42, 255, 91, 0.2), inset 0 1px 0 rgba(255,255,255,0.55);
  color: #041006;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.primary-button:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.text-button {
  position: relative;
  z-index: 1;
  margin-top: 14px;
  padding: 8px;
  border: 0;
  background: transparent;
  color: #cbd4e6;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.record {
  position: relative;
  z-index: 1;
  margin: 22px 0 0;
  color: #7f8797;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.compact-overlay {
  background: rgba(2, 1, 6, 0.9);
}

.compact-overlay h2 {
  margin-bottom: 28px;
  color: var(--white);
  text-shadow: 0 0 30px rgba(190,70,255,0.55);
}

.controls-modal {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 1, 6, 0.86);
  backdrop-filter: blur(10px);
}

.controls-card {
  position: relative;
  width: min(100%, 510px);
  max-height: 94%;
  padding: 28px;
  overflow: auto;
  border: 1px solid rgba(81,255,124,0.42);
  border-radius: 24px;
  background:
    linear-gradient(160deg, rgba(255,255,255,0.07), transparent 20%),
    #0d0b15;
  box-shadow: 0 24px 70px rgba(0,0,0,0.75), 0 0 38px rgba(190,70,255,0.17);
  text-align: left;
}

.controls-card h2 {
  margin-bottom: 22px;
  font-size: clamp(2rem, 8vw, 3.2rem);
}

.controls-card > p:last-of-type {
  margin: 22px 0;
  color: #bbc4d4;
  font-size: 0.92rem;
  line-height: 1.55;
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  cursor: pointer;
  font-size: 1.65rem;
  line-height: 1;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.control-grid div {
  display: flex;
  min-height: 58px;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  background: rgba(255,255,255,0.035);
}

.control-grid kbd {
  min-width: 38px;
  padding: 7px;
  border: 1px solid rgba(81,255,124,0.55);
  border-radius: 7px;
  background: #050408;
  box-shadow: inset 0 -2px 0 rgba(255,255,255,0.15);
  color: var(--green);
  font-size: 0.68rem;
  font-weight: 900;
  text-align: center;
}

.control-grid span {
  color: #d7ddea;
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.25;
}

.cabinet-controls {
  display: grid;
  grid-template-columns: 0.78fr 1fr 1fr 0.94fr;
  gap: 8px;
  padding: 11px;
  border-top: 1px solid rgba(255,255,255,0.13);
  border-bottom: 1px solid rgba(255,255,255,0.09);
  background:
    linear-gradient(180deg, #16131d, #08070b 65%),
    #09080d;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
}

.cabinet-button {
  display: flex;
  min-width: 0;
  min-height: 64px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 14px;
  background: linear-gradient(180deg, #24202d, #0a090d);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 4px 0 #020103;
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

.cabinet-button small {
  color: #919aab;
  font-size: clamp(0.46rem, 1.8vw, 0.58rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.cabinet-button strong {
  margin-top: 3px;
  font-size: clamp(0.75rem, 2.6vw, 0.94rem);
  font-weight: 1000;
  letter-spacing: 0.04em;
}

.cabinet-button.flipper {
  border-color: rgba(73,255,119,0.42);
}

.cabinet-button.launch {
  border-color: rgba(190,70,255,0.56);
}

.cabinet-button.nudge {
  border-color: rgba(53,232,255,0.42);
}

.cabinet-button.is-active,
.cabinet-button:active {
  box-shadow: inset 0 0 24px rgba(76,255,121,0.28), 0 1px 0 #020103;
  color: var(--green);
  transform: translateY(3px);
}

.cabinet-button.launch.is-active,
.cabinet-button.launch:active {
  box-shadow: inset 0 0 26px rgba(190,70,255,0.36), 0 1px 0 #020103;
  color: #e4a5ff;
}

.cabinet-footer {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  color: #6f7685;
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.cabinet-footer button {
  min-height: 32px;
  padding: 6px 14px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  color: #aab2c1;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.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;
}

@keyframes float-logo {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-8px) rotate(1deg); }
}

@keyframes scan {
  from { transform: translateY(-25%); }
  to { transform: translateY(25%); }
}

@media (max-width: 560px) {
  .game-shell { padding-inline: 0; }
  .cabinet { border-radius: 0; border-inline: 0; box-shadow: none; }
  .topper { min-height: 84px; grid-template-columns: 76px 1fr auto; padding: 6px 10px; gap: 8px; }
  .brand-logo { width: 74px; height: 74px; }
  .title-lockup > small { display: none; }
  .icon-button { min-width: 64px; min-height: 40px; padding: 6px; font-size: 0.56rem; }
  .hud-cell { padding: 7px 6px; }
  .hud-cell span { font-size: 0.51rem; }
  .best-cell { display: none; }
  .hud { grid-template-columns: 1.4fr 1fr 1fr; }
  .mission-bar { grid-template-columns: minmax(0, 1fr) 39%; gap: 8px; padding: 7px 9px; }
  .mission-copy span, .hyper-meter > span { font-size: 0.51rem; }
  .mission-copy strong { font-size: 0.7rem; }
  .game-overlay { padding: 20px; }
  .overlay-logo { width: 42%; margin-bottom: -12px; }
  .briefing { margin-block: 13px 16px; }
  .cabinet-controls { gap: 5px; padding: 8px 6px; }
  .cabinet-button { min-height: 58px; border-radius: 11px; }
  .cabinet-footer { padding-inline: 9px; }
  .control-grid { grid-template-columns: 1fr; }
}

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