/* Gold Filter — 基於 moneyflow，含場次 tab 與回測 FAB */
:root {
  --bg: #f4f5f7;
  --card: #fff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --accent: #e85d04;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --tabs-h: 3.25rem;
  --fab-h: 2.35rem;
  --footer-stack: calc(var(--tabs-h) + var(--fab-h) + 1.25rem + env(safe-area-inset-bottom, 0px));
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: 'Noto Sans TC', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

a {
  color: inherit;
  text-decoration: none;
}

.page-container {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}

.header-content {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-top: 0.1rem;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  flex-shrink: 0;
}

.back-btn:active {
  background: var(--bg);
}

.page-title {
  flex: 1;
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.35;
}

.page-title--race {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.4;
}

.page-title-sub {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 400;
  margin: 0.2rem 0 0;
}

.main-content {
  flex: 1;
  padding: 0.75rem 1rem var(--footer-stack);
}

.horse-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.horse-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 0.55rem 0.45rem 0.55rem 0.65rem;
  box-shadow: var(--shadow);
  font-size: 0.95rem;
  line-height: 1.35;
}

.horse-col-no {
  flex: 0 0 1.35rem;
  align-self: center;
  font-weight: 800;
  color: var(--accent);
  text-align: center;
  font-size: 1.05rem;
}

.horse-col-body {
  flex: 1 1 auto;
  min-width: 0;
}

.horse-line1 {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.horse-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.horse-odd {
  flex-shrink: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 2rem;
  text-align: right;
}

.horse-odd.horse-odd--fav {
  color: #dc2626;
  font-weight: 700;
}

.horse-line2 {
  margin-top: 0.2rem;
  font-size: 0.74rem;
  color: #868e96;
}

.horse-chevron {
  flex: 0 0 2rem;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2.5rem;
  margin-left: 0.15rem;
  color: var(--accent);
  border-radius: 8px;
}

.horse-chevron:active {
  background: #fff7ed;
  color: #c2410c;
}

.fab-backtest {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabs-h) + 0.65rem + env(safe-area-inset-bottom, 0px));
  z-index: 25;
  width: auto;
  max-width: 88vw;
  padding: 0.5rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, #f97316 0%, var(--accent) 100%);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(232, 93, 4, 0.45);
  text-align: center;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.fab-backtest:active {
  opacity: 0.9;
  transform: translateX(-50%) scale(0.98);
}

.race-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
  background: var(--card);
  border-top: 1px solid var(--border);
  z-index: 30;
  -webkit-overflow-scrolling: touch;
}

.race-tab {
  flex: 0 0 auto;
  min-width: 2.1rem;
  height: 2.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  color: var(--text);
}

.race-tab.is-active {
  border-width: 2px;
  border-color: var(--text);
  background: var(--card);
}

.detail-section {
  margin-bottom: 1rem;
}

.detail-section h2 {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 0.5rem;
  text-transform: none;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  font-size: 0.88rem;
}

.detail-grid dt {
  color: var(--muted);
  margin: 0;
}

.detail-grid dd {
  margin: 0;
  font-weight: 500;
  text-align: right;
}

.backtest-race {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.5rem;
}

.backtest-race-title {
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0 0 0.4rem;
}

.backtest-pla {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}

.empty-state,
.loading {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--footer-stack) + 0.5rem);
  transform: translateX(-50%) translateY(120%);
  max-width: min(90vw, 360px);
  padding: 0.65rem 1rem;
  background: #1e293b;
  color: #fff;
  border-radius: 10px;
  font-size: 0.88rem;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.bottom-tips {
  text-align: center;
  padding: 0.35rem 0.65rem;
  font-size: 10px;
  color: #9ca3af;
}
