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

:root {
  --bg:        #0e0e12;
  --bg2:       #16161c;
  --bg3:       #1e1e26;
  --border:    #2a2a36;
  --text:      #e0e0ee;
  --muted:     #7070a0;
  --accent:    #66c0f4;
  --accent2:   #4a90d9;
  --danger:    #e74c3c;
  --success:   #2ecc71;
  --radius:    10px;
  --radius-lg: 16px;
  --font-head: 'Rajdhani', sans-serif;
  --font-body: 'Inter', sans-serif;
  --transition: 0.18s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Navbar ── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 52px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.navbar-brand {
  font-family: var(--font-head);
  font-size: 20px; font-weight: 700;
  color: var(--accent); letter-spacing: 1px;
  text-decoration: none;
}
.navbar-nav { display: flex; align-items: center; gap: 8px; }
.nav-link {
  padding: 6px 14px; border-radius: var(--radius);
  color: var(--muted); font-size: 13px; font-weight: 500;
  text-decoration: none; transition: var(--transition);
  border: 1px solid transparent;
}
.nav-link:hover, .nav-link.active {
  color: var(--text); background: var(--bg3); border-color: var(--border);
}
.nav-badge {
  font-size: 11px; padding: 3px 10px; border-radius: 20px;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--muted);
}

/* ── Botões ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 20px; border-radius: var(--radius);
  font-family: var(--font-body); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: var(--transition);
  border: 1px solid transparent; text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent); color: #0e0e12; border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent2); border-color: var(--accent2); }
.btn-secondary {
  background: var(--bg3); color: var(--text); border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger {
  background: transparent; color: var(--danger); border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Inputs ── */
.input {
  width: 100%; padding: 9px 14px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-family: var(--font-body); font-size: 14px;
  transition: var(--transition); outline: none;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--muted); }

/* ── Cards ── */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  font-family: var(--font-head); font-size: 16px; font-weight: 600;
  color: var(--text);
}
.card-body { padding: 20px; }

/* ── Game Grid ── */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
}
.game-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  cursor: pointer; transition: var(--transition);
  text-align: left;
}
.game-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(102,192,244,0.12);
}
.game-card-thumb {
  aspect-ratio: 3/4; background: var(--bg3);
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.game-card-thumb img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}
.game-card-thumb .no-thumb {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; padding: 12px; width: 100%; height: 100%;
  color: var(--muted); font-size: 12px; text-align: center;
}
.game-card-thumb .no-thumb span:first-child { font-size: 36px; }
.sys-badge {
  position: absolute; top: 6px; left: 6px;
  font-size: 10px; font-weight: 700; padding: 2px 8px;
  border-radius: 4px; letter-spacing: 0.5px;
}
.game-card-info { padding: 10px 12px; }
.game-card-name {
  font-size: 12px; font-weight: 500; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
  line-height: 1.4;
}

/* Sistema badges */
.sys-snes  { background: #4a1a8a; color: #c8a0ff; }
.sys-n64   { background: #8a1a1a; color: #ffaaaa; }
.sys-ps1, .sys-psx { background: #1a3a8a; color: #aaccff; }
.sys-gba   { background: #8a5a1a; color: #ffdaaa; }
.sys-gbc   { background: #1a6a3a; color: #aaffcc; }
.sys-gb    { background: #3a3a4a; color: #ccccdd; }
.sys-megadrive, .sys-genesis, .sys-md { background: #1a6a6a; color: #aaffff; }
.sys-nes   { background: #7a1a2a; color: #ffaacc; }

/* ── Filtros ── */
.filters {
  position: sticky; top: 52px; z-index: 90;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.search-wrap { position: relative; flex: 1; min-width: 200px; }
.search-wrap::before {
  content: '🔍'; position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%); font-size: 13px; pointer-events: none;
}
.search-wrap .input { padding-left: 34px; }
.sys-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.sys-btn {
  padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: var(--transition);
  background: var(--bg3); border: 1px solid var(--border); color: var(--muted);
}
.sys-btn:hover { color: var(--text); border-color: var(--accent); }
.sys-btn.active { background: var(--accent); color: #0e0e12; border-color: var(--accent); }

/* ── Paginação ── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: 32px 0;
}
.page-info { color: var(--muted); font-size: 13px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.8); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 100%; max-width: 480px;
  overflow: hidden;
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-title { font-family: var(--font-head); font-size: 18px; font-weight: 600; }
.modal-close {
  background: none; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer; padding: 4px;
  transition: var(--transition);
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 16px 20px; border-top: 1px solid var(--border);
}

/* ── Toast ── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); min-width: 240px;
  animation: toastIn 0.2s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Login ── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #1a2a3a 0%, var(--bg) 70%);
}
.login-box {
  width: 100%; max-width: 380px; padding: 20px;
}
.login-logo {
  text-align: center; margin-bottom: 32px;
}
.login-logo h1 {
  font-family: var(--font-head); font-size: 36px; font-weight: 700;
  color: var(--accent); letter-spacing: 2px;
}
.login-logo p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 500; color: var(--muted); }

/* ── Player ── */
.player-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 48px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
}
.player-info { display: flex; align-items: center; gap: 12px; }
.player-title { font-family: var(--font-head); font-size: 16px; font-weight: 600; }
.player-sys { font-size: 11px; color: var(--muted); }
.player-actions { display: flex; gap: 8px; }
#emulator-container {
  width: 100%; background: #000; display: block;
}
.fs-btns {
  position: fixed; top: 12px; right: 12px; z-index: 9999;
  display: flex; gap: 8px;
  opacity: 0; transition: opacity 0.4s ease;
  pointer-events: none;
}
.fs-btns.visible { opacity: 1; pointer-events: auto; }
.fs-btn {
  background: rgba(0,0,0,0.75); color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px; padding: 8px 14px;
  font-size: 16px; cursor: pointer; backdrop-filter: blur(4px);
}

/* ── Game Menu (player) ── */
.game-menu-overlay {
  position: absolute; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.game-menu {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 320px; overflow: hidden;
  animation: modalIn 0.15s ease;
}
.game-menu-header {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.game-menu-header .title { font-family: var(--font-head); font-size: 16px; }
.game-menu-item {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 18px; cursor: pointer;
  transition: var(--transition); border: none;
  background: none; color: var(--text); width: 100%;
  font-family: var(--font-body); font-size: 14px; text-align: left;
  border-left: 3px solid transparent;
}
.game-menu-item:hover, .game-menu-item.selected {
  background: var(--bg3); border-left-color: var(--accent); color: var(--accent);
}
.game-menu-hint {
  padding: 10px 18px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--muted); text-align: center;
}

/* ── Admin ── */
.admin-layout {
  display: grid; grid-template-columns: 200px 1fr;
  min-height: calc(100vh - 52px);
}
.admin-sidebar {
  background: var(--bg2); border-right: 1px solid var(--border);
  padding: 20px 0;
}
.admin-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; cursor: pointer;
  transition: var(--transition); color: var(--muted);
  font-size: 13px; font-weight: 500; border: none;
  background: none; width: 100%; text-align: left;
  border-left: 3px solid transparent;
}
.admin-nav-item:hover { color: var(--text); background: var(--bg3); }
.admin-nav-item.active { color: var(--accent); border-left-color: var(--accent); background: var(--bg3); }
.admin-content { padding: 24px; overflow-y: auto; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  text-align: left; padding: 10px 14px; font-size: 11px;
  font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.8px; border-bottom: 1px solid var(--border);
}
.admin-table td {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-size: 13px; vertical-align: middle;
}
.admin-table tr:hover td { background: var(--bg3); }
.thumb-preview { width: 32px; height: 42px; object-fit: cover; border-radius: 4px; }

/* ── RetroVision ── */
#retrovision {
  position: fixed; inset: 0; background: #0a0a0f;
  overflow: hidden; user-select: none;
}
.rv-bg {
  position: absolute; inset: 0; pointer-events: none;
  transition: background 0.7s ease;
}
.rv-systems {
  position: relative; z-index: 10;
  display: flex; justify-content: center; align-items: flex-end;
  gap: 4px; padding: 20px 16px 8px; flex-wrap: wrap;
}
.rv-sys-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 12px; border-radius: 12px; cursor: pointer;
  border: 1px solid transparent; background: none;
  transition: all 0.2s ease;
}
.rv-sys-btn.active {
  border-color: currentColor;
  filter: brightness(1.2);
}
.rv-sys-emoji { font-size: 20px; transition: font-size 0.2s; }
.rv-sys-btn.active .rv-sys-emoji { font-size: 24px; }
.rv-sys-label { font-size: 9px; font-weight: 700; white-space: nowrap; color: rgba(255,255,255,0.5); }
.rv-sys-btn.active .rv-sys-label { color: #fff; }

.rv-carousel {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  height: calc(100vh - 210px);
  perspective: 1200px;
}
.rv-cards-wrap {
  position: relative; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.rv-card {
  position: absolute; cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34,1.2,0.64,1), opacity 0.3s ease;
  transform-style: preserve-3d;
}
.rv-card-inner {
  border-radius: 14px; overflow: hidden; background: #111;
  transition: all 0.3s ease;
}
.rv-card-inner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rv-card-placeholder {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; padding: 12px;
}
.rv-card-placeholder span:first-child { font-size: 36px; }
.rv-card-placeholder span:last-child {
  color: #fff; font-size: 11px; text-align: center;
  font-weight: 600; line-height: 1.3;
}

.rv-info {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 20;
  background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, transparent 100%);
  padding: 50px 0 20px; text-align: center;
}
.rv-game-title {
  font-family: var(--font-head); font-size: 26px; font-weight: 700;
  color: #fff; margin-bottom: 4px;
}
.rv-game-sub { color: rgba(255,255,255,0.5); font-size: 12px; margin-bottom: 14px; }
.rv-play-btn {
  padding: 11px 28px; border: none; border-radius: 10px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  font-family: var(--font-body);
}
.rv-hint { color: rgba(255,255,255,0.2); font-size: 10px; margin-top: 8px; }

.rv-menu-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
}
.rv-menu {
  background: #0f0f18; border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px; overflow: hidden; width: 260px;
}
.rv-menu-header { padding: 16px 20px 8px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.rv-menu-title { font-family: var(--font-head); font-size: 16px; color: #fff; font-weight: 700; }
.rv-menu-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px; border: none; cursor: pointer; width: 100%;
  background: none; color: rgba(255,255,255,0.6); font-size: 14px; text-align: left;
  border-left: 3px solid transparent; transition: all 0.15s;
  font-family: var(--font-body);
}
.rv-menu-item.selected, .rv-menu-item:hover {
  background: rgba(255,255,255,0.05); color: #fff;
}
.rv-menu-hint {
  padding: 8px 20px; border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 10px; color: rgba(255,255,255,0.25); text-align: center;
}

.rv-confirm {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(8px);
}
.rv-confirm-box {
  background: #0f0f18; border-radius: 16px; padding: 28px 40px;
  text-align: center; border: 1px solid;
}
.rv-confirm-title { color: #fff; font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.rv-confirm-sub { color: rgba(255,255,255,0.5); font-size: 12px; margin-bottom: 20px; }
.rv-confirm-btns { display: flex; gap: 12px; justify-content: center; }

/* ── Launch animation ── */
.launch-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0); animation: launchBg 0.7s forwards;
}
.launch-card { border-radius: 16px; overflow: hidden; animation: launchCard 0.7s forwards; }
@keyframes launchBg  { to { background: rgba(0,0,0,0.98); } }
@keyframes launchCard { to { transform: scale(1.2); opacity: 0; } }

/* ── Intro RetroVision ── */
.rv-intro {
  position: fixed; inset: 0; background: #000; z-index: 300;
  display: flex; align-items: center; justify-content: center;
}
.rv-intro-content { text-align: center; animation: rvIntroIn 0.7s cubic-bezier(0.34,1.56,0.64,1) 0.2s both; }
.rv-intro-logo { font-size: 64px; margin-bottom: 12px; }
.rv-intro-title {
  font-family: var(--font-head); font-size: 40px; font-weight: 800;
  color: #fff; letter-spacing: 8px; text-transform: uppercase;
  text-shadow: 0 0 40px rgba(102,192,244,0.8);
}
.rv-intro-line {
  height: 2px; margin: 10px auto;
  background: linear-gradient(to right, transparent, #66c0f4, transparent);
  animation: rvLine 0.8s ease 0.7s both; transform: scaleX(0);
}
.rv-intro-sub {
  font-size: 11px; letter-spacing: 6px; text-transform: uppercase;
  color: #66c0f4; opacity: 0; animation: rvFade 0.5s ease 1.1s forwards;
}
@keyframes rvIntroIn { from{opacity:0;transform:scale(0.85)} to{opacity:1;transform:scale(1)} }
@keyframes rvLine    { from{transform:scaleX(0)} to{transform:scaleX(1)} }
@keyframes rvFade    { from{opacity:0} to{opacity:1} }

/* ── Utilities ── */
.hidden { display: none !important; }
.loading { opacity: 0.5; pointer-events: none; }
.skeleton { background: var(--bg3); border-radius: var(--radius); animation: pulse 1.5s ease infinite; }
@keyframes pulse { 0%,100%{opacity:0.5} 50%{opacity:0.8} }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-3 { margin-bottom: 12px; }
.text-muted { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-sm { font-size: 12px; }
.font-head { font-family: var(--font-head); }
.container { max-width: 1280px; margin: 0 auto; padding: 24px; }
