:root {
  --bg: #05060a;
  --cyan: #00e5ff;
  --blue: #3fa9ff;
  --pink: #ff2d55;
  --text: #e8f1ff;
  --muted: #8ea0bd;
  --glass: rgba(10, 16, 28, 0.72);
  --line: rgba(120, 200, 255, 0.18);
  --accent: var(--cyan);
  --font-display: "Orbitron", "Segoe UI", sans-serif;
  --font-body: "Rajdhani", "Segoe UI", sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#app, #scene { position: fixed; inset: 0; }
#scene { display: block; width: 100%; height: 100%; touch-action: none; }

/* ================= HUD ================= */
.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
  z-index: 20;
}
.hud.visible { opacity: 1; }

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: clamp(14px, 2.4vw, 32px);
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  display: grid; place-items: center;
  width: 42px; height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 229, 255, 0.06);
  color: var(--cyan);
  font-size: 20px;
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.18), inset 0 0 18px rgba(0, 229, 255, 0.08);
}
.brand strong {
  display: block;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.28em;
}
.brand small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  margin-top: 2px;
}

.hud-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--muted);
}
#fpsLabel { color: rgba(0, 229, 255, 0.75); }

.crosshair {
  position: absolute;
  top: 50%; left: 50%;
  width: 26px; height: 26px;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.crosshair.active { opacity: 1; }
.crosshair::before, .crosshair::after {
  content: "";
  position: absolute;
  background: rgba(190, 240, 255, 0.85);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.9);
}
.crosshair::before { left: 50%; top: 0; width: 1px; height: 100%; transform: translateX(-50%); }
.crosshair::after { top: 50%; left: 0; height: 1px; width: 100%; transform: translateY(-50%); }
.crosshair span {
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(0, 229, 255, 0.65);
  border-radius: 50%;
  background: rgba(0, 229, 255, 0.08);
}

.prompt {
  position: absolute;
  left: 50%; bottom: 21%;
  transform: translate(-50%, 12px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border: 1px solid rgba(0, 229, 255, 0.35);
  border-radius: 999px;
  background: rgba(4, 10, 20, 0.72);
  backdrop-filter: blur(14px);
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #d8f6ff;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 0 30px rgba(0, 229, 255, 0.15);
}
.prompt.visible { opacity: 1; transform: translate(-50%, 0); }
.prompt kbd {
  display: grid; place-items: center;
  min-width: 26px; height: 26px;
  border: 1px solid rgba(0, 229, 255, 0.5);
  border-radius: 7px;
  background: rgba(0, 229, 255, 0.12);
  color: var(--cyan);
  font-family: var(--font-display);
  font-size: 12px;
}

.hud-bottom {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(14px, 2vw, 26px) clamp(14px, 2.4vw, 32px);
}
.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.keys span { display: flex; align-items: center; gap: 7px; }
.keys kbd {
  display: inline-grid; place-items: center;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: #cfe8ff;
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.resume-hint {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(4, 10, 20, 0.6);
  backdrop-filter: blur(10px);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.resume-hint.visible { opacity: 1; transform: none; }

/* ================= JOYSTICK ================= */
.joystick {
  position: absolute;
  left: 22px; bottom: 26px;
  display: none;
  pointer-events: none;
}
.joystick-base {
  position: relative;
  width: 118px; height: 118px;
  border: 1px solid rgba(0, 229, 255, 0.28);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 229, 255, 0.08), rgba(4, 10, 20, 0.55) 70%);
  backdrop-filter: blur(8px);
}
.joystick-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 48px; height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(0, 229, 255, 0.55), rgba(0, 120, 170, 0.25));
  border: 1px solid rgba(0, 229, 255, 0.6);
  box-shadow: 0 0 22px rgba(0, 229, 255, 0.35);
}
body.touch .joystick { display: block; }
body.touch .keys { display: none; }
body.touch .prompt kbd { display: none; }

/* ================= OVERLAYS ================= */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
}

.start-screen {
  overflow: hidden;
  background:
    radial-gradient(900px 600px at 50% 8%, rgba(0, 120, 190, 0.22), transparent 70%),
    radial-gradient(700px 500px at 82% 92%, rgba(255, 45, 85, 0.12), transparent 70%),
    linear-gradient(180deg, #060912 0%, #04060c 60%, #020308 100%);
  transition: opacity 0.7s ease, visibility 0.7s ease;
}
.start-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.start-glow {
  position: absolute;
  width: 120vmin; height: 120vmin;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 229, 255, 0.06), transparent 62%);
  filter: blur(20px);
  animation: pulse 7s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.75; }
  50% { transform: scale(1.08); opacity: 1; }
}

.start-content {
  position: relative;
  width: min(720px, 90vw);
  text-align: center;
  padding: 24px;
}

.eyebrow {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.5em;
  color: rgba(0, 229, 255, 0.8);
  margin-bottom: 18px;
}

.start-content h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(46px, 9vw, 92px);
  line-height: 0.92;
  letter-spacing: 0.06em;
  background: linear-gradient(180deg, #ffffff 10%, #8fd8ff 55%, #2f7fb8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 42px rgba(0, 180, 255, 0.3));
}
.start-content h1 span {
  display: block;
  margin-top: 10px;
  font-size: clamp(11px, 1.8vw, 17px);
  font-weight: 500;
  letter-spacing: 0.62em;
  color: rgba(190, 225, 255, 0.72);
  background: none;
  -webkit-text-fill-color: rgba(190, 225, 255, 0.72);
}

.start-copy {
  max-width: 520px;
  margin: 26px auto 0;
  color: #a9bdd8;
  font-size: 16px;
  line-height: 1.65;
}

.roster {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 28px 0 30px;
}
.roster-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #c9dcf2;
}
.roster-item .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

.btn-primary {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 17px 34px;
  border: 1px solid rgba(0, 229, 255, 0.55);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.16), rgba(0, 120, 190, 0.08));
  color: #eaffff;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease, opacity 0.25s ease;
  box-shadow: 0 0 0 rgba(0, 229, 255, 0);
}
.btn-primary::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 14px;
  background: linear-gradient(90deg, transparent, rgba(0, 229, 255, 0.28), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.btn-primary:not(:disabled):hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.28), rgba(0, 120, 190, 0.12));
  box-shadow: 0 10px 48px rgba(0, 229, 255, 0.22);
}
.btn-primary:not(:disabled):hover::after { opacity: 1; }
.btn-primary:disabled { opacity: 0.45; cursor: wait; letter-spacing: 0.22em; }
.btn-arrow { font-size: 18px; line-height: 1; }

.loading { max-width: 340px; margin: 24px auto 0; }
.loading-bar {
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.loading-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0a7fb0, var(--cyan));
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.7);
  transition: width 0.35s ease;
}
.loading-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 9px;
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}
#loadingPct { color: rgba(0, 229, 255, 0.85); }

.start-foot {
  margin-top: 30px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(140, 165, 195, 0.6);
}
.start-credits {
  position: absolute;
  left: 0; right: 0; bottom: 18px;
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(120, 145, 175, 0.45);
}

/* ================= TARJETA ================= */
.card { z-index: 60; }
.card[hidden] { display: none; }
.card-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 4, 9, 0.72);
  backdrop-filter: blur(10px);
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.card-panel {
  position: relative;
  width: min(520px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  padding: clamp(26px, 4vw, 40px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  background:
    radial-gradient(400px 200px at 100% 0%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%),
    linear-gradient(180deg, rgba(17, 25, 41, 0.96), rgba(8, 12, 21, 0.98));
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  animation: cardIn 0.4s cubic-bezier(0.2, 0.9, 0.25, 1);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.card-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 38px; height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  color: #cfe2f7;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}
.card-close:hover { background: rgba(255, 255, 255, 0.12); transform: rotate(90deg); }

.card-series {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}
.card-name {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(30px, 4.4vw, 44px);
  line-height: 1;
  letter-spacing: 0.01em;
  color: #fff;
}
.card-tagline {
  margin-top: 10px;
  font-size: 17px;
  font-weight: 600;
  color: color-mix(in srgb, var(--accent) 65%, white);
  letter-spacing: 0.04em;
}
.card-desc {
  margin-top: 16px;
  color: #a9bdd8;
  font-size: 15.5px;
  line-height: 1.7;
}

.card-stats { margin-top: 24px; display: grid; gap: 14px; }
.stat-head {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.stat-head b { color: #dff5ff; font-weight: 700; }
.stat-bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.stat-bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 55%, #0a5f80), var(--accent));
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 60%, transparent);
  transition: width 0.8s cubic-bezier(0.2, 0.9, 0.25, 1);
}

.card-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.card-tags span {
  padding: 6px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: #cfe8ff;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 28px;
}
.btn-ghost {
  flex: 1;
  padding: 13px 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: #cfe2f7;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.btn-ghost:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: #fff;
}

/* ================= FATAL ================= */
.fatal[hidden] { display: none; }
.fatal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  gap: 12px;
  text-align: center;
  padding: 24px;
  background: #05060a;
}
.fatal h2 { font-family: var(--font-display); font-size: 22px; }
.fatal p { color: var(--muted); max-width: 420px; }

@media (max-width: 640px) {
  .hud-meta { display: none; }
  .start-copy { font-size: 14.5px; }
  .prompt { bottom: 26%; }
  .hud-bottom { justify-content: center; }
}
