:root {
  --bg-dark: #030305;
  --bg-panel: rgba(20, 25, 35, 0.6);
  --text-main: #e0e6ed;
  --text-muted: #94a3b8;
  --accent-primary: #39ff14;
  --accent-secondary: #00d4ff;
  --accent-tertiary: #ff006e;
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-bg: rgba(255, 255, 255, 0.03);
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(0, 212, 255, 0.05), transparent 25%),
    radial-gradient(circle at 85% 30%, rgba(255, 0, 110, 0.05), transparent 25%),
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 255, 255, 0.01) 2px, rgba(255, 255, 255, 0.01) 4px);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
}

main {
  position: relative;
  z-index: 10;
  padding-bottom: 3rem;
}

/* Typography */
h1, h2, h3, h4 {
  margin: 0 0 1rem 0;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

h1 { font-size: clamp(2.5rem, 5vw, 4.5rem); line-height: 1.1; }
h2 { font-size: clamp(2rem, 4vw, 3rem); }
h3 { font-size: 1.5rem; }

a { color: inherit; text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-primary); }

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* Header */
.site-header {
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 100;
  padding: 1.5rem 0;
  background: linear-gradient(to bottom, rgba(3,3,5,0.8), transparent);
  backdrop-filter: blur(5px);
}

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand .num {
  color: var(--accent-primary);
  text-shadow: 0 0 20px rgba(57, 255, 20, 0.6);
}

.brand .x {
  color: var(--accent-secondary);
  text-shadow: 0 0 15px rgba(0, 212, 255, 0.6);
}

.nav nav a {
  margin-left: 2rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
}

.nav nav a:hover {
  color: var(--accent-secondary);
  text-shadow: 0 0 8px rgba(0, 212, 255, 0.5);
}

/* Hero */
.hero {
  position: relative;
  min-height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 8rem;
  padding-bottom: 4rem;
  overflow: hidden;
}

.hero-inner {
  position: relative;
  z-index: 10;
  text-align: center;
  max-width: 800px;
  animation: float 6s ease-in-out infinite;
}

.hero-portfolio {
  margin: 3rem 0;
}

.hero-card {
  margin: 2rem auto;
  max-width: 600px;
}

.cta-row {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.cta-row .btn {
  flex: 1;
  max-width: 200px;
}

.hero h1 {
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 1;
  font-size: clamp(3rem, 6vw, 5.5rem);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.4;
  color: rgba(255, 255, 255, 0.3);
  text-shadow: 
    0 0 40px rgba(0, 212, 255, 0.3),
    0 0 80px rgba(0, 212, 255, 0.2),
    0 0 120px rgba(0, 212, 255, 0.1);
  filter: blur(0.5px);
  transform: translateZ(-100px) scale(0.95);
  animation: float 6s ease-in-out infinite, distantPulse 4s ease-in-out infinite;
}

@keyframes distantPulse {
  0%, 100% { opacity: 0.3; filter: blur(0.5px); }
  50% { opacity: 0.5; filter: blur(0.3px); }
}

.accent {
  color: var(--accent-secondary);
  text-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
}

.typewriter {
  font-family: var(--font-mono);
  color: var(--accent-tertiary);
  margin-top: 2rem;
  min-height: 1.6em;
}
.herotypewriter {
  font-family: var(--font-mono);
  color: #fff;
  margin-top: 2rem;
  display: inline-block;
  min-height: 1.6em;
  line-height: 1.6em;
  vertical-align: middle;
}
/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.8rem;
  border-radius: 50px;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  font-size: 1rem;
  position: relative;
  transform-style: preserve-3d;
  perspective: 1000px;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50px;
  background: inherit;
  transform: translateZ(-8px);
  filter: brightness(0.6);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 52px;
  background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
  opacity: 0;
  transition: opacity 0.2s;
  z-index: -1;
}

.btn.btn-large {
  padding: 1.2rem 2.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  box-shadow: 
    0 8px 20px rgba(0, 212, 255, 0.4),
    0 4px 8px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.btn.btn-large::before {
  transform: translateZ(-12px);
}

.btn.primary {
  background: linear-gradient(135deg, #00e5ff 0%, var(--accent-secondary) 50%, #0099cc 100%);
  color: #000;
  border: none;
  box-shadow: 
    0 4px 15px rgba(0, 212, 255, 0.4),
    0 2px 4px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn.primary:hover {
  transform: translateY(-4px) translateZ(4px);
  box-shadow: 
    0 12px 30px rgba(0, 212, 255, 0.6),
    0 4px 8px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  background: linear-gradient(135deg, #00ffff 0%, #00e5ff 50%, #00b8d4 100%);
}

.btn.primary:hover::after {
  opacity: 1;
}

.btn.primary:active {
  transform: translateY(2px) translateZ(-4px);
  box-shadow: 
    0 2px 8px rgba(0, 212, 255, 0.3),
    0 1px 2px rgba(0, 0, 0, 0.2),
    inset 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: all 0.1s;
}

.btn.primary:active::before {
  transform: translateZ(-4px);
}

.btn.btn-large:active {
  transform: translateY(4px) translateZ(-6px);
  box-shadow: 
    0 2px 10px rgba(0, 212, 255, 0.3),
    0 1px 3px rgba(0, 0, 0, 0.2),
    inset 0 3px 6px rgba(0, 0, 0, 0.4);
}

.btn.btn-large:active::before {
  transform: translateZ(-6px);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: #fff;
  backdrop-filter: blur(5px);
  box-shadow: 
    0 4px 12px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn.ghost::before {
  background: rgba(0, 0, 0, 0.3);
  filter: none;
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-3px) translateZ(3px);
  box-shadow: 
    0 8px 20px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn.ghost:active {
  transform: translateY(1px) translateZ(-2px);
  box-shadow: 
    0 2px 6px rgba(0, 0, 0, 0.2),
    inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn.ghost:active::before {
  transform: translateZ(-4px);
}

/* Sections */
section {
  padding: 2rem 0;
}

section.games {
  padding: 8rem 0 1rem 0;
  margin-bottom: 0;
}

/* Features */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.feature {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 2.5rem;
  border-radius: 16px;
  transition: transform 0.3s, border-color 0.3s;
  backdrop-filter: blur(10px);
}

.feature:hover {
  transform: translateY(-5px);
  border-color: var(--accent-secondary);
  box-shadow: 0 8px 20px rgba(0, 212, 255, 0.15);
}

.feature .icon {
  font-size: 2.5rem;
  margin-bottom: 1.5rem;
  display: inline-block;
}

/* About */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
}

.card {
  background: var(--bg-panel);
  border: 1px solid var(--glass-border);
  padding: 2.5rem;
  border-radius: 16px;
  backdrop-filter: blur(10px);
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 4px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 16px;
  background: inherit;
  transform: translateZ(-10px);
  filter: brightness(0.5);
  z-index: -1;
}

.card::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 17px;
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.2), transparent, rgba(255, 0, 110, 0.2));
  opacity: 0;
  transition: opacity 0.3s;
  z-index: -1;
}

.card:hover {
  transform: translateY(-4px) translateZ(8px);
  box-shadow: 
    0 16px 48px rgba(0, 0, 0, 0.5),
    0 8px 16px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.card:hover::after {
  opacity: 1;
}

/* Games Area */
.games-area {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
}

/* Games placeholder (lazy load state) */
.games.hidden { display: block; }
.games.hidden .contact-grid { display: none; }
.games.hidden .games-placeholder { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 1rem; padding: 2rem; }
.games-placeholder .loader { font-weight: 700; color: var(--text-muted); }

.game-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.game-card.open {
  grid-column: 1 / -1;
  background: var(--bg-panel);
  border-color: rgba(0, 212, 255, 0.5);
  box-shadow: 0 0 50px rgba(0, 212, 255, 0.15);
}

.game-card.open .game-preview {
  display: none;
}

.game-preview {
  padding: 2rem;
  cursor: pointer;
}

.game-preview:hover .preview-head h3 {
  color: var(--accent-secondary);
  text-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

.game-panel {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 'Second page' feel when games are visible */
.games-page-visible .hero { opacity: 0.18; filter: blur(2px); transform: scale(0.99); transition: opacity 0.4s, filter 0.4s, transform 0.4s; }
.games-page-visible .site-header { opacity: 0.8; }
.games-page-visible #games { z-index: 210; position: fixed; inset: 0; background: rgba(3,3,5,0.9); overflow-y: auto; padding: 6rem 2rem 2rem 2rem; display: block; transform: translateY(0); opacity: 1; }
/* Hide the main page contents to reduce render work while games overlay is visible */
/* (applied to body when games overlay is visible) */
.main-hidden main > :not(#games) { display: none !important; }

#games { transform: translateY(100%); opacity: 0; transition: transform 0.45s cubic-bezier(0.22,1,0.36,1), opacity 0.3s ease; }
#games > h2 { margin-top: 0; padding-top: 0; }
.games-page-visible #games .contact-grid { display: grid; grid-template-columns: 1fr 320px; gap: 2rem; max-width: 90%; margin: 0 auto; }
.close-games { position: fixed; top: 5.5rem; right: 1rem; z-index: 999; }

/* Fullscreen game when an item is opened */
.games-page-visible #games.fullscreen-game .contact-grid { grid-template-columns: 1fr; }
.games-page-visible #games.fullscreen-game .contact-info { display: none; }
.games-page-visible #games.fullscreen-game .games-area { display: block; }
.games-page-visible #games.fullscreen-game .game-card:not(.open) { display: none !important; }
.games-page-visible #games.fullscreen-game .game-card.open { position: absolute; inset: 6rem 2rem 2rem 2rem; margin: 0; width: auto; height: auto; z-index: 2000; }
.games-page-visible #games.fullscreen-game .game-panel { max-height: 100%; height: 100%; overflow: hidden; }
/* Hide the section heading and close-games button when a game is open */
.games-page-visible #games.fullscreen-game > h2 { display: none; }
.games-page-visible #games.fullscreen-game ~ .close-games { display: none; }
body.games-open .close-games { display: none; }

.game-card.open .game-panel {
  max-height: 100%;
  opacity: 1;
  padding: 0 2rem 2rem 2rem;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.game-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--glass-border);
  gap: 1rem;
}

.panel-header h4 {
  margin: 0;
  font-size: 1.1rem;
}

.panel-header .header-hint {
  font-size: 0.85rem;
  font-weight: normal;
  color: var(--text-muted);
  opacity: 0.7;
}

@media (max-width: 768px) {
  .panel-header .header-hint {
    display: none;
  }
}

/* Compact header layout: controls on the right */
.panel-header .header-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: nowrap;
}

/* Make game panels fill available space */
.game-card.open .game-panel {
  max-height: 100%;
  opacity: 1;
  padding: 0 2rem 2rem 2rem;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Game Boards */
/* Game-specific CSS (t3, memory, etc.) moved to assets/games/css/*.css for modularity */

/* RPS & Reaction */
/* RPS & Reaction CSS moved to assets/games/css/ */

/* Reaction target moved to per-game CSS */

/* Snake */
/* Snake styles moved to assets/games/css/snake.css */

/* 2048 */
/* 2048 styling moved to assets/games/css/g2048.css */

/* Typing Test */

.game-instruction {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 1rem;
  opacity: 0.7;
}

/* Footer */
.site-footer {
  padding: 0.3rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  margin-top: 0;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
}

.site-footer .container {
  display: flex;
  justify-content: flex-end; /* align items to the right */
  align-items: center;
  gap: 1rem;
  flex-wrap: nowrap; /* keep everything on one line */
  padding: 0 2rem;
}

.site-footer .left,
.site-footer .right {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.75rem;
  opacity: 0.7;
}

/* For very small screens, shrink font slightly but keep single line behavior */
@media (max-width: 420px) {
  .site-footer .container { gap: 0.5rem; padding: 0 1rem; }
  .site-footer { font-size: 0.7rem; }
  .site-footer .left,
  .site-footer .right {
    font-size: 0.65rem;
  }
}

/* Utilities */
.particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.grid {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 0 1rem;
  }
  
  .hero {
    padding-top: 6rem;
    padding-bottom: 2rem;
  }
  
  .hero h1 {
    font-size: 2.5rem;
  }
  
  .hero-inner {
    padding: 0 1rem;
  }
  
  .cta-row {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .cta-row .btn {
    max-width: none;
    width: 100%;
  }
  
  .feature-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .feature {
    padding: 1.5rem;
  }
  
  .about-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  
  .games-area {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
  }
  
  .game-preview {
    padding: 1.5rem;
  }
  
  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  .panel-header .header-controls {
    width: 100%;
    justify-content: space-between;
  }
  
  /* Games overlay mobile adjustments */
  .games-page-visible #games {
    padding: 4rem 1rem 1rem 1rem;
  }
  
  .games-page-visible #games .contact-grid {
    grid-template-columns: 1fr;
    max-width: 100%;
    gap: 1.5rem;
  }
  
  .games-page-visible #games.fullscreen-game .game-card.open {
    inset: 4rem 1rem 1rem 1rem;
  }
  
  .close-games {
    top: 5.5rem;
    right: 0.75rem;
  }
  
  .games-page-visible #games > h2 {
    margin-top: 3rem;
    padding-top: 1rem;
  }
}

@media (max-width: 480px) {
  .hero {
    padding-top: 5rem;
    padding-bottom: 1.5rem;
  }
  
  .hero h1 {
    font-size: 2rem;
  }
  
  .games-area {
    grid-template-columns: 1fr;
  }
  
  .game-preview {
    padding: 1rem;
  }
  
  .btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
  }
  
  .btn.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
  }
  
  .feature {
    padding: 1.25rem;
  }
  
  .card {
    padding: 1.5rem;
  }
  
  /* Touch-friendly button sizes */
  .game-card .preview-open,
  .game-card .close-panel,
  .close-games {
    min-height: 44px;
    min-width: 44px;
    padding: 0.75rem;
  }
  
  /* Game controls mobile */
  .panel-header .header-controls button {
    min-height: 40px;
    min-width: 40px;
    font-size: 0.9rem;
  }
  
  /* Improve touch scrolling in games overlay */
  .games-page-visible #games {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Better mobile game board sizing */
  .game-content {
    padding: 0.5rem;
  }
}

/* Animations */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.hero-inner { animation: float 6s ease-in-out infinite; }
