/* Palette follows the logo: green #037d3b · gold #f6b600 · navy #03214f */
:root {
  --c-primary: #037d3b;
  --c-primary-hover: #02652f;
  --c-primary-pressed: #014a22;
  --c-on-primary: #ffffff;
  --c-tint-100: #c6e7d3;
  --c-tint-50: #e9f6ee;
  --c-gold: #f6b600;
  --c-gold-50: #fff6d9;
  --c-gold-ink: #6b4c00;
  --c-navy: #03214f;
  --c-heading: #03214f;
  --c-fg: #3c4658;
  --c-caption: #5f6878;
  --c-grey-500: #a3abba;
  --c-border: #e6ece9;
  --c-surface: #f5f8f6;
  --c-canvas: #ffffff;
  --c-danger: #d93a3a;
  --c-success: #2fb36a;

  /* ball families */
  --b1-bg: #fff1c2; --b1-fg: #6b4c00;
  --b2-bg: #d3eedd; --b2-fg: #024d24;
  --b3-bg: #dbe3f3; --b3-fg: #03214f;
  --b4-bg: #ffe2d1; --b4-fg: #7a3410;
  --b5-bg: #ffd9d9; --b5-fg: #9e1924;
  --pb-bg: #03214f; --pb-fg: #ffffff;

  --shadow: rgba(3, 33, 79, 0.06) 0 1px 4px;
  --r-md: 12px;
  --r-lg: 16px;
  --header-h: 76px;
  --font: "Alan Sans", AlanSans, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c-primary: #2fb36a;
    --c-primary-hover: #45c47c;
    --c-primary-pressed: #6fd69b;
    --c-on-primary: #04230f;
    --c-tint-100: #145c34;
    --c-tint-50: #0f3221;
    --c-gold-50: #3a2e08;
    --c-gold-ink: #ffd75e;
    --c-heading: #f1f4fa;
    --c-fg: #c9d1df;
    --c-caption: #93a0b6;
    --c-grey-500: #5e6b82;
    --c-border: #1e2b44;
    --c-surface: #0a1324;
    --c-canvas: #111d33;
    --b1-bg: #4a3800; --b1-fg: #ffe9a3;
    --b2-bg: #0f4a2a; --b2-fg: #c9f0d8;
    --b3-bg: #22355e; --b3-fg: #dbe3f3;
    --b4-bg: #5a2c14; --b4-fg: #ffe2d1;
    --b5-bg: #5c1d23; --b5-fg: #ffd9d9;
    --pb-bg: #f6b600; --pb-fg: #03214f;
    --shadow: rgba(0, 0, 0, 0.4) 0 1px 4px;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--c-fg);
  background: var(--c-surface);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { color: var(--c-heading); margin: 0; line-height: 1.2; }
h1 { font-size: clamp(26px, 5vw, 44px); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; margin: 24px 0 8px; }
.panel h3:first-child { margin-top: 0; }
button, select { font: inherit; }
button { touch-action: manipulation; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.caption { color: var(--c-caption); font-size: 14px; }
.small { font-size: 13px; margin: 4px 0 8px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--c-canvas) 90%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--c-border);
  padding-top: env(safe-area-inset-top);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: var(--header-h); gap: 12px; }
.brand { display: flex; align-items: center; text-decoration: none; flex: none; border-radius: 10px; }
.brand img { display: block; height: 52px; width: auto; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand { background: #fff; padding: 4px 10px; }
  :root:not([data-theme="light"]) .brand img { height: 44px; }
}
.live { display: flex; align-items: center; gap: 8px; font-size: 13.33px; color: var(--c-caption); padding: 6px 12px; border-radius: var(--r-lg); background: var(--c-surface); white-space: nowrap; min-width: 0; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-grey-500); flex: none; }
.live.ok .live-dot { background: var(--c-success); animation: pulse 2s infinite; }
.live.err .live-dot { background: var(--c-danger); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(47,179,106,.6); } 50% { box-shadow: 0 0 0 5px rgba(47,179,106,0); } }

[hidden] { display: none !important; }

/* Visitors */
.visitors { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--c-caption); padding: 6px 12px; border-radius: var(--r-lg); background: var(--c-surface); white-space: nowrap; }
.visitors b { color: var(--c-heading); font-weight: 700; font-variant-numeric: tabular-nums; }
.visitors .live-dot { background: var(--c-success); animation: pulse 2s infinite; }

/* Title line */
.topline { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; padding: 24px 0 16px; }
.topline h1 { font-size: clamp(20px, 3vw, 28px); }
.eyebrow { display: inline-block; padding: 4px 12px; border-radius: var(--r-lg); background: var(--c-gold-50); color: var(--c-gold-ink); font-weight: 600; font-size: 13px; }

/* View switch (desktop); the bottom tabbar replaces it on phones */
.views { display: flex; gap: 4px; margin: 0 0 16px; border-bottom: 1px solid var(--c-border); }
.views button {
  border: 0; background: none; height: 44px; padding: 0 16px; font-size: 15px; color: var(--c-caption); cursor: pointer;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.views button.on { color: var(--c-primary); border-bottom-color: var(--c-primary); font-weight: 600; }
.subtabs { display: none; }
.latest-card .live { margin: 16px 0 0; padding: 0; background: none; font-size: 12px; }

/* Day tabs */
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 6px; background: var(--c-canvas); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.days button {
  border: 0; background: transparent; color: var(--c-heading); height: 48px; border-radius: var(--r-md);
  cursor: pointer; font-size: 15px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; position: relative;
}
.days button small { font-size: 11px; color: var(--c-caption); margin-top: 3px; }
.days button.on { background: var(--c-primary); color: var(--c-on-primary); }
.days button.on small { color: inherit; opacity: .8; }
.days button.today::after { content: ""; position: absolute; top: 6px; right: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--c-gold); }

/* Game cards */
.games { display: flex; gap: 12px; margin: 16px 0 24px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; scroll-snap-type: x mandatory; }
.games::-webkit-scrollbar { display: none; }
.game {
  flex: 1 0 200px; text-align: left; border: 2px solid transparent; background: var(--c-canvas); border-radius: var(--r-lg);
  padding: 16px; box-shadow: var(--shadow); cursor: pointer; color: var(--c-fg); scroll-snap-align: start;
}
.game.on { border-color: var(--c-primary); }
.game strong { display: block; color: var(--c-heading); font-size: 17px; }
.game .rule { font-size: 13px; color: var(--c-caption); }
.game .jackpot { margin-top: 10px; display: flex; gap: 4px; flex-wrap: wrap; }

/* Cards */
.card { background: var(--c-canvas); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 24px; margin-bottom: 24px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head.wrap-row { align-items: center; }
.card-head p { margin: 4px 0 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-2 > .card { margin-bottom: 0; }
section.grid-2 { margin-bottom: 24px; }
.grid-2.tight { gap: 16px; margin-top: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 24px; }
.panel { background: var(--c-surface); border-radius: var(--r-lg); padding: 16px; min-width: 0; }
#bonusPanel { margin-top: 16px; }

/* Balls */
.ball {
  --bg: var(--b1-bg); --fg: var(--b1-fg);
  width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--fg); font-weight: 700; font-size: 16px; flex: none; font-variant-numeric: tabular-nums;
}
.ball.r2 { --bg: var(--b2-bg); --fg: var(--b2-fg); }
.ball.r3 { --bg: var(--b3-bg); --fg: var(--b3-fg); }
.ball.r4 { --bg: var(--b4-bg); --fg: var(--b4-fg); }
.ball.r5 { --bg: var(--b5-bg); --fg: var(--b5-fg); }
.ball.sm { width: 30px; height: 30px; font-size: 13px; }
.ball.xs { width: 24px; height: 24px; font-size: 11px; }
.ball.supp { background: transparent; box-shadow: inset 0 0 0 2px var(--fg); color: var(--c-heading); }
.ball.pb { background: var(--pb-bg); color: var(--pb-fg); }
.ball.pop { animation: pop .35s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.balls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.plus { color: var(--c-grey-500); font-weight: 600; margin: 0 2px; }

/* Latest */
.latest .meta { display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 14px; color: var(--c-caption); }
.latest .meta strong { color: var(--c-heading); }
.latest .balls .ball { width: 44px; height: 44px; font-size: 17px; }
.prizes { margin-top: 20px; display: grid; grid-template-columns: auto 1fr auto; gap: 6px 16px; font-size: 14px; }
.prizes .h { color: var(--c-caption); font-size: 12px; }
.prizes .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--c-heading); }
.skeleton { height: 120px; border-radius: var(--r-md); background: linear-gradient(90deg, var(--c-surface), var(--c-border), var(--c-surface)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* Controls */
.controls { display: flex; gap: 12px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1 1 220px; font-size: 13px; color: var(--c-caption); }
.field-sm { flex: 0 1 110px; }
.field select {
  height: 48px; border-radius: var(--r-lg); border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-heading);
  padding: 0 14px; font-size: 16px; min-width: 0; width: 100%;
}
.picker { margin-top: 16px; border: 1px solid var(--c-border); border-radius: var(--r-lg); padding: 0 16px; }
.picker summary { cursor: pointer; color: var(--c-heading); font-size: 15px; display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 48px; list-style: none; }
.picker summary::-webkit-details-marker { display: none; }
.picker[open] { padding-bottom: 16px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.pick-grid button {
  height: 40px; border-radius: 10px; border: 1px solid var(--c-border); background: var(--c-canvas); color: var(--c-heading); cursor: pointer; font-size: 14px; font-variant-numeric: tabular-nums;
}
.pick-grid button.fix { background: var(--c-primary); color: var(--c-on-primary); border-color: var(--c-primary); }
.pick-grid button.ex { background: var(--c-surface); color: var(--c-grey-500); text-decoration: line-through; }

.actions { display: flex; gap: 12px; margin-top: 16px; }
.btn {
  height: 48px; padding: 0 22px; border-radius: var(--r-lg); font-size: 16px; font-weight: 500; cursor: pointer; box-shadow: var(--shadow);
  border: 1px solid transparent;
}
.btn-primary { background: var(--c-primary); color: var(--c-on-primary); flex: 1; }
.btn-primary:active { background: var(--c-primary-pressed); }
.btn-secondary { background: var(--c-canvas); color: var(--c-primary); border-color: var(--c-border); }
.btn-secondary:active { border-color: var(--c-surface); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-block { width: 100%; margin-top: 16px; }

.tickets { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tickets li { display: flex; align-items: center; gap: 8px 12px; padding: 10px 12px; border-radius: var(--r-md); background: var(--c-surface); flex-wrap: wrap; }
.tickets .idx { width: 18px; color: var(--c-caption); font-size: 13px; font-weight: 600; }
.tickets .tags { margin-left: auto; display: flex; gap: 6px; font-size: 12px; color: var(--c-caption); }
.tag { padding: 2px 8px; border-radius: 10px; background: var(--c-canvas); white-space: nowrap; }

/* Segment */
.seg { display: inline-flex; background: var(--c-surface); border-radius: var(--r-lg); padding: 4px; gap: 2px; }
.seg button { border: 0; background: transparent; height: 36px; padding: 0 14px; border-radius: var(--r-md); font-size: 13.33px; color: var(--c-heading); cursor: pointer; }
.seg button.on { background: var(--c-canvas); color: var(--c-primary); font-weight: 600; box-shadow: var(--shadow); }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { background: var(--c-surface); border-radius: var(--r-lg); padding: 14px 16px; min-width: 0; }
.stat .k { font-size: 13px; color: var(--c-caption); }
.stat .v { font-size: 24px; font-weight: 700; color: var(--c-heading); font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--c-caption); }

/* Frequency chart */
.freq { position: relative; display: flex; align-items: flex-end; gap: 2px; height: 200px; padding-bottom: 22px; }
.freq-sm { height: 140px; }
.freq .bar { flex: 1; min-width: 0; position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; cursor: pointer; }
.freq .fill { background: var(--c-tint-100); border-radius: 4px 4px 0 0; transition: height .4s ease, background .2s; }
.freq .bar.hot .fill { background: var(--c-primary); }
.freq .bar.cold .fill { background: var(--c-grey-500); }
.freq .bar.sel .fill { background: var(--c-gold); }
.freq .lbl { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--c-caption); font-variant-numeric: tabular-nums; }
.freq .expect { position: absolute; left: 0; right: 0; border-top: 1.5px dashed var(--c-caption); opacity: .5; pointer-events: none; }
.tip {
  position: fixed; z-index: 30; pointer-events: none; background: var(--c-navy); color: #fff; font-size: 12px; padding: 6px 10px;
  border-radius: 8px; white-space: nowrap; opacity: 0; transition: opacity .1s;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--c-caption); }

.dist { display: flex; flex-direction: column; gap: 6px; }
.row { display: grid; grid-template-columns: 68px 1fr 46px; align-items: center; gap: 8px; font-size: 13px; }
.row .track { height: 10px; background: var(--c-canvas); border-radius: 6px; overflow: hidden; }
.row .track i { display: block; height: 100%; background: var(--c-gold); border-radius: 6px; }
.row .pct { text-align: right; color: var(--c-heading); font-variant-numeric: tabular-nums; }

/* History */
.table-wrap { overflow-x: auto; }
.history { width: 100%; border-collapse: collapse; font-size: 14px; }
.history th { text-align: left; font-weight: 500; color: var(--c-caption); font-size: 13px; padding: 8px; border-bottom: 1px solid var(--c-border); }
.history td { padding: 8px; border-bottom: 1px solid var(--c-border); white-space: nowrap; }
.history td:first-child { color: var(--c-heading); font-weight: 600; }

.foot { padding: 8px 0 48px; font-size: 13px; color: var(--c-caption); max-width: 760px; }

/* Mobile bottom navigation */
.tabbar { display: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--c-navy); color: #fff;
  padding: 10px 18px; border-radius: var(--r-lg); font-size: 14px; opacity: 0; transition: .25s; pointer-events: none; max-width: calc(100% - 32px); z-index: 40;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Hover only where a real pointer exists, so taps don't leave sticky hover states */
@media (hover: hover) {
  .days button:not(.on):hover { background: var(--c-surface); }
  .game:not(.on):hover { border-color: var(--c-tint-100); }
  .btn-primary:hover { background: var(--c-primary-hover); }
  .seg button:not(.on):hover { background: var(--c-canvas); }
  .freq .bar:hover .fill { background: var(--c-gold); }
}

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

@media (max-width: 600px) {
  :root { --header-h: 64px; }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .brand img { height: 44px; }
  .visitors { padding: 5px 10px; font-size: 12px; }
  .visitors .v-more { display: none; }

  .topline { padding: 14px 0 10px; }
  .topline h1 { font-size: 18px; }
  .eyebrow { font-size: 12px; padding: 3px 10px; }
  .views { display: none; }

  .days { gap: 2px; padding: 4px; }
  .days button { font-size: 15px; height: 44px; }
  .days button small { display: none; }
  .days button.today::after { top: 5px; right: 5px; }

  .games { margin: 12px -16px 16px; padding: 0 16px 4px; scroll-padding: 0 16px; }
  .game { flex: 0 0 78%; padding: 14px; }
  .games .game:only-child { flex-basis: 100%; }

  .card { padding: 18px 16px; margin-bottom: 16px; border-radius: var(--r-lg); }
  .grid-2 { gap: 16px; }
  section.grid-2 { margin-bottom: 16px; }
  .card-head { margin-bottom: 12px; }
  h2 { font-size: 18px; }

  .ball { width: 36px; height: 36px; font-size: 15px; }
  .latest .balls { gap: 5px; }
  .latest .balls .ball { width: 36px; height: 36px; font-size: 15px; }
  .prizes { gap: 6px 10px; font-size: 13px; }

  .controls { flex-wrap: nowrap; gap: 8px; }
  .field { flex: 1 1 auto; }
  .field-sm { flex: 0 0 84px; }
  .field select { padding: 0 10px; }
  .picker { margin-top: 12px; }
  .actions { margin-top: 12px; }

  .tickets li { padding: 10px; }
  .tickets .balls { gap: 4px; }
  .tickets .ball.sm { width: 30px; height: 30px; font-size: 13px; }
  .tickets .tags { margin-left: 30px; flex-basis: 100%; }

  .card-head.wrap-row { flex-direction: column; align-items: stretch; }
  .seg { display: flex; }
  .seg button { flex: 1; height: 40px; padding: 0 6px; }

  .subtabs { display: flex; gap: 6px; margin: 16px 0 4px; }
  .subtabs button { flex: 1; height: 38px; border-radius: var(--r-lg); border: 1px solid var(--c-border); background: var(--c-canvas); color: var(--c-heading); font-size: 13px; }
  .subtabs button.on { background: var(--c-tint-50); border-color: var(--c-primary); color: var(--c-primary); font-weight: 600; }
  #statsCard[data-sub="freq"] .sub:not([data-sub="freq"]),
  #statsCard[data-sub="hotcold"] .sub:not([data-sub="hotcold"]),
  #statsCard[data-sub="dist"] .sub:not([data-sub="dist"]) { display: none; }
  .sub > h3:first-child { margin-top: 12px; }

  .stats { gap: 8px; }
  .stat { padding: 12px; }
  .stat .v { font-size: 20px; }

  .freq { height: 160px; padding-bottom: 20px; gap: 1px; }
  .freq .lbl { display: none; }
  .freq .bar:nth-child(5n) .lbl, .freq .bar:first-child .lbl { display: block; }
  .grid-3 { gap: 12px; margin-top: 16px; }
  .panel { padding: 14px; }
  .chips { gap: 6px; }

  /* History as stacked rows */
  .history thead { display: none; }
  .history tr { display: grid; grid-template-columns: 1fr auto; gap: 6px 8px; padding: 10px 0; border-bottom: 1px solid var(--c-border); }
  .history td { padding: 0; border: 0; }
  .history td:nth-child(2) { text-align: right; color: var(--c-caption); font-size: 13px; }
  .history td:nth-child(3) .balls, .history td:nth-child(4) .balls { gap: 3px; flex-wrap: nowrap; }
  .history td:nth-child(4) { justify-self: end; }

  .foot { padding-bottom: 24px; }

  .tabbar {
    display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: color-mix(in srgb, var(--c-canvas) 94%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--c-border); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    text-decoration: none; color: var(--c-caption); font-size: 11px;
  }
  .tabbar a.on { color: var(--c-primary); font-weight: 600; }
  .tabbar svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

@media (max-width: 360px) {
  .ball, .latest .balls .ball { width: 32px; height: 32px; font-size: 14px; }
  .tickets .ball.sm { width: 27px; height: 27px; font-size: 12px; }
  .history .ball.xs { width: 22px; height: 22px; font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
