:root {
  color-scheme: light;
  --bg: #eef2f4;
  --panel: #ffffff;
  --ink: #11151a;
  --muted: #68717d;
  --line: #d9e1e8;
  --navy: #071a2d;
  --cyan: #16a3c7;
  --green: #148451;
  --green-soft: #e8f7ef;
  --gold: #bc7a13;
  --gold-soft: #fff3d8;
  --red: #cf3f3f;
  --red-soft: #fff0ee;
  --soft: #f2f5f7;
  --shadow: 0 10px 24px rgba(18, 30, 42, .08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

body {
  padding: max(12px, env(safe-area-inset-top)) 10px max(76px, env(safe-area-inset-bottom));
}

button, input, select { font: inherit; }

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: var(--soft);
  color: var(--ink);
  font-weight: 850;
  cursor: pointer;
}

button:active { transform: translateY(1px); }
button:disabled { opacity: .56; cursor: not-allowed; }

input, select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input:focus, select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(22, 163, 199, .16);
}

h1, h2, h3, p { margin: 0; }

.app {
  width: min(100%, 1060px);
  margin: 0 auto;
  display: grid;
  gap: 10px;
}

.topbar {
  min-height: 64px;
  border-radius: 8px;
  padding: 10px;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--cyan), #21b56b);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 22px;
  font-weight: 950;
}

.brand strong,
.wallet strong {
  display: block;
  line-height: 1.05;
  font-size: 18px;
  font-weight: 950;
  white-space: nowrap;
}

.brand small,
.wallet span {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, .68);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.wallets {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.wallet {
  min-width: 104px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .1);
  text-align: right;
}

.wallet-negative strong {
  color: #ffb4a8;
}

.quick-tabs,
.market-filter {
  display: grid;
  gap: 6px;
  padding: 5px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.quick-tabs {
  grid-template-columns: repeat(4, 1fr);
  position: sticky;
  top: 8px;
  z-index: 10;
}

.quick-tabs button,
.market-filter button {
  min-height: 36px;
  background: transparent;
  color: var(--muted);
}

.quick-tabs button.active,
.market-filter button.active {
  background: var(--navy);
  color: #fff;
}

.promo {
  position: relative;
  min-height: 132px;
  border-radius: 8px;
  overflow: hidden;
  background: #15202b;
  box-shadow: var(--shadow);
}

.promo img {
  width: 100%;
  height: 100%;
  min-height: 132px;
  object-fit: cover;
  display: block;
  opacity: .72;
}

.promo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(7, 26, 45, .86), rgba(7, 26, 45, .18));
}

.promo-copy {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 1;
  color: #fff;
  display: grid;
  gap: 4px;
}

.promo-copy span {
  color: rgba(255, 255, 255, .74);
  font-size: 13px;
  font-weight: 850;
}

.promo-copy strong {
  font-size: clamp(22px, 6vw, 34px);
  line-height: 1.05;
  font-weight: 950;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.summary-strip div,
.match-card,
.slip-panel,
.settle-panel,
.settings,
.record {
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.summary-strip div {
  min-height: 72px;
  padding: 12px;
  display: grid;
  align-content: space-between;
}

.summary-strip span,
label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.summary-strip strong {
  font-size: clamp(18px, 4vw, 26px);
  line-height: 1;
  font-weight: 950;
  white-space: nowrap;
}

.view {
  display: none;
  gap: 10px;
}

.view.active { display: grid; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-head h1 {
  font-size: 24px;
  line-height: 1;
  font-weight: 950;
}

.section-head select { max-width: 148px; }

.icon-btn {
  min-width: 72px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.market-filter {
  grid-template-columns: repeat(4, 1fr);
  box-shadow: none;
  border: 1px solid var(--line);
}

.match-board,
.records {
  display: grid;
  gap: 10px;
}

.match-card {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.match-meta,
.record-top,
.receipt-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.match-meta span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.teams strong {
  min-width: 0;
  font-size: 19px;
  line-height: 1.15;
  font-weight: 950;
  word-break: break-word;
}

.teams strong:last-child { text-align: right; }

.teams span {
  width: 34px;
  height: 24px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 950;
}

.odds-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(58px, .78fr) minmax(0, 1fr);
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fbfcfd;
}

.odd-btn {
  min-height: 44px;
  padding: 6px 7px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  text-align: center;
}

.odd-btn:last-child { border-right: 0; }

.odd-btn span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 820;
  white-space: nowrap;
}

.odd-btn strong {
  color: var(--green);
  font-size: 17px;
  line-height: 1;
  font-weight: 950;
  white-space: nowrap;
}

.odd-btn.selected {
  border-color: var(--green);
  background: var(--green-soft);
}

.source-line {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  line-height: 1.35;
}

.slip-panel,
.settle-panel {
  padding: 12px;
  display: grid;
  gap: 12px;
}

.selected-odds {
  min-height: 72px;
  border: 1px solid var(--green);
  border-radius: 8px;
  padding: 12px;
  background: var(--green-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.selected-odds.empty {
  border-color: var(--line);
  background: var(--soft);
  color: var(--muted);
  justify-content: center;
  font-weight: 850;
}

.selected-odds strong,
.record-top strong {
  display: block;
  font-size: 17px;
  line-height: 1.2;
  font-weight: 950;
}

.selected-odds span,
.record-top span,
.record-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  line-height: 1.35;
}

.selected-odds b {
  color: var(--green);
  font-size: 22px;
  white-space: nowrap;
}

label {
  display: grid;
  gap: 6px;
}

.stake-chips,
.actions,
.record-actions {
  display: grid;
  gap: 8px;
}

.stake-chips { grid-template-columns: repeat(4, 1fr); }
.actions { grid-template-columns: repeat(2, 1fr); }
.actions.three { grid-template-columns: repeat(3, 1fr); }

.slip-total {
  min-height: 56px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.slip-total span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.slip-total strong {
  font-size: 28px;
  line-height: 1;
  color: var(--green);
  font-weight: 950;
}

.primary-btn {
  background: var(--green);
  color: #fff;
}

.danger-btn {
  background: var(--red-soft);
  color: var(--red);
}

.filters,
.score-grid,
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 128px;
  gap: 8px;
}

.score-grid,
.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.record {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.pill {
  min-width: 42px;
  min-height: 26px;
  padding: 5px 8px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 950;
  white-space: nowrap;
}

.pill.pending { background: var(--gold-soft); color: var(--gold); }
.pill.win { background: var(--green-soft); color: var(--green); }
.pill.lose { background: var(--red-soft); color: var(--red); }
.pill.void { background: var(--soft); color: var(--muted); }

.money-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.money-grid div {
  min-height: 58px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  display: grid;
  gap: 4px;
}

.money-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.money-grid strong {
  font-size: 17px;
  font-weight: 950;
  white-space: nowrap;
}

.record-actions {
  grid-template-columns: repeat(5, 1fr);
}

.record-actions button {
  min-height: 34px;
  padding: 0 6px;
  font-size: 12px;
}

.bet-table {
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 12px;
  overflow: hidden;
}

.bet-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px 72px 78px;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 10px;
  color: var(--ink);
}

.bet-row:nth-child(odd):not(.bet-head):not(.bet-total) {
  background: #f7f9fb;
  border-radius: 8px;
}

.bet-row span {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.bet-row strong {
  min-width: 0;
  font-size: 15px;
  line-height: 1.25;
  font-weight: 780;
  overflow-wrap: anywhere;
}

.bet-head {
  min-height: 44px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.bet-total {
  min-height: 58px;
  margin-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 20px;
}

.bet-total span:last-child {
  font-size: 26px;
}

.pl-win { color: #0d9a55; }
.pl-lose { color: var(--red); }

.hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  line-height: 1.45;
}

.receipt-wrap { display: none; }
.receipt-wrap.show { display: block; }

.receipt {
  border-radius: 8px;
  padding: 14px;
  background: var(--navy);
  color: #fff;
  display: grid;
  gap: 12px;
}

.receipt-head {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .18);
}

.receipt h3 {
  font-size: 20px;
  line-height: 1.15;
}

.receipt-head span,
.receipt-total span,
.receipt p {
  color: rgba(255, 255, 255, .72);
  font-size: 13px;
  font-weight: 760;
}

.receipt-head strong {
  font-size: 24px;
  white-space: nowrap;
}

.receipt-list { display: grid; gap: 8px; }

.receipt-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  font-size: 14px;
}

.receipt-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.receipt-row b {
  color: rgba(255, 255, 255, .72);
}

.receipt-total {
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, .18);
  display: grid;
  gap: 6px;
}

.receipt-total strong {
  font-size: 26px;
  line-height: 1;
}

.settings {
  padding: 0;
  overflow: hidden;
}

.settings summary {
  min-height: 48px;
  padding: 14px 12px;
  font-weight: 950;
  cursor: pointer;
}

.settings-grid {
  padding: 0 12px 12px;
}

.settings-wide {
  grid-column: 1 / -1;
}

.empty {
  padding: 26px 12px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  text-align: center;
  font-weight: 850;
  box-shadow: var(--shadow);
}

.mobile-slip {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 18;
}

.mobile-slip button {
  width: min(100%, 1060px);
  min-height: 54px;
  margin: 0 auto;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 12px 30px rgba(7, 26, 45, .24);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mobile-slip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-slip strong {
  color: #8ce0a9;
  white-space: nowrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(76px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(16px);
  max-width: calc(100% - 32px);
  padding: 11px 14px;
  border-radius: 999px;
  background: rgba(17, 21, 26, .94);
  color: #fff;
  font-size: 14px;
  font-weight: 850;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 820px) {
  .app {
    grid-template-columns: minmax(0, 1fr) 360px;
    align-items: start;
  }

  .topbar,
  .quick-tabs,
  .promo,
  .summary-strip {
    grid-column: 1 / -1;
  }

  #lobbyView,
  #recordsView,
  #settleView {
    grid-column: 1;
  }

  #betslipView {
    display: grid;
    grid-column: 2;
    position: sticky;
    top: 70px;
  }

  #betslipView .section-head {
    display: none;
  }

  .mobile-slip { display: none; }
}

@media (max-width: 700px) {
  .summary-strip { grid-template-columns: 1fr 1fr; }
  .summary-strip div:first-child { grid-column: 1 / -1; }
  .odds-grid { grid-template-columns: minmax(0, 1fr) minmax(52px, .72fr) minmax(0, 1fr); }
  .filters,
  .score-grid,
  .settings-grid,
  .actions.three { grid-template-columns: 1fr; }
  .record-actions { grid-template-columns: repeat(3, 1fr); }
  .receipt-row { grid-template-columns: 1fr auto; }
  .receipt-row b { display: none; }
}

@media (max-width: 380px) {
  .quick-tabs button,
  .market-filter button,
  .record-actions button {
    padding: 0 6px;
    font-size: 12px;
  }
  .money-grid { grid-template-columns: 1fr; }
}
