:root {
  --bg: #020612;
  --panel: rgba(5, 14, 32, .74);
  --panel-strong: rgba(3, 10, 24, .9);
  --line: rgba(112, 228, 255, .26);
  --text: #ecf8ff;
  --muted: #9cb5c6;
  --accent: #70e4ff;
  --defend-green: #a6ff3d;
  --hot: #ffd166;
  --inverse: #ff5f8f;
  --good: #86efac;
}

* { box-sizing: border-box; }

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, "Segoe UI", Arial, sans-serif;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: fixed;
  z-index: 4;
  backdrop-filter: blur(14px);
}

body.hide-hud .hud {
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}

.topbar {
  top: 18px;
  left: 24px;
  right: 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  pointer-events: none;
}

.brand {
  min-width: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: #f7fdff;
  font-size: clamp(32px, 5vw, 76px);
  line-height: .9;
  letter-spacing: 0;
  text-shadow: 0 0 28px rgba(112, 228, 255, .35);
}

h2 {
  font-size: 18px;
  margin-bottom: 10px;
}

.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 8px;
}

.defend-brand {
  color: var(--defend-green);
  text-shadow:
    0 0 8px rgba(166, 255, 61, .75),
    0 0 22px rgba(166, 255, 61, .35);
}

.actions {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

button {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(112, 228, 255, .2), rgba(112, 228, 255, .06));
  color: var(--text);
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(112, 228, 255, .12);
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(112, 228, 255, .72);
}

.panel {
  top: 132px;
  width: min(348px, 38vw);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .34);
}

.left-panel { left: 24px; }
.right-panel { right: 24px; }

.panel p {
  color: var(--muted);
  line-height: 1.45;
  font-size: 14px;
  margin-bottom: 14px;
}

.stat {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.stat span { color: var(--muted); }
.stat strong { color: var(--accent); }

.meter {
  margin: 2px 0 14px;
}

.meter span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
}

.meter div {
  height: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
}

.meter i {
  display: block;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, var(--inverse), var(--hot), var(--good));
}

.bottom-help {
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(4, 12, 28, .72);
  color: var(--muted);
  font-size: 13px;
}

.youtube-status {
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid rgba(112, 228, 255, .46);
  border-radius: 8px;
  background: rgba(2, 6, 18, .78);
  box-shadow:
    0 0 18px rgba(112, 228, 255, .18),
    inset 0 0 18px rgba(112, 228, 255, .08);
  color: #e8fbff;
  font-size: 12px;
  line-height: 1;
  text-transform: uppercase;
  transition: opacity .22s ease, transform .22s ease;
}

.youtube-status.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(.96);
}

.youtube-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #70e4ff;
  box-shadow:
    0 0 8px rgba(112, 228, 255, .95),
    0 0 18px rgba(112, 228, 255, .7);
  animation: openAiPulse .8s ease-in-out infinite alternate;
}

.youtube-status__label {
  color: rgba(112, 228, 255, .82);
  letter-spacing: 1px;
}

.youtube-status strong {
  display: inline-block;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  text-shadow:
    0 0 6px #fff,
    0 0 14px rgba(112, 228, 255, .95),
    0 0 24px rgba(255, 95, 143, .55);
  animation: openAiPulse .8s ease-in-out infinite alternate;
}

.youtube-status.playing::before {
  background: var(--defend-green);
  box-shadow:
    0 0 8px rgba(166, 255, 61, .95),
    0 0 18px rgba(166, 255, 61, .7);
}

.youtube-status.paused::before,
.youtube-status.error::before {
  background: #ff5f8f;
  box-shadow:
    0 0 8px rgba(255, 95, 143, .95),
    0 0 18px rgba(255, 95, 143, .7);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(112, 228, 255, .16), rgba(2, 6, 18, .9) 54%, #020612),
    linear-gradient(180deg, #020612, #071022 52%, #020612);
}

.overlay.hidden { display: none; }

.overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    180deg,
    rgba(255, 255, 255, .035) 0,
    rgba(255, 255, 255, .035) 1px,
    transparent 1px,
    transparent 4px
  );
  mix-blend-mode: overlay;
  opacity: .38;
}

.demo-parallax {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.demo-grid {
  position: absolute;
  left: -20%;
  right: -20%;
  bottom: -26%;
  height: 62%;
  transform: perspective(420px) rotateX(62deg);
  transform-origin: center bottom;
  background:
    linear-gradient(rgba(112, 228, 255, .22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(112, 228, 255, .18) 1px, transparent 1px);
  background-size: 42px 42px;
  opacity: .42;
  animation: gridRush 2.8s linear infinite;
}

.demo-stars {
  position: absolute;
  inset: -20%;
  background-repeat: repeat;
  opacity: .5;
}

.demo-stars.layer-a {
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, .9) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(112, 228, 255, .7) 0 1px, transparent 1.5px);
  background-size: 96px 96px, 148px 148px;
  animation: starSlideA 18s linear infinite;
}

.demo-stars.layer-b {
  background-image:
    radial-gradient(circle, rgba(255, 209, 102, .8) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(255, 95, 143, .7) 0 1px, transparent 1.5px);
  background-size: 180px 180px, 240px 240px;
  animation: starSlideB 32s linear infinite;
}

.demo-orbit {
  position: absolute;
  left: 50%;
  top: 48%;
  border: 1px solid rgba(112, 228, 255, .35);
  border-radius: 50%;
  transform: translate(-50%, -50%) rotateX(65deg);
  box-shadow: 0 0 36px rgba(112, 228, 255, .12);
}

.orbit-a {
  width: min(72vw, 760px);
  height: min(72vw, 760px);
  animation: orbitSpin 13s linear infinite;
}

.orbit-b {
  width: min(48vw, 510px);
  height: min(48vw, 510px);
  border-color: rgba(255, 95, 143, .32);
  animation: orbitSpin 8s linear infinite reverse;
}

.demo-scroller {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 24px;
  z-index: 12;
  height: 34px;
  overflow: hidden;
  border-top: 1px solid rgba(112, 228, 255, .26);
  border-bottom: 1px solid rgba(112, 228, 255, .26);
  background: rgba(2, 6, 18, .74);
  color: #ffd166;
  font: 800 18px/34px "Courier New", monospace;
  letter-spacing: 2px;
  text-shadow:
    0 0 8px rgba(255, 209, 102, .8),
    0 0 18px rgba(112, 228, 255, .45);
  white-space: nowrap;
}

.demo-scroller div {
  display: inline-block;
  padding-left: 100%;
  animation: demoScroll 22s linear infinite;
}

.demo-scroller strong {
  display: inline-block;
  color: #fff;
  font-size: 22px;
  letter-spacing: 3px;
  padding: 0 10px;
  text-transform: none;
  animation: openAiPulse .8s ease-in-out infinite alternate;
  text-shadow:
    0 0 6px #fff,
    0 0 14px rgba(112, 228, 255, .95),
    0 0 26px rgba(255, 95, 143, .75),
    0 0 42px rgba(255, 209, 102, .55);
}

.demo-scroller b {
  display: inline-block;
  color: var(--defend-green);
  font-size: 23px;
  letter-spacing: 4px;
  padding: 0 12px;
  animation: defendSignal 1.1s steps(2, end) infinite;
  text-shadow:
    0 0 8px rgba(166, 255, 61, .95),
    0 0 18px rgba(166, 255, 61, .75),
    0 0 34px rgba(112, 228, 255, .42);
}

.modal {
  width: min(600px, calc(100vw - 34px));
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 16, 38, .88);
  box-shadow: 0 24px 90px rgba(0, 0, 0, .55);
  position: relative;
  z-index: 11;
}

.modal h2 {
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1;
  letter-spacing: 0;
}

.modal p {
  color: var(--muted);
  line-height: 1.6;
  margin: 14px 0 20px;
}

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

@media (max-width: 960px) {
  .topbar {
    left: 14px;
    right: 14px;
  }

  .panel {
    width: min(340px, calc(100vw - 28px));
    top: auto;
  }

  .left-panel {
    left: 14px;
    right: auto;
    bottom: 78px;
    max-height: none;
    overflow: visible;
    padding: 14px;
  }

  .left-panel p {
    display: none;
  }

  .left-panel .stat {
    padding: 7px 0;
  }

  .right-panel,
  .bottom-help {
    display: none;
  }
}

@media (max-width: 560px) {
  .actions {
    flex-direction: column;
  }

  button {
    padding: 9px 11px;
  }
}

@keyframes gridRush {
  from { background-position: 0 0, 0 0; }
  to { background-position: 0 42px, 42px 0; }
}

@keyframes starSlideA {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-96px, 48px, 0); }
}

@keyframes starSlideB {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(120px, 80px, 0); }
}

@keyframes orbitSpin {
  from { transform: translate(-50%, -50%) rotateX(65deg) rotateZ(0); }
  to { transform: translate(-50%, -50%) rotateX(65deg) rotateZ(360deg); }
}

@keyframes demoScroll {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

@keyframes openAiPulse {
  from {
    transform: translateY(0) scale(1);
    filter: hue-rotate(0deg);
  }
  to {
    transform: translateY(-2px) scale(1.12);
    filter: hue-rotate(35deg);
  }
}

@keyframes defendSignal {
  0%, 100% {
    transform: translateY(0) skewX(0deg);
    filter: brightness(1);
  }
  50% {
    transform: translateY(-1px) skewX(-6deg);
    filter: brightness(1.35);
  }
}
