/* ===========================
   DESIGN SYSTEM - Sriram4n Games
   Matching Portfolio: Clean & Minimal Modern + Sky Blue Accent
   =========================== */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* --- CSS Custom Properties --- */
:root {
  /* Colors - Light Theme (matches portfolio) */
  --bg-primary: #FAFBFE;
  --bg-secondary: #F0F4F8;
  --bg-tertiary: #E8EDF3;
  --text-primary: #1A1D2E;
  --text-secondary: #5A6178;
  --text-tertiary: #8B92A8;
  --accent: #5BA4E6;
  --accent-hover: #4A93D5;
  --accent-glow: rgba(91, 164, 230, 0.15);
  --accent-subtle: rgba(91, 164, 230, 0.08);
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(91, 164, 230, 0.18);
  --card-bg: rgba(255, 255, 255, 0.6);
  --card-border: rgba(91, 164, 230, 0.12);
  --card-shadow: 0 4px 24px rgba(91, 164, 230, 0.08);
  --card-hover-shadow: 0 8px 40px rgba(91, 164, 230, 0.16);
  --divider: rgba(91, 164, 230, 0.1);
  --selection-bg: #C5DEF5;
  --toggle-color: #5A6178;

  /* Signal colors (game specific) */
  --signal-off: #222;
  --signal-red: #ff0000;
  --signal-yellow: #ffcc00;
  --signal-green: #00ff00;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Spacing */
  --section-padding: 120px 24px;
  --container-max: 1080px;
  --nav-height: 64px;

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-base: 0.3s ease;
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);

  /* Border radius */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
}

[data-theme="dark"] {
  --bg-primary: #0F1117;
  --bg-secondary: #1A1D27;
  --bg-tertiary: #242836;
  --text-primary: #E8ECF4;
  --text-secondary: #8B92A8;
  --text-tertiary: #5A6178;
  --accent: #6BB3F0;
  --accent-hover: #7EC0F7;
  --accent-glow: rgba(107, 179, 240, 0.12);
  --accent-subtle: rgba(107, 179, 240, 0.06);
  --glass-bg: rgba(15, 17, 23, 0.78);
  --glass-border: rgba(107, 179, 240, 0.12);
  --card-bg: rgba(26, 29, 39, 0.6);
  --card-border: rgba(107, 179, 240, 0.1);
  --card-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --card-hover-shadow: 0 8px 40px rgba(107, 179, 240, 0.12);
  --divider: rgba(107, 179, 240, 0.08);
  --selection-bg: #2A3A50;
  --toggle-color: #8B92A8;

  --signal-off: #1a1a1a;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--nav-height);
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  font-weight: 400;
  transition: background var(--transition-base), color var(--transition-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
  user-select: none;
}

input {
  user-select: auto;
  -webkit-user-select: auto;
}

::selection {
  background-color: var(--selection-bg);
  color: var(--text-primary);
}

a {
  text-decoration: none;
  color: var(--accent);
  font-weight: 500;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-hover);
}

/* --- Container --- */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
}

/* ===========================
   NAVBAR - Sticky Frosted Glass
   =========================== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  z-index: 1000;
  transition: background var(--transition-base), border-color var(--transition-base);
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  position: relative;
}

/* --- Brand / Logo with Letter Animation --- */
.brand {
  display: flex;
  align-items: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  cursor: pointer;
  text-decoration: none;
  min-width: 0;
  flex-shrink: 0;
}

.brand .letter {
  display: inline-block;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    margin 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 1em;
  opacity: 1;
  overflow: hidden;
  white-space: nowrap;
}

.brand .letter.collapsible {
  max-width: 0.9em;
}

/* Collapsed state - hide middle letters */
.navbar.collapsed .brand .letter.collapsible {
  max-width: 0;
  opacity: 0;
  margin: 0;
}

/* Uppercase the 'n' when collapsed to show "S4N." */
.navbar.collapsed .brand .brand-n {
  text-transform: uppercase;
}

/* The accent dot after the brand */
.brand .brand-dot {
  color: var(--accent);
  margin-left: 1px;
  transition: opacity var(--transition-fast);
}

/* --- Nav Links --- */
.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
  list-style: none;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.nav-links a {
  position: relative;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9rem;
  text-decoration: none;
  padding: 4px 0;
  transition: color var(--transition-fast);
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text-primary);
}

.nav-links a:hover::after,
.nav-links a.active::after {
  width: 100%;
}

/* --- Theme Toggle in Navbar --- */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--toggle-color);
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

#theme-toggle:hover {
  background: var(--accent-subtle);
  color: var(--accent);
  transform: scale(1.05);
}

#theme-toggle .sun-icon {
  display: none;
}

#theme-toggle .moon-icon {
  display: block;
}

[data-theme="dark"] #theme-toggle .sun-icon {
  display: block;
}

[data-theme="dark"] #theme-toggle .moon-icon {
  display: none;
}

/* --- Mobile Nav Toggle --- */
.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 1001;
}

.nav-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: var(--radius-full);
  transition: transform var(--transition-base), opacity var(--transition-fast);
}

.nav-hamburger.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.nav-hamburger.active span:nth-child(2) {
  opacity: 0;
}

.nav-hamburger.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ===========================
   HERO SECTION
   =========================== */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 120px 24px 80px;
  position: relative;
}

.hero h1 {
  font-size: clamp(2.2rem, 4.5vw, 3.4rem);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 12px;
  word-spacing: 0.05em;
}

.hero h1 .accent {
  color: var(--accent);
  letter-spacing: -0.01em;
}

.hero-subtitle {
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--text-secondary);
  font-weight: 400;
  min-height: 1.8em;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Pop-fade subtitle animation */
.pop-text {
  display: inline-block;
  animation: popFade 3s ease-in-out infinite;
}

@keyframes popFade {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }

  12% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  80% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
}

.hero-scroll-hint {
  position: absolute;
  bottom: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-tertiary);
  font-size: 0.8rem;
  font-weight: 500;
  animation: floatDown 2s ease-in-out infinite;
}

.hero-scroll-hint svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-tertiary);
}

@keyframes floatDown {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(6px);
  }
}

/* ===========================
   GAME SELECTION SECTION
   =========================== */
.games-section {
  padding: var(--section-padding);
  border-top: 1px solid var(--divider);
}

.section-header {
  text-align: center;
  margin-bottom: 64px;
}

.section-header h2 {
  font-size: clamp(1.8rem, 3.5vw, 2.4rem);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.section-label {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 12px;
}

/* --- Game Selection Cards --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 28px;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
}

.game-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  cursor: pointer;
  transition: transform var(--transition-base),
    box-shadow var(--transition-base),
    border-color var(--transition-base);
}

.game-card:hover {
  transform: translateY(-6px);
}

/* Gradient-matched hover glow per card */
.game-card:nth-child(1):hover {
  box-shadow: 0 8px 40px rgba(91, 164, 230, 0.22);
  border-color: #5BA4E6;
}

.game-card:nth-child(2):hover {
  box-shadow: 0 8px 40px rgba(230, 103, 160, 0.22);
  border-color: #E667A0;
}

.game-card:nth-child(3):hover {
  box-shadow: 0 8px 40px rgba(107, 196, 166, 0.22);
  border-color: #6BC4A6;
}

.game-card:nth-child(4):hover {
  box-shadow: 0 8px 40px rgba(230, 163, 77, 0.22);
  border-color: #E6A34D;
}

.game-card:nth-child(5):hover {
  box-shadow: 0 8px 40px rgba(155, 107, 230, 0.22);
  border-color: #9B6BE6;
}

.game-card:nth-child(6):hover {
  box-shadow: 0 8px 40px rgba(230, 103, 160, 0.22);
  border-color: #E667A0;
}

.game-card:nth-child(7):hover {
  box-shadow: 0 8px 40px rgba(107, 196, 166, 0.22);
  border-color: #6BC4A6;
}

/* Gradient header strip */
.game-card-header {
  height: 8px;
  width: 100%;
}

.game-card-header.gradient-1 {
  background: linear-gradient(135deg, #5BA4E6, #8BC4F6);
}

.game-card-header.gradient-2 {
  background: linear-gradient(135deg, #E667A0, #F5A0C0);
}

.game-card-header.gradient-3 {
  background: linear-gradient(135deg, #6BC4A6, #A0E6D0);
}

.game-card-header.gradient-4 {
  background: linear-gradient(135deg, #E6A34D, #F0C878);
}

.game-card-header.gradient-5 {
  background: linear-gradient(135deg, #9B6BE6, #C4A0F0);
}

.game-card-header.gradient-6 {
  background: linear-gradient(135deg, #E667A0, #F5A0C0);
}

.game-card-header.gradient-7 {
  background: linear-gradient(135deg, #6BC4A6, #A0E6D0);
}

.card-content {
  text-align: center;
  padding: 32px 28px;
}

.card-content h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}

.card-content p {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 0;
  pointer-events: none;
}

/* CSS Icons */
.card-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  border-radius: var(--radius-md);
}

.red-light-icon {
  background: radial-gradient(circle at 30% 30%, #ff5555, #cc0000);
  border: 3px solid var(--card-border);
  position: relative;
  box-shadow: 0 4px 16px rgba(255, 0, 0, 0.15);
}

.red-light-icon::after {
  content: '';
  position: absolute;
  top: 20%;
  left: 20%;
  width: 20%;
  height: 20%;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
}

.keyboard-icon {
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  padding: 10px;
  gap: 5px;
  border: 1px solid var(--card-border);
}

.keyboard-icon::before,
.keyboard-icon::after {
  content: '';
  width: 20px;
  height: 20px;
  background: var(--text-tertiary);
  border-radius: 4px;
}

.trading-icon {
  background: var(--bg-tertiary);
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  border: 1px solid var(--card-border);
}

.trading-icon::before,
.trading-icon::after {
  content: '';
  width: 15px;
  border-radius: 2px;
}

.trading-icon::before {
  height: 40px;
  background: #4caf50;
}

.trading-icon::after {
  height: 60px;
  background: #ef5350;
}

.typing-icon {
  background: var(--bg-tertiary);
  border: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 800;
  color: #E6A34D;
  position: relative;
  overflow: hidden;
}

.typing-icon::after {
  content: 'A';
  animation: typing-fall 2s ease-in-out infinite;
}

@keyframes typing-fall {
  0% { transform: translateY(-20px); opacity: 0; }
  30% { transform: translateY(0); opacity: 1; }
  70% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(20px); opacity: 0; }
}

.rhythm-icon {
  background: var(--bg-tertiary);
  border: 1px solid var(--card-border);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  padding-bottom: 12px;
}

.rhythm-icon::before,
.rhythm-icon::after {
  content: '';
  width: 10px;
  border-radius: 3px;
}

.rhythm-icon::before {
  height: 35px;
  background: #9B6BE6;
  box-shadow: -18px 0 0 0 #5BA4E6, -18px 15px 0 0 transparent;
}

.rhythm-icon::after {
  height: 50px;
  background: #E667A0;
  box-shadow: 18px 0 0 0 #E6A34D;
}

/* ===========================
   VIEW MANAGEMENT
   =========================== */
.view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: calc(100vh - var(--nav-height));
  padding-top: var(--nav-height);
  transition: opacity 0.3s ease;
}

.view.hidden {
  display: none;
}

.view.active {
  display: flex;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===========================
   BACK BUTTON
   =========================== */
.back-button {
  position: fixed;
  top: calc(var(--nav-height) + 16px);
  right: 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-sans);
  border-radius: var(--radius-sm);
  cursor: pointer;
  z-index: 101;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.back-button:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

.back-button.hidden {
  display: none;
}

/* ===========================
   LEADERBOARD SIDEBAR
   =========================== */
.hamburger {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 100;
  cursor: pointer;
  font-size: 1.6rem;
  color: var(--text-secondary);
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  transition: color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.hamburger:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: scale(1.05);
}

.leaderboard-panel {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 300px;
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--glass-border);
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
  transform: translateX(-100%);
  transition: transform var(--transition-base);
  padding: 80px 20px 20px;
  z-index: 99;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.leaderboard-panel.open {
  transform: translateX(0);
}

.leaderboard-panel h2 {
  color: var(--accent);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 20px;
  text-align: center;
  letter-spacing: -0.01em;
}

.leaderboard-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
  width: 100%;
}

.leaderboard-tabs .tab {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  padding: 6px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  border-radius: var(--radius-full);
  flex: 1;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.leaderboard-tabs .tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.leaderboard-tabs .tab:hover:not(.active) {
  border-color: var(--accent);
  color: var(--accent);
}

.score-list {
  list-style: none;
  width: 100%;
}

.score-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 8px;
  border-bottom: 1px solid var(--divider);
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: background var(--transition-fast);
}

.score-item:first-child {
  font-weight: 600;
  color: var(--accent);
}

.score-item:hover {
  background: var(--accent-subtle);
  border-radius: var(--radius-sm);
}

.score-item span.time {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-weight: 600;
}

/* ===========================
   GAME VIEWS - COMMON
   =========================== */
#app-reaction,
#app-keyboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

#app-reaction h1,
#app-keyboard h1 {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
  pointer-events: none;
}

.instruction-main {
  color: var(--text-secondary);
  font-size: 1.05rem;
  margin-bottom: 1.5rem;
  pointer-events: none;
}

.instruction-alt {
  color: var(--text-tertiary);
  font-size: 0.85rem;
  margin-top: 1.5rem;
  pointer-events: none;
}

#result {
  color: var(--accent);
  font-size: 2.2rem;
  font-weight: 800;
  height: 3rem;
  margin-top: 1rem;
}

/* --- Inputs --- */
input[type="text"] {
  padding: 12px 20px;
  font-size: 1rem;
  font-family: var(--font-sans);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-primary);
  margin-bottom: 1.2rem;
  text-align: center;
  outline: none;
  width: 260px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input[type="text"]::placeholder {
  color: var(--text-tertiary);
  opacity: 0.8;
}

/* --- Buttons --- */
button {
  padding: 12px 32px;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-sans);
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  z-index: 10;
}

button:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

button:active {
  transform: scale(0.97);
}

/* ===========================
   REACTION GAME - F1 Signal
   =========================== */
.signal-container {
  background-color: #0a0a0a;
  padding: 20px 40px;
  border-radius: var(--radius-md);
  display: none;
  flex-direction: row;
  gap: 30px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.light {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background-color: var(--signal-off);
  transition: background-color 0.05s, box-shadow 0.05s;
  border: 4px solid #000;
  position: relative;
}

.light::after {
  content: '';
  position: absolute;
  top: 20%;
  left: 20%;
  width: 20%;
  height: 20%;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
}

.light.red.active {
  background-color: var(--signal-red);
  box-shadow: 0 0 40px var(--signal-red);
}

.light.yellow.active {
  background-color: var(--signal-yellow);
  box-shadow: 0 0 40px var(--signal-yellow);
}

.light.green.active {
  background-color: var(--signal-green);
  box-shadow: 0 0 40px var(--signal-green);
}

.game-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  display: none;
  cursor: crosshair;
}

/* ===========================
   KEYBOARD REFLEX GAME
   =========================== */
.shortcut-container {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 28px 48px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--card-border);
  margin: 20px 0;
  box-shadow: var(--card-shadow);
}

.shortcut-container .key {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 1.8rem;
  display: inline-block;
  border: 1px solid var(--card-border);
  box-shadow: 0 3px 0 var(--divider), 0 4px 8px rgba(0, 0, 0, 0.08);
  transition: transform var(--transition-fast);
}

.stats-container {
  display: flex;
  gap: 20px;
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  font-weight: 500;
}

.feedback-msg {
  height: 1.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--signal-red);
}

.summary-container {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 32px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--card-border);
  text-align: center;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--card-shadow);
}

.summary-container h2 {
  color: var(--text-primary);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.summary-container h3 {
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.summary-container p {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 8px;
}

.educational-list {
  margin: 20px 0;
  text-align: left;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--card-border);
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-subtle);
}

.edu-item {
  margin-bottom: 8px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--divider);
  padding-bottom: 6px;
  color: var(--text-secondary);
}

.edu-item strong {
  color: var(--accent);
}

/* ===========================
   TRADING SIMULATOR
   =========================== */
#app-trading {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 24px 50px;
}

#app-trading h1 {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 8px;
}

.market-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
}

.stock-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

#stock-select {
  font-size: 1rem;
  font-family: var(--font-sans);
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
}

.price-display {
  display: flex;
  flex-direction: column;
}

#stock-price {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.positive {
  color: #4caf50;
}

.negative {
  color: #ef5350;
}

.icon-btn {
  background: transparent !important;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  transition: transform var(--transition-fast);
  box-shadow: none !important;
}

.icon-btn:hover {
  transform: scale(1.15);
  background: transparent !important;
  box-shadow: none !important;
}

.account-summary {
  display: flex;
  gap: 16px;
  align-items: center;
}

.time-box,
.balance-box,
.pnl-box {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.time-box span,
.balance-box span,
.pnl-box span {
  font-weight: 700;
  color: var(--accent);
}

/* Graph */
.graph-container {
  width: 100%;
  height: 300px;
  background: #0a0a0a;
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
}

#trading-canvas {
  width: 100%;
  height: 100%;
}

.news-ticker {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--transition-base);
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.news-ticker.visible {
  opacity: 1;
  animation: pulse-news 0.6s ease;
}

.news-ticker.positive {
  border-color: #4caf50;
  color: #4caf50;
}

.news-ticker.negative {
  border-color: #ef5350;
  color: #ef5350;
}

@keyframes pulse-news {
  0% {
    transform: translateX(-50%) scale(0.92);
  }

  50% {
    transform: translateX(-50%) scale(1.04);
  }

  100% {
    transform: translateX(-50%) scale(1);
  }
}

/* Trading Controls */
.trading-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  gap: 20px;
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

.trade-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

#trade-qty {
  width: 60px;
  padding: 8px;
  font-family: var(--font-sans);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  text-align: center;
  margin: 0;
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  font-size: 0.95rem;
}

#trade-qty:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.trade-btn {
  padding: 10px 20px;
  font-weight: 700;
  font-family: var(--font-sans);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.trade-btn.buy {
  background: #4caf50;
}

.trade-btn.buy:hover {
  background: #43a047;
  box-shadow: 0 4px 16px rgba(76, 175, 80, 0.3);
}

.trade-btn.sell {
  background: #ef5350;
}

.trade-btn.sell:hover {
  background: #e53935;
  box-shadow: 0 4px 16px rgba(239, 83, 80, 0.3);
}

/* Custom Range Slider */
input[type=range] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
}

input[type=range]:focus {
  outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  background: var(--bg-tertiary);
  border-radius: 3px;
}

input[type=range]::-webkit-slider-thumb {
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: -6px;
  box-shadow: 0 2px 8px var(--accent-glow);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 12px var(--accent-glow);
}

input[type=range]::-moz-range-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  background: var(--bg-tertiary);
  border-radius: 3px;
}

input[type=range]::-moz-range-thumb {
  height: 18px;
  width: 18px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* Trading Dashboard */
.trading-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.portfolio-panel,
.log-panel {
  background: var(--card-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  min-height: 140px;
  box-shadow: var(--card-shadow);
}

.portfolio-panel h3,
.log-panel h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.portfolio-panel p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 6px;
}

.log-panel ul {
  list-style: none;
  max-height: 120px;
  overflow-y: auto;
  font-size: 0.85rem;
}

.log-panel li {
  margin-bottom: 6px;
  border-bottom: 1px solid var(--divider);
  padding-bottom: 4px;
  color: var(--text-secondary);
}

#user-balance {
  font-weight: 700;
  color: var(--text-primary);
}

/* ===========================
   VIEW 7: AIM TRAINER
   =========================== */
.aim-setup {
  text-align: center;
  max-width: 500px;
  margin: 2rem auto;
}

.aim-arena {
  width: 100%;
  height: 500px;
  background: #060610;
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  cursor: crosshair;
}

.aim-hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(10, 10, 10, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(4px);
  z-index: 10;
  font-weight: 700;
  font-family: var(--font-mono);
}

#aim-target-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.aim-target {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ff8a80, #e53935);
  box-shadow: 0 0 15px rgba(229, 57, 53, 0.6);
  transform: translate(-50%, -50%) scale(0);
  pointer-events: auto;
  cursor: crosshair;
  transition: transform 0.1s ease-out;
  animation: aim-pop-in 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.aim-target::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60%;
  height: 60%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff, #ffebee);
}

.aim-target::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20%;
  height: 20%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #c62828;
}

.aim-target.hit {
  animation: aim-pop-out 0.15s ease-in forwards;
  pointer-events: none;
}

@keyframes aim-pop-in {
  from { transform: translate(-50%, -50%) scale(0); }
  to { transform: translate(-50%, -50%) scale(1); }
}

@keyframes aim-pop-out {
  from { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  to { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
}

/* ===========================
   VIEW 8: RETRO PLATFORMER
   =========================== */
.platformer-setup {
  text-align: center;
  max-width: 500px;
  margin: 2rem auto;
}

.platformer-arena {
  width: 100%;
  height: auto;
  background: #000;
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.platformer-hud {
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 8px 16px;
  background: #111;
  border-bottom: 2px solid #333;
  font-family: var(--font-mono);
  font-weight: bold;
  font-size: 1.1rem;
}

#platformer-canvas {
  background: #0a0a0a;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  max-width: 100%;
  height: auto;
  display: block;
}

/* ===========================
   TYPING INVADERS
   =========================== */
#app-typing {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 24px 50px;
}

#app-typing h1 {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 8px;
}

.typing-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.typing-setup .instruction-main {
  margin-bottom: 0;
}

.typing-arena {
  width: 100%;
  height: 500px;
  background: #060610;
  background-image:
    radial-gradient(1px 1px at 10% 15%, rgba(255,255,255,0.25), transparent),
    radial-gradient(1px 1px at 25% 40%, rgba(255,255,255,0.15), transparent),
    radial-gradient(1.5px 1.5px at 50% 10%, rgba(91,164,230,0.3), transparent),
    radial-gradient(1px 1px at 70% 60%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 80% 25%, rgba(155,107,230,0.25), transparent),
    radial-gradient(1px 1px at 90% 80%, rgba(255,255,255,0.15), transparent),
    radial-gradient(1px 1px at 15% 85%, rgba(230,103,160,0.2), transparent),
    radial-gradient(1px 1px at 35% 70%, rgba(255,255,255,0.1), transparent),
    radial-gradient(1.5px 1.5px at 60% 45%, rgba(107,196,166,0.25), transparent),
    radial-gradient(1px 1px at 45% 90%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 5% 50%, rgba(230,163,77,0.2), transparent),
    radial-gradient(1px 1px at 95% 55%, rgba(255,255,255,0.12), transparent);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
}

/* Screen Shake Animation */
@keyframes screen-shake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-4px, 2px); }
  20% { transform: translate(3px, -3px); }
  30% { transform: translate(-3px, 1px); }
  40% { transform: translate(2px, -2px); }
  50% { transform: translate(-2px, 3px); }
  60% { transform: translate(3px, -1px); }
  70% { transform: translate(-1px, 2px); }
  80% { transform: translate(2px, -2px); }
  90% { transform: translate(-2px, 1px); }
}

.typing-arena.shake {
  animation: screen-shake 0.4s ease-out;
}

.typing-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 5;
  font-size: 0.85rem;
  font-weight: 600;
  color: #ccc;
}

.typing-hud-stat {
  display: flex;
  align-items: center;
  gap: 6px;
}

.typing-hud-stat span {
  color: var(--accent);
  font-weight: 700;
}

.typing-lives {
  display: flex;
  gap: 4px;
}

.typing-heart {
  font-size: 1.1rem;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.typing-heart.lost {
  opacity: 0.2;
  transform: scale(0.8);
}

.defense-line {
  position: absolute;
  bottom: 18%;
  left: 0;
  right: 0;
  height: 2px;
  background: #ef5350;
  box-shadow: 0 0 12px rgba(239, 83, 80, 0.6), 0 0 24px rgba(239, 83, 80, 0.3);
  z-index: 2;
}

.defense-line::before {
  content: 'DEFENSE LINE';
  position: absolute;
  right: 12px;
  top: -18px;
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(239, 83, 80, 0.6);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.typing-word {
  position: absolute;
  padding: 6px 16px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 1rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
  z-index: 3;
  transition: border-color 0.15s, box-shadow 0.15s;
  pointer-events: none;
  user-select: none;
}

.typing-word.active {
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(91, 164, 230, 0.4);
  color: #fff;
}

.typing-word .matched {
  color: var(--accent);
}

.typing-word.destroying {
  animation: word-destroy 0.35s ease-out forwards;
}

@keyframes word-destroy {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.3);
    opacity: 0.6;
    box-shadow: 0 0 30px rgba(91, 164, 230, 0.6);
  }
  100% {
    transform: scale(0.5);
    opacity: 0;
  }
}

.typing-input-area {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 5;
}

.typing-input-area input {
  width: 100%;
  padding: 12px 20px;
  font-size: 1.1rem;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  outline: none;
  text-align: center;
  letter-spacing: 0.05em;
  margin: 0;
}

.typing-input-area input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 164, 230, 0.2);
}

.typing-gameover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
  animation: fadeIn 0.4s ease;
}

.typing-gameover-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 32px 40px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--card-border);
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--card-shadow);
}

.typing-gameover-card h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.typing-gameover-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 20px;
}

.typing-gameover-card p {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 8px;
}

.typing-gameover-card button {
  margin-top: 16px;
}

/* ===========================
   RHYTHM TAP
   =========================== */
#app-rhythm {
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 24px 50px;
}

#app-rhythm h1 {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 8px;
}

.rhythm-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.rhythm-setup .instruction-main {
  margin-bottom: 0;
}

.rhythm-difficulty {
  display: flex;
  gap: 10px;
}

.rhythm-difficulty button {
  padding: 10px 24px;
  font-size: 0.9rem;
  font-weight: 600;
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.rhythm-difficulty button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
  transform: translateY(-2px);
  box-shadow: none;
}

.rhythm-difficulty button.selected {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.rhythm-stage {
  width: 100%;
  height: 520px;
  background: #060610;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(91,164,230,0.2), transparent),
    radial-gradient(1px 1px at 40% 70%, rgba(155,107,230,0.15), transparent),
    radial-gradient(1px 1px at 75% 30%, rgba(230,103,160,0.15), transparent),
    radial-gradient(1px 1px at 90% 85%, rgba(107,196,166,0.15), transparent);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
}

.rhythm-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 5;
  font-size: 0.82rem;
  font-weight: 600;
  color: #ccc;
}

.rhythm-hud-stat span {
  color: var(--accent);
  font-weight: 700;
}

.rhythm-health-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: #ccc;
}

.rhythm-health-bar {
  width: 80px;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.rhythm-health-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #4caf50, #8bc34a);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.rhythm-health-fill.low {
  background: linear-gradient(90deg, #ef5350, #ff7043);
}

.rhythm-lanes {
  position: absolute;
  top: 40px;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
}

.rhythm-lane {
  flex: 1;
  position: relative;
  border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.rhythm-lane:last-child {
  border-right: none;
}

.rhythm-hit-zone {
  position: absolute;
  bottom: 60px;
  left: 0;
  right: 0;
  height: 4px;
  z-index: 4;
}

.rhythm-hit-zone-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.15);
}

.rhythm-key-label {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.9rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  z-index: 4;
  transition: background 0.1s, color 0.1s, box-shadow 0.1s, transform 0.1s;
}

.rhythm-lane.flash .rhythm-key-label {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.2);
  transform: translateX(-50%) scale(1.1);
}

/* Lane glow pulse on flash */
.rhythm-lane.flash::after {
  content: '';
  position: absolute;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  pointer-events: none;
  animation: lane-glow-pulse 0.3s ease-out forwards;
}

.rhythm-lane:nth-child(1).flash::after {
  background: radial-gradient(circle, rgba(91,164,230,0.4), transparent 70%);
}
.rhythm-lane:nth-child(2).flash::after {
  background: radial-gradient(circle, rgba(230,103,160,0.4), transparent 70%);
}
.rhythm-lane:nth-child(3).flash::after {
  background: radial-gradient(circle, rgba(107,196,166,0.4), transparent 70%);
}
.rhythm-lane:nth-child(4).flash::after {
  background: radial-gradient(circle, rgba(230,163,77,0.4), transparent 70%);
}

@keyframes lane-glow-pulse {
  0% { opacity: 1; transform: translateX(-50%) scale(0.5); }
  100% { opacity: 0; transform: translateX(-50%) scale(1.5); }
}

.rhythm-note {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 18px;
  border-radius: 6px;
  z-index: 3;
  pointer-events: none;
}

/* Lane colors */
.rhythm-lane:nth-child(1) .rhythm-note {
  background: #5BA4E6;
  box-shadow: 0 0 10px rgba(91, 164, 230, 0.5);
}

.rhythm-lane:nth-child(2) .rhythm-note {
  background: #E667A0;
  box-shadow: 0 0 10px rgba(230, 103, 160, 0.5);
}

.rhythm-lane:nth-child(3) .rhythm-note {
  background: #6BC4A6;
  box-shadow: 0 0 10px rgba(107, 196, 166, 0.5);
}

.rhythm-lane:nth-child(4) .rhythm-note {
  background: #E6A34D;
  box-shadow: 0 0 10px rgba(230, 163, 77, 0.5);
}

.rhythm-note.hit {
  animation: note-hit 0.25s ease-out forwards;
}

@keyframes note-hit {
  0% { transform: translateX(-50%) scale(1); opacity: 1; }
  50% { transform: translateX(-50%) scale(1.5); opacity: 0.5; }
  100% { transform: translateX(-50%) scale(0.3); opacity: 0; }
}

.rhythm-note.missed {
  opacity: 0.2;
}

.rhythm-feedback {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 6;
  pointer-events: none;
  animation: feedback-pop 0.5s ease-out forwards;
  white-space: nowrap;
}

@keyframes feedback-pop {
  0% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-20px) scale(1.2); }
}

.rhythm-feedback.perfect { color: #4caf50; }
.rhythm-feedback.good { color: #E6A34D; }
.rhythm-feedback.miss { color: #ef5350; }

.rhythm-combo {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.08);
  z-index: 1;
  pointer-events: none;
  transition: transform 0.15s ease;
}

.rhythm-combo.bump {
  animation: combo-bump 0.2s ease;
}

@keyframes combo-bump {
  0% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.15); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

/* --- Countdown Overlay --- */
.rhythm-countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 15;
  font-size: 5rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  text-shadow: 0 0 40px rgba(91, 164, 230, 0.5);
}

.rhythm-countdown-overlay.pop {
  animation: countdown-pop 0.6s ease-out;
}

@keyframes countdown-pop {
  0% { opacity: 0; transform: scale(2); }
  30% { opacity: 1; transform: scale(0.9); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* --- Grade Display --- */
.rhythm-grade {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin: 8px 0 12px;
  text-shadow: 0 0 20px var(--accent-glow);
}

.rhythm-results {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
  animation: fadeIn 0.4s ease;
}

.rhythm-results-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 32px 40px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--card-border);
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--card-shadow);
}

.rhythm-results-card h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.rhythm-results-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 20px;
}

.rhythm-results-card p {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 8px;
}

.rhythm-results-card button {
  margin-top: 16px;
}

.rhythm-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.rhythm-stat-box {
  padding: 10px;
  background: var(--accent-subtle);
  border-radius: var(--radius-sm);
  text-align: center;
}

.rhythm-stat-box .stat-label {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

.rhythm-stat-box .stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
}

/* ===========================
   AIM GAME OVER PANEL
   =========================== */
.game-over {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
  animation: fadeIn 0.4s ease;
}

.game-over-content {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 32px 40px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--card-border);
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--card-shadow);
}

.game-over-content h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.game-over-content h3 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 12px;
}

.game-over-content p {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 16px;
}

.game-over-content button {
  margin-top: 8px;
}

/* ===========================
   SCROLL REVEAL ANIMATIONS
   =========================== */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger children */
.reveal-stagger>* {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-stagger.visible>*:nth-child(1) {
  transition-delay: 0.05s;
}

.reveal-stagger.visible>*:nth-child(2) {
  transition-delay: 0.1s;
}

.reveal-stagger.visible>*:nth-child(3) {
  transition-delay: 0.15s;
}

.reveal-stagger.visible>*:nth-child(4) {
  transition-delay: 0.2s;
}

.reveal-stagger.visible>*:nth-child(5) {
  transition-delay: 0.25s;
}

.reveal-stagger.visible>* {
  opacity: 1;
  transform: translateY(0);
}

/* ===========================
   FOOTER
   =========================== */
.footer {
  padding: 40px 24px;
  border-top: 1px solid var(--divider);
  color: var(--text-tertiary);
  font-size: 0.85rem;
  text-align: center;
}

.footer-content {
  max-width: var(--container-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer a {
  color: var(--text-tertiary);
  font-weight: 500;
  transition: color var(--transition-fast);
}

.footer a:hover {
  color: var(--accent);
}

/* ===========================
   HIDDEN UTILITY
   =========================== */
.hidden {
  display: none !important;
}

/* ===========================
   FULLSCREEN MODE
   =========================== */
.global-exit-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 8px 16px;
  font-size: 1rem;
  font-weight: bold;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.global-exit-btn:hover {
  background: rgba(239, 83, 80, 0.8);
  border-color: #ef5350;
  transform: scale(1.05);
}

.global-exit-btn.hidden {
  display: none !important;
}

body.fullscreen-mode .navbar,
body.fullscreen-mode .footer,
body.fullscreen-mode .hamburger,
body.fullscreen-mode .leaderboard-panel,
body.fullscreen-mode .back-button {
  display: none !important;
}

body.fullscreen-mode .view {
  padding-top: 0;
  min-height: 100vh;
}

body.fullscreen-mode #app-reaction,
body.fullscreen-mode #app-keyboard {
  max-width: 100%;
  height: 100vh;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Typing Invaders: arena IS the entire screen */
body.fullscreen-mode #app-typing,
body.fullscreen-mode #app-aim,
body.fullscreen-mode #app-platformer {
  max-width: 100%;
  width: 100vw;
  height: 100vh;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: stretch;
}

body.fullscreen-mode #app-typing h1,
body.fullscreen-mode #app-aim h1,
body.fullscreen-mode #app-platformer h1 {
  display: none;
}

body.fullscreen-mode .typing-setup,
body.fullscreen-mode .aim-setup,
body.fullscreen-mode .platformer-setup {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
}

body.fullscreen-mode .typing-arena,
body.fullscreen-mode .aim-arena {
  width: 100vw;
  height: 100vh !important;
  border-radius: 0;
  border: none;
  box-shadow: none;
  margin: 0;
  flex: 1;
}

body.fullscreen-mode .platformer-arena {
  width: 100vw;
  height: 100vh !important;
  border-radius: 0;
  border: none;
  box-shadow: none;
  margin: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

body.fullscreen-mode #platformer-canvas {
  height: calc(100vh - 40px); /* Adjust for HUD */
  width: auto;
  max-width: 100vw;
}

/* Rhythm Tap: stage IS the entire screen */
body.fullscreen-mode #app-rhythm {
  max-width: 100%;
  width: 100vw;
  height: 100vh;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: stretch;
}

body.fullscreen-mode #app-rhythm h1 {
  display: none;
}

body.fullscreen-mode .rhythm-stage {
  width: 100vw;
  height: 100vh !important;
  border-radius: 0;
  border: none;
  box-shadow: none;
  margin: 0;
  flex: 1;
}

body.fullscreen-mode .reaction-arena,
body.fullscreen-mode .keyboard-arena {
  height: 100vh !important;
  border-radius: 0;
  border: none;
  box-shadow: none;
  margin: 0;
}

body.fullscreen-mode .shortcut-container {
  font-size: 5rem;
}

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 768px) {
  :root {
    --section-padding: 80px 20px;
    --nav-height: 56px;
  }

  .nav-hamburger {
    display: flex;
  }

  .nav-links {
    position: fixed;
    top: 0;
    right: -100%;
    left: auto;
    transform: none;
    width: 280px;
    height: 100vh;
    flex-direction: column;
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-left: 1px solid var(--glass-border);
    padding: 100px 40px 40px;
    gap: 24px;
    transition: right var(--transition-base);
    z-index: 999;
  }

  .nav-links.open {
    right: 0;
  }

  .nav-links a {
    font-size: 1.1rem;
  }

  .card-grid {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 0 16px;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .market-header {
    flex-direction: column;
    gap: 12px;
  }

  .account-summary {
    flex-wrap: wrap;
    gap: 10px;
  }

  .trading-controls {
    flex-direction: column;
    gap: 12px;
  }

  .leaderboard-panel {
    width: 100%;
  }

  .view {
    padding-top: var(--nav-height);
  }

  .shortcut-container {
    font-size: 1.6rem;
    padding: 20px;
    width: 90%;
  }

  .shortcut-container .key {
    padding: 5px 10px;
    font-size: 1.3rem;
  }

  .signal-container {
    padding: 10px 20px;
    gap: 10px;
    transform: scale(0.8);
  }

  .typing-arena {
    height: 400px;
  }

  .typing-word {
    font-size: 0.85rem;
    padding: 5px 12px;
  }

  .rhythm-stage {
    height: 440px;
  }

  .rhythm-note {
    width: 40px;
    height: 14px;
  }

  .rhythm-key-label {
    width: 30px;
    height: 30px;
    font-size: 0.75rem;
  }

  .rhythm-difficulty button {
    padding: 8px 16px;
    font-size: 0.82rem;
  }

  .footer-content {
    flex-direction: column;
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .card-grid {
    padding: 0 8px;
  }

  .card-content {
    padding: 24px 20px;
  }

  .card-icon {
    width: 64px;
    height: 64px;
  }
}


/* ===========================
   AIM TRAINER - Aimlabs Style
   =========================== */
.aim-target {
  position: absolute;
  background: radial-gradient(circle, #e667a0 0%, #d946a6 70%, #b03282 100%);
  border-radius: 50%;
  cursor: crosshair;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(230, 103, 160, 0.6), inset 0 0 10px rgba(255, 255, 255, 0.3);
  transition: transform 0.1s ease;
  border: 3px solid rgba(255, 255, 255, 0.8);
}

.aim-target:hover {
  transform: scale(1.05);
}

.aim-target.hit {
  animation: aimExplode 0.3s ease forwards;
}

.aim-target.missed {
  animation: aimFade 0.2s ease forwards;
}

@keyframes aimExplode {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.3);
    opacity: 0.7;
  }
  100% {
    transform: scale(0);
    opacity: 0;
  }
}

@keyframes aimFade {
  to {
    opacity: 0;
    transform: scale(0.8);
  }
}

@keyframes aimShrink {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(0.5);
  }
}

.aim-crosshair {
  width: 100%;
  height: 100%;
  position: relative;
}

.aim-crosshair::before,
.aim-crosshair::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.9);
}

.aim-crosshair::before {
  width: 2px;
  height: 40%;
  left: 50%;
  top: 30%;
  transform: translateX(-50%);
}

.aim-crosshair::after {
  height: 2px;
  width: 40%;
  top: 50%;
  left: 30%;
  transform: translateY(-50%);
}

.aim-hit-feedback {
  position: absolute;
  font-weight: 700;
  font-size: 1.2rem;
  pointer-events: none;
  animation: aimFeedbackFloat 0.6s ease forwards;
  z-index: 1000;
}

.aim-hit-feedback.hit {
  color: #4caf50;
  text-shadow: 0 0 10px rgba(76, 175, 80, 0.8);
}

.aim-hit-feedback.miss {
  color: #ef5350;
  text-shadow: 0 0 10px rgba(239, 83, 80, 0.8);
}

@keyframes aimFeedbackFloat {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -150%) scale(1.2);
    opacity: 0;
  }
}

.aim-arena {
  background: linear-gradient(135deg, #1a1d27 0%, #242836 100%);
  cursor: crosshair;
}

.aim-hud {
  display: flex;
  gap: 40px;
  justify-content: center;
  padding: 16px;
  background: rgba(26, 29, 39, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid rgba(230, 103, 160, 0.3);
}

.aim-hud-item {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.aim-hud-item span {
  font-size: 1.4rem;
  font-weight: 700;
  margin-left: 8px;
}

#aim-target-container {
  position: relative;
  width: 100%;
  height: calc(100% - 60px);
}


/* ===========================
   GLOBAL AUTH SYSTEM
   =========================== */
.auth-container {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.auth-display {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
}

#welcome-text {
  font-size: 1rem;
  color: var(--text-secondary);
}

#username-display {
  color: var(--accent);
  font-weight: 600;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 24px;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  min-width: 300px;
}

.auth-form input[type="text"],
.auth-form input[type="password"] {
  padding: 10px 16px;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  width: 100%;
  margin: 0;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.auth-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-buttons {
  display: flex;
  gap: 8px;
}

.auth-btn {
  flex: 1;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-sans);
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.auth-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

.auth-btn.secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--card-border);
}

.auth-btn.secondary:hover {
  background: var(--bg-secondary);
}

.auth-toggle {
  padding: 8px 20px;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.auth-toggle:hover {
  background: var(--accent);
  color: #fff;
}

.auth-error {
  color: #ef5350;
  font-size: 0.85rem;
  text-align: center;
  margin: 0;
  min-height: 1.2em;
}

.hidden {
  display: none !important;
}
