
:root {
    --slider-track-bg: #374151;
    --slider-thumb-bg: #e5e7eb;
    --slider-thumb-border: #1f2937;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--slider-track-bg);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--slider-thumb-bg);
    border: 2px solid var(--slider-thumb-border);
    border-radius: 50%;
    margin-top: -6px;
    transition: transform 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--slider-thumb-bg);
    border: 2px solid var(--slider-thumb-border);
    border-radius: 50%;
    transition: transform 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.1);
}

html, body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    background-color: #111827;
    color: #e5e7eb;
    font-family: sans-serif;
    touch-action: none; /* evitar scroll/zoom táctil */
}

#metaballs-canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    position: fixed;
    inset: 0;
    z-index: 1;
    touch-action: none;
}

/* Hint browsers to isolate overlay layers for cheaper compositing */
#projectile-sprites, #food-sprites, #player-sprite-layer, #boss-sprite-layer, #popups-layer, #telegraph-layer, #boss-indicator {
    contain: layout paint;
}
#boss-sprite-layer img { will-change: transform, opacity; }
#projectile-sprites img, #food-sprites img, #player-sprite {
    will-change: transform;
}

#hud {
    position: fixed;
    top: 1rem;
    right: 1rem;
    text-align: right;
    font-weight: bold;
    font-size: 1.5rem;
    pointer-events: none;
}

#game-message {
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
    z-index: 100;
}

#game-message.hidden {
    opacity: 0;
}

#message-text {
    font-size: 4rem;
    font-weight: bold;
    color: white;
    text-align: center;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

#control-panel {
    display: none; /* Panel eliminado - modo fullscreen */
}

/* ========== ESTILOS RESPONSIVE PARA CROSSHAIR ========== */
@media (max-width: 768px) {
    .crosshair {
        /* Mantener tamaño normal en móvil para no tapar visión */
        transform: translate(-50%, -50%) scale(1.0);
    }
    .thrust-indicator { font-size: 28px; }
}

#control-panel label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #9ca3af;
}

#control-panel button {
    width: 100%;
    background-color: #374151;
    color: white;
    font-weight: 600;
    padding: 0.625rem 1rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s;
}

#control-panel button:hover {
    background-color: #4b5563;
}

#control-panel .space-y-4 > * + * {
    margin-top: 1rem;
}

#control-panel .grid {
    display: grid;
}

#control-panel .grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

#control-panel .gap-4 {
    gap: 1rem;
}

#control-panel .items-center {
    align-items: center;
}

input[type="color"] {
    height: 2.5rem;
    width: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 0.5rem;
}

/* ========== CROSSHAIR RETRO CLÁSICO (Estilo Doom/Quake) ========== */
.crosshair {
    position: fixed;
    pointer-events: none;
    z-index: 50;
    transform: translate(-50%, -50%);
    font-family: 'Courier New', monospace;
    font-weight: bold;
}

.crosshair-center {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #ffea00;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    box-shadow: 0 0 10px #ffea00, 0 0 20px rgba(255,234,0,0.7), 1px 1px 0 #000000;
}

.crosshair-line {
    position: absolute;
    background: #ffea00;
    box-shadow: 1px 1px 0 #000000, 0 0 8px rgba(255,234,0,0.6);
}

.crosshair-horizontal {
    width: 26px;
    height: 3px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.crosshair-vertical {
    width: 3px;
    height: 26px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Marcas de distancia estilo militar */
.crosshair::before {
    content: '';
    position: absolute;
    width: 8px;
    height: 2px;
    background: #ffea00;
    box-shadow: 1px 1px 0 #000000;
    top: 50%;
    left: calc(50% - 32px);
    transform: translateY(-50%);
}

.crosshair::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 2px;
    background: #ffea00;
    box-shadow: 1px 1px 0 #000000;
    top: 50%;
    right: calc(50% - 32px);
    transform: translateY(-50%);
}

/* Estado de disparo */
.crosshair.shooting .crosshair-center { box-shadow: 0 0 18px #ffea00, 0 0 26px rgba(255,234,0,0.9), 1px 1px 0 #000; }
.crosshair.shooting .crosshair-line { box-shadow: 1px 1px 0 #000, 0 0 12px rgba(255,234,0,0.9); }
/* Evitar filtros en iOS que fuerzan renderizado offscreen */
body.ios .crosshair.shooting::before, body.ios .crosshair.shooting::after { filter: none !important; }

/* Sniper-like ring */
.crosshair-ring {
    position: absolute;
    width: 54px;
    height: 54px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 3px solid #ffea00;
    border-radius: 50%;
    box-shadow: 0 0 16px rgba(255,234,0,0.6), inset 0 0 8px rgba(255,234,0,0.3);
}
.crosshair.shooting .crosshair-ring { box-shadow: 0 0 22px rgba(255,234,0,0.95), inset 0 0 12px rgba(255,234,0,0.6); }

/* ========== LÍNEA DE MIRA ========== */
.aim-line {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    opacity: 0.8;
}

/* Ocultar cursor del sistema cuando hay pointer-lock */
body.pointer-locked, body.pointer-locked #metaballs-canvas {
    cursor: none;
}

/* ========== INDICADOR DE DIRECCIÓN ========== */
.direction-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    pointer-events: none;
    z-index: 30;
    transform: translate(-50%, -50%);
}

.thrust-indicator {
    position: absolute;
    font-size: 24px;
    color: #00ff88;
    text-shadow: 0 0 10px #00ff88, 0 0 20px rgba(0,255,136,0.5);
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: all 0.2s ease-out;
    animation: thrust-glow 1s ease-in-out infinite;
}

.thrust-indicator.active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
}

@keyframes thrust-glow {
    0%, 100% { 
        text-shadow: 0 0 10px #00ff88, 0 0 20px rgba(0,255,136,0.5);
    }
    50% { 
        text-shadow: 0 0 20px #00ff88, 0 0 40px rgba(0,255,136,0.8);
    }
}

/* ========== CURSOR SUTIL ========== */
body {
    cursor: crosshair; /* Cursor sutil de apuntado */
}

#metaballs-canvas {
    cursor: crosshair;
}

/* Touch UI */
#touch-ui { position: fixed; inset: 0; pointer-events: none; z-index: 250; display: none; }

/* Left virtual joystick */
#left-pad {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 20px);
  width: 120px; height: 120px;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
#left-pad .pad-base {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(255, 228, 0, 0.20), rgba(255, 184, 0, 0.10));
  border: 2px solid rgba(255, 223, 90, 0.55);
  box-shadow: inset 0 6px 18px rgba(0,0,0,0.45), 0 6px 16px rgba(255, 200, 0, 0.25);
}
#left-pad .pad-stick {
  position: absolute;
  left: 50%; top: 50%;
  width: 54px; height: 54px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255, 250, 200, 0.95), rgba(255, 214, 0, 0.65));
  border: 2px solid rgba(255, 190, 0, 0.8);
  box-shadow: 0 8px 18px rgba(0,0,0,0.45), inset 0 2px 6px rgba(255,255,255,0.6);
}

#shoot-btn {
  position: absolute;
  right: max(12px, env(safe-area-inset-right));
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 20px);
  width: 72px; height: 72px;
  border-radius: 50%; border: 2px solid rgba(255, 184, 0, 0.9);
  background: radial-gradient(circle at 30% 30%, #fff6ad, #ffd400 45%, #ff9f00 80%);
  color: transparent; font-size: 0; line-height: 1;
  box-shadow: 0 6px 20px rgba(0,0,0,0.45), 0 0 22px rgba(255, 210, 0, 0.45);
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex; align-items: center; justify-content: center;
}
#shoot-btn::after {
  content: '';
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 34%; height: 34%; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff7b8, #ffdf5a 70%);
  box-shadow: inset 0 0 6px rgba(255,255,255,0.6), 0 0 8px rgba(255, 220, 0, 0.6);
}
#shoot-btn:active { transform: scale(0.96); }
}
@media (hover: hover) and (pointer: fine) {
  #touch-ui { display: none; }
}

/* Mobile-specific tweaks */
@media (hover: none) and (pointer: coarse) {
  /* Show touch controls only on touch/coarse devices */
  #touch-ui { display: block; }
  /* Hide instructions box on mobile */
  #mini-hud { display: none !important; }
  /* Center author credit at bottom on mobile */
  #footer-credits { left: 50% !important; transform: translateX(-50%) !important; text-align: center !important; }
  /* Slightly smaller shoot button to free space */
  #shoot-btn { width: 64px; height: 64px; font-size: 22px; }
  /* Smaller boss label + bar width */
  #boss-hud .arcade-title { font-size: clamp(18px, 5vw, 28px) !important; }
  .lifebar-wrap { width: min(82vw, 520px) !important; }
  /* Score HUD smaller */
  #score-hud > div:first-child { font-size: clamp(10px, 2.8vw, 14px) !important; }
  #score-hud #score-value { font-size: clamp(18px, 6vw, 28px) !important; }
  /* Lives icons smaller */
  #lives-icons img { width: 28px !important; }
  /* Left pad smaller on very narrow screens */
  @media (max-width: 380px) {
    #left-pad { width: 104px; height: 104px; }
    #left-pad .pad-stick { width: 48px; height: 48px; }
  }
}

/* Portrait: bajar SCORE y LIVES para no solapar la barra del boss */
@media (orientation: portrait) and (hover: none) and (pointer: coarse) {
  #score-hud { top: 72px !important; }
  #lives-hud { top: 72px !important; }
}

/* High Scores overlay: center safely on mobile */
#hiscore-screen { padding: max(8vh, env(safe-area-inset-top)) 4vw max(10vh, env(safe-area-inset-bottom)) 4vw !important; }
@media (hover: none) and (pointer: coarse) {
  #hiscore-screen .arcade-title { font-size: clamp(22px, 7vw, 56px) !important; }
  #hiscore-list { font-size: clamp(14px, 4vw, 22px) !important; }
  #hiscore-entry input#hiscore-name { font-size: clamp(18px, 5vw, 28px) !important; width: min(240px, 80vw) !important; }
}
/* ===== ARCADE TYPOGRAPHY (Sama Banana) ===== */
.arcade-title {
    text-align: center;
    font-family: Impact, 'Arial Black', system-ui, sans-serif;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-size: clamp(40px, 8vw, 96px);
    line-height: 1;
    color: #ffe400;
    -webkit-text-stroke: 2px #000;
    text-shadow:
      0 4px 0 #000,
      0 6px 0 #000,
      4px 4px 0 #000,
      -4px 4px 0 #000,
      0 0 14px rgba(255, 170, 0, 0.95),
      0 0 32px rgba(255, 80, 0, 0.85),
      0 0 54px rgba(255, 0, 128, 0.75);
}

.arcade-message {
    font-family: Impact, 'Arial Black', system-ui, sans-serif;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-size: clamp(48px, 10vw, 160px);
    line-height: 1;
    color: #fff7a1;
    -webkit-text-stroke: 3px #000;
    text-align: center;
    text-shadow:
      0 4px 0 #000,
      0 8px 0 #000,
      4px 4px 0 #000,
      -4px 4px 0 #000,
      0 0 16px rgba(255, 200, 0, 1),
      0 0 36px rgba(255, 80, 0, 0.9),
      0 0 60px rgba(255, 0, 128, 0.85);
}

/* ===== TITLE SCREEN ANIMATIONS ===== */
@keyframes pulse-float {
  0%   { transform: translateY(0) scale(0.98); }
  50%  { transform: translateY(-8px) scale(1.02); }
  100% { transform: translateY(0) scale(0.98); }
}

@keyframes blink-arcade {
  0%, 60% { opacity: 1; }
  61%,100% { opacity: 0; }
}

#title-screen #title-logo-wrap { animation: pulse-float 2.6s ease-in-out infinite; }
#title-screen #title-logo { position: relative; z-index: 3; animation: none !important; }
#title-screen #about-btn { pointer-events: auto; z-index: 5; }

#title-screen #title-start {
  animation: blink-arcade 1s steps(2, end) infinite;
  position: relative; z-index: 4;
}

/* Desktop: show hand cursor over PRESS START */
@media (hover: hover) and (pointer: fine) {
  #title-screen #title-start { cursor: pointer; }
}

/* About overlay: show hand cursor on close button */
#about-close { cursor: pointer; }

/* Title bananas (background for title screen) */
.title-banana {
  position: absolute;
  width: 48px;
  opacity: 0.85;
  filter: drop-shadow(0 0 10px rgba(255,230,0,0.5));
  animation: spin-float 3.2s linear infinite;
  z-index: 1; pointer-events: none;
}

@keyframes spin-float {
  0%   { transform: translate(-50%, -50%) rotate(0deg); }
  50%  { transform: translate(-50%, -58%) rotate(180deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}
/* iOS-specific performance tweaks applied via body.ios class */
body.ios .title-banana { filter: none !important; }

/* Title: responsive logo size in portrait/mobile */
@media (orientation: portrait) {
  #title-screen #title-logo {
    width: min(86vw, 78vh) !important;
    max-width: none !important;
  }
}

/* Landscape on mobile: keep logo within viewport height */
@media (orientation: landscape) and (hover: none) and (pointer: coarse) {
  #title-screen #title-logo {
    width: min(48vw, 40vh, 520px) !important;
    max-width: none !important;
  }
}

/* About overlay card responsive sizing */
#about-overlay .about-card {
  box-sizing: border-box;
  width: min(600px, calc(100vw - max(28px, env(safe-area-inset-left)) - max(28px, env(safe-area-inset-right))));
  max-height: calc(100vh - max(12vh, env(safe-area-inset-top)) - max(12vh, env(safe-area-inset-bottom)));
  padding: clamp(14px, 3vw, 22px);
}
@media (orientation: landscape) and (hover: none) and (pointer: coarse) {
  #about-overlay .about-card {
    width: min(520px, calc(100vw - 64px));
    max-height: calc(100vh - 22vh);
  }
}

/* Slight offset of left joystick to avoid footer overlap in portrait mobile */
@media (orientation: portrait) and (hover: none) and (pointer: coarse) {
  #left-pad { bottom: calc(max(12px, env(safe-area-inset-bottom)) + 25px); }
}
/* ===== LIFEBAR (arcade style) ===== */
.lifebar-wrap {
  position: relative;
  width: min(60vw, 720px);
  height: 18px;
  margin: 0 auto;
}
.lifebar-bg {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #1a1a1a, #000);
  border-radius: 10px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.06), inset 0 -2px 0 rgba(0,0,0,0.8);
}
.lifebar-frame {
  position: absolute; inset: -3px;
  border: 3px solid #000;
  border-radius: 12px;
  box-shadow: 0 0 0 2px #ffd400, 0 0 12px rgba(255,200,0,0.6);
  pointer-events: none;
}
.lifebar-red {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, #ff0037, #ff4d00);
  border-radius: 10px 0 0 10px;
  box-shadow: inset 0 0 8px rgba(255,255,255,0.25);
  transition: width 140ms ease-out;
}
.lifebar-chip {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, #ffe600, #ffb300);
  border-radius: 10px 0 0 10px;
  opacity: 0.9;
  transition: width 600ms ease-in;
}
