/* LD INVADERS — retro CRT styling */

:root {
  --bg: #05060a;
  --panel: #0b0f1a;
  --ink: #e8fff0;
  --green: #39ff14;
  --amber: #ffcc00;
  --cyan: #38e8ff;
  --magenta: #ff44cc;
  --red: #ff3b3b;
  --dim: #5a6b7a;
  --font: "Courier New", "Lucida Console", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: radial-gradient(circle at 50% 20%, #0a1120 0%, var(--bg) 70%);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: none;
  text-rendering: geometricPrecision;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  gap: 12px;
  min-height: 100%;
}

.crt {
  width: min(96vw, 520px);
  background: var(--panel);
  border: 2px solid #16324a;
  border-radius: 14px;
  padding: 14px;
  box-shadow:
    0 0 0 2px #0a0d16 inset,
    0 0 40px rgba(57, 255, 20, 0.08),
    0 18px 60px rgba(0, 0, 0, 0.6);
  position: relative;
  overflow: hidden;
}

/* scanline overlay */
.crt::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.18) 3px,
    rgba(0, 0, 0, 0.18) 4px
  );
  mix-blend-mode: multiply;
  z-index: 5;
}

.hud {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  letter-spacing: 2px;
  margin-bottom: 10px;
  text-transform: uppercase;
  font-size: 13px;
}

.hud-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hud-cell:nth-child(2) {
  align-items: center;
}
.hud-cell:nth-child(3) {
  align-items: flex-end;
}

.label {
  color: var(--dim);
  font-size: 10px;
}

.value {
  color: var(--green);
  font-size: 18px;
  text-shadow: 0 0 8px rgba(57, 255, 20, 0.5);
}

#lives {
  color: var(--amber);
  text-shadow: 0 0 8px rgba(255, 204, 0, 0.5);
}

.stage {
  position: relative;
  border: 2px solid #122a3f;
  border-radius: 8px;
  background: #02030a;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  background: rgba(2, 3, 10, 0.82);
  z-index: 6;
  padding: 16px;
}

.overlay.hidden {
  display: none;
}

.overlay h1 {
  margin: 0;
  font-size: clamp(28px, 9vw, 46px);
  letter-spacing: 6px;
  color: var(--green);
  text-shadow:
    0 0 12px rgba(57, 255, 20, 0.7),
    3px 3px 0 #0a3a12;
}

.overlay p {
  margin: 0;
  letter-spacing: 2px;
}

.overlay .controls {
  color: var(--cyan);
  font-size: 12px;
}

.blink {
  color: var(--amber);
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
  to {
    visibility: hidden;
  }
}

/* LaunchDarkly live-flag bar */
.ld-bar {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  letter-spacing: 1px;
  background: #060a12;
  border: 1px solid #16324a;
  border-radius: 8px;
  padding: 8px 12px;
}

.ld-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dim);
  box-shadow: 0 0 8px currentColor;
  flex: 0 0 auto;
  transition: background 0.2s;
}

.ld-dot.live {
  background: var(--green);
  color: var(--green);
}
.ld-dot.offline {
  background: var(--red);
  color: var(--red);
}

.ld-text {
  color: var(--ink);
  flex: 1 1 auto;
}

.ld-text strong {
  color: var(--amber);
}

.ld-variation {
  color: var(--dim);
}

.ld-status {
  color: var(--dim);
  font-size: 10px;
  text-transform: uppercase;
}

/* flash when a flag change streams in */
.ld-bar.flash {
  animation: ldflash 0.7s ease-out;
}

@keyframes ldflash {
  0% {
    background: #123a18;
    box-shadow: 0 0 20px rgba(57, 255, 20, 0.6);
  }
  100% {
    background: #060a12;
    box-shadow: none;
  }
}

/* touch controls */
.touch {
  display: none;
  gap: 14px;
  width: min(96vw, 520px);
}

.touch-btn {
  flex: 1;
  padding: 18px 0;
  font-size: 22px;
  font-family: var(--font);
  color: var(--green);
  background: #0b0f1a;
  border: 2px solid #16324a;
  border-radius: 10px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.touch-btn:active {
  background: #123a18;
}

@media (pointer: coarse) {
  .touch {
    display: flex;
  }
}
