:root {
  --bg: #0a0e17;
  --bg-2: #0d1420;
  --panel: #141b2b;
  --panel-2: #1a2336;
  --border: #232e46;
  --text: #e8edf7;
  --muted: #8b93a7;
  --accent: #00e58f;
  --accent-2: #00b36e;
  --gold: #f5b942;
  --danger: #ff4d6d;
  --info: #4da3ff;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

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

html, body {
  height: 100%;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #12203a 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: 'Orbitron', sans-serif; font-weight: 800; letter-spacing: 1px; }
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #00ffa3, var(--accent-2));
  color: #04110b;
  box-shadow: 0 0 18px rgba(0, 229, 143, 0.35);
}
.brand-name { font-size: 16px; }

.nav { display: flex; gap: 6px; margin-left: 8px; }
.nav a {
  padding: 8px 14px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  transition: all .15s;
}
.nav a:hover { color: var(--text); background: var(--panel-2); }
.nav a.active { color: var(--text); background: var(--panel-2); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.balance-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
}
.balance-label { color: var(--muted); font-size: 12px; }
.balance-value { font-weight: 800; font-size: 15px; color: var(--accent); }
.balance-currency { color: var(--muted); font-size: 12px; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-name { font-weight: 600; font-size: 14px; }

.lang-select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}
.lang-select:hover { border-color: var(--accent); }

.mode-toggle { display: flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.mode-toggle button {
  background: var(--bg-2);
  border: none;
  color: var(--muted);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
}
.mode-toggle button.active { background: var(--accent); color: #04110b; }

/* ---------- Layout ---------- */
.app { max-width: 1180px; margin: 0 auto; padding: 28px 20px 80px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card-title { font-size: 18px; font-weight: 700; margin-bottom: 18px; }
.card-sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 700;
  font-size: 14px;
  transition: all .15s;
  color: var(--text);
  background: var(--panel-2);
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #04110b; }
.btn-gold { background: linear-gradient(135deg, var(--gold), #ff8a3d); color: #1a0f00; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }

/* ---------- Formularios ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.input, .select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color .15s;
}
.input:focus, .select:focus { border-color: var(--accent); }
.input::placeholder { color: #5a637a; }

/* ---------- Juego ---------- */
.game-layout { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; }
@media (max-width: 860px) { .game-layout { grid-template-columns: 1fr; } }

.number-stage {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 24px;
  text-align: center;
}
.number-label { color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; }
.number-display {
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
  font-size: 120px;
  line-height: 1;
  margin: 16px 0;
  color: var(--text);
  text-shadow: 0 0 40px rgba(0, 229, 143, 0.35);
}
.number-display.dim { color: #3a4a63; text-shadow: none; }
.number-display.win { color: var(--accent); animation: numberPop .45s ease; }
.number-display.last { color: #7c8aa6; text-shadow: 0 0 30px rgba(0, 229, 143, 0.18); }
@keyframes numberPop {
  0% { transform: scale(0.75); opacity: 0.2; }
  55% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.status-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}
.status-badge.betting { background: rgba(0, 229, 143, .12); color: var(--accent); }
.status-badge.closed { background: rgba(245, 185, 66, .14); color: var(--gold); }
.status-badge.resolved { background: rgba(77, 163, 255, .14); color: var(--info); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.countdown-bar { width: 100%; height: 8px; background: var(--bg-2); border-radius: 999px; overflow: hidden; margin-top: 20px; }
.countdown-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: 999px; transition: width .5s linear; }
.countdown-text { margin-top: 10px; color: var(--muted); font-size: 13px; font-weight: 600; }

.round-meta { display: flex; justify-content: center; gap: 24px; margin-top: 18px; font-size: 13px; color: var(--muted); }
.round-meta b { color: var(--text); }

/* Bet panel */
.bet-types { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.bet-type {
  padding: 10px 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  text-align: center;
  transition: all .15s;
}
.bet-type small { display: block; font-weight: 500; color: #5a637a; }
.bet-type.active { border-color: var(--accent); color: var(--text); background: rgba(0, 229, 143, .08); }
.bet-type.active small { color: var(--accent); }

.number-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 16px; }
.number-picker .num-btn {
  padding: 12px 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  font-weight: 800;
  font-size: 16px;
}
.number-picker .num-btn.active { border-color: var(--gold); background: rgba(245, 185, 66, .12); color: var(--gold); }

.amount-quick { display: flex; gap: 8px; margin-bottom: 10px; }
.amount-quick .chip {
  flex: 1; padding: 8px 0; text-align: center;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-2); color: var(--muted); font-weight: 700; font-size: 13px;
}
.amount-quick .chip.active { border-color: var(--accent); color: var(--accent); }

.payout-hint { font-size: 13px; color: var(--muted); margin: 10px 0; }
.payout-hint b { color: var(--gold); }

/* History strip */
.history-strip { display: flex; gap: 10px; flex-wrap: wrap; }
.history-item {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 12px;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700; font-size: 17px;
  border: 1px solid var(--border);
  background: var(--bg-2);
}
.history-item.low { color: #7ee0ff; border-color: rgba(126, 224, 255, .35); }
.history-item.high { color: #ff9d7e; border-color: rgba(255, 157, 126, .35); }
.history-item.even { color: var(--accent); border-color: rgba(0, 229, 143, .35); }
.history-item.odd { color: var(--gold); border-color: rgba(245, 185, 66, .35); }
.history-item.latest { outline: 2px solid var(--accent); outline-offset: 1px; transform: scale(1.08); }

/* ---------- Wallet ---------- */
.wallet-address {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-2);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 14px;
  word-break: break-all;
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
}
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.qr-box img { border-radius: 12px; background: #fff; padding: 8px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
tr:hover td { background: rgba(255,255,255,.02); }

.badge { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-green { background: rgba(0,229,143,.14); color: var(--accent); }
.badge-red { background: rgba(255,77,109,.14); color: var(--danger); }
.badge-gold { background: rgba(245,185,66,.14); color: var(--gold); }
.badge-blue { background: rgba(77,163,255,.14); color: var(--info); }
.badge-gray { background: rgba(139,147,167,.14); color: var(--muted); }

/* ---------- Auth ---------- */
.auth-wrap { max-width: 420px; margin: 60px auto; }
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.auth-tabs button {
  flex: 1; padding: 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg-2);
  color: var(--muted); font-weight: 700;
}
.auth-tabs button.active { border-color: var(--accent); color: var(--text); background: rgba(0,229,143,.08); }

/* ---------- Stats ---------- */
.stat { background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.stat-value { font-size: 24px; font-weight: 800; font-family: 'Orbitron', sans-serif; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---------- Verify ---------- */
.verify-card { font-family: 'Orbitron', sans-serif; }
.verify-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.verify-row .k { color: var(--muted); font-family: 'Inter', sans-serif; }
.verify-row .v { word-break: break-all; text-align: right; }

/* ---------- Toast ---------- */
.toast-container { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 14px;
  max-width: 340px;
  box-shadow: var(--shadow);
  animation: slideIn .2s ease;
}
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--info); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

.muted { color: var(--muted); }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.center { text-align: center; }
.hidden { display: none !important; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  background: rgba(10, 14, 23, 0.6);
  margin-top: 40px;
}
.footer-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.footer-brand { font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 14px; color: var(--muted); }
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); font-size: 13px; transition: color .15s; }
.footer-links a:hover { color: var(--accent); }

.footer-copy {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 0 20px 18px;
}

/* ---------- Panel "Mis apuestas" (esquina, desplegable) ---------- */
.mybets-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.mybets-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow);
}
.mybets-toggle:hover { border-color: var(--accent); }
.mybets-count {
  background: var(--accent);
  color: #04110b;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 800;
}
.mybets-body {
  width: 300px;
  max-width: calc(100vw - 32px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.mybets-body-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
}
.mybets-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.mybets-close:hover { color: var(--text); }
.mybets-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 8px;
}
.mybets-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--bg-2);
}
.mybets-item:last-child { margin-bottom: 0; }
.mybets-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.mybets-type { font-weight: 700; font-size: 13px; }
.mybets-amt { font-size: 13px; color: var(--muted); font-weight: 700; }
.mybets-amt small { font-weight: 500; }
.mybets-item-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.mybets-round { color: var(--muted); }
.mybets-result { color: var(--info); font-weight: 700; }
.mybets-payout { color: var(--accent); font-weight: 700; margin-left: auto; }
.mybets-empty { text-align: center; color: var(--muted); padding: 16px; font-size: 13px; }

/* ---------- Legal pages ---------- */
.legal { max-width: 820px; margin: 0 auto; }
.legal h1 { font-size: 24px; margin-bottom: 18px; }
.legal h2 { font-size: 17px; margin: 22px 0 10px; color: var(--accent); }
.legal p, .legal li { color: var(--muted); font-size: 14px; line-height: 1.7; }
.legal ul { margin: 8px 0 8px 20px; }

/* ---------- Responsive / Móvil ---------- */
@media (max-width: 860px) {
  .app { padding: 20px 14px 70px; }
  .card { padding: 18px; }
  .number-display { font-size: 88px; }
  .number-stage { padding: 30px 18px; }
}

@media (max-width: 640px) {
  /* Topbar: se apila y la navegación se desliza horizontalmente */
  .topbar-inner { flex-wrap: wrap; gap: 8px 12px; padding: 12px 14px; }
  .brand { order: 0; }
  .topbar-right { order: 1; margin-left: auto; flex-wrap: wrap; gap: 8px; }
  .nav {
    order: 2;
    width: 100%;
    margin-left: 0;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; padding: 7px 11px; }

  .user-name { display: none; }
  .balance-label { display: none; }
  .balance-pill { padding: 6px 12px; }
  .mode-toggle button { padding: 7px 11px; }

  .brand-name { font-size: 14px; }
  .brand-mark { width: 30px; height: 30px; }

  /* Evita el auto-zoom de iOS al enfocar inputs */
  .input, .select { font-size: 16px; }

  .auth-wrap { margin: 24px auto; }
}

@media (max-width: 480px) {
  .number-display { font-size: 64px; margin: 10px 0; }
  .number-stage { padding: 24px 12px; }
  .round-meta { flex-wrap: wrap; gap: 10px 16px; }

  .bet-types { grid-template-columns: repeat(2, 1fr); }
  .bet-type { padding: 12px 6px; }
  .number-picker { grid-template-columns: repeat(5, 1fr); }
  .number-picker .num-btn { padding: 14px 0; }

  .amount-quick { flex-wrap: wrap; }
  .amount-quick .chip { flex: 1 1 28%; }

  .card-title { font-size: 16px; }
  .card { padding: 16px; }
  .stat-value { font-size: 20px; }

  .toast-container { left: 14px; right: 14px; }
  .toast { max-width: none; }

  .footer-inner { justify-content: center; text-align: center; }
  .footer-links { justify-content: center; }
}

