/* ===========================================================
   NEUROVERSE — visual identity
   Palette sourced from documented MBVISION / INNOVARTISM brand
   material: the live innovartism.com page reports a theme color
   of #050807, and MBVISION's own dark "Tech Edition" working
   palette (ink #0D0B14, violet #9B6BF3, magenta #E0568F,
   teal #3FDDC4, gold #E7B95A) was built from the same site's
   look. Exact site CSS could not be retrieved in this
   environment, so this palette is the closest verified match
   rather than an invented one — swap CSS variables below if
   brand supplies exact hex values later.
   =========================================================== */

:root {
  --ink-deepest: #050807;
  --ink: #0D0B14;
  --surface: #171225;
  --surface-2: #1F1832;
  --text: #F5F1FA;
  --muted: #B7ACC6;

  --violet: #9B6BF3;   /* primary / electric-blue-violet light */
  --blue: #4FA9F5;     /* electric blue accent */
  --cyan: #3FDDC4;     /* soft cyan */
  --magenta: #E0568F;  /* pink / magenta neural accent */
  --gold: #E7B95A;     /* small warm light accent */

  --danger: #E0568F;
  --ok: #3FDDC4;

  --font-display: 'Press Start 2P', monospace;
  --font-body: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  color-scheme: dark;
}

* { box-sizing: border-box; }

.hidden { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ink-deepest);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  touch-action: none;
  user-select: none;
}

#app {
  width: 100%;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(155,107,243,0.12), transparent 55%),
    radial-gradient(ellipse at 80% 80%, rgba(63,221,196,0.08), transparent 50%),
    var(--ink-deepest);
}

#stage-wrap {
  position: relative;
  width: min(100%, calc(100dvh * 16 / 9));
  aspect-ratio: 16 / 9;
  max-height: 100dvh;
  margin: auto;
  overflow: hidden;
  background: var(--ink);
  box-shadow: 0 0 60px rgba(0,0,0,0.6);
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* ---------- top bar ---------- */

#top-bar {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  z-index: 30;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(245,241,250,0.18);
  background: rgba(13,11,20,0.55);
  color: var(--text);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.icon-btn:focus-visible, .btn-primary:focus-visible, .btn-ghost:focus-visible,
input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
.icon-btn[data-off="true"] { opacity: 0.45; }

/* ---------- HUD ---------- */

#hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(62px, calc(62px + env(safe-area-inset-right)));
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

#progress-track {
  display: flex;
  align-items: center;
  gap: 6px;
}

.progress-label {
  font-family: var(--font-display);
  font-size: 7px;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
}

#progress-bar {
  position: relative;
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(245,241,250,0.12);
  overflow: visible;
}
#progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--violet), var(--cyan));
}
#progress-marker {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
  transform: translate(-50%, -50%);
}

#hud-stats {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.meter-block { display: flex; align-items: center; gap: 5px; }
.meter-block--bar { flex: 1; min-width: 54px; max-width: 90px; flex-direction: column; align-items: stretch; gap: 2px; }
.stat-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--text);
}
.stat-value--lg { font-size: 15px; color: var(--gold); }
.meter-block.lead .stat-value { color: var(--gold); text-shadow: 0 0 6px rgba(231,185,90,0.7); }

.mini-bar {
  height: 5px;
  border-radius: 3px;
  background: rgba(245,241,250,0.12);
  overflow: hidden;
}
.mini-bar__fill { height: 100%; width: 0%; border-radius: 3px; transition: width 0.15s linear; }
.mini-bar__fill--sync { background: linear-gradient(90deg, var(--cyan), var(--violet)); }
.mini-bar__fill--focus { background: linear-gradient(90deg, var(--gold), var(--magenta)); }
.meter-block--bar.flow .stat-label { color: var(--cyan); text-shadow: 0 0 6px rgba(63,221,196,0.7); }

#integrity-pips { gap: 4px; }
.pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 5px var(--cyan);
}
.pip.pip--lost {
  background: transparent;
  border: 1px solid rgba(245,241,250,0.3);
  box-shadow: none;
}

/* ---------- toast ---------- */

#toast {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translate(-50%, -10px);
  z-index: 25;
  padding: 8px 16px;
  border-radius: 8px;
  background: rgba(13,11,20,0.72);
  border: 1px solid rgba(245,241,250,0.15);
  font-family: var(--font-display);
  font-size: 9px;
  line-height: 1.6;
  text-align: center;
  letter-spacing: 0.02em;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
  max-width: 80%;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.toast--warn { border-color: rgba(224,86,143,0.5); color: var(--magenta); }

/* ---------- steering hint + Focus button ---------- */

#touch-controls {
  position: absolute;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
#flap-hint {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(13,11,20,0.55);
  border: 1px solid rgba(245,241,250,0.18);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  backdrop-filter: blur(3px);
  transition: opacity 0.6s ease;
}
#touch-controls.faded #flap-hint { opacity: 0; }

.focus-btn {
  pointer-events: auto;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(245,241,250,0.2);
  background: rgba(23,18,37,0.6);
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.04em;
  backdrop-filter: blur(3px);
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.focus-btn.ready {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 16px rgba(231,185,90,0.5);
}
.focus-btn.active {
  transform: scale(0.92);
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 20px rgba(63,221,196,0.6);
}


/* ---------- screens ---------- */

.screen {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 28px max(22px, env(safe-area-inset-right)) 28px max(22px, env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(5,8,7,0.94), rgba(13,11,20,0.97));
  overflow-y: auto;
}
.screen.hidden { display: none; }

.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(26px, 8vw, 40px);
  line-height: 1.3;
  color: var(--text);
  text-shadow: 0 0 18px rgba(155,107,243,0.55);
}
.title--small { font-size: clamp(18px, 6vw, 26px); }

.tagline {
  margin: 0;
  color: var(--cyan);
  font-size: 14px;
  line-height: 1.6;
}
.tagline-sub {
  margin: 0;
  color: var(--cyan);
  font-size: 15px;
  font-style: italic;
  letter-spacing: 0.02em;
}
.poster-line {
  margin: 6px 0 0;
  color: var(--text);
  font-size: 13px;
}
.poster-journey {
  margin: 0;
  max-width: 300px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.challenge-target-line {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(231,185,90,0.5);
}

/* style-select screen */
.style-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
}
.style-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(245,241,250,0.16);
  background: rgba(23,18,37,0.55);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.style-btn:active { background: rgba(155,107,243,0.22); }
.style-name { font-family: var(--font-display); font-size: 13px; color: var(--gold); }
.style-blurb { font-size: 12px; color: var(--text); }
.style-detail { font-size: 10.5px; color: var(--muted); }

.btn-primary {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  padding: 13px 26px;
  border-radius: 10px;
  border: none;
  color: var(--ink);
  background: linear-gradient(120deg, var(--cyan), var(--violet));
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(155,107,243,0.35);
}
.btn-primary:active { transform: translateY(1px); }

.btn-ghost {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid rgba(245,241,250,0.25);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.pause-settings {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
  width: 100%;
  max-width: 240px;
}
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: var(--text);
}
.toggle-row input { width: 20px; height: 20px; }

/* end screen */

#neural-style-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 20px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(155,107,243,0.16), rgba(224,86,143,0.12));
  border: 1px solid rgba(245,241,250,0.14);
  max-width: 300px;
}
.ns-label { font-size: 10px; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; }
.ns-name { font-family: var(--font-display); font-size: 15px; color: var(--gold); text-shadow: 0 0 10px rgba(231,185,90,0.5); margin: 2px 0; }
.ns-blurb { font-size: 12px; color: var(--text); }

.end-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  width: 100%;
  max-width: 300px;
  margin: 4px 0;
}
.end-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(245,241,250,0.06);
}
.end-stat .k { font-size: 10px; letter-spacing: 0.05em; color: var(--muted); text-transform: uppercase; }
.end-stat .v { font-family: var(--font-display); font-size: 13px; color: var(--text); }
.end-stat--badge {
  grid-column: 1 / -1;
  align-items: center;
  background: rgba(231,185,90,0.14);
  border: 1px solid rgba(231,185,90,0.35);
}
.end-stat--badge .v { color: var(--gold); text-align: center; width: 100%; }

.brain-seed-line {
  margin: 0;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--muted);
}

#neural-signature {
  width: 90px;
  height: 60px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.end-closing {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.04em;
  line-height: 1.7;
  color: var(--cyan);
  max-width: 260px;
}

.end-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 280px;
  margin-top: 4px;
}

.play-again-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 280px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(245,241,250,0.1);
}
.play-again-label {
  margin: 0;
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--muted);
}
.play-again-buttons {
  display: flex;
  gap: 8px;
  width: 100%;
}
.play-again-buttons .btn-primary { flex: 2; }
.play-again-buttons .btn-ghost { flex: 1; }

.outro-logo {
  display: block;
  width: min(72vw, 430px);
  height: auto;
  filter: drop-shadow(0 0 22px rgba(81,222,230,0.34));
}
.outro-url {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid rgba(183,172,198,0.3);
}

.brand-footer {
  margin: 10px 0 0;
  font-size: 10px;
  line-height: 1.7;
  color: var(--muted);
  text-align: center;
}
.brand-mark {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--text);
}
.brand-footer a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid rgba(183,172,198,0.3);
}

.btn-play-again { margin-top: 0; }

/* mobile rotate recommendation — shown only on small portrait screens;
   pure CSS media query so it updates on rotation with zero JS cost */
.rotate-hint {
  display: none;
  align-items: center;
  gap: 6px;
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
}
.rotate-hint__icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--muted);
}
@media (max-width: 480px) and (orientation: portrait) {
  .rotate-hint { display: flex; }
}

/* reduced motion: quiet down transitions app-wide */
.reduce-motion * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }

/* small phones */
@media (max-height: 560px) {
  .screen { gap: 8px; padding: 16px; }
  #neural-signature { display: none; }
}
