:root {
  --bg: #f4f5f8;
  --white: #ffffff;
  --ink: #1f2430;
  --muted: #6b6f7a;
  --indigo: #3f51b5;
  --indigo-soft: #eef0ff;
  --frame: #c8cad0;
  --row-line: #e6e7eb;
  --drop-slot: #eef0f4;
  --drop-bar: #9fa8da;
  --tag-ink: #1a237e;
  --divider: #9aa3d6;
  --hot: #d84343;
  --hot-mid: #ffcdd2;
  --hot-soft: #ffebee;
}

:root.is-os,
.app.is-os {
  --indigo: #2e7d32;
  --indigo-soft: #e8f5e9;
  --drop-slot: #eef5ee;
  --drop-bar: #81c784;
  --tag-ink: #1b5e20;
  --divider: #a5d6a7;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
}

.app {
  width: min(390px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.header {
  height: 38px;
  flex: 0 0 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  background: var(--white);
}

.header-title {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.countdown {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--indigo-soft);
  color: var(--indigo);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.countdown[hidden] {
  display: none;
}

.countdown-lab {
  font-size: 10px;
}

.countdown-time {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.view {
  flex: 1;
  background: var(--white);
  margin-top: 0;
  padding-bottom: calc(56px + 72px + env(safe-area-inset-bottom, 0px));
}

.whale-row {
  flex: 0 0 36px;
  height: 36px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  background: var(--indigo-soft);
  overflow: hidden;
}

.whale-lab {
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

.hit-tag {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 18px;
  padding: 3px 6px;
  border: 1px solid var(--indigo);
  border-radius: 6px;
  background: var(--white);
  color: var(--tag-ink);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.hit-cta {
  flex: 0 0 auto;
  margin-left: 2px;
  min-width: 60px;
  min-height: 18px;
  padding: 3px 8px;
  border: 0;
  border-radius: 6px;
  background: var(--indigo);
  color: var(--white);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
}

.paywall:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.paywall[hidden] {
  display: none !important;
}

.paywall-scrim {
  position: absolute;
  inset: 0;
  background: rgba(31, 36, 48, 0.45);
}

.paywall-modal {
  position: relative;
  z-index: 1;
  width: min(326px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 20px;
  border-radius: 18px;
  background: var(--white);
  box-shadow: 0 12px 32px rgba(31, 36, 48, 0.28);
  text-align: center;
}

.paywall-beat {
  position: relative;
  width: 140px;
  height: 140px;
  flex: 0 0 140px;
}

.paywall-ring {
  position: absolute;
  border-radius: 50%;
  background: #c62828;
}

.paywall-ring.r1 {
  inset: 4px;
  opacity: 0.1;
}

.paywall-ring.r2 {
  inset: 19px;
  opacity: 0.16;
}

.paywall-ring.r3 {
  inset: 33px;
  opacity: 0.28;
}

.paywall-clock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c62828;
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.paywall-kicker {
  margin: 0;
  width: 100%;
  color: #c62828;
  font-size: 12px;
  font-weight: 700;
}

.paywall-title {
  margin: 0;
  width: 100%;
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
}

.paywall-copy {
  margin: 0;
  width: 100%;
  color: #616161;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.2;
}

.paywall-input {
  display: flex;
  width: 100%;
}

.paywall-input input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
}

.paywall-input input::placeholder {
  color: #9e9e9e;
}

.paywall-unlock {
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: #c62828;
  color: var(--white);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.paywall-pay {
  width: 100%;
  height: 36px;
  border: 0;
  background: transparent;
  color: #c62828;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.paywall-foot {
  margin: 0;
  width: 100%;
  color: #9e9e9e;
  font-size: 10px;
  font-weight: 400;
}

.thead,
.trow {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--row-line);
}

.trow {
  min-height: 48px;
}

.trow.is-scr {
  filter: grayscale(1);
  opacity: 0.42;
  pointer-events: none;
}

.trow.is-scr .name,
.trow.is-scr .no {
  color: var(--muted);
  font-weight: 600;
}

.trow.is-scr .odds,
.trow.is-scr .meta,
.trow.is-scr .col {
  visibility: hidden;
}

.thead {
  background: var(--drop-slot);
  min-height: 44px;
  font-size: 11px;
  font-weight: 700;
  color: var(--indigo);
}

.thead .is-sort {
  margin: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  user-select: none;
}

.thead button.th-rank,
.thead button.col {
  font-family: inherit;
}

.thead .is-sort.is-on {
  color: var(--tag-ink, #1a237e);
}

.th-rank,
.td-rank {
  flex: 0 0 198px;
  width: 198px;
  max-width: 198px;
  min-width: 198px;
  padding: 0 8px 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-right: 1px solid var(--row-line);
}

.td-rank {
  padding: 6px 8px 6px 8px;
}

.td-rank .no {
  width: 18px;
  flex: 0 0 18px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.td-rank .mid {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.td-rank .head {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
}

.td-rank .name {
  flex: 0 0 var(--name-ch, 4em);
  width: var(--name-ch, 4em);
  max-width: var(--name-ch, 4em);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.td-rank .odds {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: flex-start;
  gap: 4px;
  flex: 0 0 auto;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.odd-win {
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--ink);
  text-align: left;
}

.odd-pla {
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--muted);
  text-align: left;
}

.odd-win.is-hot {
  color: #fff;
  background: #d84343;
  border-radius: 3px;
  padding: 0 4px;
  font-weight: 800;
}

.odd-win.is-empty,
.odd-pla.is-empty {
  opacity: 0.45;
}

.td-rank .meta {
  display: block;
  font-size: 10px;
  line-height: 1.3;
  color: var(--muted);
  min-width: 0;
  max-width: 100%;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  max-width: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--indigo);
  text-align: center;
  line-height: 1.15;
  gap: 0;
  padding: 0 1px;
}

.col .pct {
  display: inline-block;
  min-width: 0;
  padding: 1px 1px;
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
}

.col .pct.is-top-1 {
  color: #fff;
  background: var(--hot);
  font-weight: 800;
}

.col .pct.is-top-2 {
  color: var(--hot);
  background: var(--hot-mid);
  font-weight: 800;
}

.col .pct.is-top-3 {
  color: var(--hot);
  background: var(--hot-soft);
  font-weight: 800;
}

.thead .col:nth-child(2),
.trow .col:nth-child(2) {
  margin-left: 0;
}

.disc {
  margin: 0;
  height: 24px;
  padding: 4px 12px 6px;
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  background: var(--bg);
}

.dock {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(390px, 100%);
  z-index: 2;
  background: var(--bg);
  border: 0;
  box-shadow: none;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.race-tabs {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 0;
  margin: 0;
  padding: 8px 12px;
  overflow: hidden;
  background: var(--bg);
  border: 0;
  border-radius: 0;
}

.race-pin {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 8px;
  background: var(--bg);
  z-index: 1;
}

.race-scroll {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  scrollbar-width: none;
}

.race-scroll::-webkit-scrollbar {
  display: none;
}

.tab-div {
  flex: 0 0 auto;
  color: var(--divider);
  font-size: 12px;
  font-weight: 400;
  line-height: 16px;
}

.venue-drop {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 72px;
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--indigo);
  color: #fff;
  flex: 0 0 auto;
}

.venue-drop select {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.venue-drop .caret {
  font-size: 11px;
  font-weight: 700;
  line-height: 14px;
  pointer-events: none;
}

.tab {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border: 1px solid var(--indigo);
  border-radius: 8px;
  background: var(--white);
  color: var(--indigo);
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.tab.is-on {
  border-color: transparent;
  background: var(--indigo);
  color: #fff;
}

.float-bar {
  position: fixed;
  left: 50%;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(366px, calc(100% - 24px));
  min-height: 44px;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 8px 14px;
  background: var(--white);
  border: 0;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgb(31 36 48 / 16%), 0 1px 3px rgb(31 36 48 / 8%);
  z-index: 2;
}

.float-bar .chip {
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: var(--indigo-soft);
  color: var(--indigo);
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  white-space: nowrap;
  line-height: 26px;
}

.float-bar .chip.is-on {
  background: var(--indigo);
  color: #fff;
}

.float-bar .chip:disabled {
  opacity: 0.45;
  cursor: default;
}

.chart-page {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.chart-title {
  padding: 10px 12px 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.chart-card {
  margin: 0 8px;
  padding: 4px 0 0;
}

.chart-svg {
  display: block;
  width: 100%;
  height: auto;
  font-family: inherit;
}

.chart-pick {
  margin: 4px 12px 8px;
  min-height: 28px;
  height: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--indigo-soft);
  color: var(--indigo);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

.chart-pick-lab {
  margin-right: 2px;
}

.chart-pick-empty {
  color: var(--muted);
}

.no-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.no-tag.is-red {
  color: #fff;
  background: var(--hot);
}

.no-tag.is-pink {
  color: var(--hot);
  background: var(--hot-mid);
}

.chart-horses .trow .td-rank {
  flex: 1 1 auto;
  width: auto;
  max-width: none;
}

.chart-page .thead .th-rank {
  flex: 1 1 auto;
  width: auto;
  max-width: none;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  padding-top: 6px;
  padding-bottom: 6px;
}

.chart-page .thead .th-rank .is-sort {
  padding: 0;
  font-size: 11px;
  font-weight: 700;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.2;
}

.chart-legend .lg {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chart-legend .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex: 0 0 10px;
}

.chart-legend .swatch-pink {
  background: var(--hot-mid);
}

.chart-legend .swatch-red {
  background: var(--hot);
}

.chart-horses .chart-col {
  flex: 0 0 72px;
  width: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-page .thead .chart-col,
.chart-page .thead .col {
  flex: 0 0 72px;
  width: 72px;
}

.empty {
  padding: 24px 12px;
  color: var(--muted);
  font-size: 13px;
}
