/* ============================================
   Monito Tití vs Insectos de la Selva
   Estilos pixel art selváticos
   ============================================ */

:root {
  --jungle-dark: #1a3a1a;
  --jungle-mid: #2d5a27;
  --jungle-light: #4a8c3a;
  --leaf: #6ab04c;
  --banana: #f9ca24;
  --banana-dark: #f0932b;
  --monkey: #d35400;
  --monkey-light: #e67e22;
  --danger: #c0392b;
  --sky: #87ceeb;
  --cream: #f5f6fa;
  --shadow: rgba(0, 0, 0, 0.35);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--jungle-dark);
  font-family: 'Courier New', Courier, monospace;
  color: var(--cream);
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 0%, var(--jungle-mid) 0%, transparent 70%),
    linear-gradient(180deg, var(--jungle-mid) 0%, var(--jungle-dark) 100%);
}

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

/* ============================================
   HUD
   ============================================ */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 16px;
  pointer-events: none;
  z-index: 20;
  text-shadow: 2px 2px 0 #000;
}

.hud-left,
.hud-center,
.hud-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
}

.hud-left { align-items: flex-start; }
.hud-right { align-items: flex-end; }

.hud-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--leaf);
  margin-bottom: 2px;
}

#score,
#level,
#lives {
  font-size: clamp(18px, 4vw, 28px);
  font-weight: bold;
  color: var(--cream);
}

/* ============================================
   Pantallas superpuestas
   ============================================ */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  background: rgba(10, 25, 10, 0.88);
  backdrop-filter: blur(3px);
  padding: 20px;
}

.screen-content {
  max-width: 520px;
  width: 100%;
  text-align: center;
  background: var(--jungle-mid);
  border: 4px solid var(--leaf);
  border-radius: 12px;
  padding: clamp(24px, 6vw, 44px);
  box-shadow:
    0 0 0 4px var(--jungle-dark),
    0 12px 30px var(--shadow),
    inset 0 0 40px rgba(0,0,0,0.2);
}

.game-title {
  font-size: clamp(26px, 7vw, 46px);
  line-height: 1.15;
  margin-bottom: 16px;
  color: var(--banana);
  text-shadow:
    3px 3px 0 #000,
    -1px -1px 0 var(--monkey-light);
}

.title-line {
  display: block;
}

.title-vs {
  display: block;
  font-size: 0.55em;
  color: var(--leaf);
  margin: 6px 0;
}

.game-subtitle {
  font-size: clamp(14px, 3.5vw, 18px);
  color: var(--cream);
  margin-bottom: 24px;
}

.screen-title {
  font-size: clamp(28px, 8vw, 48px);
  color: var(--banana);
  margin-bottom: 16px;
  text-shadow: 3px 3px 0 #000;
}

.instructions {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 28px;
  font-size: clamp(12px, 3vw, 15px);
  line-height: 1.6;
  color: var(--cream);
}

.instructions strong {
  color: var(--banana);
}

.final-score {
  font-size: clamp(16px, 4vw, 22px);
  color: var(--banana);
  margin: 18px 0 26px;
}

/* ============================================
   Botones
   ============================================ */
.pixel-btn,
.control-btn {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.pixel-btn {
  display: inline-block;
  background: var(--banana);
  color: var(--jungle-dark);
  font-size: clamp(14px, 3.5vw, 18px);
  font-weight: bold;
  padding: 14px 28px;
  border-radius: 8px;
  box-shadow:
    0 5px 0 var(--banana-dark),
    0 8px 10px var(--shadow);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.pixel-btn:hover {
  transform: translateY(-2px);
}

.pixel-btn:active {
  transform: translateY(3px);
  box-shadow:
    0 2px 0 var(--banana-dark),
    0 3px 6px var(--shadow);
}

/* ============================================
   Controles móviles
   ============================================ */
#mobile-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 110px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 18px 18px;
  pointer-events: none;
  z-index: 25;
}

.control-btn {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 3px solid rgba(255, 255, 255, 0.35);
  color: var(--cream);
  font-size: 34px;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
  transition: background 0.1s ease, transform 0.08s ease;
}

.control-btn:active,
.control-btn.pressed {
  background: rgba(249, 202, 36, 0.35);
  border-color: var(--banana);
  transform: scale(0.94);
}

.control-btn .arrow {
  text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

/* ============================================
   Utilidades
   ============================================ */
.hidden {
  display: none !important;
}

/* Mostrar controles móviles solo en pantallas táctiles pequeñas o portrait */
@media (hover: none) and (pointer: coarse) {
  #mobile-controls {
    display: flex;
  }
}

@media (max-width: 768px) and (orientation: portrait) {
  #mobile-controls {
    display: flex;
  }

  #hud {
    padding-top: 8px;
  }
}

/* En desktop landscape grande, ocultar siempre */
@media (hover: hover) and (pointer: fine) and (min-width: 769px) {
  #mobile-controls {
    display: none;
  }
}

/* Ajuste para pantallas muy bajas */
@media (max-height: 500px) {
  #mobile-controls {
    height: 86px;
  }

  .control-btn {
    width: 66px;
    height: 66px;
    font-size: 26px;
  }
}
