:root {
  --bg: #1a1423;
  --surface: #262035;
  --card-bg: #2e2840;
  --text: #eee8f5;
  --text-dim: #c4bcd8;
  --accent-1: #ff6b35;
  --accent-2: #ffe66d;
  --accent-3: #4ecdc4;
  --radius-btn: 8px;
  --font-main: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

/* ─── HERO ─── */
.hero {
  position: relative;
  height: 42vh;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(175deg, #3a2d6b 0%, #1f1533 60%, #1a1423 100%);
  overflow: hidden;
}

.parallax-layer {
  position: absolute;
  inset: 0;
  will-change: transform;
}

/* Pixel-art stars */
.layer-bg::before, .layer-bg::after {
  content: '';
  position: absolute;
  background-image:
    radial-gradient(1px 1px at 20% 30%, #fff8 50%, transparent 50%),
    radial-gradient(1px 1px at 45% 60%, #fff6 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 70% 20%, #fff9 50%, transparent 50%),
    radial-gradient(1px 1px at 85% 75%, #fff5 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 15% 80%, #fff7 50%, transparent 50%),
    radial-gradient(1px 1px at 55% 40%, #fff6 50%, transparent 50%),
    radial-gradient(2px 2px at 30% 10%, var(--accent-2)cc 50%, transparent 50%),
    radial-gradient(1px 1px at 90% 45%, #fff8 50%, transparent 50%);
  background-size: 400px 300px;
  inset: -20%;
}

.layer-bg::before { opacity: 0.6; }
.layer-bg::after { opacity: 0.3; transform: translate(15%, 10%); }

/* Pixel-art hills */
.layer-mid {
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 200"><path d="M0 200 L0 160 Q180 120 360 150 T720 130 T1080 140 T1440 120 L1440 200Z" fill="%232e2840" opacity="0.5"/></svg>');
  background-size: cover;
  background-repeat: no-repeat;
  background-position: bottom;
}

.layer-fg {
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 150"><path d="M0 150 L0 120 Q200 90 400 110 T800 100 T1200 115 T1440 100 L1440 150Z" fill="%231a1423" opacity="0.7"/></svg>');
  background-size: cover;
  background-repeat: no-repeat;
  background-position: bottom;
}

.title {
  font-size: clamp(1.8rem, 5vw, 3.2rem);
  font-weight: 900;
  color: var(--text);
  text-shadow: 0 0 30px rgba(78, 205, 196, 0.3);
  letter-spacing: -0.02em;
  text-align: center;
  z-index: 1;
}

.subtitle {
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  color: var(--text-dim);
  margin-top: 0.4rem;
  z-index: 1;
}

/* ─── GAMES GRID ─── */
.games-grid {
  max-width: 960px;
  margin: -2rem auto 3rem;
  padding: 0 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
  position: relative;
  z-index: 2;
}

/* ─── GAME CARD ─── */
.game-card {
  background: var(--card-bg);
  border-radius: var(--radius-btn);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.game-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

.card-sprite {
  width: 96px;
  height: 96px;
  image-rendering: pixelated;
  filter: drop-shadow(1px 2px 0 rgba(0, 0, 0, 0.3));
  margin-bottom: 0.75rem;
}

.game-card:hover .card-sprite {
  transform: scale(1.1);
}

.card-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.card-desc {
  font-size: 1rem;
  color: var(--text-dim);
  line-height: 1.45;
  margin-bottom: 0.75rem;
}

.btn-play {
  align-self: center;
  padding: 0.55rem 2rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent-1);
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-play:hover {
  transform: scale(1.06);
  box-shadow: 0 3px 12px rgba(255, 107, 53, 0.4);
}

/* ─── MODAL ─── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden { display: none; }

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-btn);
  padding: 0.75rem;
  position: relative;
}

#gameCanvas {
  image-rendering: pixelated;
  display: block;
  border-radius: 4px;
  touch-action: none;
  cursor: crosshair;
}

.btn-close {
  position: absolute;
  top: -1rem;
  right: -1rem;
  width: 36px;
  height: 36px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 800;
  color: #fff;
  background: var(--accent-1);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.btn-close:hover {
  transform: scale(1.1);
  background: #e55a2d;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 640px) {
  .hero { height: 32vh; min-height: 200px; }
  .games-grid { grid-template-columns: 1fr; margin-top: -1.5rem; gap: 0.5rem; }
}
