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

body {
  background: #1a1a2e;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  font-family: 'Courier New', Courier, monospace;
  padding: 16px;
  gap: 16px;
  flex-wrap: wrap;
}

/* ── Game container ─────────────────────────────────────────── */
.game-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #f7f7f7;
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  overflow: hidden;
  /* Responsive: hasta 900 px, luego se llena el ancho disponible */
  width: min(900px, 100%);
}

/* Canvas ocupa todo el ancho del contenedor → en móvil se agranda */
canvas {
  display: block;
  width: 100%;
  border-radius: 20px 20px 0 0;
  /* touch-action ya está en el HTML, pero lo reforzamos aquí */
  touch-action: none;
}

/* ── Score panel ────────────────────────────────────────────── */
.score-panel {
  width: 100%;
  background: #535353;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  font-size: 1rem;
  font-weight: bold;
  letter-spacing: 2px;
  border-radius: 0 0 20px 20px;
  gap: 6px;
  flex-wrap: wrap;
}

.score-panel button {
  background: #f2a365;
  border: none;
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.score-panel button:hover { background: #ffb347; }

/* ── Side panels ────────────────────────────────────────────── */
.side-panels {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 300px;
  flex-shrink: 0;
}

.config-panel, .stats-panel, .achievements-panel {
  background: #222831;
  color: #eee;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 15px 30px rgba(0,0,0,0.6);
}

.config-panel h2, .stats-panel h2, .achievements-panel h2 {
  text-align: center;
  color: #f2a365;
  font-size: 1.2rem;
  border-bottom: 1px solid #f2a365;
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.config-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.config-group label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #a6a6a6;
}
.config-group input[type="range"] {
  width: 100%;
  cursor: pointer;
  accent-color: #f2a365;
}
.config-group span {
  font-size: 0.85rem;
  color: #f2a365;
  font-weight: bold;
  align-self: flex-end;
}

button.apply-btn, button.reset-btn {
  background: #f2a365;
  border: none;
  padding: 9px;
  border-radius: 8px;
  font-weight: bold;
  color: #222;
  cursor: pointer;
  transition: 0.2s;
  width: 100%;
  margin-top: 5px;
  text-transform: uppercase;
}
button.apply-btn:hover, button.reset-btn:hover { background: #ffb347; }

/* ── Pause overlay ──────────────────────────────────────────── */
#pauseOverlay {
  display: none;
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.7);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
#pauseOverlay .config-panel { width: min(300px, 90%); }

/* ── Flash / sepia overlays ─────────────────────────────────── */
#flashOverlay, #sepiaOverlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  transition: opacity 0.1s;
}
#flashOverlay { background: white;                    opacity: 0; z-index: 20; }
#sepiaOverlay { background: rgba(160,100,50,0.3);    opacity: 0; z-index: 15; }

button.resume-btn { padding: 10px 25px; font-size: 1.1rem; }

/* Botón ✕ para cerrar paneles de stats/logros */
.close-panel-btn {
  float: right;
  background: transparent;
  border: none;
  color: #888;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  margin-bottom: 4px;
}
.close-panel-btn:hover { color: #f2a365; }

/* ── Pantalla completa ───────────────────────────────────────── */
:fullscreen body,
:-webkit-full-screen body {
  padding: 0;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

:fullscreen .game-container,
:-webkit-full-screen .game-container {
  width: 100vw;
  max-width: none;
  border-radius: 0;
  height: 100vh;
  justify-content: center;
}

:fullscreen canvas,
:-webkit-full-screen canvas {
  width: auto;
  height: 100vh;
  max-width: 100vw;
  border-radius: 0;
}

:fullscreen .side-panels,
:-webkit-full-screen .side-panels { display: none; }

:fullscreen .score-panel,
:-webkit-full-screen .score-panel { border-radius: 0; }

/* ── Responsive: móvil (< 700 px) ───────────────────────────── */
@media (max-width: 700px) {
  body {
    padding: 8px;
    gap: 10px;
    /* En móvil los side-panels bajan automáticamente por flex-wrap */
  }

  .side-panels {
    width: 100%;  /* Ocupan todo el ancho en lugar de 300px fijo */
    max-width: 900px;
  }

  .score-panel {
    font-size: 0.85rem;
    padding: 6px 12px;
    letter-spacing: 1px;
  }
}
