:root {
  --bg: #080b18;
  --surface: rgba(14, 19, 40, 0.78);
  --surface-strong: #11162c;
  --line: rgba(147, 169, 255, 0.18);
  --text: #f6f8ff;
  --muted: #8f9ab8;
  --cyan: #27f0ff;
  --cyan-soft: rgba(39, 240, 255, 0.18);
  --purple: #8c5cff;
  --red: #ff456c;
  --green: #63ffbd;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
  --radius-lg: 28px;
  --radius-md: 18px;
  --max-width: 1240px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 10%, rgba(48, 43, 121, 0.22), transparent 28%),
    radial-gradient(circle at 90% 35%, rgba(10, 101, 131, 0.18), transparent 30%),
    var(--bg);
  font-family: "Inter", sans-serif;
}

body.fullscreen-mode .site-header,
body.fullscreen-mode .intro-panel,
body.fullscreen-mode .tips-grid,
body.fullscreen-mode .site-footer {
  display: none;
}

body.fullscreen-mode .game-page {
  width: 100%;
  max-width: none;
  padding: 14px;
}

body.fullscreen-mode .game-shell {
  min-height: calc(100vh - 28px);
}

body.fullscreen-mode .canvas-wrap {
  min-height: calc(100vh - 130px);
}

button {
  font: inherit;
}

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

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(39, 240, 255, 0.35);
  outline-offset: 4px;
}

.page-glow {
  position: fixed;
  z-index: -2;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
}

.glow-one {
  top: 20%;
  left: -80px;
  width: 260px;
  height: 260px;
  background: rgba(140, 92, 255, 0.22);
}

.glow-two {
  right: -80px;
  bottom: 10%;
  width: 300px;
  height: 300px;
  background: rgba(39, 240, 255, 0.14);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(var(--max-width), calc(100% - 40px));
  min-height: 84px;
  margin-inline: auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: var(--text);
  font-family: "Orbitron", sans-serif;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-decoration: none;
}

.brand-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(39, 240, 255, 0.46);
  border-radius: 13px;
  color: var(--cyan);
  background:
    linear-gradient(135deg, rgba(39, 240, 255, 0.12), rgba(140, 92, 255, 0.16));
  box-shadow:
    inset 0 0 24px rgba(39, 240, 255, 0.1),
    0 0 24px rgba(39, 240, 255, 0.1);
  font-size: 1.2rem;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  background: rgba(15, 20, 42, 0.72);
  cursor: pointer;
  transition: 0.2s ease;
}

.icon-button:hover {
  border-color: rgba(39, 240, 255, 0.45);
  color: var(--cyan);
  transform: translateY(-2px);
}

.game-page {
  width: min(var(--max-width), calc(100% - 40px));
  margin-inline: auto;
  padding: 34px 0 70px;
}

.intro-panel {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 30px;
  gap: 40px;
}

.intro-panel h1,
.intro-panel p {
  margin-top: 0;
}

.eyebrow {
  display: block;
  margin-bottom: 12px;
  color: var(--cyan);
  font-family: "Orbitron", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.intro-panel h1 {
  max-width: 780px;
  margin-bottom: 14px;
  font-family: "Orbitron", sans-serif;
  font-size: clamp(2.7rem, 6vw, 5.6rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.intro-panel h1 span {
  color: var(--cyan);
  text-shadow: 0 0 28px rgba(39, 240, 255, 0.28);
}

.intro-panel p {
  max-width: 650px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.best-score-card {
  min-width: 180px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(15, 20, 42, 0.66);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.best-score-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-family: "Orbitron", sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.13em;
}

.best-score-card strong {
  color: var(--cyan);
  font-family: "Orbitron", sans-serif;
  font-size: 1.6rem;
}

.game-shell {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.hud {
  display: grid;
  grid-template-columns: 0.7fr 0.7fr 1.4fr 0.8fr auto;
  align-items: center;
  min-height: 82px;
  padding: 14px 20px;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.hud-item {
  display: grid;
  gap: 6px;
}

.hud-item > span {
  color: var(--muted);
  font-family: "Orbitron", sans-serif;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hud-item strong {
  font-family: "Orbitron", sans-serif;
  font-size: 1rem;
}

.lives-wrap strong {
  color: var(--red);
  letter-spacing: 0.18em;
}

.energy-bar {
  position: relative;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.energy-bar span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--purple), var(--cyan));
  box-shadow: 0 0 18px rgba(39, 240, 255, 0.48);
  transition: width 0.2s linear;
}

.pause-button,
.primary-button,
.secondary-button {
  border: 0;
  font-weight: 700;
  cursor: pointer;
}

.pause-button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  transition: 0.2s ease;
}

.pause-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pause-button:not(:disabled):hover {
  border-color: rgba(39, 240, 255, 0.4);
  color: var(--cyan);
}

.canvas-wrap {
  position: relative;
  min-height: 620px;
  overflow: hidden;
  background: #070a14;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 620px;
  background: #070a14;
  touch-action: none;
}

.scanlines {
  position: absolute;
  z-index: 1;
  inset: 0;
  opacity: 0.13;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 3px,
      rgba(255, 255, 255, 0.04) 4px
    );
  pointer-events: none;
}

.game-overlay {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  visibility: hidden;
  opacity: 0;
  background:
    radial-gradient(circle at center, rgba(13, 19, 42, 0.42), rgba(5, 7, 15, 0.9));
  backdrop-filter: blur(8px);
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.game-overlay.active {
  visibility: visible;
  opacity: 1;
}

.overlay-card {
  width: min(520px, 100%);
  padding: 42px;
  border: 1px solid rgba(39, 240, 255, 0.18);
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(19, 25, 52, 0.96), rgba(9, 13, 29, 0.96));
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.52),
    inset 0 0 80px rgba(39, 240, 255, 0.025);
  text-align: center;
}

.overlay-card.small {
  width: min(420px, 100%);
}

.overlay-label {
  display: inline-flex;
  margin-bottom: 15px;
  padding: 7px 11px;
  border: 1px solid rgba(99, 255, 189, 0.26);
  border-radius: 999px;
  color: var(--green);
  background: rgba(99, 255, 189, 0.07);
  font-family: "Orbitron", sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.overlay-label.danger {
  border-color: rgba(255, 69, 108, 0.3);
  color: var(--red);
  background: rgba(255, 69, 108, 0.08);
}

.overlay-card h2 {
  margin: 0 0 16px;
  font-family: "Orbitron", sans-serif;
  font-size: clamp(2rem, 5vw, 3.8rem);
  letter-spacing: -0.05em;
}

.overlay-card p {
  margin: 0 auto 28px;
  color: var(--muted);
  line-height: 1.7;
}

.control-guide {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 30px;
  gap: 22px;
}

.key-grid {
  display: grid;
  grid-template-columns: repeat(3, 32px);
  gap: 4px;
}

.key-grid kbd,
.key-grid span {
  display: grid;
  width: 32px;
  height: 30px;
  place-items: center;
}

.key-grid kbd {
  border: 1px solid rgba(39, 240, 255, 0.28);
  border-radius: 7px;
  color: var(--cyan);
  background: rgba(39, 240, 255, 0.06);
  font-family: "Orbitron", sans-serif;
  font-size: 0.68rem;
}

.guide-text {
  display: grid;
  text-align: left;
}

.guide-text span {
  color: var(--muted);
  font-size: 0.75rem;
}

.guide-text strong {
  font-size: 0.9rem;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 24px;
  gap: 14px;
  border-radius: 13px;
  transition: 0.2s ease;
}

.primary-button {
  color: #061219;
  background: linear-gradient(135deg, var(--cyan), #69ffd5);
  box-shadow: 0 14px 34px rgba(39, 240, 255, 0.2);
}

.primary-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(39, 240, 255, 0.3);
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.secondary-button:hover {
  border-color: rgba(39, 240, 255, 0.36);
  color: var(--cyan);
}

.button-row {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.final-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin: 28px 0;
  gap: 12px;
}

.final-stats div {
  display: grid;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.03);
}

.final-stats span {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.72rem;
}

.final-stats strong {
  color: var(--cyan);
  font-family: "Orbitron", sans-serif;
  font-size: 1.25rem;
}

.mobile-controls {
  display: none;
  position: relative;
  width: 196px;
  height: 154px;
  margin: 20px auto;
}

.touch-button {
  position: absolute;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid rgba(39, 240, 255, 0.25);
  border-radius: 16px;
  color: var(--cyan);
  background: rgba(39, 240, 255, 0.07);
  font-size: 1rem;
  touch-action: none;
  user-select: none;
}

.touch-button:active,
.touch-button.active {
  color: #061219;
  background: var(--cyan);
}

.touch-button.up {
  top: 0;
  left: 69px;
}

.touch-button.left {
  top: 68px;
  left: 0;
}

.touch-button.down {
  top: 68px;
  left: 69px;
}

.touch-button.right {
  top: 68px;
  right: 0;
}

.tips-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 28px;
  gap: 18px;
}

.tips-grid article {
  min-height: 180px;
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(14, 19, 40, 0.56);
  backdrop-filter: blur(14px);
}

.tip-number {
  display: block;
  margin-bottom: 25px;
  color: var(--cyan);
  font-family: "Orbitron", sans-serif;
  font-size: 0.7rem;
}

.tips-grid h3 {
  margin: 0 0 9px;
  font-family: "Orbitron", sans-serif;
  font-size: 1rem;
}

.tips-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  width: min(var(--max-width), calc(100% - 40px));
  margin: 0 auto;
  padding: 0 0 34px;
  color: var(--muted);
  font-size: 0.8rem;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 900px) {
  .intro-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .hud {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }

  .pause-button {
    grid-column: 1 / -1;
  }

  .tips-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .site-header,
  .game-page,
  .site-footer {
    width: min(100% - 24px, var(--max-width));
  }

  .brand {
    font-size: 0.72rem;
  }

  .brand-icon {
    width: 38px;
    height: 38px;
  }

  .game-page {
    padding-top: 20px;
  }

  .intro-panel h1 {
    font-size: clamp(2.6rem, 14vw, 4rem);
  }

  .best-score-card {
    width: 100%;
  }

  .hud {
    grid-template-columns: repeat(2, 1fr);
    padding: 14px;
  }

  .hud-item:nth-child(3) {
    grid-column: 1 / -1;
  }

  .pause-button {
    grid-column: 1 / -1;
  }

  .canvas-wrap,
  #gameCanvas {
    min-height: 500px;
  }

  .overlay-card {
    padding: 30px 20px;
  }

  .control-guide {
    align-items: center;
    flex-direction: column;
  }

  .guide-text {
    text-align: center;
  }

  .mobile-controls {
    display: block;
  }

  .button-row {
    flex-direction: column;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
}

@media (max-width: 420px) {
  .header-actions .icon-button:first-child {
    display: none;
  }

  .overlay-card h2 {
    font-size: 2.15rem;
  }

  .final-stats {
    grid-template-columns: 1fr;
  }
}
