/* ============================================
   NEBULA · Estilos principales
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a1a;
  font-family: 'SF Mono', 'Fira Code', Consolas, 'Courier New', monospace;
  /* Soporte para safe areas (notch de iPhone) */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

canvas {
  display: block;
  cursor: crosshair;
  touch-action: none; /* Prevenir scroll/zoom nativo en el canvas */
}

/* ---------- Logo ---------- */
.logo {
  position: fixed;
  top: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10;
  pointer-events: none;
  user-select: none;
}

.logo-star {
  font-size: 22px;
  color: #7ff7ff;
  text-shadow:
    0 0 8px #00f0ff,
    0 0 18px rgba(0, 240, 255, 0.8),
    0 0 32px rgba(180, 0, 255, 0.5);
  animation: starPulse 2.8s ease-in-out infinite;
}

@keyframes starPulse {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  50% { transform: scale(1.15) rotate(180deg); opacity: 0.85; }
}

.logo-text {
  font-size: 18px;
  font-weight: 300;
  letter-spacing: 8px;
  color: #e8f9ff;
  text-shadow:
    0 0 6px rgba(127, 247, 255, 0.9),
    0 0 14px rgba(0, 240, 255, 0.6),
    0 0 28px rgba(180, 0, 255, 0.4);
}

/* ---------- Device badge ---------- */
.device-badge {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  background: rgba(8, 12, 22, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 20px;
  color: #7ff7ff;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
  transition: opacity 0.4s, transform 0.4s;
}

.device-badge.fade-out {
  opacity: 0;
  transform: translateX(-50%) translateY(-10px);
}

/* ---------- Panel de control neón ---------- */
#panel {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 280px;
  padding: 18px 20px 14px;
  background: rgba(8, 12, 22, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 240, 255, 0.35);
  border-radius: 8px;
  box-shadow:
    0 0 12px rgba(0, 240, 255, 0.25),
    0 0 30px rgba(180, 0, 255, 0.15),
    inset 0 0 12px rgba(0, 240, 255, 0.05);
  color: #b8e8ff;
  z-index: 10;
  transition: opacity 0.3s, transform 0.3s;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

#panel.hidden {
  opacity: 0;
  transform: translateX(320px);
  pointer-events: none;
}

#panel h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #7ff7ff;
  text-shadow: 0 0 8px #00e0ff, 0 0 16px #00a0ff;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 240, 255, 0.2);
  cursor: pointer;
  user-select: none;
}

.ctrl {
  margin-bottom: 14px;
}

.ctrl-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.ctrl-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #89b8d8;
}

.ctrl-value {
  font-size: 11px;
  color: #7ff7ff;
  text-shadow: 0 0 6px #00c8ff;
  min-width: 40px;
  text-align: right;
}

/* ---------- Slider neón ---------- */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #00f0ff33, #b400ff33);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #0a0a1a;
  border: 2px solid #00f0ff;
  box-shadow:
    0 0 6px #00f0ff,
    0 0 14px rgba(0, 240, 255, 0.6),
    inset 0 0 4px rgba(0, 240, 255, 0.4);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  box-shadow:
    0 0 10px #00f0ff,
    0 0 22px rgba(0, 240, 255, 0.8),
    inset 0 0 6px rgba(0, 240, 255, 0.6);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #0a0a1a;
  border: 2px solid #00f0ff;
  box-shadow: 0 0 6px #00f0ff, 0 0 14px rgba(0, 240, 255, 0.6);
  cursor: pointer;
}

input[type="range"]::-moz-range-track {
  height: 4px;
  background: linear-gradient(90deg, #00f0ff33, #b400ff33);
  border-radius: 2px;
}

/* ---------- Botón reset zoom ---------- */
#resetZoom {
  width: 100%;
  padding: 7px 0;
  margin-top: 4px;
  background: transparent;
  color: #7ff7ff;
  border: 1px solid rgba(0, 240, 255, 0.4);
  border-radius: 4px;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}

#resetZoom:hover {
  background: rgba(0, 240, 255, 0.1);
  border-color: #00f0ff;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.5);
  text-shadow: 0 0 8px #00f0ff;
}

/* ---------- Toggle panel ---------- */
#toggleBtn {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  background: rgba(8, 12, 22, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 240, 255, 0.35);
  border-radius: 50%;
  color: #7ff7ff;
  font-size: 18px;
  cursor: pointer;
  z-index: 11;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.25);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#toggleBtn:hover {
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.6);
  color: #fff;
}

#toggleBtn.hide {
  opacity: 0;
  pointer-events: none;
}

/* ---------- Info bottom ---------- */
.info {
  position: fixed;
  bottom: 12px;
  left: 14px;
  color: #5a8fb0;
  font-size: 11px;
  letter-spacing: 0.5px;
  pointer-events: none;
  opacity: 0.7;
  user-select: none;
}

/* ============================================
   RESPONSIVE · Tablets (768px - 1024px)
   ============================================ */
@media (max-width: 1024px) and (min-width: 768px) {
  #panel {
    width: 260px;
    padding: 16px 18px 12px;
  }

  .logo-text {
    font-size: 16px;
    letter-spacing: 6px;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 18px;
    height: 18px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
  }
}

/* ============================================
   RESPONSIVE · Móviles (< 768px)
   ============================================ */
@media (max-width: 767px) {
  /* Canvas ocupa todo, sin cursor específico */
  canvas {
    cursor: default;
  }

  /* Logo más pequeño */
  .logo {
    top: 10px;
    left: 10px;
    gap: 6px;
  }

  .logo-star {
    font-size: 16px;
  }

  .logo-text {
    font-size: 14px;
    letter-spacing: 4px;
  }

  /* Badge del dispositivo más pequeño */
  .device-badge {
    top: 12px;
    font-size: 9px;
    padding: 4px 10px;
    letter-spacing: 1.5px;
  }

  /* Panel como bottom sheet en móvil */
  #panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    padding: 18px 18px 22px;
    padding-bottom: calc(22px + env(safe-area-inset-bottom));
    max-height: 75vh;
    transform-origin: bottom center;
    box-shadow:
      0 -4px 20px rgba(0, 240, 255, 0.2),
      0 -10px 40px rgba(180, 0, 255, 0.15);
  }

  #panel::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: rgba(0, 240, 255, 0.3);
    border-radius: 2px;
    margin: -6px auto 12px;
  }

  #panel.hidden {
    opacity: 0;
    transform: translateY(100%);
  }

  #panel h2 {
    font-size: 13px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    text-align: center;
  }

  .ctrl {
    margin-bottom: 18px;
  }

  .ctrl-label {
    font-size: 11px;
    letter-spacing: 1.2px;
  }

  .ctrl-value {
    font-size: 12px;
  }

  /* Sliders más grandes para touch */
  input[type="range"] {
    height: 6px;
    padding: 12px 0; /* Área táctil más grande */
    margin: -6px 0;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 26px;
    height: 26px;
    box-shadow:
      0 0 8px #00f0ff,
      0 0 18px rgba(0, 240, 255, 0.7),
      inset 0 0 6px rgba(0, 240, 255, 0.5);
  }

  input[type="range"]::-moz-range-thumb {
    width: 26px;
    height: 26px;
    box-shadow:
      0 0 8px #00f0ff,
      0 0 18px rgba(0, 240, 255, 0.7);
  }

  /* Botones más grandes para touch */
  #resetZoom {
    padding: 12px 0;
    font-size: 11px;
    letter-spacing: 2.5px;
    margin-top: 8px;
  }

  #toggleBtn {
    top: auto;
    bottom: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    right: 16px;
    width: 52px;
    height: 52px;
    font-size: 22px;
    box-shadow: 0 0 16px rgba(0, 240, 255, 0.35);
  }

  /* Info en el centro superior en móvil */
  .info {
    top: 10px;
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    letter-spacing: 0.3px;
    text-align: center;
    max-width: 90%;
    padding: 6px 12px;
    background: rgba(10, 10, 26, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 12px;
    border: 1px solid rgba(0, 240, 255, 0.15);
  }
}

/* ============================================
   RESPONSIVE · Móviles pequeños (< 400px)
   ============================================ */
@media (max-width: 399px) {
  .logo-text {
    font-size: 12px;
    letter-spacing: 3px;
  }

  .logo-star {
    font-size: 14px;
  }

  #panel {
    padding: 14px 14px 18px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }

  .device-badge {
    font-size: 8px;
    padding: 3px 8px;
  }
}

/* ============================================
   RESPONSIVE · Landscape en móvil
   ============================================ */
@media (max-height: 500px) and (max-width: 900px) and (orientation: landscape) {
  #panel {
    top: 8px;
    bottom: auto;
    left: auto;
    right: 8px;
    width: 240px;
    max-height: calc(100vh - 16px);
    padding: 12px 14px 10px;
    border-radius: 8px;
  }

  #panel::before {
    display: none;
  }

  #panel.hidden {
    transform: translateX(260px);
  }

  .ctrl {
    margin-bottom: 10px;
  }

  .logo {
    top: 8px;
    left: 8px;
  }

  .logo-star {
    font-size: 14px;
  }

  .logo-text {
    font-size: 12px;
    letter-spacing: 3px;
  }

  .info {
    top: auto;
    bottom: 8px;
    left: 8px;
    transform: none;
    max-width: none;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    padding: 0;
    font-size: 9px;
  }

  #toggleBtn {
    top: 8px;
    bottom: auto;
    right: 8px;
    width: 44px;
    height: 44px;
  }

  .device-badge {
    top: 8px;
  }
}

/* ============================================
   Preferencias del usuario
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .logo-star {
    animation: none;
  }

  #panel, #toggleBtn, .device-badge {
    transition: none;
  }
}

/* Scrollbar personalizada para el panel */
#panel::-webkit-scrollbar {
  width: 4px;
}

#panel::-webkit-scrollbar-track {
  background: transparent;
}

#panel::-webkit-scrollbar-thumb {
  background: rgba(0, 240, 255, 0.3);
  border-radius: 2px;
}

#panel::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 240, 255, 0.5);
}
