:root {
  --bg-a: #030712;
  --bg-b: #0a1a34;
  --ink: #eff8ff;
  --muted: #93a6c0;
  --cyan: #62ebff;
  --amber: #ffbf62;
  --rose: #ff6680;
  --lime: #99ff7a;
  --violet: #c88fff;
  --panel: rgba(7, 14, 27, 0.74);
  --panel-border: rgba(123, 214, 255, 0.16);
  --panel-shadow: rgba(0, 0, 0, 0.34);
  --font-display: "Bahnschrift", "Aptos", "Segoe UI", sans-serif;
  --font-ui: "Trebuchet MS", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(39, 155, 255, 0.18), transparent 28%),
    radial-gradient(circle at 80% 0%, rgba(255, 113, 82, 0.15), transparent 22%),
    linear-gradient(140deg, var(--bg-b) 0%, var(--bg-a) 44%, #010308 100%);
  color: var(--ink);
  font-family: var(--font-ui);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background:
    linear-gradient(transparent 0%, rgba(255, 255, 255, 0.022) 50%, transparent 100%);
  background-size: 100% 6px;
  opacity: 0.3;
  mix-blend-mode: soft-light;
}

body::after {
  background:
    radial-gradient(circle at center, transparent 46%, rgba(0, 0, 0, 0.54) 100%);
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  inset: 0;
  padding: 20px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hud-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
}

.panel {
  background: linear-gradient(180deg, rgba(13, 27, 48, 0.84), var(--panel));
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  box-shadow:
    0 24px 60px var(--panel-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.score-panel {
  min-width: 250px;
  padding: 18px 20px;
}

.eyebrow,
.overlay-kicker,
.control-title {
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.score-value {
  margin-top: 8px;
  font-family: var(--font-display);
  font-size: clamp(32px, 4vw, 54px);
  line-height: 1;
  letter-spacing: 0.06em;
  color: #f8fbff;
  text-shadow:
    0 0 18px rgba(84, 239, 255, 0.36),
    0 0 32px rgba(84, 239, 255, 0.14);
}

.score-meta {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: #d5f7ff;
  font-size: 14px;
}

.meter-panel {
  min-width: min(34vw, 500px);
  padding: 18px;
  flex: 1;
  max-width: 520px;
}

.meter-block + .meter-block {
  margin-top: 14px;
}

.meter-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.meter-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 13px;
}

.meter-label-row.compact {
  font-size: 12px;
  margin-bottom: 6px;
}

.meter-track {
  position: relative;
  height: 16px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.meter-track.mini {
  height: 12px;
}

.meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: inherit;
  transition: width 90ms linear, filter 120ms ease;
}

.health-fill {
  background: linear-gradient(90deg, #ff5e74 0%, #ffaf68 100%);
  box-shadow: 0 0 20px rgba(255, 106, 121, 0.46);
}

.surge-fill {
  background: linear-gradient(90deg, #4fd1ff 0%, #7afffb 55%, #efff8f 100%);
  box-shadow: 0 0 20px rgba(84, 239, 255, 0.52);
}

.pulse-fill {
  background: linear-gradient(90deg, #ff6681 0%, #ffc15f 100%);
  box-shadow: 0 0 16px rgba(255, 122, 96, 0.36);
}

.dash-fill {
  background: linear-gradient(90deg, #8ef7ff 0%, #4aa7ff 100%);
  box-shadow: 0 0 16px rgba(84, 239, 255, 0.36);
}

.session-panel {
  min-width: 180px;
  padding: 16px 18px;
  display: grid;
  gap: 10px;
}

.session-line {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: #d7edf8;
  font-size: 14px;
}

.banner {
  align-self: center;
  min-width: 240px;
  max-width: min(74vw, 760px);
  min-height: 48px;
  padding: 10px 18px;
  border-radius: 18px;
  text-align: center;
  pointer-events: none;
  font-family: var(--font-display);
  font-size: clamp(18px, 2.3vw, 30px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #f7fbff;
  text-shadow:
    0 0 20px rgba(255, 237, 136, 0.38),
    0 0 34px rgba(84, 239, 255, 0.22);
  opacity: 0;
  transform: translateY(-10px) scale(0.98);
  transition: opacity 150ms ease, transform 150ms ease;
}

.banner.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.control-panel,
.threat-panel {
  width: min(430px, 100%);
  padding: 16px 18px;
}

.control-list {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.control-list span,
.feature-grid span {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e8f5ff;
  font-size: 13px;
}

.control-note {
  margin-top: 12px;
  color: #b9c9da;
  font-size: 13px;
  line-height: 1.55;
}

.threat-live {
  margin-top: 10px;
  min-height: 42px;
  color: #f7fbff;
  font-size: 14px;
  line-height: 1.5;
}

.threat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.threat-item {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.threat-item strong {
  font-size: 12px;
  letter-spacing: 0.12em;
}

.threat-item span {
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: 0.08em;
}

.threat-item.green strong,
.threat-item.green span {
  color: #a5ff8d;
}

.threat-item.red strong,
.threat-item.red span {
  color: #ff8e8e;
}

.threat-item.purple strong,
.threat-item.purple span {
  color: #d8a5ff;
}

.threat-item.gold strong,
.threat-item.gold span {
  color: #ffd079;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at center, rgba(25, 47, 83, 0.34), rgba(2, 5, 10, 0.82));
  opacity: 1;
  transition: opacity 180ms ease, visibility 180ms ease;
  pointer-events: auto;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay-card {
  width: min(700px, 100%);
  padding: clamp(24px, 4vw, 40px);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(14, 30, 56, 0.92), rgba(8, 12, 25, 0.9));
  border: 1px solid rgba(135, 222, 255, 0.18);
  box-shadow:
    0 36px 80px rgba(0, 0, 0, 0.44),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  text-align: center;
}

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

.overlay-card h1,
.overlay-card h2 {
  margin: 12px 0 14px;
  font-family: var(--font-display);
  font-size: clamp(40px, 7vw, 78px);
  line-height: 0.96;
  letter-spacing: 0.06em;
}

.overlay-card h2 {
  font-size: clamp(28px, 4vw, 42px);
}

.overlay-card p {
  margin: 0 auto 20px;
  max-width: 560px;
  color: #c7d7e7;
  line-height: 1.7;
  font-size: 15px;
}

.feature-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 22px;
}

.summary-grid {
  margin-top: 20px;
}

.primary-button {
  appearance: none;
  border: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 14px 28px;
  min-width: 180px;
  background:
    linear-gradient(90deg, #ff9361 0%, #ffd85d 30%, #79fcff 100%);
  color: #051119;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow:
    0 18px 34px rgba(76, 205, 255, 0.24),
    0 8px 20px rgba(255, 185, 85, 0.18);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

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

.primary-button:active {
  transform: translateY(1px) scale(0.995);
}

.screen-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at center, rgba(255, 236, 139, 0.2), rgba(255, 95, 120, 0.08) 42%, transparent 70%);
  mix-blend-mode: screen;
  transition: opacity 60ms linear;
}

@media (max-width: 980px) {
  .hud {
    padding: 14px;
  }

  .hud-row.top,
  .hud-row.bottom {
    flex-direction: column;
    align-items: stretch;
  }

  .score-panel,
  .meter-panel,
  .session-panel,
  .control-panel,
  .threat-panel {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .session-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .hud {
    padding: 10px;
  }

  .panel {
    border-radius: 18px;
  }

  .score-value {
    font-size: 34px;
  }

  .overlay-card h1 {
    font-size: 46px;
  }

  .meter-grid,
  .threat-grid {
    grid-template-columns: 1fr;
  }

  .banner {
    max-width: 86vw;
    font-size: 18px;
  }
}
