:root {
  color-scheme: light;
  --bg: #f4f7f2;
  --surface: #ffffff;
  --ink: #16231d;
  --muted: #65736d;
  --line: #d9e3dc;
  --green: #116149;
  --green-soft: #dcefe5;
  --blue: #285b8f;
  --amber: #8a5b10;
  --red: #a43b2b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  overflow-x: hidden;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 14px 12px calc(104px + env(safe-area-inset-bottom) + var(--viewport-bottom-inset, 0px));
}

.hero {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.12;
  letter-spacing: 0;
}

p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

button,
input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

input {
  width: 100%;
  padding: 0 10px;
  font-weight: 600;
}

.icon-button {
  min-width: 70px;
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.hero-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-button.secondary {
  background: var(--surface);
  color: var(--green);
  border-color: var(--line);
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px 0 0;
}

.compact-grid {
  padding-top: 10px;
}

.summary-item {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-item strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(18px, 5vw, 24px);
  line-height: 1.1;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.chart-panel,
.candidate-card,
.history-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.chart-panel {
  margin-top: 12px;
  padding: 12px;
}

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

.observation-head {
  padding-top: 12px;
}

.section-head span {
  color: var(--muted);
  font-size: 12px;
}

#equityChart {
  display: block;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.card-list {
  display: grid;
  gap: 11px;
  padding-top: 12px;
}

.candidate-card {
  padding: 14px;
}

.candidate-top {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.kickoff {
  color: var(--green);
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.league {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.teams {
  min-width: 0;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 800;
}

.teams span {
  display: block;
  overflow-wrap: anywhere;
}

.teams em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.market-tag {
  min-width: 54px;
  padding: 7px 8px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  text-align: center;
  font-weight: 850;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.pending-text {
  color: var(--amber);
}

.candidate-card.is-live {
  border-color: #fca5a5;
  background: linear-gradient(180deg, #fff 0%, #fff7f7 100%);
  box-shadow: 0 0 0 1px rgb(220 38 38 / 18%);
  animation: liveCardPulse 1.8s ease-in-out infinite;
}

.live-text {
  display: inline-block;
  width: fit-content;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fee2e2;
  color: #dc2626 !important;
  box-shadow: 0 0 0 0 rgb(220 38 38 / 42%);
  animation: livePulse 1.25s ease-in-out infinite;
}

@keyframes livePulse {
  0% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgb(220 38 38 / 38%);
  }
  50% {
    opacity: 0.72;
    box-shadow: 0 0 0 5px rgb(220 38 38 / 0%);
  }
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgb(220 38 38 / 0%);
  }
}

@keyframes liveCardPulse {
  0%, 100% {
    border-color: #fca5a5;
    box-shadow: 0 0 0 1px rgb(220 38 38 / 16%);
  }
  50% {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgb(220 38 38 / 12%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .candidate-card.is-live,
  .live-text {
    animation: none;
  }
}

.history-filter {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  padding-top: 12px;
}

.observation-filter {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding-top: 12px;
}

.observation-date-filter {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  padding-top: 10px;
}

.filter-button.is-active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.history-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding-top: 10px;
}

.history-summary .metric {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.history-summary .metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.history-summary .metric strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
  line-height: 1.1;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.history-card {
  padding: 12px;
}

.history-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.history-title {
  font-weight: 750;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.history-sub {
  color: var(--muted);
}

.result {
  min-width: 66px;
  text-align: right;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.empty {
  padding: 28px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.empty.mini {
  margin-top: 8px;
  padding: 14px 12px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.status-row:last-child {
  border-bottom: 0;
}

.status-row span:first-child {
  color: var(--muted);
}

.status-row span:last-child {
  text-align: right;
  overflow-wrap: anywhere;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: var(--viewport-bottom-inset, 0px);
  width: min(100%, 760px);
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(16px);
  transform: translateX(-50%);
  will-change: bottom;
}

.nav-button {
  min-width: 0;
  min-height: 44px;
  padding: 0 6px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.nav-button.is-active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

dialog {
  width: min(calc(100vw - 24px), 560px);
  max-height: min(80vh, 700px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}

dialog::backdrop {
  background: rgb(0 0 0 / 42%);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.detail-body {
  padding: 12px;
}

@media (min-width: 640px) {
  .card-list {
    grid-template-columns: 1fr 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
