@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Russo+One&family=Exo+2:wght@300;400;600;700;800&display=swap');

/* ===== DESIGN TOKENS ===== */
:root {
  --bg:           #040812;
  --bg2:          #060c18;
  --hud-surface:  rgba(6, 14, 30, 0.88);
  --hud-border:   rgba(0, 200, 255, 0.2);
  --hud-border2:  rgba(0, 200, 255, 0.08);
  --text:         #b0d8ef;
  --text-bright:  #e8f6ff;
  --text-dim:     #2a5570;
  --cyan:         #00c8ff;
  --cyan-dim:     rgba(0,200,255,0.12);
  --teal:         #00ffd0;
  --orange:       #ff6b00;
  --red:          #ff2244;
  --purple:       #9000ff;
  --yellow:       #ffe500;
  --green:        #00ff88;
  --card-bg:      rgba(4, 14, 28, 0.92);
  --scan-line:    rgba(0, 200, 255, 0.03);

  /* Per-category glow */
  --col-accion:     #ff2244;
  --col-aventura:   #00c8ff;
  --col-estrategia: #00ff88;
  --col-deportes:   #ffe500;
  --col-general:    #9000ff;
  --col-app:        #ff6b00;
}

[data-theme="light"] {
  --bg:           #e8f2fa;
  --bg2:          #ddeaf5;
  --hud-surface:  rgba(255,255,255,0.82);
  --hud-border:   rgba(0,120,180,0.2);
  --hud-border2:  rgba(0,120,180,0.08);
  --text:         #1a3a55;
  --text-bright:  #0a1e30;
  --text-dim:     #88aabb;
  --cyan:         #006fa8;
  --cyan-dim:     rgba(0,120,180,0.1);
  --teal:         #007a60;
  --card-bg:      rgba(240,250,255,0.95);
  --scan-line:    rgba(0,100,160,0.025);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Exo 2', system-ui, sans-serif;
  transition: background 0.4s, color 0.4s;
  position: relative;
}

/* ===== CANVAS ===== */
#tetris-bg {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}

/* ===== SCANLINES ===== */
body::before {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 3px,
    var(--scan-line) 3px, var(--scan-line) 4px
  );
  z-index: 1; pointer-events: none;
}

/* ===== GRID OVERLAY ===== */
body::after {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(0,200,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,200,255,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  z-index: 1; pointer-events: none;
}

/* ===== AMBIENT GLOWS ===== */
.glow-orb {
  position: fixed; border-radius: 50%;
  filter: blur(120px); z-index: 0; pointer-events: none;
}
.glow-orb-1 {
  width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(0,200,255,0.12) 0%, transparent 70%);
  top: -250px; left: -200px;
  animation: orb1 14s ease-in-out infinite alternate;
}
.glow-orb-2 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(144,0,255,0.10) 0%, transparent 70%);
  bottom: -200px; right: -150px;
  animation: orb2 11s ease-in-out infinite alternate;
}
@keyframes orb1 { to { transform: translate(80px, 60px) scale(1.2); } }
@keyframes orb2 { to { transform: translate(-60px, -40px) scale(1.15); } }

/* ===== SHELL ===== */
.shell {
  position: relative; z-index: 10;
  display: flex; flex-direction: column;
  height: 100vh;
  padding: 14px 18px 10px;
  max-width: 1400px; margin: 0 auto;
  gap: 12px;
}

/* ===== HUD PANEL MIXIN ===== */
.hud-panel {
  background: var(--hud-surface);
  border: 1px solid var(--hud-border);
  border-radius: 8px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow:
    0 0 0 1px var(--hud-border2),
    0 8px 40px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(0,200,255,0.07);
  position: relative;
}

/* Corner brackets */
.hud-panel::before,
.hud-panel::after {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  border-color: var(--cyan);
  border-style: solid;
  opacity: 0.6;
}
.hud-panel::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; border-radius: 3px 0 0 0; }
.hud-panel::after  { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; border-radius: 0 0 3px 0; }

/* ===== HEADER ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 16px; }

.logo-mark {
  position: relative;
  width: 46px; height: 46px;
  flex-shrink: 0;
}
.logo-mark svg {
  width: 100%; height: 100%;
}
.logo-mark .logo-icon {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  color: var(--cyan);
  filter: drop-shadow(0 0 8px var(--cyan));
  animation: logoSpin 20s linear infinite;
}
@keyframes logoSpin {
  0%,100% { filter: drop-shadow(0 0 8px var(--cyan)); }
  50%      { filter: drop-shadow(0 0 18px var(--cyan)) drop-shadow(0 0 4px #fff); }
}
@keyframes logoSpinRotate {
  from { transform-origin: center; transform: rotate(0deg); }
  to   { transform-origin: center; transform: rotate(360deg); }
}

.title-block { display: flex; flex-direction: column; gap: 3px; }

.app-title {
  font-family: 'Russo One', sans-serif;
  font-size: 20px;
  color: var(--text-bright);
  letter-spacing: 3px;
  text-transform: uppercase;
  line-height: 1;
}
.app-title span {
  background: linear-gradient(90deg, var(--cyan), var(--teal));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

.app-meta {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 2px;
  display: flex; align-items: center; gap: 8px;
}
.app-meta::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: blink 2s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* Header right: data readouts */
.hud-readouts {
  display: flex; align-items: center; gap: 10px;
}

.readout {
  display: flex; flex-direction: column; align-items: flex-end;
  padding: 6px 12px;
  border: 1px solid var(--hud-border);
  border-radius: 6px;
  background: rgba(0,200,255,0.04);
}
.readout-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px; color: var(--text-dim);
  letter-spacing: 1.5px; text-transform: uppercase;
}
.readout-value {
  font-family: 'Share Tech Mono', monospace;
  font-size: 18px; font-weight: 700;
  color: var(--cyan);
  line-height: 1;
  text-shadow: 0 0 12px rgba(0,200,255,0.6);
  transition: all 0.3s;
}

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 6px;
  border: 1px solid var(--hud-border);
  background: rgba(0,200,255,0.05);
  color: var(--text);
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.icon-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: var(--cyan-dim);
  box-shadow: 0 0 18px rgba(0,200,255,0.25), inset 0 0 10px rgba(0,200,255,0.05);
}

/* ===== SEARCH + PILLS ROW ===== */
.nav-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding: 10px 14px;
}

/* Search */
.search-wrap {
  display: flex; align-items: center;
  position: relative;
  min-width: 220px;
}
.search-prefix {
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  color: var(--cyan);
  padding: 0 6px 0 12px;
  white-space: nowrap;
  pointer-events: none;
  position: absolute;
  left: 0;
  opacity: 0.7;
}
.search-input {
  width: 100%;
  padding: 9px 14px 9px 60px;
  background: rgba(0,200,255,0.04);
  border: 1px solid var(--hud-border);
  border-radius: 6px;
  color: var(--text-bright);
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input::placeholder { color: var(--text-dim); }
.search-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(0,200,255,0.1), 0 0 20px rgba(0,200,255,0.08);
}

/* Category pills */
.pills-wrap {
  display: flex; gap: 6px;
  overflow-x: auto; flex: 1;
  scrollbar-width: none;
}
.pills-wrap::-webkit-scrollbar { display: none; }

.pill {
  padding: 7px 14px;
  border-radius: 5px;
  border: 1px solid var(--hud-border);
  background: transparent;
  color: var(--text-dim);
  font-family: 'Exo 2', sans-serif;
  font-size: 12px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  cursor: pointer; white-space: nowrap;
  transition: all 0.2s;
  user-select: none;
  position: relative; overflow: hidden;
}
.pill::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--cyan-dim), transparent);
  opacity: 0; transition: opacity 0.2s;
}
.pill:hover::before { opacity: 1; }
.pill:hover { border-color: rgba(0,200,255,0.4); color: var(--text); }
.pill.active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: var(--cyan-dim);
  box-shadow: 0 0 16px rgba(0,200,255,0.18), inset 0 1px 0 rgba(0,200,255,0.1);
  text-shadow: 0 0 10px rgba(0,200,255,0.5);
}

/* ===== VIEWPORT ===== */
.games-viewport {
  flex: 1; position: relative; overflow: hidden;
}
.games-viewport::before,
.games-viewport::after {
  content: ''; position: absolute;
  top: 0; bottom: 12px;
  width: 60px; z-index: 5; pointer-events: none;
}
.games-viewport::before {
  left: 0;
  background: linear-gradient(90deg, var(--bg), transparent);
}
.games-viewport::after {
  right: 0;
  background: linear-gradient(-90deg, var(--bg), transparent);
}

#gamesContainer {
  display: flex; gap: 14px;
  overflow-x: auto; height: 100%;
  align-items: flex-start;
  padding: 8px 16px 20px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,200,255,0.3) transparent;
}
#gamesContainer::-webkit-scrollbar { height: 3px; }
#gamesContainer::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  border-radius: 10px;
}

/* ===== GAME CARD ===== */
.game-card {
  min-width: 145px; max-width: 145px;
  border-radius: 8px;
  padding: 0;
  flex-shrink: 0;
  text-decoration: none;
  display: flex; flex-direction: column;
  cursor: pointer;
  position: relative; overflow: hidden;
  opacity: 0;
  background: var(--card-bg);
  border: 1px solid rgba(0,200,255,0.15);
  color: var(--text);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.35s cubic-bezier(0.2,1,0.2,1), box-shadow 0.35s, border-color 0.35s;
  --cc: var(--cyan);
}

/* Corner brackets on card */
.game-card::before,
.game-card::after {
  content: '';
  position: absolute;
  width: 8px; height: 8px;
  border-color: var(--cc);
  border-style: solid;
  opacity: 0;
  transition: opacity 0.25s;
  z-index: 4;
}
.game-card::before { top: 4px; left: 4px; border-width: 1.5px 0 0 1.5px; }
.game-card::after  { bottom: 4px; right: 4px; border-width: 0 1.5px 1.5px 0; }
.game-card:hover::before,
.game-card:hover::after { opacity: 1; }

/* Category color variables */
.game-card[data-cat="accion"]    { --cc: var(--col-accion); }
.game-card[data-cat="aventura"]  { --cc: var(--col-aventura); }
.game-card[data-cat="estrategia"]{ --cc: var(--col-estrategia); }
.game-card[data-cat="deportes"]  { --cc: var(--col-deportes); }
.game-card[data-cat="general"]   { --cc: var(--col-general); }
.game-card[data-cat="app"]       { --cc: var(--col-app); }

.game-card:hover:not(.unavailable) {
  transform: translateY(-14px) scale(1.04);
  border-color: var(--cc);
  box-shadow:
    0 24px 60px rgba(0,0,0,0.7),
    0 0 0 1px var(--cc),
    0 0 40px rgba(0,200,255,0.25),
    0 0 40px color-mix(in srgb, var(--cc) 25%, transparent),
    inset 0 0 20px rgba(0,200,255,0.06),
    inset 0 0 20px color-mix(in srgb, var(--cc) 6%, transparent);
  z-index: 20;
}

.game-card:active:not(.unavailable) {
  transform: translateY(-4px) scale(0.97);
}

.game-card.unavailable {
  opacity: 0.25 !important;
  cursor: not-allowed;
  filter: grayscale(1) blur(0.4px);
}

/* Holographic sheen */
.card-sheen {
  position: absolute; inset: 0;
  background: linear-gradient(
    135deg,
    transparent 40%,
    rgba(255,255,255,0.04) 50%,
    transparent 60%
  );
  background-size: 200% 200%;
  background-position: 100% 100%;
  transition: background-position 0.6s ease;
  z-index: 3; pointer-events: none;
}
.game-card:hover .card-sheen { background-position: 0% 0%; }

/* Scan line that sweeps on hover */
.card-scan {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cc), transparent);
  opacity: 0;
  top: 0;
  z-index: 4;
  pointer-events: none;
  transition: opacity 0.1s;
}
.game-card:hover .card-scan {
  opacity: 0.8;
  animation: scanDown 0.5s linear forwards;
}
@keyframes scanDown { from { top: 0; } to { top: 100%; opacity: 0; } }

/* Card top accent bar */
.card-accent {
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--cc), transparent);
  opacity: 0.7;
  flex-shrink: 0;
  transition: opacity 0.3s;
}
.game-card:hover .card-accent { opacity: 1; }

/* Card body */
.card-body {
  display: flex; flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 14px 16px;
  flex: 1;
}

.card-icon-ring {
  width: 68px; height: 68px;
  border-radius: 12px;
  border: 1px solid rgba(0,200,255,0.35);
  border: 1px solid color-mix(in srgb, var(--cc) 35%, transparent);
  background: rgba(0,200,255,0.08);
  background: color-mix(in srgb, var(--cc) 8%, transparent);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  transition: all 0.35s cubic-bezier(0.2,1,0.2,1);
}
.game-card:hover:not(.unavailable) .card-icon-ring {
  background: rgba(0,200,255,0.18);
  background: color-mix(in srgb, var(--cc) 18%, transparent);
  border-color: var(--cc);
  box-shadow: 0 0 30px rgba(0,200,255,0.45);
  box-shadow: 0 0 30px color-mix(in srgb, var(--cc) 45%, transparent);
  transform: scale(1.1) rotateY(8deg);
}

/* Icono real de cada aplicación.
   Si el archivo no existe, el onerror lo retira y aparece el glifo de
   Font Awesome que había antes, así que ninguna casilla queda vacía. */
.card-icon-img {
  width: 100%; height: 100%;
  border-radius: 11px;
  object-fit: cover;
  display: block;
  image-rendering: -webkit-optimize-contrast;
  transition: transform .35s cubic-bezier(0.2,1,0.2,1), filter .3s;
}
.game-card:hover:not(.unavailable) .card-icon-img { transform: scale(1.04); }
.game-card.unavailable .card-icon-img { filter: grayscale(.85) brightness(.55); }
/* con icono propio, el marco se aparta para no competir con él */
.card-icon-ring:has(.card-icon-img) {
  background: transparent;
  border-color: color-mix(in srgb, var(--cc) 22%, transparent);
  overflow: hidden;
  padding: 0;
}

/* Rotating ring */
.card-icon-ring::before {
  content: '';
  position: absolute; inset: -5px;
  border-radius: 16px;
  border: 1px solid rgba(0,200,255,0.20);
  border: 1px solid color-mix(in srgb, var(--cc) 20%, transparent);
  opacity: 0;
  transition: opacity 0.3s;
  animation: ringRotate 4s linear infinite;
}
.game-card:hover .card-icon-ring::before { opacity: 1; }
@keyframes ringRotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.card-icon {
  font-size: 26px;
  color: var(--cc);
  filter: drop-shadow(0 2px 8px rgba(0,200,255,0.5));
  filter: drop-shadow(0 2px 8px color-mix(in srgb, var(--cc) 50%, transparent));
  transition: filter 0.3s, transform 0.3s;
}
.game-card:hover:not(.unavailable) .card-icon {
  filter: drop-shadow(0 0 16px var(--cc)) brightness(1.2);
  transform: scale(1.1);
}

.card-name {
  font-size: 13px; font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-bright);
  text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%; padding: 0 4px;
  line-height: 1.2;
}

.card-cat {
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 2px;
  color: var(--cc); opacity: 0.7;
}

/* Card footer / status bar */
.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 10px;
  border-top: 1px solid rgba(0,200,255,0.07);
  background: rgba(0,0,0,0.15);
}
.card-status {
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px; letter-spacing: 1px;
  color: var(--green); text-transform: uppercase;
}
.card-status.offline { color: var(--red); opacity: 0.7; }

.badge-js {
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px;
  padding: 2px 5px;
  border: 1px solid rgba(255,230,0,0.35);
  border-radius: 3px;
  background: rgba(255,230,0,0.08);
  color: var(--yellow);
  letter-spacing: 0.5px;
}

/* Unavailable ribbon */
.badge-coming {
  position: absolute;
  top: 14px; right: -26px;
  background: linear-gradient(135deg, var(--red), #880020);
  color: white;
  font-family: 'Share Tech Mono', monospace;
  font-size: 8px; letter-spacing: 1px;
  padding: 3px 28px;
  transform: rotate(35deg);
  opacity: 0.8;
  z-index: 5;
  text-transform: uppercase;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; padding: 80px 40px;
  width: 350px; text-align: center;
}
.empty-state .empty-icon {
  font-size: 48px; color: var(--text-dim);
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}
.empty-state p {
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px; color: var(--text-dim);
  letter-spacing: 1px; line-height: 1.8;
}

/* ===== STATUS BAR / FOOTER ===== */
.status-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 14px;
  flex-shrink: 0;
}
.status-left, .status-right {
  display: flex; align-items: center; gap: 16px;
}
.status-item {
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text-dim);
  display: flex; align-items: center; gap: 5px;
}
.status-item i { font-size: 8px; }
.status-item .live { color: var(--green); }

.author-credit {
  color: var(--cyan) !important;
  opacity: 0.75;
  letter-spacing: 2px;
  transition: opacity 0.3s;
}
.author-credit:hover { opacity: 1; }

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== MOBILE ===== */
@media (max-width: 640px) {
  .shell { padding: 10px 10px 6px; gap: 8px; }
  .header { padding: 8px 12px; }
  .app-title { font-size: 16px; letter-spacing: 2px; }
  .app-meta { font-size: 9px; }
  .logo-mark { width: 38px; height: 38px; }
  .hud-readouts .readout { display: none; }
  .nav-row { padding: 8px 10px; flex-direction: column; gap: 8px; }
  .search-wrap { width: 100%; }
  .pills-wrap { width: 100%; }
  .pill { padding: 6px 11px; font-size: 11px; }
  .game-card { min-width: 122px; max-width: 122px; }
  .card-icon-ring { width: 56px; height: 56px; }
  .card-icon { font-size: 22px; }
  .card-name { font-size: 12px; }
  .card-body { gap: 8px; padding: 16px 10px 12px; }
  .status-bar { padding: 4px 10px; }
  .status-right { display: none; }
}
