:root {
  --tech-cyan: #00f5ff;
  --tech-cyan-dim: #008899;
  --tech-dark: #070c0a;
  --tech-panel: rgba(10, 20, 18, 0.9);
  --tech-green: #39ff14;
  --tech-amber: #ffaa00;
  --tech-magenta: #ff0077;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: monospace, sans-serif;
  color: var(--tech-cyan);
}

#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

canvas#game {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* BOTÓN PANTALLA COMPLETA GLOBAL */
.btn-fullscreen-global {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  background: var(--tech-panel);
  border: 2px solid var(--tech-cyan-dim);
  border-radius: 6px;
  color: var(--tech-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 250;
  pointer-events: auto;
  box-shadow: 0 0 12px rgba(0, 245, 255, 0.35);
  transition: all 0.15s ease;
}

.btn-fullscreen-global:hover {
  background: var(--tech-cyan);
  color: #03080a;
  box-shadow: 0 0 18px var(--tech-cyan);
  transform: scale(1.06);
}

.btn-fullscreen-global svg {
  display: block;
}

/* XP BAR ARRIBA */
#xp-bar-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 6px;
  background: rgba(0, 40, 50, 0.85);
  z-index: 100;
}

#xp-bar-inner {
  height: 100%;
  width: 0%;
  background: var(--tech-cyan);
  box-shadow: 0 0 10px var(--tech-cyan);
  transition: width 0.1s ease-out;
}

/* UI LAYER */
#ui-layer {
  position: absolute;
  top: 8px;
  left: 0;
  width: 100%;
  height: calc(100% - 8px);
  pointer-events: none;
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 90;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: calc(100% - 48px); /* Dejar espacio libre al botón de fullscreen en la esquina */
  gap: 8px;
}

.hud-item {
  background: var(--tech-panel);
  border: 2px solid var(--tech-cyan-dim);
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(0, 245, 255, 0.25);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
}

.btn-hud-icon {
  width: 38px;
  padding: 0;
  cursor: pointer;
  color: var(--tech-cyan);
  pointer-events: auto;
  transition: all 0.15s ease;
}

.btn-hud-icon:hover {
  background: var(--tech-cyan);
  color: #03080a;
  box-shadow: 0 0 14px var(--tech-cyan);
}

.btn-hud-icon svg {
  display: block;
}

.hp-hud-panel {
  width: 220px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hp-bar-outer {
  flex: 1;
  height: 12px;
  background: #031012;
  border: 1px solid var(--tech-cyan-dim);
  position: relative;
  overflow: hidden;
}

.hp-bar-inner {
  height: 100%;
  width: 100%;
  background: var(--tech-green);
  box-shadow: 0 0 8px var(--tech-green);
  transition: width 0.15s ease-out;
}

.hud-center-group {
  display: flex;
  gap: 6px;
}

/* PANTALLA DE TÍTULO */
#title-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(10, 25, 30, 0.95) 0%, rgba(3, 8, 10, 0.98) 100%);
  z-index: 200;
  gap: 20px;
}

.title-logo-box {
  text-align: center;
}

.main-title {
  font-size: clamp(32px, 8vw, 64px);
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--tech-cyan);
  text-shadow: 0 0 20px rgba(0, 245, 255, 0.8), 0 0 40px rgba(0, 245, 255, 0.4);
}

.subtitle {
  font-size: clamp(12px, 3vw, 16px);
  color: #70b0b8;
  letter-spacing: 3px;
  margin-top: 6px;
}

.title-loading-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(84vw, 360px);
}

.title-loading-label {
  font-size: 13px;
  letter-spacing: 1.5px;
  color: var(--tech-cyan);
}

.title-loading-bar-track {
  width: 100%;
  height: 14px;
  background: #020708;
  border: 2px solid var(--tech-cyan);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 0 12px rgba(0, 245, 255, 0.4);
}

.title-loading-bar-fill {
  width: 0%;
  height: 100%;
  background: var(--tech-cyan);
  box-shadow: 0 0 10px var(--tech-cyan);
  transition: width 0.1s ease-out;
}

.btn-start-game {
  background: #041215;
  border: 2px solid var(--tech-cyan);
  color: var(--tech-cyan);
  padding: 14px 34px;
  font-size: clamp(16px, 4vw, 22px);
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(0, 245, 255, 0.4);
  transition: all 0.15s ease;
}

.btn-start-game:hover {
  background: var(--tech-cyan);
  color: #03080a;
  transform: scale(1.05);
}

/* MODALES */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.tech-box {
  background: var(--tech-panel);
  border: 2px solid var(--tech-cyan);
  box-shadow: 0 0 25px rgba(0, 245, 255, 0.35);
  padding: 24px;
  width: min(92vw, 480px);
  text-align: center;
}

.modal-title {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--tech-cyan);
  margin-bottom: 16px;
}

.cards-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upgrade-card {
  background: rgba(0, 30, 35, 0.85);
  border: 1px solid var(--tech-cyan-dim);
  padding: 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.upgrade-card:hover {
  background: rgba(0, 60, 70, 0.95);
  border-color: var(--tech-cyan);
  transform: translateX(4px);
}

.card-title {
  font-weight: 700;
  color: var(--tech-cyan);
  margin-bottom: 4px;
}

.card-desc {
  font-size: 12px;
  color: #a0d8e0;
}

.retro-btn {
  background: #02080a;
  border: 2px solid var(--tech-cyan);
  color: var(--tech-cyan);
  padding: 10px 24px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-top: 16px;
  transition: all 0.15s ease;
}

.retro-btn:hover {
  background: var(--tech-cyan);
  color: #000;
}

/* VIRTUAL JOYSTICK (DINÁMICO EN CUALQUIER PARTE) */
#joystick-zone {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  touch-action: none;
  z-index: 20;
}

#joystick-base {
  position: absolute;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 245, 255, 0.12) 0%, rgba(0, 40, 50, 0.45) 70%, rgba(0, 245, 255, 0.3) 100%);
  border: 2px solid rgba(0, 245, 255, 0.55);
  box-shadow: 0 0 16px rgba(0, 245, 255, 0.3);
  transform: translate(-50%, -50%);
  display: none;
  pointer-events: none;
  z-index: 25;
}

#joystick-stick {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--tech-cyan);
  border: 2px solid #fff;
  box-shadow: 0 0 12px var(--tech-cyan);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: transform 0.04s ease-out;
}

.hidden {
  display: none !important;
}

@media (max-width: 600px) {
  .top-bar {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 6px;
  }
  .hp-hud-panel {
    order: 1;
    width: calc(100% - 46px);
  }
  .btn-hud-icon {
    order: 2;
  }
  .hud-center-group {
    order: 3;
    width: 100%;
    justify-content: space-between;
    display: flex;
    gap: 4px;
  }
  .hud-center-group .hud-item {
    font-size: 11px;
    padding: 0 6px;
    height: 32px;
    flex: 1;
  }
}
