:root {
  --bg0: #070b14;
  --bg1: #0d1524;
  --panel: rgba(14, 22, 38, 0.88);
  --line: rgba(120, 160, 220, 0.16);
  --text: #e8eefc;
  --muted: #8ea0c0;
  --cyan: #4fd1ff;
  --green: #22c55e;
  --red: #ef4444;
  --violet: #a855f7;
  --big: #f59e0b;
  --small: #3b82f6;
  --gold: #fbbf24;
  --ok: #34d399;
  --bad: #fb7185;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Rajdhani", sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% -10%, #132447 0%, transparent 55%),
              radial-gradient(900px 500px at 100% 0%, #1a1030 0%, transparent 50%),
              linear-gradient(180deg, var(--bg0), var(--bg1));
  overflow-x: hidden;
}

.bg-glow {
  position: fixed; inset: -20%;
  background:
    radial-gradient(circle at 20% 20%, rgba(79, 209, 255, 0.08), transparent 35%),
    radial-gradient(circle at 80% 30%, rgba(168, 85, 247, 0.07), transparent 40%),
    radial-gradient(circle at 50% 90%, rgba(34, 197, 94, 0.06), transparent 40%);
  pointer-events: none; z-index: 0;
  animation: drift 18s ease-in-out infinite alternate;
}
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(120,160,220,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120,160,220,0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at center, black 30%, transparent 85%);
}
@keyframes drift {
  from { transform: translate3d(-1%, -1%, 0) scale(1); }
  to { transform: translate3d(1%, 1.5%, 0) scale(1.05); }
}

.topbar, .board, .legend, .foot { position: relative; z-index: 1; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 22px 8px; max-width: 1440px; margin: 0 auto;
}
.brand { display: flex; gap: 14px; align-items: center; }
.brand-mark {
  width: 52px; height: 52px; border-radius: 16px;
  display: grid; place-items: center;
  font-family: Orbitron, sans-serif; font-weight: 800; font-size: 24px;
  background: linear-gradient(145deg, #1d4ed8, #0ea5e9 55%, #22c55e);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.15), 0 10px 30px rgba(14,165,233,0.35);
  animation: pulseMark 2.8s ease-in-out infinite;
}
@keyframes pulseMark {
  0%, 100% { transform: translateY(0); filter: brightness(1); }
  50% { transform: translateY(-2px); filter: brightness(1.12); }
}
.brand h1 {
  margin: 0; font-family: Orbitron, sans-serif; font-size: 22px; letter-spacing: 1px;
}
.brand h1 span { color: var(--gold); }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; letter-spacing: 0.4px; }

.top-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat-pill {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  display: flex; align-items: center; gap: 8px;
  backdrop-filter: blur(8px);
}
.stat-pill .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; }
.stat-pill strong { font-family: Orbitron, sans-serif; font-size: 14px; }
.stat-pill.live .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7);
  animation: blink 1.4s infinite;
}
@keyframes blink {
  0% { box-shadow: 0 0 0 0 rgba(52,211,153,0.7); }
  70% { box-shadow: 0 0 0 8px rgba(52,211,153,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); }
}

.board {
  max-width: 1440px; margin: 0 auto;
  padding: 12px 16px 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 14px;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 40px rgba(0,0,0,0.28);
  display: flex; flex-direction: column; gap: 12px;
  animation: cardIn 0.55s ease both;
}
.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.12s; }
.card:nth-child(3) { animation-delay: 0.18s; }
.card:nth-child(4) { animation-delay: 0.24s; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.card-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.card-head h2 {
  margin: 0; font-family: Orbitron, sans-serif; font-size: 15px; letter-spacing: 0.5px;
}
.badge {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--cyan);
  background: rgba(79,209,255,0.08);
}
.badge.err { color: var(--bad); background: rgba(251,113,133,0.08); border-color: rgba(251,113,133,0.3); }

.timer-row {
  display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 10px;
}
.panel {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
}
.panel .label {
  color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px;
}
.period {
  font-family: Orbitron, sans-serif; font-size: 12px; margin-top: 6px;
  word-break: break-all; color: #c9d7f5;
}
.timer {
  font-family: Orbitron, sans-serif; font-size: 28px; margin-top: 4px;
  color: var(--cyan); letter-spacing: 2px;
  text-shadow: 0 0 18px rgba(79,209,255,0.35);
}
.timer.warn { color: #fbbf24; }
.timer.waiting { color: #fb7185; letter-spacing: 4px; animation: pulseWait 0.8s ease infinite; }
@keyframes pulseWait {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  30% { transform: translateX(-2px); }
  60% { transform: translateX(2px); }
}

.balls {
  display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px;
}
.ball {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: Orbitron, sans-serif; font-size: 11px; font-weight: 700;
  color: #fff; border: 1px solid rgba(255,255,255,0.2);
}
.ball.red { background: linear-gradient(145deg, #f87171, #b91c1c); }
.ball.green { background: linear-gradient(145deg, #4ade80, #15803d); }
.ball.violet { background: linear-gradient(145deg, #c084fc, #6b21a8); }
.ball.split-0 {
  background: linear-gradient(90deg, #a855f7 50%, #ef4444 50%);
}
.ball.split-5 {
  background: linear-gradient(90deg, #a855f7 50%, #22c55e 50%);
}

.hints {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.hint {
  border-radius: 14px; padding: 10px;
  text-align: center; border: 1px solid transparent;
  position: relative; overflow: hidden;
}
.hint::after {
  content: ""; position: absolute; inset: auto -20% -40% -20%; height: 70%;
  background: radial-gradient(circle, rgba(255,255,255,0.18), transparent 60%);
  animation: shine 3.2s ease-in-out infinite;
}
@keyframes shine {
  0%,100% { transform: translateX(-10%); opacity: 0.3; }
  50% { transform: translateX(10%); opacity: 0.7; }
}
.hint .t { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; opacity: 0.9; }
.hint .v {
  font-family: Orbitron, sans-serif; font-size: 18px; margin-top: 4px; position: relative; z-index: 1;
}
.hint .alt { font-size: 10px; margin-top: 3px; opacity: 0.75; position: relative; z-index: 1; color: #cbd5e1; }
.vip-tag {
  display: inline-block; margin-left: 4px; padding: 1px 6px; border-radius: 999px;
  font-size: 9px; letter-spacing: 0.5px; background: rgba(251,191,36,0.25); color: #fbbf24;
  border: 1px solid rgba(251,191,36,0.4); vertical-align: middle;
}
.hint.vip { box-shadow: 0 0 0 1px rgba(251,191,36,0.25); }
.hint.pro { box-shadow: 0 0 0 1px rgba(79,209,255,0.3); }
.hint.elite {
  box-shadow: 0 0 20px rgba(251,191,36,0.2), 0 0 0 1px rgba(251,191,36,0.45);
  animation: vipPulse 2s ease-in-out infinite;
}
@keyframes vipPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.15); }
}
.hint.color { background: linear-gradient(160deg, rgba(79,209,255,0.12), rgba(255,255,255,0.03)); border-color: rgba(79,209,255,0.25); }
.hint.number { background: linear-gradient(160deg, rgba(251,191,36,0.14), rgba(255,255,255,0.03)); border-color: rgba(251,191,36,0.28); }
.hint.size.big { background: linear-gradient(160deg, rgba(245,158,11,0.2), rgba(255,255,255,0.03)); border-color: rgba(245,158,11,0.35); }
.hint.size.small { background: linear-gradient(160deg, rgba(59,130,246,0.2), rgba(255,255,255,0.03)); border-color: rgba(59,130,246,0.35); }

.flow {
  font-size: 12px; color: var(--muted); line-height: 1.45;
}
.flow strong { color: #d7e3ff; font-weight: 600; }

.acc {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.acc .box {
  background: rgba(0,0,0,0.18); border-radius: 12px; padding: 8px; text-align: center;
  border: 1px solid var(--line);
}
.acc .box span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.acc .box b { font-family: Orbitron, sans-serif; font-size: 14px; }

.table-wrap {
  max-height: 220px; overflow: auto;
  border: 1px solid var(--line); border-radius: 12px;
}
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 7px 8px; text-align: left; border-bottom: 1px solid rgba(120,160,220,0.1); }
th { color: var(--muted); position: sticky; top: 0; background: #10182a; font-weight: 600; letter-spacing: 0.4px; }
td.period-cell { font-family: Orbitron, sans-serif; font-size: 10px; color: #b7c6e6; }
.chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 52px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
}
.chip.big { background: rgba(245,158,11,0.18); color: #fbbf24; }
.chip.small { background: rgba(59,130,246,0.18); color: #93c5fd; }
.dots { display: inline-flex; gap: 4px; vertical-align: middle; }
.dotc { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dotc.red { background: #ef4444; }
.dotc.green { background: #22c55e; }
.dotc.violet { background: #a855f7; }

.train-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--muted);
}
.train-tag.ok { color: var(--ok); }
.train-tag.bad { color: var(--bad); }

.legend {
  max-width: 1440px; margin: 8px auto 0; padding: 0 16px;
  display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 12px;
  align-items: center;
}
.legend .ball { width: 16px; height: 16px; font-size: 0; }
.legend .chip { min-width: 40px; }

.foot {
  max-width: 1440px; margin: 12px auto 24px; padding: 0 16px;
  color: var(--muted); font-size: 12px; line-height: 1.5;
}
.foot span { display: block; margin-top: 4px; color: #6f82a8; }

.error-box {
  padding: 12px; border-radius: 12px;
  background: rgba(251,113,133,0.08); border: 1px solid rgba(251,113,133,0.25);
  color: #fecdd3; font-size: 13px;
}

@media (max-width: 980px) {
  .board { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .timer { font-size: 24px; }
}
