/* ═══════════════════════════════════════════════════════════════════════════
   Super System 12 — Ai Lotto Genius
   Light theme · Mobile-first · Desktop constrained column
═══════════════════════════════════════════════════════════════════════════ */

/* ── Design tokens (Set 1 – Green defaults) ─────────────────────────────── */
:root {
  --theme:        #6CBE45;
  --theme-dark:   #5BA13A;
  --theme-light:  #e8f5d8;
  --theme-xlight: #f2fbe8;
  --content-band-bg: #f0f0f0;
  --section-heading-bg: #ffffff;
  --page-bg:      #e8e8ea; /* canvas behind centered column (desktop gutters) */
  --glow-color:   rgba(108,190,69,0.15);

  --text:         #2C3E50;
  --text-muted:   #7f8c8d;
  --border:       #dde8d4;
  --white:        #ffffff;
  --shadow:       0 2px 12px rgba(0,0,0,0.09);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.16);
  --radius:       12px;
  --radius-sm:    8px;
  --footer-h:     64px;
  --sidebar-w:    350px; /* was 280px; +25% for easier tap targets */
  --max-w:        480px;
  --transition:   0.22s ease;
}

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

html {
  height: 100%;
  /* Base for all rem-based font sizes (most of the UI). */
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--page-bg);
  min-height: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* Belt-and-braces: also lock body scroll when overlay is open */
body.overlay-open { overflow: hidden; }

/* ── App wrapper — the centered light-green column ───────────────────────── */
/* Centered column: user colour / gradient + pattern (set accents unchanged) */
#app-wrapper {
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100vh;
  background-color: #ffffff;
  position: relative;
  overflow-x: hidden;
  padding-bottom: calc(var(--footer-h) + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 0 48px rgba(0,0,0,0.28);
  transition: border-color 0.5s ease;
}

  50%       { transform: translate(-50%, -50%) scale(1.22); opacity: 1;    }
}

@media (max-height: 640px) and (max-width: 380px) {
  #app-wrapper {
    padding-bottom: calc(var(--footer-h) + env(safe-area-inset-bottom, 0px) + 12px);
  }
}

/* Narrow phones: bump root rem so most UI (sized in rem) reads larger; +1px is ~6% vs 16px baseline. */
@media (max-width: 480px) {
  html {
    font-size: 17px;
  }
}

/* ── Screens ─────────────────────────────────────────────────────────────── */
.screen {
  display: none;
  position: relative;
  z-index: 1;
  animation: fadeIn 0.28s ease;
}
.screen.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header {
  background: #ffffff;
  color: var(--text);
  height: 60px;
  padding: 0 16px;
  text-align: center;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-bottom: 5px solid var(--theme);
  box-shadow: 0 2px 14px rgba(0,0,0,0.12);
  transition: border-color 0.5s ease;
}
.page-header h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-bottom: 1px;
  color: var(--text);
}
.page-header p {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 500;
}
.page-header .set-pill {
  display: inline-block;
  background: var(--theme);
  color: #fff;
  padding: 1px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  margin-left: 6px;
  text-transform: uppercase;
}

/* Numbers screen header: title row (set dropdown when compact) + lottery + set pills */
#screen-numbers .page-header {
  height: auto;
  min-height: 60px;
  padding: 8px 12px 10px;
}
.numbers-header-heading-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  position: relative;
}
.numbers-header-heading-row h1 {
  margin-bottom: 2px;
}
.numbers-header-lottery {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 500;
  margin: 0;
  line-height: 1.35;
  text-align: center;
}
.numbers-header-body {
  width: 100%;
}
.numbers-header-set-selector {
  margin-top: 8px;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  max-width: 100%;
}

.back-btn {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: #f0f0f0;
  border: none;
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background var(--transition);
}
.back-btn:active { background: #e0e0e0; }

.audio-hdr-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: #f0f0f0;
  border: none;
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background var(--transition);
}
.audio-hdr-btn:active { background: #e0e0e0; }

/* Games screen header: line 1 title, line 2 lottery, line 3 Set 1–4 pills */
#screen-games .page-header {
  height: auto;
  min-height: 60px;
  padding: 8px 48px 8px 12px;
}
.games-header-heading-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}
.games-header-heading-row h1 {
  margin: 0 0 2px 0;
}
.games-header-set-pills {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin: 4px 0 0;
  padding: 0 4px;
  box-sizing: border-box;
}
.games-header-set-pill {
  padding: 3px 10px;
  border-radius: 20px;
  border: 2px solid;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: center;
  letter-spacing: 0.45px;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.4;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
.games-header-set-pill:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}
.games-header-set-pill:active:not(:disabled) {
  opacity: 0.82;
  transform: scale(0.96);
}
#screen-games .games-header-lottery-line {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 500;
  margin: 0;
  line-height: 1.35;
  text-align: center;
  width: 100%;
}

/* ── Lottery Selector ────────────────────────────────────────────────────── */
.lottery-intro {
  text-align: center;
  padding: 14px 14px 12px;
  color: var(--text-muted);
  font-size: 0.94rem;
  position: relative;
  z-index: 1;
  background: var(--content-band-bg);
  margin: 8px 12px 6px;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.region-section { padding: 0 16px 4px; position: relative; z-index: 1; }

.region-label {
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--theme-dark);
  padding: 10px 14px 8px;
  margin: 8px 0 6px;
  background: var(--section-heading-bg);
  border-radius: var(--radius-sm);
  border-bottom: 2px solid var(--theme-light);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: color 0.5s, border-color 0.5s;
}

.lottery-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 6px;
  cursor: pointer;
  border: 1.5px solid transparent;
  box-shadow: var(--shadow);
  transition: border-color var(--transition), transform 0.15s ease;
  position: relative;
  z-index: 1;
}
.lottery-card:active { transform: scale(0.98); border-color: var(--theme); }
.lottery-flag  { font-size: 2rem; line-height: 1; flex-shrink: 0; }
.lottery-info  { flex: 1; min-width: 0; }
.lottery-info strong {
  display: block;
  font-size: 1.22rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.lottery-info span { font-size: 0.94rem; color: var(--text-muted); line-height: 1.35; display: block; }
.lottery-chevron { color: var(--theme); font-size: 1.45rem; flex-shrink: 0; }

/* Lottery selector screen only — larger title block */
#screen-lottery .page-header {
  height: auto;
  min-height: 60px;
  padding: 10px 16px;
}
#screen-lottery .page-header h1 {
  font-size: 1.38rem;
}
#screen-lottery .page-header p {
  font-size: 0.86rem;
}

/* ── Lottery links modal (official sites, by region) ─────────────────────── */
.lottery-links-modal-card {
  max-width: 440px;
}
.lottery-links-body {
  padding: 0 0 14px;
}
/* Row is not a link — only the URL line is clickable */
.lottery-link-card {
  cursor: default;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}
.lottery-link-card .lottery-info strong {
  white-space: normal;
  font-size: 1.26rem;
  font-weight: 700;
  color: var(--text);
}
.lottery-link-card .lottery-link-desc {
  display: block;
  margin-top: 4px;
  font-size: 0.94rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: normal;
  word-break: break-word;
}
.lottery-link-card .lottery-link-url {
  display: block;
  margin-top: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  color: #1565c0;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: normal;
  word-break: break-all;
  cursor: pointer;
}
.lottery-link-card .lottery-link-url:link,
.lottery-link-card .lottery-link-url:visited {
  color: #1565c0;
}
.lottery-link-card .lottery-link-url:active {
  color: #0d47a1;
}
/* Row is informational; avoid whole-card press shrink (only URL is actionable) */
.lottery-link-card.lottery-card:active {
  transform: none;
  border-color: transparent;
}
.lottery-link-external {
  color: var(--theme);
  font-size: 1.1rem;
  flex-shrink: 0;
  font-weight: 700;
}

/* ── Number Selection ────────────────────────────────────────────────────── */
.selection-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  padding: 10px 14px 8px;
  margin: 6px 12px 4px;
  position: relative;
  z-index: 1;
}
.instruction {
  flex: 1;
  min-width: 0;
  font-size: 0.88rem;
  color: #4d4d4d;
  font-weight: 500;
  line-height: 1.35;
}
.step-label   { font-weight: 800; color: var(--theme); transition: color 0.5s; }
.count-badge {
  flex-shrink: 0;
  background: var(--theme);
  color: white;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 20px;
  transition: background 0.35s, font-weight 0.35s, box-shadow 0.35s;
  white-space: nowrap;
  align-self: center;
}
/* Keep same font-size as incomplete — extra padding was widening “12 of 12” vs “11 of 12” and forcing Step 2 wrap */
.count-badge.complete {
  background: var(--theme-dark);
  font-weight: 800;
  font-size: 0.76rem;
  padding: 3px 7px;
  letter-spacing: normal;
  box-shadow:
    0 0 0 1.5px rgba(255, 255, 255, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.2);
}

/* 12 selected boxes — 2 rows of 6 (compact, inset from edges)
   Sizing: tracks & .sel-box at 80% of legacy 48px (~38.4px); digits scaled to match. */
.selected-boxes {
  display: grid;
  grid-template-columns: repeat(6, calc(48px * 0.8));
  gap: 3px;
  padding: 6px 8px 8px;
  margin-left: 10px;
  margin-right: 10px;
  justify-content: center;
  position: relative;
  z-index: 1;
  background: var(--white);
  border-radius: var(--radius-sm);
}
.sel-box {
  width: calc(48px * 0.8);
  height: calc(48px * 0.8);
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: calc(0.82rem * 0.8);
  min-width: 0;
  background: var(--white);
  color: transparent;
  transition: all 0.18s ease;
}
.sel-box.filled {
  background: var(--theme);
  border-color: var(--theme-dark);
  color: white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.selected-boxes.locked .sel-box.filled:not(.dup-split) {
  background: var(--theme-dark);
  opacity: 0.75;
  cursor: not-allowed;
}
.selected-boxes.locked .sel-box.filled.dup-split {
  opacity: 0.92;
  cursor: not-allowed;
}

/* 7-column lotteries: one row of 12 (saves vertical space on small screens) */
.selected-boxes.cols-7 {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 2px;
  margin-left: 6px;
  margin-right: 6px;
  padding-top: 0;
  padding-bottom: 6px;
}
.selected-boxes.cols-7 .sel-box {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  box-sizing: border-box;
  font-size: clamp(0.58rem, 2.8vw, 0.76rem);
  border-width: 1.5px;
}

/* Number grid */
.grid-wrap { padding: 4px 16px 6px; position: relative; z-index: 1; min-width: 0; max-width: 100%; box-sizing: border-box; }
.grid-wrap.cols-7 {
  padding-left: 28px;
  padding-right: 28px;
}
/* Games: less vertical gap between 6-up row, main grid, and Prev/Next */
#screen-games .grid-wrap {
  padding-top: 2px;
  padding-bottom: 3px;
}
.number-grid {
  display: grid;
  gap: 3px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 8px;
  border: 1px solid #aaaaaa;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.num-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  font-weight: 600;
  font-size: 0.8rem;
  min-width: 0; /* allow grid track to shrink below digit min-content */
  cursor: pointer;
  background: #f5f8f2;
  border: 2px solid transparent;
  transition: all 0.16s ease;
  user-select: none;
  color: var(--text);
}
.num-cell:active      { transform: scale(0.86); }
.num-cell.selected    {
  background: var(--theme);
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}
/* Set 4 duplicate picks: diagonal split matches select-boxes strip */
.num-cell.selected.selected-dup-split {
  color: #fff;
  border-color: var(--theme-dark);
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
.num-cell.in-game     {
  background: var(--theme);
  color: white;
  border-color: transparent;
  box-shadow: none;
}
/* Numbers already used in a previous set — greyed out, not clickable (legacy) */
.num-cell.used {
  background: #e8e8e8;
  color: #b0b0b0;
  cursor: not-allowed;
  border-color: transparent;
}
.num-cell.used:active { transform: none; }

/* Numbers used in a previous set — shown with that set's colour (inline bg applied by JS) */
.num-cell.used-prev {
  border-color: transparent;
  cursor: not-allowed;
  /* background, color, opacity applied inline per set theme */
}
.num-cell.used-prev:active { transform: none; }

/* Set 4 only: used-prev cells that can be tapped as duplicates */
.num-cell.dup-available {
  cursor: pointer;
  /* slightly brighter opacity set inline (0.62) */
}
.num-cell.dup-available:active { transform: scale(0.86); }

.num-cell.empty       { background: transparent; border: none; cursor: default; pointer-events: none; }

/* ── Audio mode buttons ──────────────────────────────────────────────────── */
.audio-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px 4px;
  position: relative;
  z-index: 1;
}
.audio-opt {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 7px 14px;
  border-radius: 20px;
  border: 2px solid var(--theme);
  background: var(--white);
  color: var(--theme-dark);
  transition: all var(--transition);
  user-select: none;
}
.audio-opt input { display: none; }
.audio-opt.active {
  background: var(--theme);
  color: white;
  border-color: var(--theme-dark);
}
.audio-opt:active { opacity: 0.8; }

/* ── Action buttons ──────────────────────────────────────────────────────── */
.btn-row {
  display: flex;
  gap: 10px;
  padding: 2px 16px;
  position: relative;
  z-index: 1;
}
.btn {
  flex: 1;
  padding: 9px 10px;
  border: 2px solid var(--theme);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--white);
  color: var(--theme-dark);
  transition: all var(--transition);
}
.btn:active { background: var(--theme-light); transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

/* View Games button — filled theme style on numbers screen */
.btn.btn-generate-main {
  background: var(--theme);
  color: white;
  border-color: var(--theme-dark);
}
.btn.btn-generate-main:active { background: var(--theme-dark); transform: scale(0.97); }
.btn.btn-generate-main:disabled { background: var(--white); color: var(--theme-dark); opacity: 0.35; cursor: not-allowed; }

/* Generate button */
.btn-generate {
  display: block;
  width: calc(100% - 32px);
  margin: 8px auto;
  padding: 15px 10px;
  background: linear-gradient(135deg, var(--theme) 0%, var(--theme-dark) 100%);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.2px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  transition: all var(--transition);
  position: relative;
  z-index: 1;
}
.btn-generate:active { transform: scale(0.98); box-shadow: none; }
.btn-generate.hidden { display: none; }

@keyframes popIn {
  0%   { transform: scale(0.8); opacity: 0; }
  70%  { transform: scale(1.04); }
  100% { transform: scale(1); opacity: 1; }
}
.btn-generate.appear { animation: popIn 0.35s ease forwards; }

@keyframes generatePulse {
  0%, 100% { box-shadow: 0 4px 14px rgba(0,0,0,0.15); transform: scale(1); }
  50%       { box-shadow: 0 4px 24px rgba(0,0,0,0.22), 0 0 0 8px var(--theme-light); transform: scale(1.025); }
}
.btn.btn-generate-main.pulse-anim:not(:disabled) {
  animation: generatePulse 1s ease-in-out infinite;
}

/* ── Games Display — status band (counter, set controls, progress) ───────── */

#screen-games .games-status-band {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  background: transparent;
  margin: 6px 12px 6px;
  padding: 8px 14px 10px;
  position: relative;
  z-index: 1;
}

#screen-games .games-line-counter-and-sets {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
#screen-games .games-status-band .progress-wrap {
  margin: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}

/* Game counter — BOLD, sits inline */
.game-counter {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  white-space: nowrap;
  flex-shrink: 0;
}
.game-counter.pre-gen {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}

/* Progress bar */
.progress-wrap { padding: 4px 16px 10px; position: relative; z-index: 1; }
.progress-track {
  background: var(--theme-light);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--theme), var(--theme-dark));
  border-radius: 99px;
  transition: width 0.4s ease;
  min-width: 4px;
}

/* ── Set Selector — inline with game counter ─────────────────────────────── */
.set-selector {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-shrink: 0;
}
.set-pill-btn {
  padding: 3px 10px;
  border-radius: 20px;
  border: 2px solid;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: center;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.4;
}
.set-pill-btn:active { opacity: 0.72; transform: scale(0.92); }

/* Current game row — match .num-cell scale; extra inset so row is narrower than grid */
.game-boxes {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 3px;
  padding: 6px 40px 6px;
  position: relative;
  z-index: 1;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
  background: var(--white);
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 10px rgba(0,0,0,0.09);
  margin: 0 12px;
}
.game-box {
  aspect-ratio: 1;
  background: var(--theme);
  color: white;
  border-radius: 7px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  min-width: 0;
  font-weight: 600;
  box-shadow: none;
  animation: gameBoxIn 0.22s ease;
}
/* 7-col lotteries: match single-row 12 strip cell size (not full-width 6-up) */
#screen-games:has(.grid-wrap.cols-7) .game-boxes {
  gap: 2px;
  max-width: calc((100% - 12px) / 2 - 2px);
  margin-left: auto;
  margin-right: auto;
  padding: 2px 6px 4px;
  box-sizing: border-box;
}
#screen-games:has(.grid-wrap.cols-7) .game-box {
  font-size: clamp(0.58rem, 2.8vw, 0.76rem);
  font-weight: 700;
  border-radius: var(--radius-sm);
}
@keyframes gameBoxIn {
  from { transform: scale(0.72); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.games-screen-spacer {
  height: 4px;
}

/* Nav buttons */
.game-nav {
  display: flex;
  gap: 8px;
  padding: 4px 16px 6px;
  position: relative;
  z-index: 1;
  align-items: stretch;
}
.btn-nav {
  flex: 1;
  padding: 10px 6px;
  border: 2px solid var(--theme);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--theme-dark);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  line-height: 1.3;
}
.btn-nav:active   { background: var(--theme-light); transform: scale(0.97); }
.btn-nav:disabled { opacity: 0.38; cursor: not-allowed; transform: none; }

/* Generate 42 Games — middle nav button (primary action) */
.btn-nav.btn-generate-games {
  background: linear-gradient(135deg, var(--theme) 0%, var(--theme-dark) 100%);
  color: white;
  border-color: var(--theme-dark);
  font-size: 0.8rem;
  padding-left: 4px;
  padding-right: 4px;
}
.btn-nav.btn-generate-games:active { opacity: 0.88; transform: scale(0.97); }

/* Mobile (≤560px): +50% number / game-row / Prev–Next type only; step line uses base .instruction */
@media (max-width: 560px) {
  .selected-boxes:not(.cols-7) {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 5px;
    width: 80%;
    max-width: calc(100% - 16px);
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
  }
  .selected-boxes:not(.cols-7) .sel-box {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    min-width: 0;
    font-size: calc(1.23rem * 0.8);
  }
  .selected-boxes.cols-7 {
    gap: 4px;
    max-width: calc(100% - 12px); /* side margins 6+6 */
    box-sizing: border-box;
  }
  .selected-boxes.cols-7 .sel-box {
    font-size: clamp(0.87rem, 4.2vw, 1.14rem); /* base clamp × 1.5 */
  }
  /* More width for .num-cell squares + slightly larger gutters */
  .grid-wrap {
    padding-left: 10px;
    padding-right: 10px;
  }
  .grid-wrap.cols-7 {
    /* Base uses 28px — too tight on narrow / devtools mobile with large type */
    padding-left: 10px;
    padding-right: 10px;
  }
  .number-grid {
    gap: 5px;
    padding: 10px;
  }
  .num-cell {
    font-size: 1.2rem; /* base 0.8rem × 1.5 */
    min-width: 0;
  }
  /* Match “Original 12” selection strip: same fluid scale + type size */
  .game-boxes {
    padding: 2px 8px 3px;
    gap: 5px;
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .game-box {
    font-size: 1.23rem;
    min-width: 0;
    border-radius: var(--radius-sm);
  }
  /*
   * 7-col lotteries: Original 12 uses one row × 12 columns (small cells). Games uses 6 balls;
   * without this, each game cell is ~2× as wide as a strip cell. Shrink + match type to .selected-boxes.cols-7 .sel-box.
   */
  #screen-games:has(.grid-wrap.cols-7) .game-boxes {
    gap: 4px;
    max-width: calc((100% - 12px) / 2 - 2px);
    margin-left: auto;
    margin-right: auto;
    padding-left: 6px;
    padding-right: 6px;
    box-sizing: border-box;
  }
  #screen-games:has(.grid-wrap.cols-7) .game-box {
    font-size: clamp(0.87rem, 4.2vw, 1.14rem);
    font-weight: 700;
    border-radius: var(--radius-sm);
  }
  .btn-nav:not(.btn-generate-games) {
    font-size: 1.23rem; /* base 0.82rem × 1.5 — Prev / Next */
  }
  #screen-games .grid-wrap {
    padding-top: 1px;
    padding-bottom: 1px;
  }
  #screen-games .game-nav {
    padding-top: 2px;
    padding-bottom: 4px;
  }
}

/*
 * Short + narrow viewport only (e.g. 360×640): tighter fit without affecting 360×800+.
 * Uses width AND height caps so taller phones at 360px wide keep the normal ≤560px mobile look.
 */
@media (max-width: 360px) and (max-height: 640px) {
  /* Games header: tighter padding + smaller pills so header fits in 360px */
  #screen-games .page-header {
    padding: 4px 44px 4px 10px;
  }
  .games-header-set-pills {
    gap: 4px;
    margin-top: 2px;
  }
  .games-header-set-pill {
    padding: 2px 7px;
    font-size: 0.62rem;
  }

  /* Games status band: tighter vertical spacing (no longer needs row layout for dropdown) */
  #screen-games .games-status-band {
    gap: 6px;
    padding: 7px 10px;
  }
  #screen-games .games-status-band .game-counter {
    font-size: 0.85rem;
  }
  #screen-games .games-status-band .progress-track {
    height: 6px;
  }

  /* Numbers screen header: reduce top/bottom padding and pill gap */
  #screen-numbers .page-header {
    padding: 4px 12px 4px;
  }
  .numbers-header-set-selector {
    margin-top: 2px;
  }

  /* Numbers screen: all three actions stay on one row — smaller type / padding */
  #btn-row-actions {
    flex-wrap: nowrap;
    gap: 6px;
    padding: 2px 8px;
  }
  #btn-row-actions .btn {
    flex: 1;
    min-width: 0;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 7px 4px;
    line-height: 1.2;
  }
  #btn-row-set-nav .btn {
    font-size: 0.76rem;
    padding: 8px 8px;
  }

  .selection-meta {
    padding: 8px 10px 6px;
    margin: 5px 8px 4px;
    gap: 4px;
  }
  #screen-numbers .instruction {
    font-size: 0.76rem;
  }

  .selected-boxes:not(.cols-7) {
    gap: 4px;
    margin-left: auto;
    margin-right: auto;
    width: 80%;
    max-width: calc(100% - 12px);
  }
  .selected-boxes:not(.cols-7) .sel-box {
    font-size: calc(1.05rem * 0.8);
  }
  .selected-boxes.cols-7 .sel-box {
    font-size: clamp(0.78rem, 3.6vw, 1rem);
  }
  .grid-wrap {
    padding-left: 6px;
    padding-right: 6px;
  }
  .grid-wrap.cols-7 {
    padding-left: 6px;
    padding-right: 6px;
  }
  .number-grid {
    gap: 4px;
    padding: 6px;
  }
  .num-cell {
    font-size: 1.05rem;
  }
  /* Same fluid scale + font as 12-slot strip on this viewport */
  .game-boxes {
    padding: 2px 8px 2px;
    gap: 4px;
    margin-left: 6px;
    margin-right: 6px;
    max-width: calc(100% - 12px);
    box-sizing: border-box;
  }
  .game-box {
    font-size: 1.05rem;
    min-width: 0;
    border-radius: 6px;
  }
  #screen-games:has(.grid-wrap.cols-7) .game-boxes {
    max-width: calc((100% - 12px) / 2 - 2px);
    padding-left: 0;
    padding-right: 0;
  }
  #screen-games:has(.grid-wrap.cols-7) .game-box {
    font-size: clamp(0.78rem, 3.6vw, 1rem);
    border-radius: var(--radius-sm);
  }
  .game-nav {
    padding: 6px 10px;
    gap: 6px;
  }
  .btn-nav:not(.btn-generate-games) {
    font-size: 1.05rem;
    padding: 9px 4px;
  }
  .btn-nav.btn-generate-games {
    font-size: 0.72rem;
    padding-left: 2px;
    padding-right: 2px;
  }
  #screen-games .grid-wrap {
    padding-top: 0;
    padding-bottom: 0;
  }
  #screen-games .game-nav {
    padding-top: 2px;
    padding-bottom: 3px;
  }
}

/* Very short viewports (e.g. 360×): avoid extra scroll from wrapper min-height + slack */
@media (max-width: 360px) and (max-height: 420px) {
  #app-wrapper {
    min-height: 0;
    padding-bottom: calc(var(--footer-h) + env(safe-area-inset-bottom, 0px));
  }
  .games-screen-spacer {
    display: none;
  }
  #screen-games .games-status-band {
    margin: 4px 10px 4px;
    padding: 6px 8px;
  }
  #screen-games .grid-wrap {
    padding-top: 0;
    padding-bottom: 0;
  }
  #screen-games .game-boxes {
    padding-bottom: 0;
    margin-bottom: 0;
  }
  #screen-games .game-nav {
    padding-top: 2px;
    padding-bottom: 2px;
  }
}


/* ── Sticky Footer ───────────────────────────────────────────────────────── */
#app-footer {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-w);
  box-sizing: border-box;
  min-height: var(--footer-h);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  height: auto;
  background: var(--white);
  border-top: 1.5px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 200;
  box-shadow: 0 -3px 16px rgba(0,0,0,0.09);
}
.footer-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  line-height: 1.25;
  text-align: center;
  transition: color var(--transition);
  padding: 0 3px;
  position: relative;
}
.footer-btn .f-icon { font-size: 1.15rem; line-height: 1; transition: transform 0.18s ease; }
.footer-btn:active .f-icon { transform: scale(0.82); }
.footer-btn.active { color: var(--theme); }
.footer-btn.active::after {
  content: '';
  position: absolute;
  top: 0; left: 15%; right: 15%;
  height: 3px;
  background: var(--theme);
  border-radius: 0 0 4px 4px;
}
.footer-btn:disabled { opacity: 0.38; cursor: not-allowed; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--white);
  z-index: 400;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  pointer-events: none;
}
#sidebar.open {
  transform: translateX(0);
  pointer-events: auto;
}

.sidebar-head {
  background: linear-gradient(135deg, var(--theme) 0%, var(--theme-dark) 100%);
  padding: 40px 20px 20px;
  color: white;
  position: relative;
  transition: background 0.5s ease;
}
.sidebar-head h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 2px; }
.sidebar-head p  { font-size: 0.79rem; opacity: 0.85; }
.sidebar-close {
  position: absolute;
  top: 14px; right: 14px;
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-close:active { background: rgba(255,255,255,0.38); }

.sidebar-nav   { flex: 1; padding: 8px 0; }
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  color: var(--text);
  font-size: 0.93rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background var(--transition);
  text-decoration: none;
}
.sidebar-item:active { background: var(--theme-light); }
.sidebar-item:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  pointer-events: none;
}
.sidebar-item .si-icon { font-size: 1.15rem; width: 22px; text-align: center; }
.sidebar-divider { height: 1px; background: var(--border); margin: 4px 20px; }

.sidebar-audio { padding: 10px 20px 12px; }
.sidebar-audio p {
  font-size: 0.78rem; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.7px;
  margin-bottom: 8px;
}
.sidebar-audio .audio-row { padding: 0; justify-content: flex-start; flex-wrap: wrap; gap: 5px; }

.sidebar-footer-note {
  padding: 14px 20px;
  font-size: 0.73rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  text-align: center;
  line-height: 1.6;
}

/* ── Overlay ─────────────────────────────────────────────────────────────── */
#overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.48);
  z-index: 300;
}
#overlay.visible { display: block; }

/* ── Modal base ──────────────────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal.open { display: flex; }

/* Enter-games modal: centered on mobile unless “Name your save” (textarea) needs top pin */
@media (max-width: 560px) {
  #modal-enter-games.modal.open {
    align-items: center;
    justify-content: center;
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top, 0px));
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #modal-enter-games.modal.open.modal-enter-top-mobile {
    align-items: flex-start;
    justify-content: center;
    padding-top: max(10px, env(safe-area-inset-top, 0px));
  }
}

.modal-card {
  background: var(--white);
  border-radius: var(--radius);
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-card.small-card { max-width: 340px; }

/* Two-line “Are Ready!” title in add-set modal */
#add-set-title {
  line-height: 1.3;
  max-width: 16em;
  margin-left: auto;
  margin-right: auto;
}

@keyframes modalIn {
  from { transform: scale(0.88) translateY(20px); opacity: 0; }
  to   { transform: scale(1)    translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--white);
  border-radius: var(--radius) var(--radius) 0 0;
  z-index: 1;
}
.modal-header h2 { font-size: 1.12rem; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--theme-light);
  color: var(--theme-dark);
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}

/* ── Intro Modal: full-page ──────────────────────────────────────────────── */
#modal-intro {
  padding: 0;
  background: var(--white);
  align-items: stretch;
  justify-content: center;
}
#modal-intro .modal-card {
  max-width: none;
  width: 100%;
  height: 100%;
  max-height: 100%;
  border-radius: 0;
  box-shadow: none;
  animation: introFade 0.3s ease;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
#modal-intro .intro-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
@keyframes introFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Tablet landscape / desktop: centered card on gradient background */
@media (min-width: 600px) {
  #modal-intro {
    align-items: center;
    padding: 24px 16px;
  }
  #modal-intro .modal-card {
    max-width: var(--max-w);
    height: auto;
    max-height: 90vh;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding-top: 0;
    padding-bottom: 0;
  }
  #modal-intro .intro-header {
    border-radius: var(--radius) var(--radius) 0 0;
  }
}

.intro-header {
  background: var(--white);
  padding: 14px 18px 12px;
  text-align: center;
  color: var(--text);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 5px solid var(--theme);
}
#modal-intro .intro-header {
  border-radius: 0;
  flex-shrink: 0;
}
.intro-header .app-badge {
  display: inline-block;
  background: var(--theme-light);
  color: var(--theme-dark);
  padding: 2px 12px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.intro-header h1 { font-size: 1.55rem; font-weight: 800; margin-bottom: 2px; color: var(--text); }
.intro-header p  { font-size: 0.86rem; margin: 0; line-height: 1.25; color: var(--text-muted); }

.intro-body { padding: 18px 20px; }

.video-placeholder {
  background: linear-gradient(135deg, #1a2a1a 0%, #2d4a2d 100%);
  border-radius: var(--radius-sm);
  aspect-ratio: 16/9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: white;
  margin-bottom: 16px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.video-placeholder::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(108,190,69,0.18) 0%, transparent 65%);
}
@keyframes playPulse {
  0%, 100% { transform: scale(1);    box-shadow: 0 0 22px rgba(108,190,69,0.5); }
  50%       { transform: scale(1.15); box-shadow: 0 0 36px rgba(108,190,69,0.85); }
}
.video-placeholder .play-btn {
  width: 50px; height: 50px;
  min-width: 50px; min-height: 50px;
  flex-shrink: 0;
  background: rgba(108,190,69,0.9);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  position: relative; z-index: 1;
  box-shadow: 0 0 22px rgba(108,190,69,0.5);
  animation: playPulse 1s ease-in-out infinite;
}

/* 360×640 small screens: shrink video so all content fits without scrolling */
@media (max-width: 390px) and (max-height: 680px) {
  #modal-intro .intro-header {
    padding: 8px 18px 6px;
  }
  #modal-intro .intro-header .app-badge {
    margin-bottom: 2px;
  }
  #modal-intro .intro-header h1 { font-size: 1.2rem; }
  #modal-intro .intro-header p  { font-size: 0.78rem; }
  #modal-intro .intro-body { padding: 12px 16px; }
  #modal-intro .video-placeholder {
    aspect-ratio: unset;
    height: 110px;
    margin-bottom: 10px;
    justify-content: flex-start;
    padding-top: 18px;
  }
}
.video-placeholder .vid-label { font-size: 0.82rem; font-weight: 600; opacity: 0.85; position: relative; z-index: 1; }
.video-placeholder .vid-soon  { font-size: 0.68rem; opacity: 0.5; position: relative; z-index: 1; }

.intro-benefits h3 {
  font-size: 0.82rem; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.7px;
  margin-bottom: 6px;
}
.benefit-item {
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 4px;
  font-size: 0.9rem;
  line-height: 1.28;
}
.benefit-item .check { color: var(--theme); font-size: 1rem; flex-shrink: 0; margin-top: 1px; font-weight: 700; line-height: 1.28; }

.guarantee-box {
  background: var(--theme-light);
  border-left: 4px solid var(--theme);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 14px;
  margin: 12px 0 14px;
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--theme-dark);
  font-style: normal;
  line-height: 1.4;
  transition: background 0.5s, border-color 0.5s, color 0.5s;
}

.intro-actions { display: flex; flex-direction: column; gap: 12px; }

.dont-show {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.82rem; color: var(--text-muted);
  cursor: pointer; justify-content: center;
}
.dont-show input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--theme);
  cursor: pointer;
}

/* ── All Games Modal ─────────────────────────────────────────────────────── */
.view-toggle {
  display: flex;
  gap: 0;
  padding: 10px 18px 8px;
  border-bottom: 1px solid var(--border);
}
.view-toggle-btn {
  flex: 1;
  padding: 8px 10px;
  border: 2px solid var(--theme);
  font-size: 0.83rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--white);
  color: var(--theme-dark);
  transition: all var(--transition);
}
.view-toggle-btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.view-toggle-btn:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: none; }
.view-toggle-btn.active      { background: var(--theme); color: white; border-color: var(--theme-dark); }

/* All Games modal: header + pills + toggle fixed; rows scroll inside */
.modal-all-games-card {
  max-width: 440px;
  max-height: min(92vh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-all-games-header {
  position: relative;
  flex-shrink: 0;
}
.all-games-set-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--white);
}
.all-games-set-pills.hidden { display: none; }
.modal-all-games-card .view-toggle {
  flex-shrink: 0;
}
.all-games-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.all-games-section {
  padding-bottom: 4px;
}
.all-games-section-heading {
  position: sticky;
  top: 0;
  z-index: 2;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.55px;
  padding: 10px 18px 6px;
  margin: 0;
  border-left: 4px solid var(--section-accent, var(--theme));
  background: linear-gradient(to bottom, #fff 70%, transparent);
}

.all-games-pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 2px solid var(--theme);
  background: var(--white);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}
.all-games-pill:active { transform: scale(0.97); }

/* List View */
.all-games-list { padding: 4px 0 12px; }
.all-game-row {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 18px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid #f5f5f5;
}
.all-game-row:active  { background: var(--theme-xlight); }
.all-game-row.current { background: var(--theme-light); }
.all-game-done-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 4px;
}
.all-game-done-wrap input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--theme);
  cursor: pointer;
  margin: 0;
}
.all-game-num {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  width: 24px;
  flex-shrink: 0;
}
.all-game-row-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.all-game-balls { display: flex; gap: 4px; flex-wrap: wrap; }
.mini-ball {
  width: 28px; height: 28px;
  background: var(--ball-bg, var(--theme));
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
}

/* Game View */
.all-games-cards { padding: 8px 12px 16px; }
.game-card-hdr {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.game-card-done-wrap {
  flex-shrink: 0;
}
.game-card-done-wrap input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--theme);
  cursor: pointer;
  margin: 0;
}
.game-card {
  background: #f9f9f9;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
}
.game-card:active  { background: var(--theme-xlight); border-color: var(--theme); }
.game-card.current {
  border-color: var(--card-accent, var(--theme));
  background: var(--theme-xlight);
}
.game-card-label {
  flex: 1;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.game-card-balls {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
}
.game-card-ball {
  aspect-ratio: 1;
  background: var(--ball-bg, var(--theme));
  color: white;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  font-weight: 800;
}

/* Legal (Privacy / Terms) popup */
.legal-modal-card {
  max-width: 520px;
  width: calc(100vw - 28px);
  height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.legal-modal-head {
  flex-shrink: 0;
  position: relative;
}
.legal-iframe {
  flex: 1;
  width: 100%;
  min-height: 240px;
  border: none;
  background: var(--white);
}

/* ── Generate Info Popup ─────────────────────────────────────────────────── */
.info-popup-body { padding: 18px 20px; text-align: center; }
.info-popup-body .info-icon { font-size: 2.5rem; margin-bottom: 8px; }
.info-popup-body h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 10px; }
.info-popup-body p  { font-size: 0.9rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 8px; }
.info-popup-body .info-steps {
  text-align: left;
  background: var(--theme-xlight);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 12px 0;
}
.info-step { font-size: 0.88rem; padding: 4px 0; display: flex; gap: 8px; align-items: flex-start; }
.info-step strong { color: var(--theme-dark); flex-shrink: 0; }

/* ── Add Another Set Popup ───────────────────────────────────────────────── */
.add-set-body { padding: 20px; text-align: center; }
.add-set-body .trophy-icon { font-size: 2.8rem; margin-bottom: 6px; }
.add-set-body h3 { font-size: 1.1rem; font-weight: 800; margin-bottom: 10px; }
.add-set-body p  { font-size: 0.88rem; color: var(--text-muted); line-height: 1.65; margin-bottom: 16px; }
.add-set-actions { display: flex; flex-direction: column; gap: 10px; }
.btn-outline {
  display: block;
  width: 100%;
  padding: 12px;
  border: 2px solid var(--theme);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--theme-dark);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
}
.btn-outline:active { background: var(--theme-light); }

/* ── Voice Speed Popup ───────────────────────────────────────────────────── */
.voice-speed-body { padding: 20px; text-align: center; }
.voice-speed-body p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 14px; }
.speed-slider {
  width: 100%;
  accent-color: var(--theme);
  cursor: pointer;
  margin: 6px 0 10px;
  height: 6px;
}
.speed-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}
.speed-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--theme);
  margin: 8px 0 14px;
}

/* ── Exit Warning Popup ──────────────────────────────────────────────────── */
/* ── Generation animation state ─────────────────────────────────────────── */
.gen-animating {
  padding: 30px 20px 26px;
  text-align: center;
}
.gen-anim-icon {
  font-size: 2.4rem;
  margin-bottom: 10px;
  animation: gen-spin 1.4s linear infinite;
}
@keyframes gen-spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.gen-anim-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 10px;
}
.gen-counter {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--theme-dark);
  margin-bottom: 16px;
  letter-spacing: 0.3px;
  font-variant-numeric: tabular-nums;
  min-width: 140px;
  display: inline-block;
}
.gen-progress-track {
  height: 8px;
  background: #e4e4e4;
  border-radius: 4px;
  overflow: hidden;
}
.gen-progress-fill {
  height: 100%;
  width: 100%;
  background: var(--theme);
  border-radius: 4px;
  transform-origin: left center;
  transform: scaleX(0);
}

/* ── Enter Games prompt popup ───────────────────────────────────────────── */
.enter-games-body {
  padding: 28px 20px 22px;
  text-align: center;
}
.enter-games-icon {
  font-size: 2.6rem;
  margin-bottom: 10px;
}
.enter-games-body h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 10px;
}
.enter-games-body p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 20px;
}
.btn-cancel-themed {
  color: var(--theme);
  border-color: var(--theme);
}
.btn-cancel-themed:active { background: var(--theme-light); }

/* ── Save prompt popup (State 2) ─────────────────────────────────────────── */
.enter-save-body {
  padding: 26px 20px 22px;
  text-align: center;
}
.save-prompt-icon {
  font-size: 2.4rem;
  margin-bottom: 10px;
}
.enter-save-body h3 {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.45;
}
.save-prompt-sub {
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}

/* ── Save name input (State 2b) ──────────────────────────────────────────── */
.enter-save-input-body {
  padding: 26px 20px 22px;
  text-align: center;
}
.enter-save-input-body h3 {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text);
}
.save-name-field {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  resize: none;
  line-height: 1.5;
  transition: border-color var(--transition);
  margin-bottom: 2px;
}
.save-name-field:focus { border-color: var(--theme); }

/* ── OK to Start popup ───────────────────────────────────────────────────── */
.ok-to-start-body {
  padding: 26px 20px 22px;
  text-align: center;
}
.ok-to-start-icon {
  font-size: 2.4rem;
  margin-bottom: 10px;
}
.ok-to-start-body h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}
.ok-to-start-body p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 18px;
}

/* ── Audio Mode popup ────────────────────────────────────────────────────── */
.audio-mode-body {
  padding: 20px 20px 16px;
  text-align: center;
}
.audio-mode-body h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}
.audio-mode-opts {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 14px;
}
.audio-mode-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 6px;
  background: #f4f4f4;
  border: 2px solid transparent;
  border-radius: 10px;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.18s;
}
.audio-mode-btn span {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}
.audio-mode-btn.active {
  background: var(--theme-light);
  border-color: var(--theme);
}
.audio-mode-btn.active span { color: var(--theme-dark); }
.audio-mode-btn:active { opacity: 0.75; }

.exit-warning-body {
  padding: 24px 20px 20px;
  text-align: center;
}
.exit-warning-body .exit-icon {
  font-size: 2.6rem;
  margin-bottom: 8px;
}
.exit-warning-body h3 {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text);
}
.exit-warning-body p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 18px;
}
.exit-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.btn-exit-danger {
  color: #c0392b;
  border-color: #c0392b;
}
.btn-exit-danger:active { background: #fdecea; }

/* ── Modals (except first-time intro): larger copy ───────────────────────── */
.modal:not(#modal-intro) .modal-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
}
.modal:not(#modal-intro) .modal-close {
  font-size: 1.1rem;
  width: 32px;
  height: 32px;
}
.modal:not(#modal-intro) .info-popup-body .info-icon { font-size: 2.85rem; }
.modal:not(#modal-intro) .info-popup-body h3 { font-size: 1.34rem; }
.modal:not(#modal-intro) .info-popup-body p { font-size: 0.93rem; }
.modal:not(#modal-intro) .info-step { font-size: 0.9rem; }
.modal:not(#modal-intro) .info-popup-body .dont-show { font-size: 0.88rem; }
.modal:not(#modal-intro) .add-set-body .trophy-icon { font-size: 3.1rem; }
.modal:not(#modal-intro) .add-set-body h3 { font-size: 1.36rem; }
.modal:not(#modal-intro) .add-set-body p { font-size: 0.93rem; }
.modal:not(#modal-intro) .btn-outline { font-size: 0.98rem; padding: 13px; }
.modal:not(#modal-intro) .enter-games-icon { font-size: 2.85rem; }
.modal:not(#modal-intro) .enter-games-body h3 { font-size: 1.34rem; }
.modal:not(#modal-intro) .enter-games-body p { font-size: 0.93rem; }
.modal:not(#modal-intro) .save-prompt-icon { font-size: 2.65rem; }
.modal:not(#modal-intro) .enter-save-body h3 { font-size: 1.22rem; }
.modal:not(#modal-intro) .save-prompt-sub { font-size: 0.9rem; }
.modal:not(#modal-intro) .enter-save-input-body h3 { font-size: 1.28rem; }
.modal:not(#modal-intro) .save-name-field { font-size: 0.96rem; }
.modal:not(#modal-intro) .ok-to-start-icon { font-size: 2.65rem; }
.modal:not(#modal-intro) .ok-to-start-body h3 { font-size: 1.34rem; }
.modal:not(#modal-intro) .ok-to-start-body p { font-size: 0.93rem; }
.modal:not(#modal-intro) .btn-generate { font-size: 1.1rem; }
.modal:not(#modal-intro) .voice-speed-body p { font-size: 0.9rem; }
.modal:not(#modal-intro) .speed-labels { font-size: 0.8rem; }
.modal:not(#modal-intro) .speed-value { font-size: 1.05rem; }
.modal:not(#modal-intro) .audio-mode-body h3 { font-size: 1.26rem; }
.modal:not(#modal-intro) .audio-mode-btn { font-size: 1.6rem; }
.modal:not(#modal-intro) .audio-mode-btn span { font-size: 0.76rem; }
.modal:not(#modal-intro) .exit-warning-body .exit-icon { font-size: 2.85rem; }
.modal:not(#modal-intro) .exit-warning-body h3 { font-size: 1.34rem; }
.modal:not(#modal-intro) .exit-warning-body p { font-size: 0.93rem; }
.modal:not(#modal-intro) .gen-anim-icon { font-size: 2.65rem; }
.modal:not(#modal-intro) .gen-anim-title { font-size: 1.3rem; }
.modal:not(#modal-intro) .gen-counter { font-size: 0.9rem; }
.modal:not(#modal-intro) .view-toggle-btn { font-size: 0.9rem; padding: 9px 12px; }
.modal:not(#modal-intro) #all-games-modal-title { font-size: 1.34rem; }
.modal:not(#modal-intro) .all-games-set-pills .all-games-pill { font-size: 0.84rem; }
.modal:not(#modal-intro) .all-games-section-heading { font-size: 0.9rem; }
.modal:not(#modal-intro) .all-game-num { font-size: 0.74rem; }
.modal:not(#modal-intro) .mini-ball { font-size: 0.74rem; width: 30px; height: 30px; }
.modal:not(#modal-intro) .game-card-label { font-size: 0.78rem; }
.modal:not(#modal-intro) .game-card-ball { font-size: 0.98rem; }
.modal:not(#modal-intro) #legal-modal-title { font-size: 1.3rem; }

/* Lottery Links title must stay larger than generic modal headers */
#modal-lottery-links .modal-header h2 {
  font-size: 1.48rem;
  font-weight: 800;
}


/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: calc(var(--footer-h) + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: rgba(44,62,80,0.92);
  color: white;
  padding: 9px 20px;
  border-radius: 24px;
  font-size: 0.84rem;
  font-weight: 500;
  white-space: nowrap;
  z-index: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.28s ease;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden     { display: none !important; }
.text-center { text-align: center; }
