:root {
  --bg: #040b15;
  --bg-elevated: rgba(9, 20, 35, 0.78);
  --panel-border: rgba(131, 225, 255, 0.18);
  --text: #ecf6ff;
  --muted: #8ca3bb;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #5bcfff;
  --accent-strong: #92e3ff;
  --silver: #d8e4f2;
  --success: #5af0b2;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.36);
  --radius-lg: 28px;
  --radius-md: 20px;
  --container: min(1180px, calc(100vw - 32px));
  --transition: 180ms ease;
  --mode-accent: var(--accent);
  --mode-glow: rgba(91, 207, 255, 0.25);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(91, 207, 255, 0.08), transparent 28%),
    radial-gradient(circle at bottom right, rgba(146, 227, 255, 0.08), transparent 22%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
}

body.mode-challenge {
  --mode-accent: #ffcf70;
  --mode-glow: rgba(255, 207, 112, 0.28);
}

img {
  display: block;
  max-width: 100%;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.is-hidden,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-grid,
.bg-ring,
.bg-orb {
  position: absolute;
}

.bg-grid {
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 88%);
}

.bg-ring {
  top: 14%;
  right: -8rem;
  width: 28rem;
  height: 28rem;
  border: 2px solid rgba(255, 255, 255, 0.06);
  border-radius: 50%;
  box-shadow: 0 0 0 50px rgba(255, 255, 255, 0.02), 0 0 0 100px rgba(255, 255, 255, 0.01);
}

.bg-orb {
  border-radius: 50%;
  filter: blur(30px);
  opacity: 0.7;
}

.orb-a {
  top: 12%;
  left: -4rem;
  width: 13rem;
  height: 13rem;
  background: rgba(91, 207, 255, 0.18);
  animation: drift 10s ease-in-out infinite;
}

.orb-b {
  bottom: 12%;
  right: 5%;
  width: 16rem;
  height: 16rem;
  background: rgba(131, 225, 255, 0.12);
  animation: drift 14s ease-in-out infinite reverse;
}

.app-shell {
  position: relative;
  width: var(--container);
  margin: 0 auto;
  padding: 20px 0 48px;
}

.topbar,
.panel,
.footer {
  backdrop-filter: blur(18px);
}

.topbar {
  position: sticky;
  top: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  margin-bottom: 18px;
  background: rgba(7, 17, 31, 0.8);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(91, 207, 255, 0.18), rgba(255, 255, 255, 0.08));
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-copy span:last-child,
.topnav a,
.mode-toggle-label,
.eyebrow,
.status-label,
.track-tag,
.trait-kicker,
.game-kicker,
.stat-label,
.time-readout {
  color: var(--muted);
}

.topnav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.topnav a {
  font-size: 0.96rem;
  transition: color var(--transition);
}

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

.mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), background var(--transition);
}

.mode-toggle-state {
  min-width: 36px;
  text-align: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(91, 207, 255, 0.14);
  color: #b8f1ff;
}

.mode-toggle:hover,
.mode-toggle:focus-visible,
.button:hover,
.button:focus-visible,
.game-button:hover,
.game-button:focus-visible,
.audio-toggle:hover,
.audio-toggle:focus-visible,
.target-cell:hover,
.target-cell:focus-visible,
.memory-pad:focus-visible {
  transform: translateY(-1px);
}

.panel {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.hero,
.section,
.footer {
  overflow: hidden;
}

.hero::after,
.trait-card::after,
.badge-card::after,
.game-card::after,
.gallery-card::after,
.music-player::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.03));
  pointer-events: none;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 28px;
  padding: 34px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
}

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

h1 {
  margin-bottom: 14px;
  font-size: clamp(2.5rem, 5vw, 4.5rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
}

.hero-text,
.challenge-copy,
.badge-card p,
.gallery-copy p,
.game-description,
.track-meta p,
.trait-card p {
  color: #bfd1e2;
}

.hero-actions,
.hero-tags,
.topnav,
.summary-row,
.score-row,
.target-scoreboard,
.challenge-status,
.player-controls,
.music-player {
  display: flex;
  gap: 14px;
}

.hero-actions {
  flex-wrap: wrap;
  margin: 24px 0 28px;
}

.button,
.game-button,
.audio-toggle {
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.button:disabled,
.game-button:disabled,
.audio-toggle:disabled {
  opacity: 0.72;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  font-weight: 700;
}

.button-primary,
.game-button,
.audio-toggle {
  background: linear-gradient(135deg, var(--mode-accent), #d7f4ff);
  color: #03121f;
  box-shadow: 0 16px 30px var(--mode-glow);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.hero-stats,
.about-grid,
.games-grid,
.gallery-grid,
.badge-grid {
  display: grid;
  gap: 18px;
}

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

.stat-card,
.trait-card,
.badge-card,
.game-card,
.gallery-card,
.music-player,
.badge-summary {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
}

.stat-card,
.trait-card,
.game-card,
.gallery-card,
.music-player,
.badge-summary {
  padding: 22px;
}

.stat-value {
  display: block;
  margin-bottom: 6px;
  font-size: clamp(1.7rem, 5vw, 2.6rem);
  font-weight: 800;
  color: #b6f0ff;
}

.hero-visual {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.portrait-shell {
  position: relative;
  min-height: 400px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 35%),
    linear-gradient(160deg, rgba(91, 207, 255, 0.18), rgba(8, 18, 31, 0.86));
}

.portrait-glow {
  position: absolute;
  inset: auto 12% 0;
  height: 34%;
  background: radial-gradient(circle, rgba(91, 207, 255, 0.4), transparent 70%);
  filter: blur(18px);
}

.hero-portrait {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portrait-fallback,
.gallery-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  padding: 18px;
  color: var(--silver);
}

.portrait-fallback strong {
  font-size: 1.5rem;
}

.hero-tags {
  flex-wrap: wrap;
}

.hero-tags span,
.track-tag {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.section {
  margin-top: 18px;
  padding: 28px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.about-grid,
.gallery-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.trait-card {
  min-height: 200px;
  transition: transform var(--transition), border-color var(--transition);
  animation: float-in 700ms ease both;
}

.trait-card:nth-child(2) {
  animation-delay: 70ms;
}

.trait-card:nth-child(3) {
  animation-delay: 140ms;
}

.trait-card:nth-child(4) {
  animation-delay: 210ms;
}

.trait-card:hover,
.trait-card:focus-within,
.badge-card:hover,
.game-card:hover,
.gallery-card:hover {
  transform: translateY(-4px);
  border-color: rgba(146, 227, 255, 0.25);
}

.badges-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
  gap: 20px;
}

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

.badge-card {
  padding: 20px;
  opacity: 0.72;
  transition: opacity var(--transition), transform var(--transition), border-color var(--transition);
}

.badge-card.is-unlocked {
  opacity: 1;
  border-color: rgba(90, 240, 178, 0.35);
  box-shadow: inset 0 0 0 1px rgba(90, 240, 178, 0.12);
}

.badge-icon {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: #b8f1ff;
  font-weight: 800;
}

.badge-summary {
  display: grid;
  gap: 14px;
  align-content: start;
}

.summary-row,
.score-row {
  justify-content: space-between;
}

.challenge-zone {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 18%), rgba(9, 20, 35, 0.82);
}

.challenge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.challenge-status {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.challenge-status div {
  min-width: 126px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

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

.game-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background-size: cover;
  background-position: center;
}

.game-card-reaction {
  background:
    linear-gradient(180deg, rgba(4, 11, 21, 0.74), rgba(4, 11, 21, 0.92)),
    url("assets/generated/backgrounds/futuristic-grid-bg.jpg") center/cover;
}

.game-card-football {
  background:
    linear-gradient(180deg, rgba(4, 11, 21, 0.62), rgba(4, 11, 21, 0.92)),
    url("assets/generated/backgrounds/stadium-energy-bg.jpg") center/cover;
}

.game-card-memory {
  background:
    linear-gradient(180deg, rgba(4, 11, 21, 0.68), rgba(4, 11, 21, 0.92)),
    url("assets/generated/backgrounds/gamer-neon-bg.jpg") center/cover;
}

.reaction-button.is-ready {
  background: linear-gradient(135deg, #79ffc9, #d6ffe7);
}

.reaction-button.is-live {
  box-shadow: 0 0 0 3px rgba(121, 255, 201, 0.16), 0 16px 30px rgba(121, 255, 201, 0.24);
}

.game-status {
  min-height: 48px;
  margin-bottom: 0;
}

.game-metrics {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.target-scoreboard {
  flex-wrap: wrap;
  justify-content: space-between;
  color: #d9e8f8;
}

.target-grid,
.memory-grid {
  display: grid;
}

.target-grid {
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.target-cell,
.memory-pad {
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.target-cell {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.08), transparent 55%), rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.target-ring {
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 12px rgba(255, 255, 255, 0.02);
  transition: transform 160ms ease, opacity 160ms ease, border-color 160ms ease;
}

.target-cell.is-active {
  background: radial-gradient(circle at center, rgba(255, 207, 112, 0.65), transparent 42%), rgba(255, 207, 112, 0.16);
  border-color: rgba(255, 207, 112, 0.5);
  box-shadow: 0 0 24px rgba(255, 207, 112, 0.3);
  animation: pulse-target 720ms ease infinite;
}

.target-cell.is-active .target-ring {
  border-color: rgba(255, 245, 214, 0.8);
  transform: scale(1.08);
}

.target-cell.is-bonus {
  background: radial-gradient(circle at center, rgba(91, 207, 255, 0.72), transparent 44%), rgba(91, 207, 255, 0.16);
  border-color: rgba(91, 207, 255, 0.58);
  box-shadow: 0 0 26px rgba(91, 207, 255, 0.32);
}

.target-cell.is-bonus .target-ring {
  border-color: rgba(215, 247, 255, 0.92);
}

.target-cell.is-miss {
  background: radial-gradient(circle at center, rgba(255, 111, 134, 0.48), transparent 42%), rgba(255, 111, 134, 0.12);
  border-color: rgba(255, 111, 134, 0.45);
}

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

.memory-pad {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.04);
}

.memory-pad::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.68), transparent 55%);
  transition: opacity 120ms ease;
}

.memory-pad-a {
  background: linear-gradient(135deg, rgba(91, 207, 255, 0.45), rgba(91, 207, 255, 0.12));
}

.memory-pad-b {
  background: linear-gradient(135deg, rgba(220, 230, 242, 0.45), rgba(220, 230, 242, 0.12));
}

.memory-pad-c {
  background: linear-gradient(135deg, rgba(99, 255, 227, 0.45), rgba(99, 255, 227, 0.12));
}

.memory-pad-d {
  background: linear-gradient(135deg, rgba(247, 206, 118, 0.5), rgba(247, 206, 118, 0.12));
}

.memory-pad.is-active,
.memory-pad:active,
.memory-pad:focus-visible,
.target-cell:focus-visible,
.target-cell:hover {
  transform: scale(0.98);
  border-color: rgba(255, 255, 255, 0.42);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.memory-pad.is-active {
  transform: scale(0.95);
  border-color: rgba(255, 255, 255, 0.86);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.18),
    0 0 30px rgba(255, 255, 255, 0.28),
    inset 0 0 30px rgba(255, 255, 255, 0.18);
  filter: brightness(1.45) saturate(1.2);
}

.memory-pad.is-active::after {
  opacity: 1;
}

.gallery-card {
  display: grid;
  gap: 16px;
}

.gallery-image-shell {
  position: relative;
  min-height: 280px;
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(160deg, rgba(91, 207, 255, 0.16), rgba(8, 18, 31, 0.9)), rgba(255, 255, 255, 0.04);
}

.gallery-image {
  width: 100%;
  height: 100%;
  min-height: 280px;
  object-fit: cover;
}

.gallery-copy code {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: #b8f1ff;
  word-break: break-word;
}

.music-player {
  align-items: center;
  justify-content: space-between;
}

.track-meta h3 {
  margin-bottom: 10px;
  font-size: 1.5rem;
}

.player-controls {
  align-items: center;
  flex: 1;
}

.audio-toggle {
  min-width: 100px;
  font-weight: 800;
}

.progress-wrap {
  flex: 1;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--mode-accent);
}

.footer {
  margin-top: 18px;
  padding: 22px;
  text-align: center;
  background: rgba(7, 17, 31, 0.82);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
}

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 10px;
  z-index: 30;
}

.toast {
  min-width: 240px;
  max-width: 320px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(9, 20, 35, 0.92);
  border: 1px solid rgba(90, 240, 178, 0.25);
  box-shadow: var(--shadow);
}

.toast strong {
  display: block;
  margin-bottom: 4px;
  color: var(--success);
}

.mode-challenge .panel {
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 207, 112, 0.04);
}

.mode-challenge .challenge-zone {
  background: linear-gradient(180deg, rgba(255, 207, 112, 0.05), transparent 18%), rgba(14, 21, 31, 0.88);
}

.mode-challenge .mode-toggle-state {
  background: rgba(255, 207, 112, 0.18);
  color: #ffdc97;
}

.mode-challenge .hero-tags span,
.mode-challenge .track-tag {
  border-color: rgba(255, 207, 112, 0.14);
}

@keyframes pulse-target {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

@keyframes drift {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(18px, -18px, 0);
  }
}

@keyframes float-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1024px) {
  .hero,
  .badges-layout {
    grid-template-columns: 1fr;
  }

  .about-grid,
  .gallery-grid {
    grid-template-columns: 1fr;
  }

  .hero-stats,
  .badge-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .games-grid,
  .music-player,
  .challenge-header {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .player-controls,
  .challenge-status {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 20px, 100%);
    padding-top: 12px;
  }

  .topbar,
  .hero,
  .section,
  .footer {
    padding: 18px;
  }

  .topbar {
    position: static;
    flex-direction: column;
    align-items: stretch;
  }

  .topnav {
    justify-content: space-between;
  }

  .hero-stats,
  .badge-grid,
  .games-grid {
    grid-template-columns: 1fr;
  }

  .portrait-shell,
  .gallery-image-shell {
    min-height: 240px;
  }

  .challenge-status div,
  .summary-row,
  .score-row,
  .target-scoreboard,
  .music-player,
  .player-controls {
    width: 100%;
  }

  .player-controls,
  .music-player,
  .challenge-status,
  .challenge-header {
    align-items: stretch;
  }

  .time-readout {
    min-width: 0;
    text-align: left;
  }
}
