:root {
  --bg: #08111f;
  --bg-2: #0e1b2f;
  --panel: #13243b;
  --panel-strong: #172c49;
  --text: #f4f8ff;
  --muted: #a9b8cf;
  --line: rgba(244, 248, 255, 0.14);
  --green: #38d9a9;
  --blue: #6ea8fe;
  --yellow: #ffd166;
  --red: #ff6b6b;
  --blood: #9e1030;
  --blood-dark: #370817;
  --radius: 24px;
  --max: 1180px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { overflow-x: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 16% 0%, rgba(56, 217, 169, 0.16), transparent 30rem),
    radial-gradient(circle at 88% 8%, rgba(110, 168, 254, 0.18), transparent 34rem),
    radial-gradient(circle at 50% 70%, rgba(255, 107, 107, 0.08), transparent 36rem),
    linear-gradient(180deg, var(--bg), var(--bg-2) 54%, #07101c);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(244,248,255,0.032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(244,248,255,0.032) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.85), transparent 74%);
}

a { color: inherit; }
button, canvas { font: inherit; }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 10;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  background: var(--green);
  color: #06100d;
  transition: top 160ms ease;
}
.skip-link:focus { top: 1rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  min-height: 74px;
  padding-inline: max(1rem, calc((100vw - var(--max)) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 17, 31, 0.84);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
}

.brand span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(56,217,169,0.35);
  border-radius: 14px;
  color: var(--green);
  background: rgba(56,217,169,0.08);
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.96rem;
}
.topbar nav a { text-decoration: none; }
.topbar nav a:hover,
.topbar nav a:focus-visible { color: var(--text); }

.hero,
.panel,
.game-shell,
.footer {
  width: min(var(--max), calc(100% - 2rem));
  margin-inline: auto;
}

.hero {
  min-height: calc(86vh - 74px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.82fr);
  align-items: center;
  gap: clamp(1.25rem, 4vw, 3rem);
  padding-block: clamp(3.5rem, 7vw, 6rem);
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 950;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 1rem;
  max-width: 900px;
  font-size: clamp(2.75rem, 8vw, 6.25rem);
  line-height: 0.92;
  letter-spacing: -0.08em;
}

h2 {
  margin-bottom: 0.7rem;
  font-size: clamp(1.65rem, 3.8vw, 3rem);
  line-height: 1;
  letter-spacing: -0.06em;
}

.lede {
  max-width: 740px;
  color: var(--muted);
  font-size: clamp(1.04rem, 2vw, 1.25rem);
  line-height: 1.68;
}

.hero-actions,
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1.25rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.78rem 1.12rem;
  border: 1px solid rgba(56,217,169,0.45);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--green), #aef5dc);
  color: #06100d;
  font-weight: 950;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 14px 38px rgba(56,217,169,0.16);
}

.button.ghost {
  background: rgba(244,248,255,0.07);
  color: var(--text);
  border-color: var(--line);
  box-shadow: none;
}

.button.medicine {
  background: linear-gradient(135deg, var(--blue), var(--yellow));
  color: #08111f;
  border-color: rgba(255, 209, 102, 0.42);
}

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

.science-card {
  position: relative;
  min-height: 380px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 36px;
  background:
    radial-gradient(circle at 50% 42%, rgba(56,217,169,0.16), rgba(244,248,255,0.055) 58%, rgba(244,248,255,0.025)),
    linear-gradient(135deg, rgba(23,44,73,0.92), rgba(19,36,59,0.74));
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(0,0,0,0.25);
}

.fingerprint {
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle at 48% 52%, transparent 0 13px, rgba(244,248,255,0.075) 14px 17px),
    radial-gradient(circle, rgba(110,168,254,0.12), transparent 70%);
  opacity: 0.9;
}

.blob-demo {
  position: relative;
  display: grid;
  place-items: center;
  width: 240px;
  height: 240px;
}

.arrow {
  position: absolute;
  top: 16px;
  left: 20px;
  color: var(--red);
  font-size: 2rem;
  transform: rotate(132deg);
}

.mag-blob {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #9ea7b5, #16181d 42%, #050506 70%);
  box-shadow: inset -8px -10px 18px rgba(255,255,255,0.08), 0 0 36px rgba(56,217,169,0.24), 0 18px 40px rgba(0,0,0,0.5);
  z-index: 2;
}

.field-ring {
  position: absolute;
  border: 2px solid rgba(56,217,169,0.35);
  border-radius: 50%;
  animation: pulse 2.2s ease-in-out infinite;
}
.ring-one { width: 120px; height: 120px; }
.ring-two { width: 180px; height: 180px; animation-delay: 0.4s; }
.science-card p {
  position: absolute;
  bottom: 1.25rem;
  text-align: center;
  color: var(--muted);
  font-weight: 850;
}

@keyframes pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.45; }
  50% { transform: scale(1.08); opacity: 1; }
}

.panel,
.game-card,
.mission-log,
.hud-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(23,44,73,0.88), rgba(19,36,59,0.74));
  box-shadow: 0 20px 60px rgba(0,0,0,0.22);
}

.panel {
  margin-bottom: 1.25rem;
  padding: clamp(1.2rem, 3vw, 2rem);
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 1.3rem;
}

.steps {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  line-height: 1.75;
}
.steps strong { color: var(--text); }
.note {
  grid-column: 1 / -1;
  margin: 0;
  padding: 1rem;
  border: 1px solid rgba(255, 209, 102, 0.26);
  border-radius: 18px;
  background: rgba(255, 209, 102, 0.08);
  color: #ffe7a6;
}

.inspiration p {
  color: var(--muted);
  line-height: 1.7;
}
.compact-note { margin-top: 1rem; }

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 1rem;
  padding-block: 1.75rem 4rem;
}

.hud {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.8rem;
}
.hud-card {
  padding: 0.9rem 1rem;
  border-radius: 20px;
}
.hud-card span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.hud-card strong {
  display: block;
  margin-top: 0.3rem;
  font-size: 1.55rem;
  letter-spacing: -0.04em;
}

.game-card {
  border-radius: var(--radius);
  padding: 1rem;
}
.game-card-top {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
}
.game-card-top h2 { margin-bottom: 0; }
.mission-status {
  margin: 0;
  justify-self: end;
  max-width: 520px;
  color: var(--muted);
  line-height: 1.55;
  text-align: right;
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(244,248,255,0.18);
  border-radius: 22px;
  background: #19030a;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04), 0 18px 55px rgba(0,0,0,0.28);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  cursor: crosshair;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
  background: radial-gradient(circle, rgba(8,17,31,0.68), rgba(8,17,31,0.92));
}
.overlay[hidden] { display: none; }
.overlay h3 {
  margin-bottom: 0;
  font-size: clamp(2rem, 6vw, 4.2rem);
  line-height: 0.92;
  letter-spacing: -0.07em;
}
.overlay p {
  max-width: 620px;
  margin-inline: auto;
  color: var(--muted);
  line-height: 1.65;
}

.touch-controls {
  display: none;
  gap: 0.75rem;
  margin-top: 0.9rem;
}
.touch-controls button {
  flex: 1;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(244,248,255,0.08);
  color: var(--text);
  font-size: 1.12rem;
  font-weight: 950;
}
.touch-controls .touch-release {
  background: linear-gradient(135deg, var(--blue), var(--yellow));
  color: #08111f;
  border-color: rgba(255, 209, 102, 0.42);
}
.touch-controls button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.mission-log {
  align-self: start;
  border-radius: var(--radius);
  padding: 1.2rem;
}
.mission-log h2 {
  margin-bottom: 1rem;
  font-size: 1.55rem;
}
.mission-log ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  line-height: 1.65;
}
.mission-log li + li { margin-top: 0.7rem; }

.footer {
  padding: 2rem 0 3rem;
  color: var(--muted);
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-links a { color: var(--muted); }
.footer-links a:hover,
.footer-links a:focus-visible { color: var(--text); }

@media (max-width: 920px) {
  .hero,
  .panel,
  .game-shell,
  .game-card-top {
    grid-template-columns: 1fr;
  }
  .science-card { min-height: 320px; }
  .hud { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hud-card:last-child { grid-column: 1 / -1; }
  .mission-status {
    justify-self: stretch;
    text-align: left;
  }
  .touch-controls { display: flex; }
}

@media (max-width: 660px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding-block: 0.8rem;
    padding-inline: 0.75rem;
  }
  .topbar nav {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.65rem;
  }
  .topbar nav a {
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(244,248,255,0.05);
  }
  .hero,
  .panel,
  .game-shell,
  .footer {
    width: min(var(--max), calc(100% - 0.75rem));
  }
  .hero {
    min-height: auto;
    gap: 1rem;
    padding-block: 2rem;
  }
  h1 {
    font-size: clamp(2.55rem, 15vw, 4.4rem);
    letter-spacing: -0.075em;
  }
  h2 { font-size: clamp(1.55rem, 9vw, 2.35rem); }
  .science-card {
    min-height: 230px;
    border-radius: 24px;
  }
  .panel {
    gap: 0.9rem;
    border-radius: 20px;
  }
  .steps { line-height: 1.55; }
  .game-shell {
    gap: 0.75rem;
    padding-block: 1rem 7rem;
  }
  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
  }
  .hud-card,
  .hud-card:last-child {
    grid-column: auto;
    padding: 0.65rem;
    border-radius: 16px;
  }
  .hud-card span { font-size: 0.66rem; }
  .hud-card strong { font-size: 1.15rem; }
  .game-card {
    border-radius: 20px;
    padding: 0.65rem;
  }
  .game-card-top {
    gap: 0.5rem;
    margin-bottom: 0.65rem;
  }
  .mission-status { font-size: 0.95rem; }
  .canvas-wrap { border-radius: 16px; }
  canvas {
    width: 100%;
    height: auto;
  }
  .overlay { padding: 1rem; }
  .overlay h3 { font-size: clamp(1.75rem, 11vw, 3rem); }
  .overlay p {
    font-size: 0.95rem;
    line-height: 1.5;
  }
  .controls {
    position: sticky;
    bottom: 0.45rem;
    z-index: 9;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
    padding: 0.5rem;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(8, 17, 31, 0.94);
    backdrop-filter: blur(14px);
  }
  .controls .button {
    width: 100%;
    min-height: 46px;
    padding: 0.62rem 0.75rem;
    font-size: 0.92rem;
  }
  #release-button { grid-column: 1 / -1; }
  .touch-controls {
    display: grid;
    grid-template-columns: 1fr 1fr 1.15fr;
    gap: 0.45rem;
    position: sticky;
    bottom: 5.25rem;
    z-index: 9;
    padding: 0.45rem;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(8, 17, 31, 0.94);
    backdrop-filter: blur(14px);
  }
  .touch-controls button {
    min-height: 48px;
    border-radius: 14px;
    font-size: 0.95rem;
  }
  .mission-log { display: none; }
}
