/* Thai Lottery Checker web: the app's Material 3 theme (ui/theme/Color.kt, Theme.kt). */
:root {
  --gold: #D4AF37; --gold-light: #F5D76E; --gold-dark: #B8860B;
  --blue: #1E3A5F; --blue-light: #2E5A8F; --navy: #0A1628; --red: #E31E24;
  --win: #2E7D32; --win-bg: #E8F5E9; --lose: #616161; --reward-ink: #7A5A00;

  --primary: var(--blue); --on-primary: #fff;
  --primary-container: var(--gold-light); --on-primary-container: #1b1400;
  --secondary: var(--gold);
  --bg: #F8F9FA; --surface: #F8F9FA; --card: #fff; --card-2: rgba(245, 215, 110, .3);
  --text: #1a1c1e; --muted: #5b5f66; --line: #d9dce1; --outline: #74777f;
  --nav-bg: var(--blue); --nav-fg: rgba(248, 249, 250, .7); --nav-active: var(--gold-light);
  --lose-ink: var(--lose);
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: var(--gold); --on-primary: #1b1400;
    --primary-container: var(--blue); --on-primary-container: #e8eefc;
    --secondary: var(--gold-light);
    --bg: #121212; --surface: #1E1E1E; --card: #1E1E1E; --card-2: #2C2C2C;
    --text: #e6e6e6; --muted: #b0b0b0; --line: #3a3a3a; --outline: #8e9099;
    --nav-bg: #0A1628; --lose-ink: #B0B0B0; --reward-ink: #F5D76E; --win-bg: #1f3322;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --primary: var(--gold); --on-primary: #1b1400;
  --primary-container: var(--blue); --on-primary-container: #e8eefc;
  --secondary: var(--gold-light);
  --bg: #121212; --surface: #1E1E1E; --card: #1E1E1E; --card-2: #2C2C2C;
  --text: #e6e6e6; --muted: #b0b0b0; --line: #3a3a3a; --outline: #8e9099;
  --nav-bg: #0A1628; --lose-ink: #B0B0B0; --reward-ink: #F5D76E; --win-bg: #1f3322;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 "Noto Sans Thai", "Sarabun", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh; padding-bottom: calc(80px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); }
button, input, textarea, select { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 8px; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--blue); color: #fff;
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; min-height: 56px;
}
.topbar img { width: 32px; height: 32px; border-radius: 8px; }
.topbar .t { font-weight: 700; font-size: 18px; line-height: 1.15; }
.topbar .s { font-size: 12px; opacity: .8; }
.topbar .sp { flex: 1; }
.topbar .pro-badge { background: var(--gold); color: #1b1400; font-weight: 700; font-size: 12px; padding: 3px 10px; border-radius: 999px; }
.icon-btn { background: none; border: 0; color: inherit; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: rgba(255,255,255,.12); }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }

main { max-width: 720px; margin: 0 auto; padding: 16px; }
@media (min-width: 900px) { main { max-width: 860px; } }

/* bottom navigation */
.nav {
  position: sticky; top: 0; z-index: 30; background: var(--nav-bg);
  display: flex; justify-content: center; gap: 4px; padding: calc(4px + env(safe-area-inset-top)) 4px 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
}
.nav a {
  flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--nav-fg); text-decoration: none; font-size: 12px; padding: 4px 0; border-radius: 12px;
}
.nav a svg { width: 24px; height: 24px; fill: currentColor; }
.nav a .pill { padding: 2px 18px; border-radius: 999px; }
.nav a[aria-current="page"] { color: var(--nav-active); font-weight: 700; }
.nav a[aria-current="page"] .pill { background: rgba(245, 215, 110, .18); }

/* cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 0 0 16px; }
.card.tint { background: var(--card-2); box-shadow: none; }
.card.primary { background: var(--blue); color: #fff; }
.card h2, .card h3 { margin: 0 0 4px; }
.h-th { font-size: 22px; font-weight: 700; margin: 0; }
.h-en { font-size: 14px; color: var(--muted); margin: 0 0 12px; }
.card.primary .h-en { color: rgba(255,255,255,.8); }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 8px; }
.hidden { display: none !important; }

/* inputs + buttons */
.field { width: 100%; border: 2px solid var(--outline); border-radius: 12px; background: var(--card); padding: 12px 14px; }
.field:focus { border-color: var(--primary); outline: none; }
.ticket-input {
  font-size: 34px; font-weight: 700; letter-spacing: .35em; text-align: center; direction: ltr;
  font-variant-numeric: tabular-nums; padding: 12px 6px 12px calc(6px + .35em);
}
textarea.field { min-height: 96px; resize: vertical; direction: ltr; }
.label { display: block; font-size: 14px; color: var(--muted); margin: 0 0 6px; }
.err { color: var(--red); font-size: 14px; margin: 6px 0 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
  padding: 10px 20px; border-radius: 999px; border: 0; cursor: pointer; font-weight: 700; text-decoration: none;
  background: var(--primary); color: var(--on-primary); text-align: center; line-height: 1.25;
}
.btn.block { width: 100%; }
.btn.gold { background: var(--gold); color: #1b1400; }
.btn.outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn.text { background: transparent; color: var(--primary); min-height: 40px; padding: 8px 12px; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn svg { width: 20px; height: 20px; fill: currentColor; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--gold); color: inherit;
  background: rgba(212, 175, 55, .12); border-radius: 999px; padding: 6px 14px; font-weight: 700; cursor: pointer; font-size: 14px;
}

/* numbers */
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; letter-spacing: .06em; }
.first-prize { font-size: 40px; font-weight: 800; color: var(--gold-light); letter-spacing: .12em; }
.card:not(.primary) .first-prize { color: var(--primary); }
.reward { color: var(--reward-ink); font-weight: 700; }
.card.primary .reward { color: var(--gold-light); }
.running { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.running .cell { background: rgba(255,255,255,.1); border-radius: 12px; padding: 8px; text-align: center; }
.card:not(.primary) .running .cell { background: var(--card-2); }
.running .cell .v { font-size: 20px; font-weight: 700; }
.running .cell .l { font-size: 12px; opacity: .85; }
.prize-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
@media (max-width: 420px) { .prize-grid { grid-template-columns: repeat(3, 1fr); } }
.prize-grid span { background: var(--card-2); border-radius: 8px; padding: 6px 2px; text-align: center; font-weight: 600; font-size: 15px; }
.prize-grid span.hit { background: var(--gold); color: #1b1400; }

/* win / lose */
.result-win { background: var(--win-bg); border: 2px solid var(--win); }
.result-win .big { color: var(--win); }
.result-lose .big { color: var(--lose-ink); }
.big { font-size: 26px; font-weight: 800; margin: 4px 0; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.badge { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.badge.won { background: var(--win); color: #fff; }
.badge.lost { background: var(--line); color: var(--text); }
.badge.wait { background: var(--gold-light); color: #1b1400; }
.badge.na { background: transparent; border: 1px solid var(--outline); color: var(--muted); }
.dot { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 800; }
.dot.won { background: var(--win); color: #fff; }
.dot.lost { background: var(--line); color: var(--lose-ink); }

/* sheet / dialog */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--surface); color: var(--text); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 24px 24px 0 0; padding: 8px 24px calc(88px + env(safe-area-inset-bottom)); direction: ltr; text-align: center;
  animation: up .22s ease-out;
}
.sheet .grip { width: 32px; height: 4px; border-radius: 2px; background: var(--outline); opacity: .5; margin: 6px auto 14px; }
.scrim.center { align-items: center; padding: 16px; }
.dialog { background: var(--surface); border-radius: 24px; padding: 24px; max-width: 420px; width: 100%; animation: up .18s ease-out; }
.dialog h2 { margin: 0 0 12px; font-size: 20px; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.pp-box { min-height: 50px; margin: 6px 0 4px; }
.trial { color: var(--primary); font-weight: 800; font-size: 22px; }
.plan-btn { white-space: pre-line; }
.plan-btn[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--gold); }

.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #323232; color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 60; max-width: calc(100% - 32px);
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
.spinner { width: 36px; height: 36px; border: 4px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; margin: 16px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* scanner */
.scan-wrap { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3 / 4; max-height: 70vh; margin: 0 auto 16px; }
.scan-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 22% 10%; border: 3px solid var(--gold); border-radius: 16px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }

footer.site { max-width: 860px; margin: 8px auto 24px; padding: 0 16px; font-size: 13px; color: var(--muted); text-align: center; }
footer.site a { color: inherit; }
footer.site nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin: 8px 0; }
.stores { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0; }
.stores a { border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; text-decoration: none; color: var(--text); font-size: 13px; }

/* first prize card (LotteryResultCard) */
.fp { background: var(--blue); color: #fff; text-align: center; padding: 20px; box-shadow: 0 6px 16px rgba(0,0,0,.2); }
.fp p { margin: 0; }
.fp-th { color: var(--gold-light); font-size: 16px; }
.fp-en { color: rgba(245,215,110,.7); font-size: 12px; margin-bottom: 8px !important; }
.fp-digits { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; max-width: 318px; margin: 0 auto; }
.fp-digits span { background: var(--gold); color: var(--navy); border-radius: 8px; font-weight: 800; font-size: clamp(20px, 7vw, 28px); aspect-ratio: .85; display: grid; place-items: center; }
.fp-amt { color: var(--gold); font-weight: 800; font-size: 22px; margin-top: 8px !important; }
.fp-date { color: rgba(248,249,250,.7); font-size: 12px; }
.run-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.run { text-align: center; margin-bottom: 8px; }
.run p { margin: 0; }
.run-th { font-weight: 600; }
.run-en { font-size: 12px; color: var(--muted); }
.run-nums { font-size: 26px; font-weight: 800; color: var(--primary); display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.source { margin: 0 0 16px; }
.disclaimer .links { display: flex; flex-direction: column; }
.disclaimer .links a { min-height: 40px; display: flex; align-items: center; color: var(--primary); }
.disclaimer .links a.credit { color: var(--muted); text-decoration: none; }
.ic { display: inline-block; width: 20px; line-height: 0; vertical-align: middle; }
.ic svg { width: 100%; height: auto; fill: currentColor; display: block; }
.btn .ic, .chip .ic { width: 20px; display: inline-block; }

/* six ticket boxes (TicketInputField) */
.boxes { position: relative; display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; max-width: 420px; margin: 0 auto; direction: ltr; }
.boxes span { aspect-ratio: .8; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--outline) 30%, transparent); background: var(--surface);
  display: grid; place-items: center; font-size: clamp(22px, 8vw, 32px); font-weight: 800; color: var(--primary); }
.boxes span.filled { background: rgba(245,215,110,.3); }
.boxes span.next { border: 2px solid var(--gold); }
.boxes input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; font-size: 16px; cursor: text; }
.boxes:focus-within span.next { box-shadow: 0 0 0 2px rgba(212,175,55,.35); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.btn-row .btn { border-radius: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.notice { text-align: center; }
.multi-row { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.multi-row .n { width: 88px; flex: none; font-weight: 700; }
.multi-row .w { font-weight: 700; color: var(--primary); }
.feedback-fab { position: fixed; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 25; transition: transform .4s; }
.feedback-fab.tucked { transform: translateX(55%); }
.feedback-fab > button { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--gold); color: #1b1400; box-shadow: 0 4px 12px rgba(0,0,0,.3); cursor: pointer; display: grid; place-items: center; }
.feedback-fab > button .ic { width: 26px; }
.fab-menu { position: absolute; right: 0; bottom: 62px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.fab-menu a { background: var(--card); color: var(--text); box-shadow: var(--shadow); border-radius: 999px; padding: 10px 16px; text-decoration: none; white-space: nowrap; font-size: 14px; }
.wallet-group { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.wallet-group h4 { margin: 0 0 6px; font-size: 14px; }
.wrow { padding: 8px 0; }
.wrow .num { font-weight: 800; font-size: 18px; }
.wrow.won .num, .wrow.won .st { color: var(--win); }
.wrow .acts { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.hist { display: flex; gap: 12px; align-items: center; padding: 16px; border-radius: 12px; background: var(--card-2); margin-bottom: 8px; }
.hist.win { background: var(--win-bg); color: var(--win); }
.hist .ic { width: 32px; flex: none; }
.hist .num { font-size: 20px; font-weight: 800; }
.hist .meta { font-size: 13px; opacity: .8; }
.hist .prize { text-align: right; margin-left: auto; }
.tile { display: flex; align-items: center; gap: 12px; }
