/* ═══════════════════════════════════════════════════════════════════
   KAPALJUDI — Liquid Glass (violet)
   All colours and glass materials are tokens on :root; the light theme
   only redefines tokens. Three glass levels: clear / regular / tinted.
   ═══════════════════════════════════════════════════════════════════ */

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

:root {
  /* palette */
  --violet-300: #C4B5FD;
  --violet-400: #A78BFA;
  --violet-500: #8B5CF6;
  --violet-700: #6D28D9;
  --violet-900: #4C1D95;
  --fuchsia-400: #E879F9;
  --fuchsia-500: #D946EF;
  --fuchsia-700: #A21CAF;
  --indigo-400: #818CF8;
  --indigo-500: #6366F1;

  --primary: var(--violet-500);
  --accent: var(--fuchsia-500);

  /* surfaces & text — dark (default) */
  --bg-0: #0B0614;
  --bg-1: #1E1033;
  --bg-2: #3B0764;
  --bg-photo-overlay: linear-gradient(160deg, rgba(11, 6, 20, 0.86) 0%, rgba(30, 16, 51, 0.74) 55%, rgba(59, 7, 100, 0.72) 100%);
  --txt: #F5F3FF;
  --txt-2: #DDD6FE;
  --txt-3: #B3A8D6;
  --primary-txt: #C4B5FD;
  --accent-txt: #F0ABFC;
  --on-accent: #FFFFFF;
  --red: #FDA4AF;

  /* glass material */
  --g-clear: rgba(255, 255, 255, 0.06);
  --g-regular: rgba(255, 255, 255, 0.09);
  --g-tinted: rgba(27, 13, 48, 0.74);
  --g-tint: rgba(139, 92, 246, 0.08);
  --g-border: rgba(255, 255, 255, 0.16);
  --g-spec: rgba(255, 255, 255, 0.30);
  --g-reflect: rgba(255, 255, 255, 0.18);
  --g-rim: rgba(255, 255, 255, 0.55);
  --g-spot: rgba(196, 181, 253, 0.22);
  --g-shadow: 0 10px 40px rgba(139, 92, 246, 0.18);
  --g-shadow-hi: 0 18px 50px rgba(139, 92, 246, 0.30);
  --g-blur: blur(24px) saturate(170%);
  --g-blur-sm: blur(14px) saturate(160%);
  --g-inset: inset 0 1px 0 var(--g-spec);

  --chip-bg: rgba(139, 92, 246, 0.16);
  --chip-border: rgba(196, 181, 253, 0.26);
  --hover-fill: rgba(139, 92, 246, 0.16);
  --zebra: rgba(255, 255, 255, 0.025);
  --line: rgba(255, 255, 255, 0.08);
  --track: rgba(255, 255, 255, 0.07);

  /* shape & motion */
  --r-xl: 32px;
  --r-lg: 26px;
  --r-md: 20px;
  --r-sm: 14px;
  --r-xs: 10px;
  --pill: 999px;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 380ms;

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --focus-ring: 0 0 0 2px var(--bg-0), 0 0 0 4px var(--violet-400);
  --nav-offset: 96px;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg-0: #FAF5FF;
  --bg-1: #EDE9FE;
  --bg-2: #F5F3FF;
  --bg-photo-overlay: linear-gradient(160deg, rgba(250, 245, 255, 0.88) 0%, rgba(237, 233, 254, 0.80) 55%, rgba(221, 214, 254, 0.78) 100%);
  --txt: #1E1B4B;
  --txt-2: #36306B;
  --txt-3: #5A548A;
  --primary-txt: #6D28D9;
  --accent-txt: #A21CAF;
  --red: #BE123C;

  --g-clear: rgba(255, 255, 255, 0.50);
  --g-regular: rgba(255, 255, 255, 0.60);
  --g-tinted: rgba(255, 255, 255, 0.80);
  --g-tint: rgba(139, 92, 246, 0.05);
  --g-border: rgba(255, 255, 255, 0.85);
  --g-spec: rgba(255, 255, 255, 0.95);
  --g-reflect: rgba(255, 255, 255, 0.55);
  --g-rim: rgba(255, 255, 255, 1);
  --g-spot: rgba(167, 139, 250, 0.20);
  --g-shadow: 0 10px 40px rgba(109, 40, 217, 0.14), 0 0 0 1px rgba(109, 40, 217, 0.06);
  --g-shadow-hi: 0 18px 50px rgba(109, 40, 217, 0.22), 0 0 0 1px rgba(109, 40, 217, 0.10);

  --chip-bg: rgba(139, 92, 246, 0.10);
  --chip-border: rgba(109, 40, 217, 0.20);
  --hover-fill: rgba(139, 92, 246, 0.10);
  --zebra: rgba(109, 40, 217, 0.03);
  --line: rgba(109, 40, 217, 0.10);
  --track: rgba(109, 40, 217, 0.08);
  --focus-ring: 0 0 0 2px var(--bg-0), 0 0 0 4px var(--violet-700);

  color-scheme: light;
}

/* Reduced transparency: glass becomes solid, no blur. */
@media (prefers-reduced-transparency: reduce) {
  :root {
    --g-clear: #22123A; --g-regular: #22123A; --g-tinted: #1A0D2E; --g-tint: transparent;
    --g-blur: none; --g-blur-sm: none; --g-reflect: transparent; --g-spot: transparent;
  }
  :root[data-theme="light"] {
    --g-clear: #FFFFFF; --g-regular: #FFFFFF; --g-tinted: #FFFFFF;
  }
  .aurora .blob { opacity: 0.35; }
}

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: var(--font);
  font-feature-settings: 'cv11', 'ss01';
  color: var(--txt);
  background: var(--bg-0);
  background-image: linear-gradient(160deg, var(--bg-0) 0%, var(--bg-1) 55%, var(--bg-2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
/* Photo backdrop tinted violet. A fixed pseudo-element instead of
   background-attachment: fixed, which iOS Safari ignores on body. */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: var(--bg-photo-overlay), url('img/background.png') center 70% / cover no-repeat;
}
:is(a, button, select, input, [tabindex]):focus-visible { outline: none; box-shadow: var(--focus-ring); }
::selection { background: rgba(217, 70, 239, 0.35); color: var(--txt); }
img { max-width: 100%; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ─── AURORA BACKGROUND ─── */
.aurora { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.blob {
  position: absolute; border-radius: 50%;
  width: 70vmax; height: 70vmax;
  opacity: 0.55;
  will-change: transform;
}
.blob-a { top: -30vmax; left: -20vmax; background: radial-gradient(circle, rgba(139, 92, 246, 0.55), transparent 62%); animation: drift-a 48s ease-in-out infinite alternate; }
.blob-b { top: 20vh; right: -30vmax; background: radial-gradient(circle, rgba(217, 70, 239, 0.38), transparent 62%); animation: drift-b 60s ease-in-out infinite alternate; }
.blob-c { bottom: -35vmax; left: 10vw; background: radial-gradient(circle, rgba(99, 102, 241, 0.40), transparent 62%); animation: drift-c 56s ease-in-out infinite alternate; }
.blob-d { top: 45vh; left: -25vmax; width: 50vmax; height: 50vmax; background: radial-gradient(circle, rgba(109, 40, 217, 0.45), transparent 62%); animation: drift-b 70s ease-in-out infinite alternate-reverse; }
:root[data-theme="light"] .blob { opacity: 0.32; }
@keyframes drift-a { to { transform: translate3d(12vw, 10vh, 0) scale(1.08); } }
@keyframes drift-b { to { transform: translate3d(-10vw, -8vh, 0) scale(0.94); } }
@keyframes drift-c { to { transform: translate3d(8vw, -12vh, 0) scale(1.1); } }

/* ═══ LIQUID GLASS MATERIAL ═══
   Every glass surface shares: translucent fill + violet tint, backdrop blur,
   hairline border, top specular inset, floating violet shadow.
   ::before = diagonal reflection + cursor-follow highlight (--spot-x/y set by script.js)
   ::after  = specular rim, brightens on hover. */
:is(.nav-inner, .draw-header, .prize-card-new, .sub-prize-card, .history-card, .glass, .date-select,
    .disclaimer, .footer-inner, .sk-block, .mimpi-search-wrap, .dh-chip) {
  position: relative;
  isolation: isolate;
  background-color: var(--g-regular);
  background-image: linear-gradient(var(--g-tint), var(--g-tint));
  -webkit-backdrop-filter: var(--g-blur);
  backdrop-filter: var(--g-blur);
  border: 1px solid var(--g-border);
  box-shadow: var(--g-inset), var(--g-shadow);
}
/* glass levels */
:is(.disclaimer, .footer-inner, .dh-chip, .mimpi-search-wrap, .date-select, .sk-block) { background-color: var(--g-clear); }
:is(.history-card, .paito-row, .toto-match-frequency-card) { background-color: var(--g-tinted); }

:is(.nav-inner, .draw-header, .prize-card-new, .sub-prize-card, .history-card, .glass, .date-select,
    .disclaimer, .footer-inner, .mimpi-search-wrap)::before {
  content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background:
    radial-gradient(240px circle at var(--spot-x, -999px) var(--spot-y, -999px), var(--g-spot), transparent 70%),
    linear-gradient(135deg, var(--g-reflect), transparent 40%);
}
:is(.nav-inner, .draw-header, .prize-card-new, .sub-prize-card, .history-card, .glass, .date-select,
    .footer-inner, .mimpi-search-wrap)::after {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  padding: 1px;
  background: linear-gradient(160deg, var(--g-rim), transparent 32%, transparent 68%, rgba(217, 70, 239, 0.45));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.45;
  transition: opacity var(--dur) ease;
}
:is(.draw-header, .prize-card-new, .sub-prize-card, .history-card, .glass, .date-select, .mimpi-search-wrap):hover::after { opacity: 1; }

/* lift on hover for card-like glass */
:is(.prize-card-new, .sub-prize-card, .glass) {
  transition: transform var(--dur) var(--spring), box-shadow var(--dur) ease, background-color var(--dur) ease;
}
:is(.prize-card-new, .sub-prize-card, .glass):hover { transform: translateY(-2px); box-shadow: var(--g-inset), var(--g-shadow-hi); }

/* pill controls (tabs, chips) — a lighter glass with no pseudo layers */
:is(.paito-btn, .mimpi-cat, .theme-toggle) {
  background: var(--g-clear);
  -webkit-backdrop-filter: var(--g-blur-sm);
  backdrop-filter: var(--g-blur-sm);
  border: 1px solid var(--g-border);
  box-shadow: var(--g-inset);
  color: var(--txt-2);
  border-radius: var(--pill);
  font-family: var(--font);
  cursor: pointer;
  transition: transform var(--dur) var(--spring), background var(--dur) ease, color 200ms ease, box-shadow var(--dur) ease;
}
:is(.paito-btn, .mimpi-cat, .theme-toggle):hover { color: var(--txt); transform: translateY(-1px); background: var(--hover-fill); }
:is(.paito-btn, .mimpi-cat):active { transform: scale(0.96); }
:is(.paito-btn, .mimpi-cat).active {
  color: #fff;
  background: linear-gradient(135deg, var(--violet-500), var(--fuchsia-500));
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 6px 20px rgba(217, 70, 239, 0.35);
}

/* ─── NAV: floating glass pill ─── */
.main-nav { position: sticky; top: 0; z-index: 100; padding: 14px 16px 0; transition: padding var(--dur) var(--ease-out); }
.main-nav.scrolled { padding-top: 8px; }
.nav-inner {
  max-width: 1160px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 8px 8px 18px;
  border-radius: var(--pill);
}
.main-nav.scrolled .nav-inner { box-shadow: var(--g-inset), var(--g-shadow-hi); }
.nav-brand {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
  font-weight: 800; font-size: 1.05rem; letter-spacing: 0.02em; color: var(--txt); text-decoration: none; white-space: nowrap;
  border-radius: var(--pill);
}
.brand-logo { height: 1.6em; width: auto; filter: drop-shadow(0 2px 8px rgba(139, 92, 246, 0.5)); }
.brand-accent {
  background: linear-gradient(120deg, var(--violet-400), var(--fuchsia-500));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
:root[data-theme="light"] .brand-accent { background-image: linear-gradient(120deg, var(--violet-700), var(--fuchsia-700)); }

.nav-links { position: relative; display: flex; gap: 2px; margin-left: auto; }
.nav-links a {
  position: relative; z-index: 1;
  padding: 9px 14px; border-radius: var(--pill);
  font-size: 0.74rem; font-weight: 600; letter-spacing: 0.06em;
  color: var(--txt-2); text-decoration: none; white-space: nowrap;
  transition: color 250ms ease;
}
.nav-links a:hover { color: var(--txt); }
.nav-links a.nav-active { color: #fff; }
.nav-pill {
  position: absolute; top: 0; left: 0; z-index: 0;
  width: 0; height: 0; border-radius: var(--pill);
  background: linear-gradient(135deg, var(--violet-500), var(--violet-700) 60%, var(--fuchsia-500));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 6px 18px rgba(139, 92, 246, 0.45);
  opacity: 0;
  transition: transform 450ms var(--spring), width 450ms var(--spring), height 450ms var(--spring), opacity 200ms ease;
}
.nav-pill.ready { opacity: 1; }
.nav-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.theme-toggle { width: 40px; height: 40px; display: grid; place-items: center; padding: 0; }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

.nav-toggle {
  display: none; flex-direction: column; justify-content: center; align-items: center; gap: 5px;
  width: 44px; height: 44px; padding: 11px; border-radius: var(--pill);
  background: none; border: none; cursor: pointer;
}
.nav-toggle span { display: block; width: 20px; height: 2px; background: var(--txt); border-radius: 2px; transition: transform var(--dur) var(--spring), opacity 200ms ease; }
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ─── HERO INTRO ─── */
.hero-intro { position: relative; z-index: 2; max-width: 1160px; margin: 0 auto; padding: 40px 16px 4px; text-align: center; }
.hero-logo { height: 76px; width: auto; filter: drop-shadow(0 10px 30px rgba(217, 70, 239, 0.45)); margin-bottom: 10px; }
.hero-title { font-size: clamp(2rem, 1.4rem + 3vw, 3.4rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; }
.hero-sub { margin: 10px auto 0; max-width: 520px; font-size: clamp(0.92rem, 0.88rem + 0.2vw, 1.05rem); color: var(--txt-2); }

/* ─── LAYOUT ─── */
#app { position: relative; z-index: 2; max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.section, .draw-module, .history-module { scroll-margin-top: var(--nav-offset); }
.section { padding: 44px 0 8px; }
.section-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px 16px; margin-bottom: 20px; flex-wrap: wrap; }
.section-title, .results-title, .history-title {
  font-size: clamp(1.25rem, 1.1rem + 0.7vw, 1.7rem); font-weight: 800; letter-spacing: -0.01em; color: var(--txt);
  display: flex; align-items: center; gap: 10px;
}
.section-title::before, .results-title::before, .history-title::before {
  content: ''; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--violet-400), var(--fuchsia-500));
  box-shadow: 0 0 12px rgba(217, 70, 239, 0.7);
}
.section-date, .section-sub {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 0.78rem; font-weight: 600; color: var(--primary-txt);
  padding: 6px 12px; border-radius: var(--pill); background: var(--chip-bg); border: 1px solid var(--chip-border);
}

/* scroll reveal (class added by script.js) */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out); }
.reveal.in-view { opacity: 1; transform: none; }

/* ─── HERO RESULT PANEL ─── */
.draw-module { position: relative; margin: 24px 0 0; }
.draw-module::before {
  content: ''; position: absolute; top: 140px; left: 50%; z-index: 0; pointer-events: none;
  width: min(720px, 100%); height: 420px;
  background: radial-gradient(ellipse at center, rgba(217, 70, 239, 0.28), rgba(139, 92, 246, 0.12) 45%, transparent 70%);
  transform: translate(-50%, -50%) translate(var(--mx, 0px), var(--my, 0px));
  transition: transform 0.5s var(--ease-out);
}
.draw-module > * { position: relative; z-index: 1; }

.draw-header {
  border-radius: var(--r-xl);
  padding: 22px clamp(16px, 4vw, 40px) 26px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  text-align: center;
}
.dh-top { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dh-label {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--txt-2);
}
.dh-live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fuchsia-500); box-shadow: 0 0 0 4px rgba(217, 70, 239, 0.22), 0 0 12px var(--fuchsia-500); animation: live-pulse 2s ease-in-out infinite; flex-shrink: 0; }
@keyframes live-pulse { 50% { box-shadow: 0 0 0 8px rgba(217, 70, 239, 0), 0 0 12px var(--fuchsia-500); } }

/* 4D digits as liquid glass capsules */
.dh-balls { display: flex; justify-content: center; gap: clamp(8px, 2.4vw, 18px); perspective: 800px; }
.dh-ball {
  position: relative; overflow: hidden;
  width: clamp(58px, 16.5vw, 104px); aspect-ratio: 0.74;
  display: grid; place-items: center;
  border-radius: var(--pill);
  background:
    radial-gradient(120% 70% at 50% -5%, rgba(255, 255, 255, 0.40), rgba(255, 255, 255, 0.04) 55%, transparent 70%),
    linear-gradient(165deg, rgba(167, 139, 250, 0.42), rgba(217, 70, 239, 0.26) 55%, rgba(99, 102, 241, 0.34));
  border: 1px solid rgba(255, 255, 255, 0.30);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.50),
    inset 0 -14px 26px rgba(76, 29, 149, 0.50),
    0 14px 40px rgba(217, 70, 239, 0.30),
    0 0 50px rgba(139, 92, 246, 0.25);
  -webkit-backdrop-filter: var(--g-blur-sm);
  backdrop-filter: var(--g-blur-sm);
}
.dh-ball::after { /* specular streak */
  content: ''; position: absolute; top: 7%; left: 22%; width: 56%; height: 20%; border-radius: var(--pill);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.dh-digit {
  position: relative; z-index: 1;
  font-family: var(--mono); font-weight: 800; font-size: clamp(2.1rem, 9vw, 3.7rem); line-height: 1;
  color: #fff; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 22px rgba(217, 70, 239, 0.75), 0 2px 0 rgba(76, 29, 149, 0.55);
}
:root[data-theme="light"] .dh-ball {
  background:
    radial-gradient(120% 70% at 50% -5%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.05) 55%, transparent 70%),
    linear-gradient(165deg, var(--violet-500), var(--fuchsia-500) 60%, var(--indigo-500));
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6), inset 0 -14px 26px rgba(76, 29, 149, 0.45), 0 14px 36px rgba(139, 92, 246, 0.35);
}
.dh-animate .dh-ball { animation: capsule-in 800ms var(--spring) both; animation-delay: calc(var(--i, 0) * 110ms); }
@keyframes capsule-in {
  from { opacity: 0; transform: translateY(24px) rotateX(-80deg) scale(0.85); }
  to { opacity: 1; transform: none; }
}

.dh-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.dh-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--pill);
  font-size: 0.82rem; font-weight: 600; color: var(--txt-2);
}
.dh-chip strong { font-family: var(--mono); color: var(--accent-txt); font-weight: 700; }

.dh-schedule {
  width: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 18px;
  padding-top: 16px; border-top: 1px solid var(--line);
}
.dh-sched-lbl { display: block; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--txt-3); }
.dh-datetime { font-size: clamp(1rem, 0.9rem + 0.6vw, 1.3rem); font-weight: 700; color: var(--txt); }
.dh-next {
  display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center;
  padding: 8px 16px; border-radius: var(--pill);
  background: var(--chip-bg); border: 1px solid var(--chip-border);
}
.dh-next-lbl { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--primary-txt); }
.dh-next-sep { color: var(--txt-3); }
.dh-next-val { font-family: var(--mono); font-size: 0.9rem; font-weight: 700; color: var(--txt); font-variant-numeric: tabular-nums; }

.buy-btn {
  position: relative; overflow: hidden; display: inline-flex; align-items: center;
  padding: 10px 22px; border-radius: var(--pill);
  font-weight: 700; font-size: 0.88rem; color: #fff; text-decoration: none; white-space: nowrap;
  background: linear-gradient(135deg, var(--violet-500), var(--fuchsia-500));
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 8px 24px rgba(217, 70, 239, 0.40);
  transition: transform var(--dur) var(--spring), box-shadow var(--dur) ease;
}
.buy-btn::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.45) 50%, transparent 65%);
  background-size: 250% 100%; background-position: 120% 0;
  transition: background-position 0.7s ease;
}
.buy-btn:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 12px 30px rgba(217, 70, 239, 0.55); }
.buy-btn:hover::after { background-position: -20% 0; }
.buy-btn:active { transform: scale(0.96); }

/* ─── RESULTS DETAIL ─── */
.results-section { padding: 34px 0 0; }
.results-title { margin-bottom: 14px; }
.results-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.date-select { display: inline-flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: var(--pill); cursor: pointer; }
.date-select-label { font-weight: 600; font-size: 0.9rem; color: var(--txt); }
.date-select-arrow { width: 8px; height: 8px; border-right: 2px solid var(--txt-2); border-bottom: 2px solid var(--txt-2); transform: rotate(45deg); margin-top: -4px; }
.date-select select { position: absolute; inset: 0; z-index: 2; opacity: 0; cursor: pointer; width: 100%; height: 100%; border-radius: var(--pill); font-size: 16px; }
.date-select:focus-within { box-shadow: var(--g-inset), var(--g-shadow), var(--focus-ring); }
.draw-no-badge {
  font-size: 0.82rem; font-weight: 600; color: var(--txt-2);
  padding: 7px 14px; border-radius: var(--pill); background: var(--chip-bg); border: 1px solid var(--chip-border);
}
.draw-no-badge strong { font-family: var(--mono); color: var(--accent-txt); }

.prize-cards-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.prize-card-new { border-radius: var(--r-lg); padding: 18px 20px; display: flex; align-items: center; gap: 12px; }
.pc-icon {
  width: 40px; height: 40px; flex-shrink: 0; display: grid; place-items: center; font-size: 1.25rem;
  border-radius: 50%; background: var(--chip-bg); border: 1px solid var(--chip-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.pc-text { flex: 1; min-width: 0; }
.pc-label { display: block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--txt-3); }
.pc-num { font-family: var(--mono); font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); font-weight: 800; letter-spacing: 0.04em; color: var(--txt); font-variant-numeric: tabular-nums; }
/* Metal glass: 1st gold, 2nd silver, 3rd bronze — colour only, same glass structure. */
.prize-card-new.pc-1 { --metal-tint: rgba(251, 191, 36, 0.20); --metal-border: rgba(252, 211, 77, 0.55); --metal-glow: rgba(245, 158, 11, 0.30); --metal-num: linear-gradient(180deg, #FEF3C7 0%, #FCD34D 45%, #F59E0B 100%); --metal-solid: #FCD34D; }
.prize-card-new.pc-2 { --metal-tint: rgba(226, 232, 240, 0.16); --metal-border: rgba(226, 232, 240, 0.55); --metal-glow: rgba(203, 213, 225, 0.22); --metal-num: linear-gradient(180deg, #FFFFFF 0%, #E2E8F0 45%, #94A3B8 100%); --metal-solid: #E2E8F0; }
.prize-card-new.pc-3 { --metal-tint: rgba(217, 119, 6, 0.18); --metal-border: rgba(234, 160, 100, 0.55); --metal-glow: rgba(194, 101, 42, 0.28); --metal-num: linear-gradient(180deg, #FDE0C5 0%, #E9A06B 45%, #B45309 100%); --metal-solid: #E9A06B; }
:root[data-theme="light"] .prize-card-new.pc-1 { --metal-tint: rgba(251, 191, 36, 0.22); --metal-border: rgba(217, 119, 6, 0.45); --metal-num: linear-gradient(180deg, #D97706 0%, #B45309 55%, #78350F 100%); --metal-solid: #B45309; }
:root[data-theme="light"] .prize-card-new.pc-2 { --metal-tint: rgba(148, 163, 184, 0.20); --metal-border: rgba(100, 116, 139, 0.45); --metal-num: linear-gradient(180deg, #64748B 0%, #475569 55%, #1E293B 100%); --metal-solid: #475569; }
:root[data-theme="light"] .prize-card-new.pc-3 { --metal-tint: rgba(217, 119, 6, 0.16); --metal-border: rgba(180, 83, 9, 0.45); --metal-num: linear-gradient(180deg, #C2410C 0%, #9A3412 55%, #7C2D12 100%); --metal-solid: #9A3412; }
.prize-card-new:is(.pc-1, .pc-2, .pc-3) {
  background-image: linear-gradient(135deg, var(--metal-tint), transparent 75%);
  border-color: var(--metal-border);
  box-shadow: var(--g-inset), 0 10px 36px var(--metal-glow);
}
.prize-card-new:is(.pc-1, .pc-2, .pc-3)::after { background: linear-gradient(160deg, var(--metal-border), transparent 32%, transparent 68%, var(--metal-border)); }
.prize-card-new:is(.pc-1, .pc-2, .pc-3) .pc-icon { border-color: var(--metal-border); background: var(--metal-tint); }
.prize-card-new:is(.pc-1, .pc-2, .pc-3) .pc-num {
  color: var(--metal-solid);
  background: var(--metal-num);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sub-prizes-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.sub-prize-card { border-radius: var(--r-lg); padding: 18px 20px; }
.sub-prize-title { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--primary-txt); margin-bottom: 12px; }
.sub-prize-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.sub-prize-num {
  font-family: var(--mono); font-size: 0.95rem; font-weight: 700; color: var(--txt); text-align: center; font-variant-numeric: tabular-nums;
  padding: 7px 4px; border-radius: var(--r-xs); background: var(--chip-bg); border: 1px solid var(--chip-border);
}

/* ─── HISTORY ─── */
.history-module { padding: 44px 0 8px; }
.history-title { margin-bottom: 18px; }
.history-card { border-radius: var(--r-lg); overflow: hidden; }
.history-wrap {
  overflow: auto; max-height: 560px; overscroll-behavior-x: contain;
  scrollbar-width: thin; scrollbar-color: rgba(139, 92, 246, 0.45) transparent;
}
.history-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
.history-wrap::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.45); border-radius: var(--pill); }
.history-table { width: 100%; min-width: 560px; border-collapse: separate; border-spacing: 0; }
.history-table thead th {
  position: sticky; top: 0; z-index: 2;
  padding: 14px 18px; text-align: left; white-space: nowrap;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--primary-txt);
  background: var(--g-tinted);
  -webkit-backdrop-filter: var(--g-blur-sm); backdrop-filter: var(--g-blur-sm);
  border-bottom: 1px solid var(--line);
}
.history-table td { padding: 12px 18px; font-size: 0.92rem; white-space: nowrap; color: var(--txt); border-bottom: 1px solid var(--line); transition: background 200ms ease; }
.history-table tbody tr:last-child td { border-bottom: none; }
.history-table tbody tr:nth-child(even) td { background: var(--zebra); }
.history-table tbody tr:hover td { background: var(--hover-fill); }
.hist-date, .hist-day { color: var(--txt-2); }
.hist-date { font-family: var(--mono); font-size: 0.84rem; }
.hist-num { font-family: var(--mono); font-weight: 700; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.hist-num.hist-1 { color: var(--accent-txt); }
.hist-row-latest td { background: linear-gradient(90deg, rgba(139, 92, 246, 0.18), rgba(217, 70, 239, 0.08)) !important; font-weight: 600; }
.hist-row-latest .hist-num.hist-1 { font-size: 1.05rem; }
.hist-latest-badge {
  display: inline-block; margin-left: 8px; vertical-align: middle;
  padding: 2px 9px; border-radius: var(--pill);
  font-family: var(--font); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #fff;
  background: linear-gradient(135deg, var(--violet-500), var(--fuchsia-500));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* ─── PREDIKSI ─── */
.glass { border-radius: var(--r-md); }
.pred-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.pred-card { padding: 20px; border-radius: var(--r-lg); }
.pred-card-t {
  display: inline-flex; margin: 0 auto 16px; padding: 5px 12px; border-radius: var(--pill);
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; color: var(--primary-txt);
  background: var(--chip-bg); border: 1px solid var(--chip-border);
}
.pred-card { display: flex; flex-direction: column; align-items: center; text-align: center; }
.pred-nums { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.pred-chip {
  font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 8px 14px; border-radius: var(--r-sm); color: var(--txt);
  background: var(--chip-bg); border: 1px solid var(--chip-border);
  transition: transform var(--dur) var(--spring);
}
.pred-chip:hover { transform: translateY(-2px); }
.pred-chip-4d { font-size: 1.3rem; color: var(--accent-txt); background: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(217, 70, 239, 0.18)); }
.pred-chip-3d { font-size: 1.2rem; }
.pred-chip-2d { font-size: 1.15rem; color: var(--primary-txt); }

.pred-pos { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.pos-card { padding: 16px; text-align: center; }
.pos-lbl { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em; color: var(--txt-3); margin-bottom: 12px; }
.pos-nums { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.pos-num {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%;
  font-family: var(--mono); font-size: 1rem; font-weight: 700; color: var(--txt);
  background: var(--chip-bg); border: 1px solid var(--chip-border); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform var(--dur) var(--spring), background 200ms ease;
}
.pos-num:hover { transform: scale(1.12); background: linear-gradient(135deg, var(--violet-500), var(--fuchsia-500)); color: #fff; }

.hot-cold { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.hc-card { padding: 20px; border-radius: var(--r-lg); }
.hc-icon { font-size: 1.4rem; margin-bottom: 6px; }
.hc-lbl { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; margin-bottom: 12px; }
.hot .hc-lbl { color: var(--accent-txt); }
.cold .hc-lbl { color: var(--indigo-400); }
:root[data-theme="light"] .cold .hc-lbl { color: #4338CA; }
.hc-nums { display: flex; flex-wrap: wrap; gap: 8px; }
.hc-num {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%;
  font-family: var(--mono); font-size: 1rem; font-weight: 700;
  transition: transform var(--dur) var(--spring);
}
.hot-num { color: var(--accent-txt); background: rgba(217, 70, 239, 0.14); border: 1px solid rgba(217, 70, 239, 0.32); }
.cold-num { color: var(--indigo-400); background: rgba(99, 102, 241, 0.14); border: 1px solid rgba(99, 102, 241, 0.34); }
:root[data-theme="light"] .cold-num { color: #4338CA; }
.hc-num:hover { transform: scale(1.12); }

/* ─── TOTO MATCH ─── */
.toto-match-subtitle { margin-top: 6px; color: var(--txt-2); font-size: 0.92rem; }
.toto-match-meta-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.toto-match-meta-card { min-width: 0; padding: 14px 18px; }
.toto-match-meta-label { display: block; margin-bottom: 2px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--txt-3); }
.toto-match-meta-value { display: block; font-size: 0.95rem; font-weight: 600; color: var(--txt); overflow-wrap: anywhere; }
.toto-match-prediction-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.toto-match-card { min-width: 0; padding: 18px 14px; display: flex; flex-direction: column; align-items: center; text-align: center; border-radius: var(--r-lg); }
.toto-match-card .pred-card-t { margin-bottom: 12px; }
.toto-match-numbers, .toto-match-analysis-numbers { display: flex; min-height: 48px; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-bottom: 10px; }
.toto-match-number {
  width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; border-radius: 50%;
  font-family: var(--mono); font-size: 1rem; font-weight: 700; color: #fff;
  background: linear-gradient(150deg, var(--violet-500), var(--fuchsia-500));
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), 0 6px 18px rgba(217, 70, 239, 0.3);
}
.toto-match-number.toto-match-analysis-number { width: 34px; height: 34px; flex-basis: 34px; font-size: 0.82rem; }
.toto-match-label { font-size: 0.88rem; font-weight: 700; color: var(--txt); }
.toto-match-rule { margin-top: 4px; font-size: 0.76rem; line-height: 1.45; color: var(--txt-3); }
.toto-match-empty { font-size: 0.82rem; color: var(--txt-3); }
.toto-match-heading { margin: 0 0 12px; }
.toto-match-analysis-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 10px; }
.toto-match-analysis-card { min-width: 0; padding: 16px 18px; }
.toto-match-analysis-numbers { justify-content: flex-start; margin-bottom: 0; }
.toto-match-disclaimer { margin-bottom: 16px; font-size: 0.78rem; color: var(--txt-3); }
.toto-match-frequency-card { padding: 16px 18px; border-radius: var(--r-lg); }
.toto-match-frequency { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 0.88rem; color: var(--txt); }
.toto-match-frequency th, .toto-match-frequency td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.toto-match-frequency th { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--primary-txt); }
.toto-match-frequency tbody tr:hover td { background: var(--hover-fill); }
.toto-match-frequency-empty { color: var(--txt-3); text-align: center !important; }

/* ─── PAITO WARNA ─── */
.paito-filters, .mimpi-cats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.paito-btn { min-width: 64px; padding: 9px 18px; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em; }
.paito-grid { display: flex; flex-direction: column; gap: 8px; }
.paito-row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: var(--r-md); }
.paito-row:hover { transform: none; }
.paito-date { font-family: var(--mono); font-size: 0.78rem; font-weight: 600; color: var(--txt-3); min-width: 98px; white-space: nowrap; }
.paito-cells { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
/* default cell + violet / fuchsia / indigo scale (replaces gold/silver/bronze) */
.paito-cell {
  font-family: var(--mono); font-size: 0.9rem; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 6px 11px; border-radius: var(--r-xs);
  color: #fff; background: var(--violet-700); border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition: transform var(--dur) var(--spring);
}
.paito-gold { background: linear-gradient(150deg, #C026D3, #A21CAF); }
.paito-silver { background: linear-gradient(150deg, #7C3AED, #6D28D9); }
.paito-bronze { background: linear-gradient(150deg, #4F46E5, #4338CA); }
.paito-cell:hover { transform: scale(1.08); }
.paito-sep { width: 1px; align-self: stretch; margin: 4px 2px; background: var(--g-border); }
.paito-digits { margin-top: -6px; }
.paito-digits .paito-btn { min-width: 44px; padding: 9px 0; font-family: var(--mono); }
.pd { display: inline-block; transition: opacity 200ms ease; }
.pd-off { opacity: 0.3; }
.pd-hit { color: var(--violet-900); background: #fff; border-radius: 4px; box-shadow: 0 0 10px rgba(255, 255, 255, 0.6); }

/* plain-language notes: sample size, method, stale data */
.section-note { margin: -6px 0 16px; max-width: 80ch; font-size: 0.8rem; line-height: 1.55; color: var(--txt-3); }
.section-note-warn { color: var(--red); font-weight: 600; }

/* ─── BUKU MIMPI ─── */
.mimpi-search-wrap { display: flex; align-items: center; border-radius: var(--pill); margin-bottom: 14px; }
.mimpi-search-wrap:focus-within { box-shadow: var(--g-inset), var(--g-shadow-hi), var(--focus-ring); }
.mimpi-search-icon { position: absolute; left: 18px; width: 18px; height: 18px; fill: none; stroke: var(--txt-3); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.mimpi-search {
  width: 100%; padding: 14px 20px 14px 46px; border: none; background: transparent; border-radius: var(--pill);
  font-family: var(--font); font-size: 1rem; color: var(--txt);
}
.mimpi-search:focus, .mimpi-search:focus-visible { outline: none; box-shadow: none; }
.mimpi-search::placeholder { color: var(--txt-3); }
.mimpi-cats { margin-bottom: 20px; }
.mimpi-cat { padding: 8px 14px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; }
.mimpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.mimpi-card { padding: 16px; border-radius: var(--r-md); -webkit-backdrop-filter: var(--g-blur-sm); backdrop-filter: var(--g-blur-sm); }
.mimpi-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.mimpi-ico {
  width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; font-size: 1rem;
  background: linear-gradient(150deg, rgba(139, 92, 246, 0.35), rgba(217, 70, 239, 0.25));
  border: 1px solid var(--chip-border); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.mimpi-kw { flex: 1; min-width: 0; font-size: 0.92rem; font-weight: 800; letter-spacing: 0.02em; color: var(--txt); overflow-wrap: anywhere; }
.mimpi-tag { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--primary-txt); background: var(--chip-bg); border: 1px solid var(--chip-border); padding: 3px 9px; border-radius: var(--pill); }
.mimpi-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.mimpi-lbl { font-family: var(--mono); font-size: 0.68rem; font-weight: 700; color: var(--txt-3); min-width: 24px; }
.mimpi-nums { display: flex; flex-wrap: wrap; gap: 4px; }
.mimpi-num { font-family: var(--mono); font-size: 0.8rem; font-weight: 600; padding: 3px 8px; border-radius: var(--pill); color: var(--txt); background: var(--chip-bg); border: 1px solid var(--chip-border); }
.mimpi-empty { grid-column: 1 / -1; text-align: center; padding: 32px; color: var(--txt-3); }

/* ─── STATISTIK ─── */
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.stat-card { padding: 20px; border-radius: var(--r-lg); min-width: 0; }
.stat-card.wide { grid-column: 1 / -1; }
.stat-card-t { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; color: var(--primary-txt); margin-bottom: 16px; }
.stat-bars { display: flex; flex-direction: column; gap: 10px; }
.stat-bar-row { position: relative; display: flex; align-items: center; gap: 10px; border-radius: var(--r-xs); }
.stat-bar-lbl { font-family: var(--mono); font-size: 0.82rem; font-weight: 700; color: var(--txt); min-width: 44px; }
.stat-bar-track {
  flex: 1; height: 10px; border-radius: var(--pill); overflow: hidden;
  background: var(--track);
  /* hairline gridlines at 25 / 50 / 75 % */
  background-image: linear-gradient(90deg, transparent calc(25% - 0.5px), var(--line) 25%, transparent calc(25% + 0.5px), transparent calc(50% - 0.5px), var(--line) 50%, transparent calc(50% + 0.5px), transparent calc(75% - 0.5px), var(--line) 75%, transparent calc(75% + 0.5px));
}
.stat-bar-fill {
  height: 100%; border-radius: var(--pill);
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.25), var(--violet-500) 60%, var(--fuchsia-500));
  box-shadow: 0 0 12px rgba(217, 70, 239, 0.35);
  transition: width 0.9s var(--ease-out);
}
.stat-bar-fill-alt { background: linear-gradient(90deg, rgba(99, 102, 241, 0.25), var(--indigo-500) 60%, var(--violet-400)); box-shadow: 0 0 12px rgba(99, 102, 241, 0.35); }
.stat-bar-val { font-family: var(--mono); font-size: 0.8rem; font-weight: 600; color: var(--txt-2); min-width: 28px; text-align: right; }

.missing-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.missing-cell { display: flex; flex-direction: column; align-items: center; padding: 10px 4px; border-radius: var(--r-sm); background: var(--chip-bg); border: 1px solid var(--chip-border); }
.missing-num { font-family: var(--mono); font-size: 0.95rem; font-weight: 700; color: var(--txt); }
.missing-count { font-size: 0.7rem; color: var(--txt-3); margin-top: 2px; }

.digit-freq {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; height: 170px;
  padding-bottom: 40px; position: relative;
  /* hairline horizontal gridlines */
  background-image: repeating-linear-gradient(to top, var(--line) 0 1px, transparent 1px 32.5px);
  background-position: 0 calc(100% - 40px); background-size: 100% calc(100% - 40px); background-repeat: no-repeat;
}
.digit-freq-cell { position: relative; flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; border-radius: var(--r-xs); }
.digit-freq-bar {
  width: min(70%, 28px); min-height: 4px; border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, var(--fuchsia-500), var(--violet-500) 45%, rgba(139, 92, 246, 0.05));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
  transition: height 0.9s var(--ease-out);
}
.digit-freq-digit { position: absolute; bottom: -24px; font-family: var(--mono); font-size: 0.85rem; font-weight: 700; color: var(--txt); }
.digit-freq-count { position: absolute; bottom: -40px; font-family: var(--mono); font-size: 0.66rem; color: var(--txt-3); }

.odd-even { display: flex; height: 44px; border-radius: var(--pill); overflow: hidden; background: var(--track); border: 1px solid var(--g-border); }
.odd-bar, .even-bar {
  display: flex; align-items: center; justify-content: center; min-width: 64px; white-space: nowrap;
  font-size: 0.76rem; font-weight: 700; letter-spacing: 0.04em; color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.odd-bar { background: linear-gradient(90deg, var(--violet-700), var(--violet-500)); }
.even-bar { background: linear-gradient(90deg, #C026D3, var(--fuchsia-500)); }

/* glass tooltip for chart marks (data-tip set in script.js) */
[data-tip] { cursor: default; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 8px); z-index: 10;
  transform: translate(-50%, 4px) scale(0.96); opacity: 0; pointer-events: none;
  padding: 6px 11px; border-radius: var(--r-xs); white-space: nowrap;
  font-family: var(--mono); font-size: 0.75rem; font-weight: 700; color: var(--txt);
  background: var(--g-tinted);
  -webkit-backdrop-filter: var(--g-blur-sm); backdrop-filter: var(--g-blur-sm);
  border: 1px solid var(--g-border);
  box-shadow: var(--g-inset), var(--g-shadow);
  transition: opacity 180ms ease, transform 300ms var(--spring);
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0) scale(1); }
.stat-bar-row[data-tip]::after { left: auto; right: 0; transform: translate(0, 4px) scale(0.96); }
.stat-bar-row[data-tip]:hover::after, .stat-bar-row[data-tip]:focus-visible::after { transform: none; }
.digit-freq-cell[data-tip]::after { bottom: auto; top: -34px; }
/* edge cells: anchor the tooltip inward so it never pokes past the viewport */
.digit-freq-cell:first-child[data-tip]::after { left: 0; transform: translateY(4px) scale(0.96); }
.digit-freq-cell:last-child[data-tip]::after { left: auto; right: 0; transform: translateY(4px) scale(0.96); }
.digit-freq-cell:is(:first-child, :last-child)[data-tip]:is(:hover, :focus-visible)::after { transform: none; }
.stat-bar-row:hover .stat-bar-fill, .digit-freq-cell:hover .digit-freq-bar { filter: brightness(1.15); }

/* ─── BANNER (GIF in a glass frame, same width as the #app content / wide stat-card) ─── */
.banner {
  position: relative; z-index: 2;
  width: min(1128px, calc(100% - 32px)); margin: 48px auto 0;
  padding: 8px; border-radius: var(--r-lg);
}
.banner img { display: block; width: 100%; height: auto; aspect-ratio: 640 / 178; border-radius: calc(var(--r-lg) - 8px); }

/* ─── SERVICE MARQUEE: glass pills looping inside a glass strip ─── */
.service-marquee {
  position: relative; z-index: 2; isolation: isolate; overflow: hidden;
  width: min(1128px, calc(100% - 32px)); margin: 12px auto 0;
  padding: 8px 0; border-radius: var(--pill);
  background-color: var(--g-clear);
  background-image: linear-gradient(var(--g-tint), var(--g-tint));
  -webkit-backdrop-filter: var(--g-blur); backdrop-filter: var(--g-blur);
  border: 1px solid var(--g-border);
  box-shadow: var(--g-inset), var(--g-shadow);
  /* soft fade at both ends */
  -webkit-mask: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent);
  mask: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent);
}
.sm-track { display: flex; width: max-content; animation: sm-scroll var(--sm-dur, 24s) linear infinite; }
.service-marquee:hover .sm-track, .service-marquee:focus-within .sm-track { animation-play-state: paused; }
.sm-group { display: flex; gap: 10px; padding-right: 10px; list-style: none; flex-shrink: 0; }
.sm-item {
  position: relative; display: inline-flex; align-items: center; gap: 9px; white-space: nowrap;
  padding: 9px 18px 9px 14px; border-radius: var(--pill);
  font-size: 0.86rem; font-weight: 700; color: var(--txt); text-decoration: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.03)), var(--g-tint);
  border: 1px solid var(--g-border);
  box-shadow: inset 0 1px 0 var(--g-spec), 0 4px 14px rgba(11, 6, 20, 0.25);
  transition: transform var(--dur) var(--spring), background 200ms ease, box-shadow var(--dur) ease;
}
.sm-item:hover {
  transform: translateY(-2px);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05)), rgba(139, 92, 246, 0.25);
  box-shadow: inset 0 1px 0 var(--g-spec), 0 8px 22px rgba(139, 92, 246, 0.4);
}
.sm-item:focus-visible { border-radius: var(--pill); }
.sm-item svg { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: var(--violet-400); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sm-item svg.sm-fill { fill: var(--violet-400); stroke: none; }
:root[data-theme="light"] .sm-item svg { stroke: var(--violet-700); }
:root[data-theme="light"] .sm-item svg.sm-fill { fill: var(--violet-700); }
:root[data-theme="light"] .sm-item { box-shadow: inset 0 1px 0 var(--g-spec), 0 4px 14px rgba(109, 40, 217, 0.12); }
@keyframes sm-scroll { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .sm-track { animation: none; }
  .service-marquee { overflow-x: auto; -webkit-mask: none; mask: none; }
}

/* ─── FOOTER ─── */
.app-footer { position: relative; z-index: 2; max-width: 1160px; margin: 16px auto 0; padding: 0 16px 32px; }
.footer-inner { border-radius: var(--r-lg); padding: 26px 20px; text-align: center; }
.footer-brand { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 1rem; font-weight: 800; color: var(--txt); margin-bottom: 4px; }
.footer-tagline { font-size: 0.84rem; color: var(--txt-2); margin-bottom: 14px; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.footer-links a { padding: 6px 12px; border-radius: var(--pill); font-size: 0.8rem; font-weight: 600; color: var(--txt-2); text-decoration: none; transition: background 200ms ease, color 200ms ease; }
.footer-links a:hover { color: var(--txt); background: var(--hover-fill); }
.footer-disclaimer { font-size: 0.8rem; color: var(--txt-3); }

/* ─── LOADING SKELETON ─── */
.loading-screen { display: flex; flex-direction: column; gap: 14px; padding: 24px 0 8px; }
.loading-screen > p { text-align: center; font-weight: 600; color: var(--txt-3); }
.data-error { align-items: center; padding: 48px 0 16px; }
.data-error .section-note { margin: 0; text-align: center; }
.data-error-t { font-size: 1.05rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--red) !important; }
.data-error-detail { font-family: var(--mono); font-size: 0.72rem !important; opacity: 0.8; }

/* ─── DATA STATUS (under the hero result) ─── */
.data-status { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 14px auto 0; padding: 0 8px; text-align: center; }
.data-status-line { font-size: 0.78rem; line-height: 1.5; color: var(--txt-3); }
.data-status-line strong { color: var(--txt-2); font-weight: 700; }
.data-status-warn { color: var(--red); font-weight: 600; }
.data-status-src { font-size: 0.72rem; }
.sk-block { border-radius: var(--r-xl); padding: 24px; display: flex; flex-direction: column; gap: 14px; overflow: hidden; }
.sk-hero { align-items: center; padding: 32px 24px; }
.sk-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.sk-card { border-radius: var(--r-lg); }
.sk-balls { display: flex; gap: clamp(8px, 2.4vw, 18px); }
.sk-balls i { display: block; width: clamp(58px, 16.5vw, 104px); aspect-ratio: 0.74; border-radius: var(--pill); }
.sk-line { display: block; height: 12px; border-radius: var(--pill); }
.sk-w30 { width: 30%; } .sk-w40 { width: 40%; } .sk-w50 { width: 50%; } .sk-w70 { width: 70%; }
.sk-line, .sk-balls i {
  background: linear-gradient(100deg, rgba(139, 92, 246, 0.14) 30%, rgba(217, 70, 239, 0.32) 50%, rgba(139, 92, 246, 0.14) 70%);
  background-size: 300% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}
.sk-label { text-align: center; font-size: 0.85rem; font-weight: 600; letter-spacing: 0.08em; color: var(--txt-3); }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ═══ RESPONSIVE ═══ */
@media (max-width: 1000px) {
  .nav-toggle { display: flex; }
  .nav-links {
    position: absolute; top: calc(100% + 10px); left: 0; right: 0;
    flex-direction: column; gap: 2px; margin: 0; padding: 8px;
    border-radius: var(--r-lg);
    background-color: var(--g-tinted);
    -webkit-backdrop-filter: var(--g-blur); backdrop-filter: var(--g-blur);
    border: 1px solid var(--g-border);
    box-shadow: var(--g-inset), var(--g-shadow-hi);
    opacity: 0; transform: translateY(-8px) scale(0.98); transform-origin: top center; pointer-events: none; visibility: hidden;
    transition: opacity 220ms ease, transform var(--dur) var(--spring), visibility 0s linear 220ms;
  }
  .nav-links.open { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition: opacity 220ms ease, transform var(--dur) var(--spring); }
  .nav-links a { text-align: center; padding: 12px; font-size: 0.82rem; }
  .nav-actions { margin-left: auto; }
  .pred-pos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toto-match-prediction-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  :root { --nav-offset: 80px; --g-blur: blur(16px) saturate(160%); --g-blur-sm: blur(10px) saturate(150%); }
  .hero-intro { padding-top: 26px; }
  .hero-logo { height: 58px; }
  .section, .history-module { padding-top: 34px; }
  .pred-grid, .hot-cold, .prize-cards-row, .sub-prizes-row, .stats-grid, .toto-match-analysis-grid, .sk-row { grid-template-columns: 1fr; }
  .toto-match-meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mimpi-grid { grid-template-columns: 1fr; }
  .missing-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .results-toolbar { justify-content: center; }
  .dh-top { justify-content: center; }
  .history-wrap { max-height: 460px; }
  .history-table td, .history-table thead th { padding: 11px 14px; }
  .paito-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  /* touch targets ≥ 44px on touch-sized screens */
  .paito-btn, .mimpi-cat { min-height: 44px; }
  .footer-links a { display: inline-flex; align-items: center; min-height: 44px; }
  .sk-row .sk-card:nth-child(n+2) { display: none; }
  .blob-d { display: none; }
}

@media (max-width: 480px) {
  #app { padding: 0 12px; }
  .main-nav { padding: 10px 10px 0; }
  .nav-inner { padding: 6px 6px 6px 14px; gap: 8px; }
  .nav-brand { font-size: 0.95rem; }
  .theme-toggle { width: 44px; height: 44px; }
  .draw-header { border-radius: var(--r-lg); padding: 18px 12px 20px; gap: 14px; }
  .prize-card-new, .sub-prize-card, .pred-card, .stat-card { padding: 16px; }
  .missing-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .toto-match-meta-grid, .toto-match-prediction-grid { grid-template-columns: 1fr; }
  .banner, .service-marquee { width: calc(100% - 24px); }
  .banner { padding: 6px; }
  .sm-item { font-size: 0.8rem; padding: 8px 14px 8px 12px; }
  .app-footer { padding: 0 12px 24px; }
}

/* ─── Motion preferences ─── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .reveal { opacity: 1; transform: none; }
  .sk-line, .sk-balls i { animation: none; }
}

/* ═══ FLYING BALLS ═══
   Layer order: .floater (scroll + pointer parallax, set by script.js as --px/--py)
   > .floater-enter (one-off fly-in) > .floater-body (endless bob + sway)
   with .floater-shadow bobbing in sync: it shrinks and fades as the ball rises. */
.floaters { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.floater {
  position: absolute; left: var(--x); top: var(--y);
  width: var(--size); height: var(--size);
  translate: -50% -50%;
  transform: translate3d(var(--px, 0px), var(--py, 0px), 0);
  will-change: transform;
}
.floater-enter { position: relative; width: 100%; height: 100%; animation: floater-in 1.6s var(--spring) both; animation-delay: calc(var(--i, 0) * 120ms + 150ms); }
.floater-body {
  position: relative; z-index: 1; width: 100%; height: 100%;
  animation: floater-bob var(--dur) ease-in-out infinite; animation-delay: var(--delay);
}
.orb {
  position: absolute; inset: 0; overflow: hidden; border-radius: 50%;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.10),
    0 0 calc(var(--size) * 0.45) var(--glow),
    0 calc(var(--size) * 0.12) calc(var(--size) * 0.35) rgba(11, 6, 20, 0.45);
  animation: floater-spin calc(var(--dur) * 2.2) ease-in-out infinite alternate; animation-delay: var(--delay);
}
.orb img {
  position: absolute; max-width: none;
  width: calc(100% * var(--sw)); height: auto;
  left: calc(-100% * var(--ox)); top: calc(-100% * var(--oy));
  user-select: none; -webkit-user-drag: none;
}
/* violet rim light + glassy top sheen, so the balls belong to the aurora scene */
.orb::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background:
    radial-gradient(60% 40% at 32% 18%, rgba(255, 255, 255, 0.35), transparent 70%),
    radial-gradient(circle at 70% 85%, rgba(217, 70, 239, 0.40), transparent 55%),
    radial-gradient(circle at 50% 50%, transparent 58%, rgba(139, 92, 246, 0.45) 100%);
  mix-blend-mode: screen;
}
.floater-shadow {
  position: absolute; left: 2%; width: 96%; height: 30%;
  top: calc(100% + var(--amp) * 0.5 + 14px);
  border-radius: 50%;
  /* dark contact core + violet light pool, so it reads on the dark aurora */
  background:
    radial-gradient(closest-side, rgba(5, 2, 12, 0.92), rgba(5, 2, 12, 0.55) 45%, transparent 75%),
    radial-gradient(closest-side, rgba(139, 92, 246, 0.55), rgba(217, 70, 239, 0.18) 70%, transparent 100%);
  animation: floater-shadow var(--dur) ease-in-out infinite; animation-delay: var(--delay);
}
.floater-shadow::after { /* coloured bounce light from the ball itself */
  content: ''; position: absolute; inset: -30% 10%; border-radius: 50%;
  background: radial-gradient(closest-side, var(--glow), transparent 100%);
  opacity: 0.55;
}
:root[data-theme="light"] .floater-shadow { background: radial-gradient(closest-side, rgba(46, 16, 101, 0.55), rgba(76, 29, 149, 0.25) 50%, transparent 78%), radial-gradient(closest-side, rgba(139, 92, 246, 0.30), transparent 100%); }
:root[data-theme="light"] .orb { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5), 0 0 calc(var(--size) * 0.4) var(--glow), 0 calc(var(--size) * 0.12) calc(var(--size) * 0.3) rgba(76, 29, 149, 0.25); }

/* far layer: soft focus, dimmer, no heavy shadow */
.floater--far .orb { filter: blur(1.2px) saturate(0.9); opacity: 0.7; }
.floater--far .floater-shadow { opacity: 0.5; }

@keyframes floater-in {
  from { opacity: 0; transform: translate(var(--from)) scale(0.3) rotate(-120deg); }
  to { opacity: 1; transform: none; }
}
@keyframes floater-bob {
  0%, 100% { transform: translateY(0) rotate(var(--rot)); }
  50% { transform: translateY(calc(var(--amp) * -1)) rotate(calc(var(--rot) * -0.4)); }
}
@keyframes floater-spin {
  from { rotate: -10deg; }
  to { rotate: 14deg; }
}
@keyframes floater-shadow {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(0.58); opacity: 0.45; }
}

@media (max-width: 768px) {
  .floater--sm-hide { display: none; }
  .floater { --size: 58px !important; }
  /* hug the screen edges so balls pass behind panel borders, not text */
  .floater:nth-child(1) { --x: 5% !important; }
  .floater:nth-child(2) { --x: 94% !important; }
  .floater:nth-child(3) { --x: 97% !important; }
  .floater:nth-child(5) { --x: 4% !important; --y: 92% !important; }
  .floater:nth-child(6) { --x: 90% !important; }
  .floater:nth-child(7) { --x: 8% !important; }
  .floater--far { --size: 30px !important; }
}
@media (prefers-reduced-motion: reduce) {
  .floater-enter, .floater-body, .orb, .floater-shadow { animation: none !important; }
}
