/* ═══════════════════════════════════════════════════════════════
   GBA Online — Stylesheet
   Aesthetic: retro-futuristic dark arcade
═══════════════════════════════════════════════════════════════ */

:root {
  --bg: #0a0b0f;
  --bg2: #11131a;
  --bg3: #1a1d27;
  --border: #2a2d3a;
  --accent: #7c3aed;
  --accent2: #a855f7;
  --glow: #7c3aed66;
  --green: #22d3a0;
  --red: #f43f5e;
  --yellow: #fbbf24;
  --text: #e2e4f0;
  --text-muted: #6b7280;
  --radius: 12px;
  --font-pixel: 'Press Start 2P', monospace;
  --font-body: 'Rajdhani', sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Overlays ─────────────────────────────── */
.scanlines {
  pointer-events: none;
  position: fixed; inset: 0; z-index: 9999;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    rgba(0,0,0,.08) 2px, rgba(0,0,0,.08) 4px
  );
}
.noise {
  pointer-events: none;
  position: fixed; inset: 0; z-index: 9998; opacity: .025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── Pages ────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* ── Navbar ───────────────────────────────── */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(10,11,15,.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.logo { font-family: var(--font-pixel); font-size: .85rem; cursor: default; }
.logo-gba { color: var(--accent2); }
.logo-online { color: var(--green); margin-left: 4px; }

.nav-links { display: flex; align-items: center; gap: 1rem; }
.nav-links a {
  color: var(--text-muted); text-decoration: none; font-weight: 600;
  transition: color .2s;
}
.nav-links a:hover { color: var(--text); }

.btn-nav {
  background: transparent; border: 1px solid var(--border);
  color: var(--text); padding: .45rem 1rem;
  border-radius: 8px; cursor: pointer; font-family: var(--font-body);
  font-weight: 600; font-size: .9rem; transition: all .2s;
}
.btn-nav:hover { border-color: var(--accent2); color: var(--accent2); }
.btn-nav--primary {
  background: var(--accent); border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 16px var(--glow);
}
.btn-nav--primary:hover { background: var(--accent2); }

/* ── Hero ─────────────────────────────────── */
.hero {
  min-height: 100vh; padding-top: 72px;
  display: flex; align-items: center; justify-content: center;
  gap: 4rem; padding: 100px 3rem 4rem;
  position: relative; overflow: hidden;
}
.hero-bg {
  position: absolute; inset: 0; pointer-events: none;
}
.pixel-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(124,58,237,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124,58,237,.08) 1px, transparent 1px);
  background-size: 40px 40px;
}
.glow-orb {
  position: absolute; border-radius: 50%;
  filter: blur(80px); opacity: .3; animation: float 8s ease-in-out infinite;
}
.glow-orb--1 { width: 400px; height: 400px; background: var(--accent); top: -100px; left: -100px; }
.glow-orb--2 { width: 300px; height: 300px; background: var(--green); bottom: -50px; right: 20%; animation-delay: -3s; }
.glow-orb--3 { width: 200px; height: 200px; background: var(--accent2); top: 40%; right: -50px; animation-delay: -6s; }

@keyframes float {
  0%,100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-30px) scale(1.05); }
}

.hero-content { position: relative; z-index: 1; max-width: 560px; }

.badge-chip {
  display: inline-block;
  background: rgba(124,58,237,.2); border: 1px solid rgba(124,58,237,.4);
  color: var(--accent2); padding: .4rem 1rem; border-radius: 999px;
  font-size: .8rem; font-weight: 700; letter-spacing: .05em;
  margin-bottom: 1.5rem;
  animation: fadeUp .6s ease both;
}

.hero-title {
  font-family: var(--font-pixel); font-size: clamp(1.1rem, 2.5vw, 1.6rem);
  line-height: 1.7; margin-bottom: 1.2rem;
  animation: fadeUp .6s ease .1s both;
}
.hero-accent { color: var(--accent2); }

.hero-sub {
  color: var(--text-muted); font-size: 1.1rem; margin-bottom: 2rem;
  animation: fadeUp .6s ease .2s both;
}

.hero-cta { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 2.5rem;
  animation: fadeUp .6s ease .3s both;
}
.btn-hero {
  padding: .8rem 1.8rem; border-radius: 10px;
  font-family: var(--font-body); font-weight: 700; font-size: 1rem;
  cursor: pointer; transition: all .2s;
  background: var(--accent); border: none; color: #fff;
  box-shadow: 0 0 24px var(--glow);
}
.btn-hero:hover { transform: translateY(-2px); background: var(--accent2); }
.btn-hero--ghost {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  box-shadow: none;
}
.btn-hero--ghost:hover { border-color: var(--accent2); color: var(--accent2); }

.hero-stats {
  display: flex; gap: 2rem;
  animation: fadeUp .6s ease .4s both;
}
.stat { display: flex; flex-direction: column; }
.stat-n { font-family: var(--font-pixel); font-size: .9rem; color: var(--green); }
.stat-l { font-size: .75rem; color: var(--text-muted); margin-top: .2rem; }

/* ── GBA Device illustration ──────────────── */
.hero-device { position: relative; z-index: 1; animation: fadeUp .8s ease .2s both; }

.gba-device {
  width: 260px; height: 360px;
  background: linear-gradient(145deg, #1a1d27, #0f1118);
  border-radius: 24px 24px 60px 60px;
  border: 2px solid #2a2d3a;
  box-shadow: 0 0 60px rgba(124,58,237,.3), inset 0 1px 0 rgba(255,255,255,.05);
  padding: 1.5rem;
  display: flex; flex-direction: column; align-items: center;
  position: relative;
}
.gba-screen-wrap {
  width: 200px; height: 140px;
  background: #000; border-radius: 8px;
  border: 3px solid #222;
  box-shadow: inset 0 0 20px rgba(0,0,0,.8), 0 0 20px rgba(34,211,160,.2);
  overflow: hidden; margin-bottom: 1.2rem;
}
.gba-screen { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
#hero-canvas { image-rendering: pixelated; width: 100%; height: 100%; }

.gba-controls { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 0 .5rem; }
.gba-dpad { width: 70px; height: 70px; position: relative; }
.dp-v, .dp-h {
  position: absolute; background: #1f2230; border-radius: 4px;
  border: 1px solid #2a2d3a;
}
.dp-v { width: 24px; height: 70px; left: 23px; top: 0; }
.dp-h { width: 70px; height: 24px; left: 0; top: 23px; }
.dp-center {
  position: absolute; width: 24px; height: 24px;
  background: #2a2d3a; border-radius: 50%; left: 23px; top: 23px; z-index: 1;
}
.gba-btns { display: flex; gap: 8px; }
.gba-btn {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-pixel); font-size: .4rem;
  font-weight: bold; cursor: default;
}
.btn-a { background: #7c3aed; color: #fff; box-shadow: 0 0 10px #7c3aed88; }
.btn-b { background: #1f2230; color: var(--text-muted); border: 1px solid var(--border); }

.gba-shoulder {
  position: absolute; top: -2px; left: 0; right: 0;
  display: flex; justify-content: space-between;
}
.gba-sh {
  background: #1a1d27; border: 2px solid var(--border);
  padding: .2rem .6rem; font-size: .65rem; color: var(--text-muted);
  border-radius: 8px 8px 0 0;
}

/* ── Features ─────────────────────────────── */
.features {
  padding: 5rem 3rem;
  background: linear-gradient(to bottom, var(--bg), var(--bg2));
}
.section-title {
  font-family: var(--font-pixel); font-size: 1rem;
  text-align: center; margin-bottom: 3rem;
  color: var(--accent2);
}
.features-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem; max-width: 1000px; margin: 0 auto;
}
.feat-card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.8rem;
  transition: border-color .2s, transform .2s;
}
.feat-card:hover { border-color: var(--accent2); transform: translateY(-4px); }
.feat-icon { font-size: 2rem; margin-bottom: .8rem; }
.feat-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: .5rem; color: var(--text); }
.feat-card p { font-size: .95rem; color: var(--text-muted); line-height: 1.6; }

/* ── Footer ───────────────────────────────── */
.footer {
  background: var(--bg); border-top: 1px solid var(--border);
  padding: 2rem; text-align: center;
}
.footer-logo { font-family: var(--font-pixel); font-size: .7rem; margin-bottom: .5rem; }
.footer-note { color: var(--text-muted); font-size: .85rem; }

/* ── Modal ────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.75); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px; padding: 2.5rem; width: 90%; max-width: 420px;
  position: relative;
  box-shadow: 0 0 60px rgba(124,58,237,.25);
  transform: translateY(20px); transition: transform .25s;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-close {
  position: absolute; top: 1rem; right: 1rem;
  background: transparent; border: none; color: var(--text-muted);
  font-size: 1.1rem; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal-panel { display: none; }
.modal-panel.active { display: block; }

.modal-header { text-align: center; margin-bottom: 1.8rem; }
.modal-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.modal-header h2 { font-size: 1.5rem; font-weight: 700; }
.modal-header p { color: var(--text-muted); font-size: .9rem; margin-top: .3rem; }

.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; color: var(--text-muted); margin-bottom: .4rem; }
.form-group input {
  width: 100%; padding: .7rem 1rem;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-family: var(--font-body); font-size: 1rem;
  outline: none; transition: border-color .2s;
}
.form-group input:focus { border-color: var(--accent2); }

.form-error { color: var(--red); font-size: .85rem; margin-bottom: .8rem; min-height: 1.2em; }

.btn-submit {
  width: 100%; padding: .85rem;
  background: var(--accent); border: none; color: #fff;
  border-radius: 10px; font-family: var(--font-body); font-weight: 700; font-size: 1.05rem;
  cursor: pointer; transition: background .2s, transform .2s;
  box-shadow: 0 0 20px var(--glow);
}
.btn-submit:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-submit:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.modal-switch { text-align: center; font-size: .88rem; color: var(--text-muted); margin-top: 1.2rem; }
.modal-switch a { color: var(--accent2); cursor: pointer; }

/* ── App Layout ───────────────────────────── */
.app-nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 1.5rem;
  background: rgba(10,11,15,.95); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.app-nav-right { display: flex; align-items: center; gap: 1rem; }
.user-chip {
  font-size: .85rem; font-weight: 600; color: var(--green);
  background: rgba(34,211,160,.1); border: 1px solid rgba(34,211,160,.3);
  padding: .3rem .8rem; border-radius: 999px;
}

.app-layout {
  display: flex; min-height: calc(100vh - 56px);
}

/* ── Sidebar ──────────────────────────────── */
.sidebar {
  width: 280px; min-width: 240px;
  background: var(--bg2); border-right: 1px solid var(--border);
  padding: 1.5rem; overflow-y: auto;
}
.sidebar-title { font-size: .85rem; font-weight: 700; color: var(--text-muted); margin-bottom: 1rem; letter-spacing: .08em; text-transform: uppercase; }

.rom-list { display: flex; flex-direction: column; gap: .5rem; }
.rom-loading { color: var(--text-muted); font-size: .9rem; }
.rom-item {
  display: flex; align-items: center; gap: .8rem;
  padding: .7rem .9rem; border-radius: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  cursor: pointer; transition: all .15s;
}
.rom-item:hover, .rom-item.active { border-color: var(--accent2); background: rgba(124,58,237,.15); }
.rom-item-icon { font-size: 1.4rem; flex-shrink: 0; }
.rom-item-info { overflow: hidden; }
.rom-item-name { font-size: .9rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rom-item-size { font-size: .75rem; color: var(--text-muted); }

/* ── Emulator Main ────────────────────────── */
.emu-main { flex: 1; padding: 1.5rem; display: flex; flex-direction: column; align-items: center; }

.emu-empty { text-align: center; margin: auto; padding: 3rem; }
.emu-empty-icon { font-size: 4rem; margin-bottom: 1rem; opacity: .5; }
.emu-empty h2 { font-size: 1.4rem; margin-bottom: .5rem; }
.emu-empty p { color: var(--text-muted); }
.emu-tip { margin-top: .5rem; font-size: .85rem; }
.emu-tip code { background: var(--bg3); padding: .1rem .4rem; border-radius: 4px; color: var(--green); }

.emu-container { width: 100%; max-width: 720px; }

.emu-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .8rem; flex-wrap: wrap; gap: .5rem;
}
.emu-rom-name { font-family: var(--font-pixel); font-size: .7rem; color: var(--accent2); }
.emu-controls-bar { display: flex; gap: .5rem; flex-wrap: wrap; }
.emu-btn {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); padding: .4rem .8rem; border-radius: 6px;
  cursor: pointer; font-family: var(--font-body); font-size: .85rem;
  transition: all .15s;
}
.emu-btn:hover { border-color: var(--accent2); color: var(--accent2); }

.emu-screen-wrap {
  position: relative; background: #000;
  border: 2px solid var(--border); border-radius: 8px;
  overflow: hidden; aspect-ratio: 3/2;
  box-shadow: 0 0 40px rgba(0,0,0,.5);
}
.emu-canvas {
  width: 100%; height: 100%;
  display: block; image-rendering: pixelated;
}
.emu-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
}
.emu-loading-text {
  font-family: var(--font-pixel); font-size: .7rem; color: var(--accent2);
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ── Virtual Pad ──────────────────────────── */
.vpad {
  display: none; /* hidden on desktop */
  justify-content: space-between; align-items: center;
  padding: 1rem 0; gap: 1rem;
  margin-top: .8rem;
}
@media (max-width: 700px) { .vpad { display: flex; } }

.vd {
  min-width: 44px; min-height: 44px;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; font-size: .85rem;
  cursor: pointer; user-select: none; display: flex;
  align-items: center; justify-content: center;
}
.vd:active { background: var(--accent); border-color: var(--accent); }

.vpad-dpad { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.vd-row { display: flex; align-items: center; gap: 2px; }
.vd-center { width: 28px; height: 28px; }
.vpad-mid { display: flex; flex-direction: column; gap: .4rem; }
.vd-sm { font-size: .65rem; padding: .3rem .5rem; min-width: 40px; min-height: 30px; }
.vpad-ab { display: flex; gap: .5rem; justify-content: flex-end; margin-bottom: .4rem; }
.vd-a { background: rgba(124,58,237,.4); border-color: var(--accent); }
.vd-b { background: rgba(244,63,94,.2); border-color: var(--red); }
.vpad-lr { display: flex; gap: .5rem; }
.vd-l, .vd-r { font-size: .7rem; }

/* ── Save Panel ───────────────────────────── */
.save-panel {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.2rem; margin-top: 1rem;
}
.save-panel h4 { margin-bottom: .8rem; font-size: .9rem; }
.save-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: .8rem; }
.save-slot {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: .7rem;
  text-align: center; font-size: .8rem; cursor: pointer;
  transition: border-color .15s;
}
.save-slot:hover { border-color: var(--accent2); }
.save-slot.has-save { border-color: var(--green); color: var(--green); }
.save-slot .slot-label { font-weight: 700; }
.save-slot .slot-date { font-size: .65rem; color: var(--text-muted); }

/* ── Keymap Modal ─────────────────────────── */
.keymap-modal {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,.8); display: flex;
  align-items: center; justify-content: center;
}
.keymap-inner {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; padding: 2rem; min-width: 280px;
}
.keymap-inner h3 { margin-bottom: 1rem; font-size: 1rem; }
.keymap-table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.keymap-table th, .keymap-table td { padding: .5rem .8rem; text-align: left; font-size: .9rem; border-bottom: 1px solid var(--border); }
.keymap-table th { color: var(--text-muted); font-size: .75rem; text-transform: uppercase; }
kbd {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 4px; padding: .1rem .4rem; font-size: .8rem;
}

/* ── Animations ───────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ───────────────────────────── */
@media (max-width: 900px) {
  .hero { flex-direction: column; text-align: center; gap: 2rem; padding-top: 80px; }
  .hero-stats { justify-content: center; }
  .hero-cta { justify-content: center; }
  .hero-device { transform: scale(.85); }
}
@media (max-width: 600px) {
  .sidebar { width: 100%; min-width: unset; }
  .app-layout { flex-direction: column; }
  .navbar, .app-nav { padding: .8rem 1rem; }
  .nav-links { gap: .5rem; }
  .btn-nav { padding: .4rem .7rem; font-size: .8rem; }
}
