:root {
  color-scheme: dark;
  --bg:         #0d0f14;
  --surface:    #161a22;
  --surface2:   #1e2330;
  --border:     #262d3d;
  --text:       #edf0f7;
  --muted:      #7b879e;
  --green:      #3ecf6e;
  --green-dim:  rgba(62,207,110,.15);
  --blue:       #4da6ff;
  --blue-dim:   rgba(77,166,255,.12);
  --red:        #ff5c6e;
  --red-dim:    rgba(255,92,110,.13);
  --amber:      #f5b83d;
  --amber-dim:  rgba(245,184,61,.12);
  --radius:     12px;
  --radius-sm:  8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overscroll-behavior: none;
}

/* ── Shell ── */
.appShell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 480px;
  margin: 0 auto;
}

/* ── Header ── */
.appHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  flex-shrink: 0;
}

.headerLeft { display: flex; align-items: baseline; gap: 8px; }

.appTitle {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.3px;
}

.appSubtitle {
  font-size: 11px;
  color: var(--muted);
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.statusDot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: background .3s;
  flex-shrink: 0;
}
.statusDot.is-online  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.statusDot.is-stale   { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.statusDot.is-error   { background: var(--red); }

/* ── Filter chips ── */
.filterBar {
  display: flex;
  gap: 6px;
  padding: 0 16px 12px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.filterBar::-webkit-scrollbar { display: none; }

.filterChip {
  flex-shrink: 0;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 700 11px/1 inherit;
  letter-spacing: .3px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.filterChip.is-active {
  background: var(--green-dim);
  border-color: rgba(62,207,110,.4);
  color: var(--green);
}

/* ── Page content ── */
.pageContent {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 12px 24px;
}

.panel { display: none; }
.panel.is-active { display: block; }

/* ── Card list ── */
.cardList { display: flex; flex-direction: column; gap: 10px; }

/* ── Match card ── */
.matchCard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s;
}

.matchCard.is-live {
  border-color: rgba(62,207,110,.3);
}

/* Card top row */
.matchCardTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px 8px;
}

.matchLeague {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.matchTags {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.liveTag {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--green-dim);
  border: 1px solid rgba(62,207,110,.35);
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .5px;
}

.liveDot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .3; }
}

.clockTag {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--blue-dim);
  border: 1px solid rgba(77,166,255,.3);
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
}

.lockedTag {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--red-dim);
  border: 1px solid rgba(255,92,110,.3);
  color: var(--red);
  font-size: 10px;
  font-weight: 800;
}

.oddsTag {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--amber-dim);
  border: 1px solid rgba(245,184,61,.3);
  color: var(--amber);
  font-size: 10px;
  font-weight: 800;
}

/* Teams row */
.matchTeams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 12px;
}

.teamName {
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.teamName.is-away { text-align: right; }

.teamName.is-pending { color: var(--muted); font-weight: 500; }

.scoreBox {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.scoreVal {
  min-width: 64px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  text-align: center;
  letter-spacing: 1px;
}

.scoreTime {
  font-size: 10px;
  font-weight: 700;
  color: var(--blue);
}

/* Markets */
.markets {
  border-top: 1px solid var(--border);
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mRow {
  display: grid;
  gap: 4px;
  align-items: stretch;
}

.mCell, .mCellSkeleton {
  min-width: 0;
}

.mCell {
  min-height: 44px;
  padding: 5px 7px;
  border-radius: 6px;
  background: var(--surface2);
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 2px;
  transition: border-color .15s;
}

.mCell.is-locked {
  border-color: rgba(255,92,110,.3);
  background: rgba(255,92,110,.06);
}

.mCell.trend-up   { border-color: rgba(62,207,110,.3); }
.mCell.trend-down { border-color: rgba(255,92,110,.25); }

.mCellLabel {
  font-size: 10px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mCellVal {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mCell.is-locked .mCellVal { color: var(--red); font-size: 11px; }
.mCell.trend-up   .mCellVal { color: #6ee89a; }
.mCell.trend-down .mCellVal { color: #ff8b9b; }


/* Loading skeleton */
.mCellSkeleton {
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface2) 0%, var(--surface) 50%, var(--surface2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  min-height: 44px;
}
@keyframes shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}


/* ── Table card ── */
.tableCard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.tableCardTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.tableName {
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tableMeta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.playerCount {
  flex-shrink: 0;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--blue-dim);
  border: 1px solid rgba(77,166,255,.3);
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
}

.tableKvGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
}

.tableKv {
  padding: 8px 12px;
  background: var(--surface);
}

.tableKvKey {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.tableKvVal {
  font-size: 13px;
  font-weight: 700;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Empty state ── */
.emptyState {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 20px;
  color: var(--muted);
  text-align: center;
}

.emptyIcon { font-size: 36px; line-height: 1; }

.emptyState strong {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.emptyState span { font-size: 13px; }

/* ── Raw log ── */
#rawLog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 11px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 200px;
}

/* ── Bettable cell ── */
.mCell.is-bettable { cursor: pointer; }
.mCell.is-bettable:active { opacity: .7; transform: scale(.97); }

/* ── Bet Slip ── */
.betSlipBackdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 100;
}

.betSlip {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: 480px; margin: 0 auto;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  border-top: 1px solid var(--border);
  z-index: 101;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

.betSlipHandle {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 10px auto 4px;
}

.betSlipHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 4px;
}

.betSlipTitle { font-size: 15px; font-weight: 700; }

.betSlipClose {
  background: none; border: none;
  color: var(--muted); font-size: 16px;
  cursor: pointer; padding: 4px 8px;
}

.betSlipBody { padding: 8px 16px; display: flex; flex-direction: column; gap: 8px; }

.betSlipRow {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px;
}
.betSlipKey { color: var(--muted); }
.betSlipVal { font-weight: 600; text-align: right; }
.betSlipOdds { color: var(--amber); font-size: 16px; font-weight: 800; }

.betSlipStakeRow {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px;
  border-top: 1px solid var(--border);
  padding-top: 8px; margin-top: 2px;
}

.betSlipStakeInput {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 18px; font-weight: 700;
  padding: 6px 10px;
  width: 140px; text-align: right;
  outline: none;
}
.betSlipStakeInput:focus { border-color: var(--green); }

.betSlipPotential { border-top: 1px solid var(--border); padding-top: 8px; }

.betSlipSubmit {
  margin: 8px 16px 12px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--green);
  color: #000;
  font-size: 15px; font-weight: 800;
  border: none; cursor: pointer;
  transition: opacity .15s;
}
.betSlipSubmit:disabled { opacity: .5; cursor: default; }

.betSlipStatus {
  margin: 0 16px 12px;
  font-size: 12px; text-align: center;
}

/* ── Bets Panel ── */
.betsPanel { padding: 0 0 24px; }

.betsSummary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}

.betsSummaryItem {
  background: var(--surface);
  padding: 10px 8px;
  display: flex; flex-direction: column;
  align-items: center; gap: 3px;
  font-size: 14px; font-weight: 700;
}
.betsSummaryKey { font-size: 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; }

.betCard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 5px;
}

.betCardTop {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; font-weight: 600;
}
.betCardMatch { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.betCardStatus { font-size: 11px; font-weight: 700; flex-shrink: 0; margin-left: 8px; }

.betCardDetail {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--muted);
}
.betCardOdds { font-weight: 700; color: var(--amber); }

.betCardFooter {
  display: flex; justify-content: space-between;
  font-size: 12px; font-weight: 600;
}
