/* ================================================================
   myLottoBuddy brand: cobalt and marigold
   Headlines and numbers: Inter
   Interface: DM Sans, ticket details: DM Mono
   ================================================================ */
:root {
  --cobalt: #192A9E;
  --marigold: #FFC63D;
  --rose: #FFA6C9;
  --rose-deep: #B42A6B;
  --ink: #12152B;
  --porcelain: #F1F2F8;

  --bg: var(--porcelain);
  --card: #FFFFFF;
  --header-bg: #FFFFFF;
  --text: var(--ink);
  --muted: #565B75;
  --line: #CDD0E2;
  --line-strong: #8B90AB;
  --chip: var(--porcelain);         /* neutral ball / pill fill */
  --accent-text: var(--cobalt);     /* cobalt used as text or a thin line */
  --pressed-bg: var(--ink);
  --pressed-fg: #FFFFFF;
  --danger: var(--rose-deep);

  --f-display: 'Inter', system-ui, sans-serif;
  --f-ui: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --f-mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --error-bg: #FFE3EE;
  --error-fg: #8A1C50;
  --toast-bg: var(--ink);
  --toast-fg: #FFFFFF;
  color-scheme: light;
}
/* Dark theme. The app sets data-theme on <html> from the user's Appearance
   setting (Light, Dark, or System, which follows the phone). */
:root[data-theme="dark"] {
  --bg: #0B0D1E;
  --card: #171A33;
  --header-bg: var(--card);
  --text: #F1F2F8;
  --muted: #A6AACB;
  --line: #2C3157;
  --line-strong: #5A5F86;
  --chip: #232745;
  --accent-text: #A9B3FF;
  --pressed-bg: var(--porcelain);
  --pressed-fg: var(--ink);
  --danger: #FF8FBF;
  --error-bg: #3D1428;
  --error-fg: #FFC2DA;
  --toast-bg: var(--porcelain);
  --toast-fg: var(--ink);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 16px/1.45 var(--f-ui);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 520px; margin: 0 auto; min-height: 100%; position: relative; background: var(--bg); }
@media (min-width: 560px) { #app { box-shadow: 0 0 0 1px var(--line); } }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--marigold); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--f-mono); font-weight: 500; font-size: 13px; letter-spacing: .01em; text-transform: uppercase; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { flex: none; }

/* ---------- Logo ---------- */
.logo { display: block; flex: none; max-width: 100%; }
.logo img { display: block; height: 100%; width: auto; max-width: 100%; object-fit: contain; object-position: left center; }

/* ---------- Header / nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--header-bg);
  padding: calc(10px + var(--safe-t)) 20px 10px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
}
.topbar .logo { height: 66px; } /* 40px + 65% */
.offline-pill { font-family: var(--f-mono); font-size: 12px; font-weight: 500; background: var(--rose); color: var(--ink); padding: 6px 10px; border-radius: 12px; }

.page-title {
  font-family: var(--f-display); font-weight: 800; font-size: 28px; letter-spacing: -0.02em; line-height: 44px;
  margin: 14px 0 8px;
}
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 8px; }
.title-row .page-title { margin: 0; }

main.view { padding: 0 20px calc(112px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; }
main.view > .page-title, main.view > .title-row { margin-bottom: -4px; }

.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px; z-index: 6;
  display: grid; grid-template-columns: 1fr 1fr 76px 1fr 1fr; align-items: center;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 8px 8px calc(10px + var(--safe-b));
}
.tabbar .tab {
  border: 0; background: none; min-height: 48px; padding: 4px 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 13px; font-weight: 500; color: var(--muted);
}
.tabbar .tab svg { width: 24px; height: 24px; }
.tabbar .tab[aria-current="page"] { color: var(--accent-text); font-weight: 700; }
.tabbar .add {
  justify-self: center; width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: var(--cobalt); color: var(--marigold);
  display: grid; place-items: center;
}
.tabbar .add svg { width: 28px; height: 28px; }

/* ---------- Building blocks ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 2px -2px; min-height: 44px; }
.section-head h2 { font-size: 17px; font-weight: 700; }
.link { border: 0; background: none; color: var(--accent-text); font-weight: 700; padding: 0; font-size: 15px; min-height: 44px; display: inline-flex; align-items: center; }
.note .link, p .link { min-height: 0; display: inline; font-size: inherit; text-decoration: underline; }

.card { background: var(--card); border-radius: 18px; padding: 16px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }

.btn {
  border: 0; border-radius: 18px; min-height: 56px; padding: 0 20px;
  font-weight: 700; font-size: 17px; text-decoration: none;
  background: var(--cobalt); color: #FFFFFF; width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn svg { width: 18px; height: 18px; }
.btn.gold { background: var(--marigold); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 2px var(--line-strong); }
.btn.danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 2px var(--danger); }
.btn.light { background: #FFFFFF; color: var(--ink); }
.btn.sm { width: auto; min-height: 44px; padding: 0 18px; font-size: 15px; border-radius: 22px; white-space: nowrap; }
.btn:disabled { opacity: .55; cursor: default; }

.icon-btn {
  border: 0; width: 44px; height: 44px; flex: none; border-radius: 50%;
  background: var(--card); color: var(--text); display: grid; place-items: center; padding: 0;
}
.icon-btn svg { width: 20px; height: 20px; }

/* Pills (filters) and segmented controls */
.pills { display: flex; gap: 8px; overflow-x: auto; padding: 4px 20px; margin: 0 -20px; scrollbar-width: none; flex: none; }
.pills::-webkit-scrollbar { display: none; }
.pill {
  min-height: 44px; padding: 0 18px; border-radius: 22px; border: 0; white-space: nowrap;
  background: var(--card); color: var(--text); font-weight: 500; font-size: 15px;
}
.pill[aria-pressed="true"] { background: var(--pressed-bg); color: var(--pressed-fg); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px; background: var(--card); border-radius: 24px; flex: none; }
.seg.scroll { display: flex; overflow-x: auto; scrollbar-width: none; }
.seg.scroll::-webkit-scrollbar { display: none; }
.seg button {
  min-height: 44px; border: 0; border-radius: 20px; padding: 0 14px; white-space: nowrap;
  background: transparent; color: var(--text); font-weight: 500; font-size: 15px;
}
.seg.scroll button { flex: 1 0 auto; }
.seg.tight button { padding: 0 6px; }
.seg button[aria-pressed="true"] { background: var(--pressed-bg); color: var(--pressed-fg); }

/* ---------- Forms ---------- */
label.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
label.field > span { font-size: 15px; font-weight: 700; }
label.field > span .muted { font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; min-height: 50px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--text); outline: none; font-size: 16px; font-weight: 500;
}
.input:focus { border-color: var(--cobalt); box-shadow: 0 0 0 3px rgba(25, 42, 158, .2); }
textarea.input { min-height: 84px; padding: 12px 14px; resize: vertical; }
.error { background: var(--error-bg); color: var(--error-fg); padding: 12px 14px; border-radius: 12px; font-size: 15px; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Balls ---------- */
.balls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ball {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-family: var(--f-display); font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums;
  background: var(--chip); color: var(--text);
}
.ball.open { background: var(--card); box-shadow: inset 0 0 0 1.5px var(--accent-text); }
.ball.bonus { background: var(--rose); color: var(--ink); }
.ball.hit, .ball.bonus.hit { background: var(--cobalt); color: var(--marigold); box-shadow: none; }
.ball.sm { width: 34px; height: 34px; font-size: 13px; }
.ball.lg { width: 46px; height: 46px; font-size: 17px; }
.balls.many .ball { width: 36px; height: 36px; font-size: 14px; }
.balls.many .ball.sm { width: 30px; height: 30px; font-size: 12px; }
.balls.spread { justify-content: space-between; flex-wrap: nowrap; }
.balls.spread.many .ball.lg { width: 40px; height: 40px; font-size: 15px; }

/* ---------- Ticket card (notched stub with a perforation) ---------- */
.ticket {
  position: relative; overflow: hidden; background: var(--card); border-radius: 18px;
  display: flex; flex-direction: column; text-align: left; color: var(--text); flex: none;
}
.ticket[data-act] { cursor: pointer; }
.ticket-head { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ticket-head .name { font-weight: 700; font-size: 17px; }
.ticket-head .mono { color: var(--muted); }
.ticket-body { padding: 12px 16px 14px; display: flex; flex-direction: column; gap: 8px; }
.perf { position: relative; border-top: 2px dashed var(--line); margin: 0 16px; }
.perf::before, .perf::after {
  content: ""; position: absolute; top: -10px; width: 18px; height: 18px; border-radius: 50%; background: var(--notch, var(--bg));
}
.perf::before { left: -25px; }
.perf::after { right: -25px; }

.badge { flex: none; border-radius: 12px; padding: 5px 12px; font-weight: 700; font-size: 14px; white-space: nowrap; }
.badge.win { background: var(--marigold); color: var(--cobalt); }
.badge.wait { background: var(--rose); color: var(--ink); }
.badge.none { background: var(--chip); color: var(--text); font-weight: 500; }

/* ---------- Cobalt panels ---------- */
.panel-cobalt { background: var(--cobalt); color: #FFFFFF; border-radius: 22px; padding: 20px; flex: none; }
.panel-cobalt .mono { color: var(--marigold); }

.next-draw { display: flex; align-items: flex-end; gap: 12px; }
.next-draw .grow { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.next-draw .game { font-family: var(--f-display); font-weight: 700; font-size: 28px; letter-spacing: -0.02em; line-height: 1.1; }
.next-draw .when { font-size: 15px; }
.next-draw .count { text-align: right; }
.next-draw .count b { display: block; font-family: var(--f-display); font-weight: 800; font-size: 34px; line-height: 1; letter-spacing: -0.02em; color: var(--marigold); }
.next-draw .count span { display: block; font-size: 13px; margin-top: 4px; }

.most-played { display: flex; flex-direction: column; gap: 12px; border-radius: 18px; padding: 16px; }
.most-played h2 { font-family: var(--f-display); font-weight: 700; font-size: 20px; letter-spacing: -0.01em; color: var(--marigold); }
.most-played .ball { background: var(--marigold); color: var(--cobalt); }
.most-played p { margin: 0; font-size: 14px; line-height: 1.4; }

/* ---------- Saved number sets ---------- */
.set-card { background: var(--card); border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; flex: none; }
.set-card .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.set-card .name { border: 0; background: none; padding: 0; text-align: left; font-weight: 700; font-size: 17px; color: var(--text); min-height: 24px; }
.set-card .mono { color: var(--muted); }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--card); border-radius: 16px; padding: 14px 12px; }
.stat .k { font-family: var(--f-mono); font-size: 12px; color: var(--muted); text-transform: uppercase; }
.stat .v { font-family: var(--f-display); font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .v.pos { color: var(--accent-text); }
.stat .v.neg { color: var(--danger); }

/* ---------- Lists ---------- */
.list { background: var(--card); border-radius: 18px; overflow: hidden; flex: none; }
.list .item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 56px; border: 0; background: none; width: 100%; text-align: left; color: var(--text); }
button.item, label.item { cursor: pointer; }
.list .item + .item { border-top: 1px solid var(--line); }
.list .item .grow { flex: 1; min-width: 0; }
.list .item .t { font-weight: 700; }
.list .item .s { font-size: 14px; color: var(--muted); }

.empty { text-align: center; padding: 28px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty .art { width: 56px; height: 56px; border-radius: 50%; background: var(--cobalt); color: var(--marigold); display: grid; place-items: center; margin-bottom: 4px; }
.empty .art svg { width: 26px; height: 26px; }
.empty h3 { font-family: var(--f-display); font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.empty p { margin: 0 0 8px; color: var(--muted); max-width: 30ch; }
.empty.plain { color: var(--muted); padding: 24px 16px; }

.note { font-size: 14px; line-height: 1.45; color: var(--muted); background: var(--card); padding: 12px 14px; border-radius: 14px; }
.disclaimer { font-size: 13px; line-height: 1.4; text-align: center; color: var(--muted); margin: 6px 0 0; }

/* ---------- Number picker ---------- */
.pick-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 4px 0 10px; }
.pick-head b { font-size: 17px; }
.pick-head .mono { color: var(--muted); }
.slots { display: flex; justify-content: space-between; gap: 6px; margin-bottom: 14px; }
.slot {
  width: 50px; height: 50px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-family: var(--f-display); font-weight: 700; font-size: 18px;
  box-shadow: inset 0 0 0 2px var(--line-strong); background: transparent;
}
.slot.empty-slot { background: transparent; box-shadow: none; border: 2px dashed var(--line-strong); }
.slot.on { background: var(--marigold); color: var(--cobalt); box-shadow: none; }
.slot.on.bonus { background: var(--rose); color: var(--ink); }
.slots.many .slot { width: 42px; height: 42px; font-size: 16px; }
.picker-label { display: flex; justify-content: space-between; font-size: 15px; font-weight: 700; margin: 6px 2px 8px; }
.picker-label .mono { color: var(--muted); font-weight: 500; }
.picker { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-bottom: 16px; }
.picker button {
  height: 44px; border-radius: 50%; border: 0; padding: 0;
  background: var(--card); color: var(--text);
  font-family: var(--f-display); font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums;
}
.picker button[aria-pressed="true"] { background: var(--cobalt); color: var(--marigold); }
.picker.bonus button[aria-pressed="true"] { background: var(--rose); color: var(--ink); }
.line-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.line-tabs button { min-height: 44px; border: 0; background: var(--card); border-radius: 22px; padding: 0 16px; font-weight: 500; font-size: 15px; display: inline-flex; align-items: center; gap: 6px; }
.line-tabs button svg { width: 16px; height: 16px; color: var(--accent-text); }
.line-tabs button[aria-pressed="true"] { background: var(--pressed-bg); color: var(--pressed-fg); }
.line-tabs button[aria-pressed="true"] svg { color: inherit; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tools select.input { width: auto; min-height: 44px; border-radius: 22px; font-size: 15px; }

/* ---------- Sheets and full-screen pages ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(18, 21, 43, .55); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet {
  background: var(--bg); width: 100%; max-width: 520px; max-height: 94vh; overflow-y: auto; outline: none;
  border-radius: 24px 24px 0 0; padding: 8px 20px calc(24px + var(--safe-b)); animation: up .22s cubic-bezier(.2,.8,.2,1);
}
.sheet .grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 4px auto 10px; }
.sheet .sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; position: sticky; top: -8px; background: var(--bg); padding: 6px 0; z-index: 1; }
.sheet .sheet-head h2 { font-family: var(--f-display); font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }

.sheet.page {
  height: 100%; max-height: none; border-radius: 0;
  padding: calc(16px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  display: flex; flex-direction: column; gap: 14px;
}
.sheet-backdrop.full { align-items: stretch; background: var(--bg); }
.page-head { display: flex; align-items: center; gap: 12px; flex: none; }
.page-head h1 { flex: 1; min-width: 0; font-family: var(--f-display); font-weight: 800; font-size: 28px; letter-spacing: -0.02em; }
.page-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding-top: 6px; }

.sheet.result { background: var(--cobalt); color: #FFFFFF; --notch: var(--cobalt); }
.sheet-backdrop.full.result-bg { background: var(--cobalt); }
.result-hero { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; }
.result-hero .mono { font-size: 14px; color: var(--marigold); }
.result-hero h1 { font-family: var(--f-display); font-weight: 800; font-size: 76px; line-height: .95; letter-spacing: -0.04em; color: var(--marigold); overflow-wrap: anywhere; }
.result-hero h1.mid { font-size: 56px; }
.result-hero p { margin: 6px 0 0; font-size: 18px; }
.result .ticket { color: var(--ink); background: #FFFFFF; }
.result .ticket .ball { background: var(--porcelain); color: var(--ink); }
.result .ticket .ball.bonus { background: var(--rose); }
.result .ticket .ball.hit { background: var(--cobalt); color: var(--marigold); }
.result .ticket .perf { border-color: #CDD0E2; }
.result .ticket .input { background: #FFFFFF; color: var(--ink); border-color: #8B90AB; }
.result .ticket .muted, .result .ticket .mono { color: #565B75; }
.result .disclaimer { color: #FFFFFF; }
.result .line-label { font-family: var(--f-mono); font-size: 12px; color: #565B75; width: 16px; flex: none; }

@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.photo-thumb { width: 100%; border-radius: 14px; display: block; max-height: 260px; object-fit: cover; }

/* ---------- Scan ---------- */
.scan { flex: 1; min-height: 420px; border-radius: 24px; padding: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; }
.scan .frame {
  width: 240px; height: 300px; border: 2px dashed var(--marigold); border-radius: 18px; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; cursor: pointer;
  font-family: var(--f-mono); font-size: 13px; color: #FFFFFF;
}
.scan .frame svg { width: 36px; height: 36px; color: var(--marigold); }
.scan .frame img { width: 100%; height: 100%; object-fit: cover; }
.scan h2 { font-family: var(--f-display); font-weight: 700; font-size: 22px; color: var(--marigold); }
.scan p { margin: 0; font-size: 15px; line-height: 1.45; max-width: 30ch; }

/* ---------- Generator ---------- */
.gen { display: flex; flex-direction: column; gap: 16px; padding: 20px 18px; }
.gen .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gen .top .status { color: #FFFFFF; }
.gen .balls { min-height: 48px; }
.gen .ball { width: 46px; height: 46px; font-size: 18px; }
.gen .balls.many .ball { width: 40px; height: 40px; font-size: 16px; }
.gen .ball.idle { background: transparent; border: 2px dashed #FFFFFF; }
.gen .ball.rolling { background: #FFFFFF; color: var(--ink); animation: rollShake 80ms linear infinite alternate; }
.gen .ball.locked { background: var(--marigold); color: var(--ink); }
.gen .ball.locked.bonus { background: var(--rose); }
.gen .ball.pop { animation: lockPop 180ms ease-out; }
@keyframes lockPop { 0% { transform: scale(.8); } 60% { transform: scale(1.14); } 100% { transform: scale(1); } }
@keyframes rollShake { 0% { transform: translateY(-2px); } 100% { transform: translateY(2px); } }
@media (prefers-reduced-motion: reduce) { .gen .ball.rolling, .gen .ball.pop { animation: none; } }
.saved-mini { background: var(--card); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.saved-mini b { font-size: 15px; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.auth-top { background: var(--header-bg); padding: calc(12px + var(--safe-t)) 20px 12px; }
.auth-top .logo { height: 73px; } /* 44px + 65% */
.auth-hero { background: var(--cobalt); color: #FFFFFF; padding: 36px 20px 64px; display: flex; flex-direction: column; gap: 14px; }
.auth-hero h1 { font-family: var(--f-display); font-weight: 800; font-size: 42px; line-height: 1; letter-spacing: -0.03em; text-wrap: balance; }
.auth-hero h1 span { color: var(--marigold); }
.auth-hero p { margin: 0; font-size: 17px; line-height: 1.5; max-width: 34ch; }
.auth-body { padding: 0 20px 32px; margin-top: -40px; display: flex; flex-direction: column; gap: 22px; }
.auth-card { background: var(--card); border-radius: 24px; padding: 20px; }
.auth-card .seg { background: var(--chip); margin-bottom: 18px; }
.perks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.perks li { display: flex; gap: 14px; }
.perks .ic { width: 44px; height: 44px; flex: none; border-radius: 50%; background: var(--cobalt); color: #FFFFFF; display: grid; place-items: center; }
.perks .ic svg { width: 22px; height: 22px; }
.perks h3 { font-size: 17px; font-weight: 700; margin-bottom: 2px; }
.perks p { margin: 0; font-size: 15px; line-height: 1.45; color: var(--muted); }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 72px; }
.pw-wrap button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--accent-text); font-weight: 700; font-size: 14px; min-height: 44px; padding: 0 12px; }

/* ---------- Misc ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(104px + var(--safe-b)); transform: translate(-50%, 20px);
  background: var(--toast-bg); color: var(--toast-fg); padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: 15px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--game); flex: none; }

/* ---------- Account screens ---------- */
.auth-h { font-family: var(--f-display); font-weight: 800; font-size: 26px; letter-spacing: -0.02em; margin-bottom: 8px; }
.auth-card .field .seg { background: var(--chip); margin-bottom: 0; }
.auth-card > .seg { margin-bottom: 18px; }
.checks { display: flex; flex-direction: column; gap: 12px; margin: 4px 0 18px; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; line-height: 1.4; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--cobalt); }
.code-input { font-family: var(--f-display); font-weight: 700; font-size: 26px; letter-spacing: .35em; text-align: center; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.test-note { border: 2px dashed var(--marigold); position: relative; z-index: 1; }
.offer { text-align: center; display: flex; flex-direction: column; align-items: center; }
.offer .btn { width: 100%; }
.offer p { margin: 0 0 18px; }
.offer-ic { width: 72px; height: 72px; border-radius: 50%; background: var(--cobalt); color: var(--marigold); display: grid; place-items: center; margin-bottom: 16px; }
.offer-ic svg { width: 36px; height: 36px; }
.link:disabled { color: var(--muted); cursor: default; }
.switch { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; flex: none; border-radius: 15px; background: var(--line-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #FFFFFF; transition: transform .15s; }
.switch:checked { background: var(--cobalt); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: .45; cursor: default; }

/* ---------- Privacy Policy and Terms pages ---------- */
.legal-page { height: auto; background: var(--bg); color: var(--text); }
.legal-top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px; background: var(--header-bg, var(--card)); border-bottom: 1px solid var(--line); }
.legal-top .logo { height: 40px; margin-left: auto; }
.legal-back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 8px 0 0; color: var(--accent-text); font-weight: 700; text-decoration: none; }
.legal { max-width: 720px; margin: 0 auto; padding: 8px 20px calc(48px + env(safe-area-inset-bottom, 0px)); font-size: 16px; line-height: 1.6; overflow-wrap: anywhere; }
.legal h1 { font-family: var(--f-display); font-weight: 800; font-size: clamp(28px, 7vw, 40px); line-height: 1.1; letter-spacing: -0.02em; margin: 24px 0 8px; }
.legal h2 { font-family: var(--f-display); font-weight: 700; font-size: 20px; line-height: 1.25; margin: 32px 0 4px; }
.legal p { margin: 12px 0; }
.legal ul { margin: 8px 0; padding-left: 22px; }
.legal li { margin: 6px 0; }
.legal a { color: var(--accent-text); }
.legal-other { margin-top: 40px !important; padding-top: 16px; border-top: 1px solid var(--line); }
.legal-links { display: flex; justify-content: center; gap: 4px 20px; flex-wrap: wrap; margin: 4px 0 0; font-size: 14px; }
.legal-links a { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); text-decoration: underline; }
.choice-card { background: var(--card); border-radius: 18px; padding: 4px 16px; margin: 12px 0; box-shadow: inset 0 0 0 1px var(--line); }
.choice-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; cursor: pointer; line-height: 1.4; }
.choice-row .grow { flex: 1; min-width: 0; }
.choice-row .muted { font-size: 14px; }
.choice-status { margin: 0 0 12px !important; padding-top: 10px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.legal-callout { background: var(--card); border-radius: 16px; padding: 14px 16px; box-shadow: inset 0 0 0 1px var(--line); }
.legal .table-wrap { overflow-x: auto; margin: 12px 0; border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line); }
.legal table { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 14px; line-height: 1.45; }
.legal th, .legal td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--line); overflow-wrap: normal; }
.legal th { background: var(--card); font-weight: 700; }
.legal tr:last-child td { border-bottom: 0; }
@media (max-width: 640px) {
  .legal .table-wrap { overflow: visible; box-shadow: none; border-radius: 0; }
  .legal table, .legal tbody, .legal tr, .legal td { display: block; min-width: 0; width: auto; }
  .legal thead { display: none; }
  .legal tr { background: var(--card); border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line); padding: 6px 0; margin: 0 0 10px; }
  .legal td { border: 0; padding: 4px 14px; }
  .legal td::before { content: attr(data-label); display: block; font-family: var(--f-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
}

/* ---------- Ad slots (js/ads.js) ---------- */
.ad-slot { align-self: center; width: var(--ad-w); max-width: 100%; margin: 4px auto; display: flex; flex-direction: column; }
.ad-slot:not([data-filled]) { min-height: calc(var(--ad-h) + 22px); }
.ad-slot[hidden] { display: none; }
.ad-label { align-self: flex-end; order: -1; font-family: var(--f-mono); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); text-decoration: none; padding: 2px 0 6px 12px; }
.ad-creative { display: block; line-height: 0; border-radius: 10px; overflow: hidden; box-shadow: 0 0 0 1px var(--line); }
.ad-creative img { display: block; width: 100%; height: auto; max-width: var(--ad-w); }

/* ---------- Confirm popup ---------- */
body.dialog-open { overflow: hidden; }
.dialog-backdrop { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(18, 21, 43, .55); animation: fadeIn .15s ease-out; }
.dialog { width: 100%; max-width: 360px; background: var(--card); color: var(--text); border-radius: 24px; padding: 24px 20px 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); text-align: center; animation: popIn .18s ease-out; }
.dialog-ic { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.dialog h2 { font-family: var(--f-display); font-size: 22px; font-weight: 800; margin: 0 0 8px; }
.dialog-body p { margin: 0 0 10px; line-height: 1.5; color: var(--muted); }
.dialog-body p:last-child { color: var(--text); font-weight: 500; }
.dialog .error { margin: 0 0 12px; text-align: left; }
.dialog-actions { display: flex; gap: 10px; margin-top: 16px; }
.dialog-actions .btn { flex: 1; }
.btn.danger-solid { background: var(--danger); color: #FFFFFF; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(.94); } }
@media (prefers-reduced-motion: reduce) { .dialog-backdrop, .dialog { animation: none; } }
:root[data-theme="dark"] .btn.danger-solid { color: var(--ink); }

/* Solid strip behind the phone's status bar (clock, battery), so scrolled content never shows
   through it. Zero height in a normal browser tab; matters in the apps and the installed web app. */
body::before {
  content: ''; position: fixed; top: 0; left: 0; right: 0; height: var(--safe-t); z-index: 60;
  background: var(--header-bg); pointer-events: none;
}
