:root {
  --bg: #0f1216;
  --bg-card: #171c22;
  --bg-sunken: #11151a;
  --border: #252c35;
  --text: #e6eaef;
  --muted: #8b97a6;
  --accent: #5ac36a;
  --accent-dim: #2f6b39;
  --warn: #e0a23c;
  --danger: #d1544f;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

/* ---------- cabecera ---------- */

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

h1 {
  font-size: 1.35rem;
  margin: 0;
  letter-spacing: -0.01em;
}

.rate {
  font-size: 0.85rem;
  color: var(--muted);
  font-family: var(--mono);
}

/* ---------- tarjetas ---------- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 14px;
  font-weight: 600;
}

/* ---------- estado ---------- */

.estado-fila {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.punto {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}

.punto.on { background: var(--accent); box-shadow: 0 0 0 4px rgba(90, 195, 106, 0.15); }
.punto.cargando { background: var(--warn); animation: latido 1.2s ease-in-out infinite; }
.punto.off { background: #4a535e; }

@keyframes latido {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.estado-texto { font-size: 1.1rem; font-weight: 600; }

.sub {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 2px 0 0;
}

.jugadores {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.jugador {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.82rem;
  font-family: var(--mono);
}

/* ---------- saldo ---------- */

.saldo-grande {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.saldo-grande.vacio { color: var(--danger); }

.barra {
  height: 6px;
  background: var(--bg-sunken);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 14px;
}

.barra > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* ---------- direccion ---------- */

.direccion {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-top: 14px;
}

.direccion code {
  flex: 1;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: var(--mono);
  font-size: 0.9rem;
  overflow-x: auto;
  white-space: nowrap;
}

/* ---------- formularios y botones ---------- */

label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(90, 195, 106, 0.12);
}

button {
  background: var(--bg-sunken);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s;
}

button:hover:not(:disabled) { border-color: #3a444f; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.primario {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1a0e;
  width: 100%;
  padding: 14px;
  font-size: 1rem;
}

button.primario:hover:not(:disabled) { background: #69d079; border-color: #69d079; }

button.peligro {
  background: transparent;
  border-color: #4a2e2d;
  color: var(--danger);
  width: 100%;
  padding: 14px;
  font-size: 1rem;
}

button.peligro:hover:not(:disabled) { border-color: var(--danger); }

.fila {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.fila > * { flex: 1; min-width: 120px; }

.campo { margin-bottom: 14px; }

/* ---------- avisos ---------- */

.aviso {
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 0.88rem;
  margin-bottom: 14px;
  border: 1px solid;
}

.aviso.error { background: rgba(209, 84, 79, 0.1); border-color: #4a2e2d; color: #f0a9a6; }
.aviso.ok { background: rgba(90, 195, 106, 0.1); border-color: var(--accent-dim); color: #a8e5b3; }
.aviso.info { background: rgba(224, 162, 60, 0.08); border-color: #4a3c22; color: #e8c489; }

/* ---------- historial ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 8px 8px 0;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 8px 8px 8px 0;
  border-bottom: 1px solid rgba(37, 44, 53, 0.5);
  vertical-align: top;
}

tr:last-child td { border-bottom: none; }

td.num, th.num { text-align: right; padding-right: 0; font-family: var(--mono); }

.quien { font-weight: 600; }
.motivo { color: var(--muted); font-size: 0.8rem; }

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
}

.tabs button {
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  background: transparent;
}

.tabs button[aria-selected="true"] {
  background: var(--bg-sunken);
  border-color: var(--accent-dim);
  color: var(--accent);
}

.totales {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--muted);
}

.totales b { color: var(--text); font-family: var(--mono); font-weight: 600; }

footer {
  margin-top: 28px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

footer a { color: var(--muted); }

[hidden] { display: none !important; }

.centrado { max-width: 360px; margin: 10vh auto 0; }

/* ---------- apagado forzado (admin) ---------- */

.forzar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.84rem;
  color: var(--muted);
  cursor: pointer;
}

.forzar input { width: auto; cursor: pointer; accent-color: var(--danger); }

/* ---------- chat ---------- */

#mensajes {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
}

.msg {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent-dim);
  border-radius: 8px;
  padding: 8px 12px;
}

.msg-cabecera {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.76rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.msg-quien { font-weight: 600; color: #7fd4e8; }
.msg-texto { font-size: 0.9rem; word-break: break-word; }

#contador { margin: 8px 0 0; font-variant-numeric: tabular-nums; }
#contador.pasado { color: var(--danger); }

/* ---------- boton de Ko-fi ---------- */

.boton-kofi {
  display: block;
  text-align: center;
  text-decoration: none;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #0b1a0e;
  border-radius: 8px;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  transition: background 0.15s;
}

.boton-kofi:hover { background: #69d079; }

/* Los mensajes dichos dentro del juego, para distinguirlos de un vistazo */
.msg.del-juego {
  border-left-color: #3a6ea5;
  background: rgba(58, 110, 165, 0.07);
}

.msg.del-juego .msg-quien { color: #9ab8d8; }
