:root {
  --ink: #ffffff;
  --muted: #e8e8e8;
  --bg: #100d14;
  --card: rgba(28, 20, 27, 0.84);
  --line: rgba(255, 214, 150, 0.14);
  --crimson: #c81d3a;
  --gold: #e4b44c;
  --jade: #3ecf8e;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color-scheme: dark;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(200, 29, 58, 0.22), transparent 50%),
    radial-gradient(900px 400px at 100% 0%, rgba(228, 180, 76, 0.12), transparent 45%),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Yu Gothic UI", "Hiragino Sans", sans-serif;
}

.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(40px);
  pointer-events: none;
  z-index: 0;
}
.orb-a { width: 280px; height: 280px; background: rgba(200, 29, 58, 0.18); top: 12%; left: -80px; }
.orb-b { width: 220px; height: 220px; background: rgba(228, 180, 76, 0.12); right: -40px; top: 40%; }

body > * { position: relative; z-index: 1; }

.nav, .topbar, main, footer { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }

.nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  background: rgba(16, 13, 20, 0.86);
  backdrop-filter: blur(12px);
}

.brand {
  color: var(--gold);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.nav-links { display: flex; flex-wrap: wrap; gap: 8px; }

.nav-links a {
  color: var(--ink);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.nav-links a.active {
  border-color: var(--gold);
  background: rgba(228, 180, 76, 0.12);
  color: var(--gold);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding: 36px 0 18px;
}

.eyebrow {
  margin: 0 0 6px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  font-size: 12px;
}

h1 {
  margin: 0;
  font-size: clamp(36px, 6vw, 64px);
  letter-spacing: 0.04em;
  line-height: 0.95;
}

h1 span {
  display: block;
  margin-top: 8px;
  font-size: 18px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0;
}

.lede, .panel p, .hint, footer { color: var(--muted); }

.top-actions, .controls, .manual, .window-row, .stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.top-actions {
  align-items: flex-end;
}

.top-actions .field.compact {
  min-width: 108px;
}

.top-actions select {
  height: 42px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.panel-head h2 { margin: 0 0 6px; font-size: 22px; }
.panel-head p { margin: 0; }

.stats { margin-bottom: 18px; }

.stat {
  flex: 1 1 160px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px 18px;
}

.stat b { display: block; font-size: 28px; color: var(--gold); }
.stat span { color: var(--muted); font-size: 13px; }

.field { display: grid; gap: 6px; min-width: 150px; }
.field.compact { min-width: 110px; }
.field span { font-size: 12px; color: var(--muted); }

input, select, button {
  font: inherit;
  color: var(--ink);
}

input, select {
  background: #221820;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.btn {
  border: 1px solid var(--line);
  background: #2a1f27;
  border-radius: 12px;
  padding: 11px 16px;
  cursor: pointer;
}

.btn.primary {
  background: linear-gradient(180deg, #e23b55, #b21430);
  border-color: transparent;
  font-weight: 700;
}

.btn.ghost { background: transparent; }
.btn:hover { filter: brightness(1.08); }
.btn.danger { color: #ffb3bf; }
.btn { color: #fff; }

.icon-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  flex: 0 0 42px;
  align-self: flex-end;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  display: block;
}

.icon-btn.is-syncing svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.tickets { display: grid; gap: 14px; margin-top: 16px; }

.ticket {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
}

.balls { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }

.ball {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #3a1020;
  background: radial-gradient(circle at 30% 25%, #fff7e4, #e4b44c 55%, #b8862a);
  box-shadow: inset 0 -6px 10px rgba(0,0,0,0.18);
}

.ticket small { color: var(--muted); display: block; line-height: 1.5; }

.layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
}

.board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.cell {
  aspect-ratio: 1;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  border: 1px solid transparent;
}

.cell.unused { background: rgba(62, 207, 142, 0.16); color: var(--jade); border-color: rgba(62, 207, 142, 0.35); }
.cell.used { background: rgba(200, 29, 58, 0.16); color: #ff8ea0; border-color: rgba(200, 29, 58, 0.28); }

.legend { margin-top: 12px; color: var(--muted); font-size: 13px; }

.steps { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.7; }
.steps code { color: var(--gold); }
.note { font-size: 13px; }

.manual input { width: 92px; }
.manual input[name="draw_date"] { width: 150px; }
.manual input[name="draw_no"] { width: 120px; }

.table-wrap { overflow: auto; margin-top: 16px; }

table { width: 100%; border-collapse: collapse; color: #fff; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 14px; color: #fff; }
th { color: #fff; font-weight: 600; }

.mini-balls { display: flex; gap: 6px; flex-wrap: wrap; }
.mini {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #3a2a22;
  color: #fff;
  font-size: 12px;
}
.mini.bonus { background: var(--crimson); color: #fff; }

footer { padding: 10px 0 40px; font-size: 13px; }

.howto { margin: 12px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.75; }
.howto b { color: var(--ink); }

.compare, .charts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

.game-card h3 { margin: 6px 0 8px; }
.facts { margin: 12px 0; padding: 0; list-style: none; }
.facts li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.facts span { color: var(--muted); }
.game-card .btn { display: inline-block; margin-top: 8px; text-decoration: none; }

.chart-block {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}

.chart-block h3 { margin: 0 0 14px; }
.bar-row { display: grid; grid-template-columns: 42px 1fr; gap: 8px 12px; margin-bottom: 12px; align-items: center; }
.bar-label { color: var(--gold); font-weight: 700; }
.bar-track { grid-column: 2; height: 10px; border-radius: 999px; background: #2a1f27; overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #e4b44c, #c81d3a); }
.bar-value { grid-column: 2; }
.bar-value b { display: block; }
.bar-value small { display: block; color: var(--muted); font-size: 12px; }

.row-actions { display: flex; gap: 8px; white-space: nowrap; }

.modal {
  border: 0;
  padding: 0;
  background: transparent;
  color: #fff;
  max-width: 720px;
  width: calc(100% - 32px);
}
.modal::backdrop { background: rgba(8, 6, 10, 0.72); }
.modal-card {
  background: #1c141b;
  color: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.modal-card header { display: flex; justify-content: space-between; gap: 16px; align-items: start; margin-bottom: 16px; }
.modal-card h2,
.modal-card p,
.modal-card .hint,
.modal-card th,
.modal-card td { margin: 0; color: #fff; }
.modal-card .hint { margin-top: 12px; }
.btn { color: #fff; }
.bonus-ball { background: radial-gradient(circle at 30% 25%, #ffd0d8, #c81d3a 55%, #8a1024); color: #fff; }

@media (max-width: 840px) {
  .topbar, .layout, .compare, .charts { display: block; }
  .top-actions { margin-top: 16px; }
  .nav { flex-direction: column; align-items: start; }
}
