/* ===========================
   Tema oscuro — Predicción BTC
   =========================== */
:root {
  --bg: #0f0f0f;
  --panel: #151515;
  --panel-2: #1b1b1b;
  --panel-3: #161616;
  --line: #262626;
  --line-2: #2b2b2b;
  --line-3: #232323;
  --text: #e9e9e9;
  --muted: #bdbdbd;

  --green: #7aff7a;
  --green-2: #1d8f2d;
  --red: #c92430;
  --red-2: #7a2323;

  --btn: #2f2f2f;
  --shadow: rgba(0,0,0,.35);
  --radius-lg: 14px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

/* Tema oscuro consistente */
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.45;
}
.wrapper { padding: 18px; }
.container {
  max-width: 980px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 0 20px var(--shadow);
}

h1 {
  text-align: center;
  color: var(--green);
  margin: 0 0 10px;
  letter-spacing: .2px;
}
.intro {
  text-align: center;
  color: var(--muted);
  background: #0f0f0f;
  border: 1px solid #2c2c2c;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 14px;
}

/* ===== Aviso DEMO ===== */
.aviso-demo{
  margin:10px 0 6px;
  background:#101010;
  border:1px dashed #3a3a3a;
  color:#dcdcdc;
  padding:10px 12px;
  border-radius:10px;
  font-size:.95rem;
}
.badge-demo{
  display:inline-block;
  margin-left:6px;
  font-size:.75rem;
  font-weight:800;
  letter-spacing:.3px;
  padding:2px 6px;
  border-radius:999px;
  background:#2f2f2f;
  border:1px solid #3a3a3a;
  color:#9ee89e;
}

/* ===== Panel de controles ===== */
.panel {
  margin: 16px 0;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-md);
  padding: 14px;
}
.precio-actual {
  display: flex;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
}
.precio {
  font-size: clamp(22px, 3.2vw, 28px);
  font-weight: 800;
  color: #a9ff88;
}
.variacion { font-size: 14px; color: var(--muted); }

.controles {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
select {
  background: #121212;
  color: var(--text);
  border: 1px solid #2c2c2c;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  outline: none;
}
select:focus-visible {
  box-shadow: 0 0 0 3px rgba(122,255,122,.25);
  border-color: var(--green);
}

/* ===== Botones ===== */
.btn {
  border: none;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 700;
  transition: transform .06s ease, filter .15s ease, box-shadow .15s ease;
  outline: none;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; filter: grayscale(.3); cursor: not-allowed; }

.sube { background: var(--green-2); color: #fff; }
.baja { background: var(--red); color: #fff; }
.secundario { background: var(--btn); color: #ddd; }
.peligro { background: var(--red-2); color: #fff; }

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(122,255,122,.35);
}

/* ===== Estado y contador ===== */
.estado {
  margin-top: 8px;
  padding: 8px 10px;
  background: #101010;
  border: 1px solid #272727;
  border-radius: var(--radius-sm);
}
.contador {
  margin-top: 8px;
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  color: var(--green);
}

/* ===== Estadísticas ===== */
.estadisticas {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-md);
  padding: 12px;
  margin: 14px 0;
}
.estadisticas div {
  background: var(--panel-3);
  border: 1px solid var(--line-3);
  border-radius: var(--radius-md);
  padding: 10px;
  text-align: center;
  font-weight: 600;
}

/* ===== Historial ===== */
.historial h2, .canvas-wrap h2 { margin: 8px 0; }
.historial ul { list-style: none; padding-left: 0; margin: 0; }
.historial li {
  padding: 8px 10px;
  margin: 6px 0;
  background: #121212;
  border: 1px solid #242424;
  border-radius: var(--radius-sm);
}
.historial .win { border-color: #2ea043; }
.historial .lose { border-color: #c43d44; }

/* ===== Sparkline ===== */
.canvas-wrap {
  background: #111;
  border: 1px solid #242424;
  border-radius: var(--radius-md);
  padding: 10px;
  overflow: hidden;
}
.canvas-wrap canvas {
  width: 100%;
  height: auto;
  display: block;
}

/* ===== Banca (saldo y apuesta) ===== */
.banca {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 12px;
  margin: 14px 0;
}
.banca-item {
  background: var(--panel-3);
  border: 1px solid var(--line-3);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
}
.banca.destaque { border: 2px solid var(--green); animation: fadeIn .6s ease; }
.banca-item span#saldo {
  font-size: 1.4em;
  font-weight: bold;
  color: var(--green);
  transition: all .4s ease;
}
#apuesta {
  width: 90px;
  background:#121212;
  color:#e9e9e9;
  border:1px solid #2c2c2c;
  border-radius:8px;
  padding:6px 8px;
  text-align:center;
}
.nota-apuesta { display:block; color:#bdbdbd; font-size:.8rem; margin-top:-4px; }

.saldo-gana { color: #00ffae !important; text-shadow: 0 0 8px #00ffae; }
.saldo-pierde { color: #ff5757 !important; text-shadow: 0 0 8px #ff5757; }

@keyframes fadeIn { from {opacity:0; transform:scale(.95);} to {opacity:1; transform:scale(1);} }

/* ===== Acciones & volver ===== */
.acciones {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.volver { text-align: center; margin-top: 16px; }
.volver a { color: var(--green); text-decoration: none; }
.volver a:hover { text-decoration: underline; }

/* ===== Modal game over ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: grid;
  place-items: center;
  z-index: 999;
}
/* Ocultar overlay cuando el elemento lleva el atributo hidden */
.modal-overlay[hidden] {
  display: none !important;
}
.modal {
  width: min(92vw, 420px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  animation: fadeIn .2s ease;
}
.modal h3 { margin: 0 0 6px; color: var(--green); }
.modal-actions { display:flex; gap:10px; justify-content:flex-end; margin-top:10px; }

/* ===== Accesibilidad extra ===== */
a, button, select, input[type="radio"] {
  -webkit-tap-highlight-color: transparent;
}

/* =========================
   Breakpoints Responsivos
   ========================= */

/* XS: <=480px (móviles pequeños) */
@media (max-width: 480px) {
  .wrapper { padding: 10px; }
  .container { padding: 12px; }

  /* La banca en 1 columna */
  .banca { grid-template-columns: 1fr !important; }

  .banca-item {
    flex-direction: column;
    gap: 6px;
    text-align: center;
  }

  /* Estadísticas en 1 columna */
  .estadisticas { grid-template-columns: 1fr !important; }

  /* Botones y campos a ancho completo */
  .btn {
    width: 100% !important;
    min-width: unset;
  }
  #apuesta { width: 100%; }

  /* Títulos un poco más compactos */
  h1 { font-size: clamp(20px, 6vw, 26px); }
  .precio { font-size: clamp(20px, 6vw, 24px); }
}

/* S: 481px–720px (móvil grande / phablet) */
@media (min-width: 481px) and (max-width: 720px) {
  .wrapper { padding: 14px; }
  .container { padding: 16px; }

  /* Banca en 1 columna todavía para evitar encimes */
  .banca { grid-template-columns: 1fr; }

  /* Estadísticas en 2 columnas */
  .estadisticas { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .btn { width: calc(50% - 6px); min-width: 140px; }
}

/* M: 721px–1024px (tablet / laptop chica) */
@media (min-width: 721px) and (max-width: 1024px) {
  .banca { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .estadisticas { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* XL: >=1280px (desktop grande): un poco más de aire */
@media (min-width: 1280px) {
  .container { max-width: 1100px; }
}

/* Respeto a usuarios con poca animación */
@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}
