:root {
  color-scheme: light;
  --bg: #eef3fb;
  --surface: #ffffff;
  --soft: #f1f5fb;
  --ink: #101827;
  --muted: #647086;
  --line: #d6deeb;
  --navy: #071c5d;
  --navy-2: #102d7a;
  --blue: #1677d2;
  --cyan: #0788c7;
  --purple: #6b46c1;
  --gold: #d59a12;
  --red: #d71920;
  --ok: #1ca35b;
  --shadow: 0 18px 42px rgba(7, 28, 93, 0.1);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(7, 28, 93, 0.14), rgba(238, 243, 251, 0) 340px),
    linear-gradient(135deg, rgba(215, 25, 32, 0.08), rgba(213, 154, 18, 0.08) 58%, rgba(22, 119, 210, 0.08)),
    var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.telegram-mini-app .app-shell {
  padding: calc(12px + var(--tg-content-safe-area-inset-top, 0px))
    calc(12px + var(--tg-content-safe-area-inset-right, 0px))
    calc(12px + var(--tg-content-safe-area-inset-bottom, 0px))
    calc(12px + var(--tg-content-safe-area-inset-left, 0px));
}

.telegram-mini-app .install-button {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 70px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: block;
  width: 58px;
  height: 58px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 10px 22px rgba(7, 28, 93, 0.18);
}

.brand p,
.section-kicker {
  margin: 0;
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand h1,
.hero-card h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  color: var(--ink);
  font-size: clamp(24px, 2.5vw, 34px);
  font-weight: 950;
  white-space: nowrap;
}

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

.icon-button,
.install-button {
  border: 0;
  border-radius: 8px;
  min-height: 40px;
}

.icon-button {
  width: 42px;
  background: var(--surface);
  color: var(--navy);
  font-size: 22px;
  box-shadow: var(--shadow);
}

.install-button {
  padding: 0 14px;
  background: linear-gradient(135deg, var(--red), var(--navy));
  color: #fff;
  font-weight: 800;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.5fr) minmax(250px, 0.75fr) minmax(280px, 0.85fr);
  gap: 16px;
  margin-top: 10px;
}

.hero-card,
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.hero-card {
  min-height: 162px;
  padding: 18px;
}

.hero-card h2 {
  margin-top: 8px;
  font-size: clamp(30px, 4.2vw, 54px);
  line-height: 1;
  color: var(--navy);
}

.hero-card p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.hero-meta,
.latest-line,
.latest-tags {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hero-meta {
  margin-top: 14px;
}

.hero-meta span,
.score-pill,
.latest-tags span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f5f8fd;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.latest-card {
  min-height: 184px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.99), rgba(248, 251, 255, 0.99)),
    var(--surface);
  border-top: 5px solid var(--red);
}

.draw-template {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  row-gap: 12px;
  margin-top: 8px;
}

.template-issue {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  color: var(--navy);
  font-size: clamp(24px, 3vw, 40px);
  line-height: 1.1;
  font-weight: 900;
}

.canada-flag {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 46px;
  height: 40px;
  margin-right: 4px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(7, 28, 93, 0.12);
  font-size: 28px;
}

.template-issue strong {
  color: var(--red);
  font-size: 1.04em;
}

.template-time {
  justify-self: start;
  color: var(--ink);
  font-size: clamp(16px, 2vw, 24px);
  font-weight: 650;
  white-space: nowrap;
}

.balls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.template-balls {
  margin-top: 2px;
  padding: 8px 0 2px;
}

.ball {
  --ball-1: #68c6ff;
  --ball-2: #1777cf;
  --ball-3: #064b9f;
  --ball-text: #101827;
  --ball-inner: rgba(255, 255, 255, 0.88);
  display: grid;
  place-items: center;
  position: relative;
  isolation: isolate;
  width: 70px;
  min-width: 70px;
  height: 70px;
  flex: 0 0 70px;
  border-radius: 999px;
  overflow: hidden;
  color: var(--ball-text);
  border: 1px solid rgba(7, 28, 93, 0.34);
  background:
    radial-gradient(circle at 28% 18%, rgba(255, 255, 255, 0.36) 0 5%, rgba(255, 255, 255, 0) 17%),
    linear-gradient(145deg, var(--ball-1) 0%, var(--ball-2) 48%, var(--ball-3) 82%);
  box-shadow:
    inset 0 4px 6px rgba(255, 255, 255, 0.24),
    inset 0 -9px 12px rgba(0, 0, 0, 0.28),
    inset 0 0 0 3px rgba(255, 255, 255, 0.12),
    0 7px 14px rgba(7, 28, 93, 0.2);
  font-size: 27px;
  font-weight: 950;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.ball::before,
.ball::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.ball::before {
  inset: 10px;
  z-index: 1;
  background: var(--ball-inner);
  border: 2px solid rgba(12, 24, 42, 0.78);
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.2),
    inset 0 2px 5px rgba(7, 28, 93, 0.2);
}

.ball::after {
  top: 8px;
  left: 15px;
  z-index: 2;
  width: 18px;
  height: 10px;
  background: rgba(255, 255, 255, 0.24);
  filter: blur(1px);
}

.ball-number {
  position: relative;
  z-index: 3;
}

.tone-0,
.tone-1,
.tone-2,
.tone-3,
.tone-4 {
  --ball-1: #63c2ff;
  --ball-2: #0873c8;
  --ball-3: #003f8f;
  --ball-text: #005ca8;
  --ball-inner: #f3f6f8;
}

.tone-5,
.tone-6,
.tone-7,
.tone-8,
.tone-9 {
  --ball-1: #ff858d;
  --ball-2: #df1826;
  --ball-3: #97000f;
  --ball-text: #c60018;
  --ball-inner: #f7f2f3;
}

.tone-result {
  --ball-1: #ff7c85;
  --ball-2: #dc1422;
  --ball-3: #97000f;
  --ball-text: #c60018;
  --ball-inner: #f7f2f3;
}

.ball-blue {
  --ball-1: #79d8ff;
  --ball-2: #168fdc;
  --ball-3: #003a8b;
  --ball-text: #111827;
  --ball-inner: #f3f6f8;
}

.ball-purple {
  --ball-1: #c7a1ff;
  --ball-2: #7444c7;
  --ball-3: #32106f;
  --ball-text: #111827;
  --ball-inner: #f5f2f7;
}

.ball-green {
  --ball-1: #8ee7cf;
  --ball-2: #199b79;
  --ball-3: #005744;
  --ball-text: #111827;
  --ball-inner: #f1f6f4;
}

.ball-red {
  --ball-1: #ff9aa2;
  --ball-2: #e52a36;
  --ball-3: #97000f;
  --ball-text: #111827;
  --ball-inner: #f7f1f2;
}

.balls i {
  color: var(--ink);
  font-style: normal;
  font-weight: 900;
  font-size: 28px;
  line-height: 1;
}

.latest-tags {
  margin-top: 14px;
}

.risk-meter {
  height: 9px;
  margin-top: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--soft);
}

.risk-meter span {
  display: block;
  height: 100%;
  width: 20%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--gold), var(--red));
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.15fr) minmax(300px, 0.85fr);
  grid-template-areas:
    "predictions gates"
    "history history"
    "stats stats";
  align-items: stretch;
  gap: 16px;
  margin-top: 16px;
}

.prediction-stack {
  grid-area: predictions;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  gap: 16px;
  min-width: 0;
}

.prediction-stack > .sum-panel,
.sum-panel .sum-list,
.sum-panel .current-prediction,
.sum-panel .sum-band-section,
.sum-panel .sum-band-records,
.sum-panel .sum-band-record-grid {
  flex: 1;
}

.sum-panel .sum-list,
.sum-panel .current-prediction,
.sum-panel .sum-band-section,
.sum-panel .sum-band-records {
  display: flex;
  flex-direction: column;
}

.gate-panel {
  grid-area: gates;
}

.chase-panel {
  grid-area: chase;
  overflow: hidden;
}

.chase-panel > .panel-head {
  min-height: 74px;
  background: #e8f1ee;
  border-bottom-color: #cadfd8;
}

.chase-panel .section-kicker {
  color: #087b6d;
}

.chase-head-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.chase-head-meta .gate-help-button {
  border-color: #7ba99f;
  color: #0b645b;
}

.chase-body {
  padding: 16px;
}

.chase-intro {
  display: grid;
  grid-template-columns: minmax(170px, 0.85fr) minmax(0, 3fr);
  gap: 12px;
  align-items: stretch;
}

.chase-intro > div:first-child {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 12px 14px;
  border-left: 4px solid #0b756b;
  background: #f0f8f6;
}

.chase-intro span,
.chase-metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chase-intro > div:first-child strong {
  color: #075e57;
  font-size: 28px;
  line-height: 1.15;
}

.chase-intro small,
.chase-metrics small {
  color: #4e6e69;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.chase-number-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--line);
}

.chase-number-list > div {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  padding: 10px 12px;
  background: #fff;
}

.chase-number-list strong {
  color: var(--navy);
  font-size: 21px;
  line-height: 1.2;
}

.chase-status {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin-top: 14px;
  padding: 11px 12px;
  border-left: 3px solid #0b756b;
  background: #f0f8f6;
  font-size: 13px;
}

.chase-status strong {
  color: #075e57;
}

.chase-status span {
  color: var(--ink);
  font-weight: 750;
}

.chase-status em {
  margin-left: auto;
  color: #4e6e69;
  font-style: normal;
  font-weight: 800;
}

.chase-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: 15px;
  border: 1px solid var(--line);
  background: var(--line);
}

.chase-metrics > div {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  padding: 12px;
  background: #fff;
}

.chase-metrics strong {
  color: var(--navy);
  font-size: 20px;
  line-height: 1.2;
}

.chase-metrics strong.is-positive { color: #087b6d; }
.chase-metrics strong.is-negative { color: var(--red); }

.chase-records {
  margin-top: 16px;
}

.chase-records > strong {
  color: var(--navy);
  font-size: 14px;
}

.chase-record-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: 8px;
  border: 1px solid var(--line);
  background: var(--line);
}

.chase-record {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
  min-width: 0;
  padding: 10px 12px;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
}

.chase-record span:first-child {
  color: var(--navy);
  font-weight: 900;
}

.chase-record strong {
  color: #087b6d;
  text-align: right;
}

.chase-record.is-miss strong {
  color: var(--red);
}

.chase-record span:nth-child(2) {
  color: var(--muted);
}

.chase-footnote {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}


.focus-panel {
  display: flex;
  height: auto;
  min-height: 0;
  overflow: hidden;
  flex-direction: column;
}

.stats-panel {
  grid-area: stats;
}

.stats-panel > .panel-head {
  min-height: 84px;
  border-bottom-color: rgba(255, 255, 255, 0.2);
  background: linear-gradient(135deg, var(--navy), #1552a5);
  color: #fff;
}

.stats-panel > .panel-head h3 {
  margin-top: 4px;
  color: #fff;
  font-size: 23px;
  font-weight: 950;
}

.stats-panel > .panel-head .section-kicker {
  color: #ffb0b4;
  font-size: 13px;
  font-weight: 950;
}

.stats-panel > .panel-head #rebatePill {
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  box-shadow: none;
  white-space: nowrap;
}

.history-panel {
  grid-area: history;
}

.single-gate-panel {
  grid-area: single;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.single-gate-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: #0b625b;
  color: #fff;
}

.single-gate-panel .single-gate-head h3 {
  margin: 2px 0 0;
  color: #fff;
  font-size: 18px;
  font-weight: 950;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.single-gate-head .section-kicker {
  color: #bdf4e8;
  font-size: 11px;
  font-weight: 950;
}

.single-target-issue {
  margin: 2px 0 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 11px;
  font-weight: 850;
}

.single-head-pills {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.single-gate-head .score-pill {
  min-height: 27px;
  padding: 3px 7px;
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 11px;
}

.single-gate-head .score-pill.is-positive {
  border-color: #bdf4e8;
  background: #e6fff8;
  color: #087367;
}

.single-gate-head .score-pill.is-negative {
  border-color: #ffc6c9;
  background: #fff0f1;
  color: var(--red);
}

.single-gate-content {
  display: block;
  flex: 1;
  padding: 10px 14px;
  background: #f5f9f8;
}

.single-compact {
  padding: 12px;
  border: 1px solid #cbdedb;
  border-left: 5px solid #7a879b;
  border-radius: 7px;
  background: #fff;
}

.single-compact.is-follow { border-left-color: #0a8b78; }
.single-compact.is-reverse { border-left-color: var(--gold); }

.single-compact-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.single-compact-heading strong {
  color: var(--navy);
  font-size: 22px;
}

.single-compact-heading small {
  margin-left: auto;
  color: var(--muted);
  font-weight: 800;
}

.single-action {
  padding: 4px 10px;
  border-radius: 999px;
  background: #e4e9f1;
  color: #536077;
  font-size: 12px;
  font-weight: 950;
}

.single-compact.is-follow .single-action { background: #d8f6ed; color: #087367; }
.single-compact.is-reverse .single-action { background: #fff0c2; color: #865a00; }

.single-signal-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 3px 10px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}
.single-signal-line b { color: #0b625b; }
.single-signal-line strong { color: var(--navy); font-size: 12px; }

.single-compact-rates {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.single-compact-rates div {
  min-width: 0;
  padding: 8px;
  border: 1px solid #dbe6e4;
  border-radius: 6px;
  background: #f7f9fc;
}

.single-compact-rates span,
.single-compact-rates b { display: block; }
.single-compact-rates span { color: var(--muted); font-size: 11px; font-weight: 800; }
.single-compact-rates b { margin-top: 2px; color: var(--navy); font-size: 18px; overflow-wrap: anywhere; }
.single-compact > p { margin: 9px 0 0; color: var(--muted); font-size: 12px; font-weight: 750; }
.single-settlement { margin-top: 7px; color: #59677b; font-size: 11px; font-weight: 800; }

.single-decision,
.single-rule-block,
.single-money-block {
  min-width: 0;
  padding: 14px;
  border: 1px solid #cbdedb;
  border-radius: 7px;
  background: #fff;
}

.single-decision {
  border-left: 6px solid #7a879b;
}

.single-proof {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #cbdedb;
  border-radius: 7px;
  background: #fff;
}

.single-proof h4 {
  margin: 0 0 8px;
  color: var(--navy);
  font-size: 13px;
}

.single-proof-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 10px;
}

.single-proof-grid div {
  min-width: 0;
}

.single-proof-grid span,
.single-proof-grid strong {
  display: block;
}

.single-proof-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.single-proof-grid strong {
  color: var(--navy);
  font-size: 14px;
}

.single-proof-grid .is-negative strong {
  color: var(--red);
}

.single-proof-grid .is-positive strong {
  color: #087367;
}

.single-proof p,
.single-footnote {
  margin: 7px 0 0;
  color: #536077;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}

.single-footnote {
  grid-column: 1 / -1;
  margin: 0;
}

.single-decision.is-follow {
  border-left-color: #0a8b78;
  background: #f0fffb;
}

.single-decision.is-reverse {
  border-left-color: var(--gold);
  background: #fffaf0;
}

.single-decision.is-skip {
  background: #f7f9fc;
}

.single-decision-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.single-decision-top span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  border-radius: 999px;
  background: #e4e9f1;
  color: #536077;
  font-size: 14px;
  font-weight: 950;
}

.single-decision.is-follow .single-decision-top span {
  background: #d8f6ed;
  color: #087367;
}

.single-decision.is-reverse .single-decision-top span {
  background: #fff0c2;
  color: #865a00;
}

.single-decision-top small {
  color: var(--muted);
  font-weight: 850;
}

.single-decision > strong {
  display: block;
  margin-top: 7px;
  color: var(--navy);
  font-size: 24px;
  line-height: 1.05;
}

.single-decision > p,
.single-money-block > p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.5;
}

.single-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 7px;
}

.single-metrics div {
  min-width: 0;
  padding-top: 8px;
  border-top: 1px solid #dbe6e4;
}

.single-metrics span,
.single-metrics b {
  display: block;
}

.single-metrics span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.single-metrics b {
  margin-top: 3px;
  color: var(--ink);
  font-size: 15px;
  white-space: nowrap;
}

.single-rule-block h4,
.single-money-block h4 {
  margin: 0 0 10px;
  color: var(--navy);
  font-size: 16px;
}

.single-rule-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 9px;
  padding: 7px 0;
  border-top: 1px solid #e5eceb;
}

.single-rule-row:first-of-type {
  border-top: 0;
}

.single-rule-row b {
  color: #087367;
  font-size: 13px;
}

.single-rule-row:nth-of-type(2) b {
  color: #936400;
}

.single-rule-row:nth-of-type(3) b {
  color: #647086;
}

.single-rule-row span {
  color: #4f5d72;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.42;
}

.money-line {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) auto;
  align-items: center;
  gap: 4px 12px;
  padding: 8px 0;
  border-top: 1px solid #e5eceb;
}

.money-line:first-of-type {
  border-top: 0;
}

.money-line div {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.money-line div strong {
  color: var(--ink);
  font-size: 13px;
}

.money-line div span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.money-line > b {
  color: #087367;
  font-size: 21px;
}

.money-line small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.single-backtest-strip {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(220px, 1.3fr) minmax(220px, 1.3fr) repeat(2, minmax(110px, 0.65fr)) minmax(220px, 1.2fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid #cbdedb;
  border-radius: 7px;
  background: #cbdedb;
}

.single-backtest-strip div {
  min-width: 0;
  padding: 10px 12px;
  background: #fff;
}

.single-backtest-strip span,
.single-backtest-strip strong {
  display: block;
}

.single-backtest-strip span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.single-backtest-strip strong {
  margin-top: 4px;
  color: var(--navy);
  font-size: 13px;
  line-height: 1.3;
}

.single-backtest-strip small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  line-height: 1.35;
}

.single-backtest-strip .is-positive strong {
  color: #087367;
}

.single-backtest-strip .is-negative strong {
  color: var(--red);
}

.single-backtest-strip .is-development {
  background: #f1f5ff;
}

.single-backtest-strip .is-development strong {
  color: #17499a;
}

.history-pills {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.score-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 74px;
  padding: 15px;
  border-bottom: 1px solid var(--line);
}

.panel h3 {
  margin-top: 3px;
  font-size: 20px;
  color: var(--navy);
}

.sum-panel > .panel-head,
.gate-panel > .panel-head {
  min-height: 84px;
  border-top: 0;
  border-radius: 8px 8px 0 0;
  border-bottom-color: rgba(255, 255, 255, 0.2);
  background: linear-gradient(135deg, var(--navy), #1552a5);
  color: #fff;
}

.sum-panel > .panel-head > div:first-child,
.gate-panel > .panel-head > div:first-child {
  min-width: 250px;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.sum-panel > .panel-head h3,
.gate-panel > .panel-head h3 {
  margin-top: 4px;
  font-size: 23px;
  font-weight: 950;
  color: #fff;
}

.gate-panel > .panel-head h3 {
  white-space: nowrap;
}

.sum-panel > .panel-head .section-kicker,
.gate-panel > .panel-head .section-kicker {
  font-size: 13px;
  font-weight: 950;
  color: #ffb0b4;
}

.gate-panel > .panel-head {
  align-items: stretch;
  flex-direction: column;
  gap: 5px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #f1b313, #d98700);
  color: #fff;
}

.gate-panel > .panel-head > div:first-child {
  min-width: 0;
  background: transparent;
  box-shadow: none;
}

.gate-panel > .panel-head .section-kicker {
  color: #fff8dc;
}

.gate-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
}

.gate-title-block {
  min-width: 0;
}

.gate-issue-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.gate-target-issue {
  margin: 0;
  color: rgba(255, 255, 255, 0.94);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
  white-space: nowrap;
}

.gate-stage {
  display: inline-block;
  margin: 0;
  padding: 4px 9px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 999px;
  background: rgba(7, 28, 93, 0.2);
  color: #fff;
  font-size: 12px;
  font-weight: 950;
  line-height: 1.2;
}

.gate-help-button {
  display: grid;
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 50%;
  background: rgba(7, 28, 93, 0.08);
  color: #fff;
  font: 500 15px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
}

.gate-help-button:hover,
.gate-help-button:focus-visible {
  border-color: rgba(255, 255, 255, 0.86);
  background: rgba(7, 28, 93, 0.18);
  outline: none;
}

.gate-stage.is-hot {
  border-color: #bdf4e8;
  background: #e6fff8;
  color: #087367;
}

.gate-stage.is-cooling {
  border-color: #fff0aa;
  background: #fff7d5;
  color: #8b5a00;
}

.gate-stage.is-cold {
  border-color: #ffc6c9;
  background: #fff0f1;
  color: var(--red);
}

.sum-panel > .panel-head .score-pill,
.gate-panel > .panel-head .score-pill {
  border-color: rgba(255, 255, 255, 0.62);
  background: rgba(7, 28, 93, 0.2);
  color: #fff;
  box-shadow: none;
}

.sum-panel > .panel-head #sumHitRate {
  border-color: rgba(255, 206, 208, 0.78);
  background: rgba(215, 25, 32, 0.32);
  color: #fff;
}

.gate-panel > .panel-head .score-pill {
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  box-shadow: none;
  font-size: 15px;
  white-space: nowrap;
}

.gate-rate-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 10px;
  flex-wrap: wrap;
}

.gate-rate-group #gateMainHitRate {
  color: #fff8dc;
}

.gate-break-even {
  width: 100%;
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.35;
}

.gate-break-even.is-positive {
  color: #d8fff3;
}

.gate-break-even.is-negative {
  color: #ffe1e3;
}

body.is-modal-open {
  overflow: hidden;
}

.stage-help-modal[hidden] {
  display: none;
}

.stage-help-modal {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  padding: 18px;
  place-items: center;
}

.stage-help-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 18, 39, 0.58);
  backdrop-filter: blur(2px);
}

.stage-help-dialog {
  position: relative;
  display: flex;
  width: min(560px, 100%);
  max-height: calc(100vh - 36px);
  overflow: hidden;
  flex-direction: column;
  border: 2px solid #f5c85f;
  border-radius: 20px;
  background: #fffaf0;
  box-shadow: 0 24px 70px rgba(7, 28, 93, 0.34);
}

.stage-help-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 20px;
  background: linear-gradient(135deg, #f1b313, #d98700);
  color: #fff;
}

.stage-help-head span {
  color: #fff8dc;
  font-size: 13px;
  font-weight: 950;
}

.stage-help-head h2 {
  margin: 5px 0 0;
  color: #fff;
  font-size: 26px;
}

.stage-help-close {
  display: grid;
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background: rgba(7, 28, 93, 0.18);
  color: #fff;
  font: 700 24px/1 system-ui, sans-serif;
  cursor: pointer;
}

.stage-help-close:hover,
.stage-help-close:focus-visible {
  background: rgba(7, 28, 93, 0.34);
  outline: none;
}

.stage-help-body {
  overflow-y: auto;
  padding: 6px 24px 0;
}

.stage-help-item {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid #eadfc8;
}

.stage-help-item:last-child {
  border-bottom: 0;
}

.stage-help-item strong {
  color: #9a6100;
  font-size: 16px;
}

.stage-help-item p {
  margin: 0;
  color: #25344f;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.65;
}

.stage-help-done {
  margin: 16px 24px 22px;
  padding: 13px 18px;
  border: 0;
  border-radius: 8px;
  background: #d98700;
  color: #fff;
  font-size: 17px;
  font-weight: 950;
  cursor: pointer;
}

.stage-help-done:hover,
.stage-help-done:focus-visible {
  background: #bd7300;
  outline: 3px solid rgba(241, 179, 19, 0.28);
}

#sumHitRate,
#historySumRate,
.replay-hit-rate {
  border-color: rgba(215, 25, 32, 0.32);
  background: #fdebed;
  color: var(--red);
  font-weight: 950;
}

.gate-list,
.sum-list {
  display: grid;
  align-content: start;
  flex: 1;
  min-height: 0;
  gap: 10px;
  padding: 15px;
}

.gate-list {
  grid-template-rows: repeat(3, minmax(108px, 1fr));
  flex: 1;
  gap: 9px;
  padding: 12px;
}

.sum-list {
  gap: 10px;
}

.sum-list.is-active {
  grid-auto-rows: max-content;
  overflow-y: visible;
  overscroll-behavior-y: auto;
  scrollbar-gutter: stable;
}

.sum-list.is-active > .signal-replay {
  min-height: 282px;
}

.sum-list.is-active::-webkit-scrollbar {
  width: 8px;
}

.sum-list.is-active::-webkit-scrollbar-thumb {
  border: 2px solid #fff;
  border-radius: 999px;
  background: #aab7cf;
}

.sum-list.is-inactive {
  grid-template-rows: auto;
  align-content: start;
}

.sum-list.is-inactive > .signal-replay {
  display: flex;
  min-height: 0;
  flex-direction: column;
}

.sum-list.is-inactive > .signal-replay > .replay-body {
  min-height: 176px;
  max-height: none;
  flex: 1;
}

.current-prediction {
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--muted);
  border-radius: 8px;
  background: #f7f9fd;
}

.current-prediction.is-strong {
  border-color: rgba(215, 25, 32, 0.38);
  border-left-color: var(--red);
  background: #fff6f6;
}

.current-prediction.is-watch {
  border-color: rgba(213, 154, 18, 0.45);
  border-left-color: var(--gold);
  background: #fffaf0;
}

.exact-context {
  display: grid;
  gap: 3px;
  margin-top: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  color: #476b68;
  font-size: 12px;
  line-height: 1.4;
}

.exact-context > div { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.exact-context strong { color: #08645d; }
.exact-context small { color: var(--muted); font-size: 11px; }
.exact-context b { font-weight: 950; }
.exact-context .context-count { color: #9a6100; }
.exact-context .context-follow { color: #b81722; }
.exact-context .context-core { color: #075ca7; }
.exact-context-watch b { color: #b81722; }

.prediction-observations {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  margin-top: auto;
  padding-top: 8px;
}

.prediction-observation {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #cdd8e7;
  border-radius: 5px;
  background: #fff;
  line-height: 1.35;
}

.prediction-observation span { color: #60718c; font-size: 11px; font-weight: 800; }
.prediction-observation strong { color: var(--navy); font-size: 13px; overflow-wrap: anywhere; }
.prediction-observation small { color: #60718c; font-size: 10px; }

.manual-chase {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--navy);
}

.manual-chase-head,
.manual-chase-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; }
.manual-chase-head strong { font-size: 15px; }
.manual-chase-head span { color: #56677e; font-size: 12px; font-weight: 750; }
.manual-chase-settlement,
.manual-chase-progress { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 11px; line-height: 1.45; }
.manual-chase-settlement { color: #53667f; }
.manual-chase-settlement strong { color: #9a6100; }
.manual-chase-progress { color: #9a6100; font-weight: 800; }
.manual-chase-controls label { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 800; }
.manual-chase-controls input {
  width: 78px;
  height: 31px;
  padding: 3px 7px;
  border: 1px solid #aabbd5;
  border-radius: 5px;
  color: var(--navy);
  background: #fff;
  font: inherit;
}
.manual-chase-controls > span { color: var(--muted); font-size: 11px; font-weight: 750; }
.manual-chase-controls button {
  min-height: 31px;
  padding: 4px 11px;
  border: 1px solid #087b6d;
  border-radius: 5px;
  background: #087b6d;
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}
.manual-chase-controls button:hover { background: #075b54; }
.manual-chase-numbers { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 4px; }
.manual-chase-number {
  display: grid;
  justify-items: center;
  gap: 1px;
  min-width: 0;
  padding: 3px 1px;
  border: 1px solid #cdd8e7;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}
.manual-chase-number.is-selected { border-color: #087b6d; background: #e7f4f0; }
.manual-chase-number input { margin: 0; width: 13px; height: 13px; accent-color: #087b6d; }
.manual-chase-number b { color: var(--ball-text); font-size: 12px; font-weight: 950; }
.manual-chase-number small { color: var(--red); font-size: 9px; font-weight: 900; white-space: nowrap; }
.manual-chase-result { display: grid; gap: 3px; font-size: 11px; line-height: 1.45; }
.manual-chase-result strong { color: #08645d; }
.manual-chase-result span { color: #43566e; }
.manual-chase-note { color: var(--muted); font-size: 10px; line-height: 1.4; }

.sum-pattern-row {
  display: flex;
  gap: 6px 16px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: #536077;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.4;
}

.current-prediction-head,
.current-prediction-head > div,
.current-prediction-role {
  display: flex;
  align-items: center;
}

.current-prediction-head {
  justify-content: space-between;
  gap: 10px;
}

.current-prediction-head > div {
  gap: 9px;
}

.current-prediction-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.copy-sum-button {
  min-height: 29px;
  padding: 4px 9px;
  border: 1px solid #aabbd5;
  border-radius: 6px;
  background: #fff;
  color: var(--navy);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.copy-sum-button:hover:not(:disabled),
.copy-sum-button:focus-visible {
  border-color: var(--navy);
  background: #eef3fb;
}

.copy-sum-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bet-copy-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.bet-copy-bar label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.bet-copy-bar input,
.bet-copy-bar select {
  height: 29px;
  border: 1px solid #aabbd5;
  border-radius: 6px;
  background: #fff;
  color: var(--navy);
  font-size: 12px;
  font-weight: 800;
}

.bet-copy-bar input {
  width: 62px;
  padding: 3px 6px;
  text-align: center;
}

.bet-copy-bar :disabled {
  opacity: 0.55;
}

.bet-copy-bar select {
  padding: 3px 5px;
}

.bet-copy-button {
  background: var(--navy);
  color: #fff;
}

.bet-copy-button:hover:not(:disabled),
.bet-copy-button:focus-visible {
  background: var(--navy-2);
  color: #fff;
}

.current-prediction-head span {
  color: var(--navy);
  font-size: 17px;
  font-weight: 950;
}

.prediction-target-issue {
  padding: 0;
  background: transparent;
  color: var(--red);
  font: inherit;
  font-weight: 950;
}

.current-prediction-head strong,
.current-prediction-head b {
  min-height: 27px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 950;
}

.current-prediction-head strong {
  background: #e9eef6;
  color: var(--muted);
}

.current-prediction-head b {
  background: var(--navy);
  color: #fff;
}

.current-prediction.is-strong .current-prediction-head strong {
  background: #fde1e3;
  color: var(--red);
}

.current-prediction.is-watch .current-prediction-head strong {
  background: #fff0c2;
  color: #865a00;
}

.current-prediction p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.45;
}

.current-prediction-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.current-prediction-groups.is-single {
  grid-template-columns: 1fr;
}

.current-prediction-role {
  gap: 7px;
  min-width: 0;
  padding: 8px;
  border-radius: 7px;
  background: #fff;
  flex-wrap: wrap;
}

.sum-band-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.sum-band-heading,
.sum-band-records-head {
  display: flex;
  align-items: baseline;
  gap: 6px 16px;
  flex-wrap: wrap;
}

.sum-band-heading {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 6px;
  color: var(--navy);
}
.sum-band-pick,
.sum-band-metric {
  display: grid;
  align-content: center;
  gap: 1px;
  min-width: 0;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.sum-band-pick { border-color: #e4a10b; background: #fff2cb; }
.sum-band-pick small,
.sum-band-metric small { color: var(--muted); font-size: 11px; font-weight: 800; }
.sum-band-pick strong { color: var(--red); font-size: 24px; line-height: 1.1; }
.sum-band-metric strong { font-size: 18px; line-height: 1.15; }
.sum-band-metric.is-negative strong,
.sum-band-edge.is-negative { color: var(--red); }
.sum-band-metric.is-positive strong,
.sum-band-edge.is-positive { color: #0b625b; }
.sum-band-edge { grid-column: 1 / -1; font-size: 11px; font-weight: 850; }
.sum-band-replay { margin-top: 6px; color: var(--muted); font-size: 11px; font-weight: 750; }

.sum-head-turn {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 3px 13px;
  margin-top: 7px;
  padding: 6px 9px;
  border: 1px solid #cfe2e0;
  border-radius: 6px;
  background: #f1f8f7;
  color: #385a59;
  font-size: 11px;
  font-weight: 800;
}
.sum-head-turn strong { color: #075f58; }
.sum-head-turn.is-watch { border-color: #e9bc62; background: #fff7e6; color: #805317; }
.sum-head-turn.is-watch strong { color: #8d5300; }

.sum-band-forecast {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin-top: 7px;
  border-block: 1px solid var(--line);
}

.sum-band-item {
  display: grid;
  align-content: start;
  gap: 2px;
  min-width: 0;
  padding: 8px 10px;
  border-left: 1px solid var(--line);
  color: #536077;
  font-size: 12px;
}

.sum-band-item:first-child { border-left: 0; }
.sum-band-item b { color: var(--navy); }
.sum-band-item small { font-size: 11px; font-weight: 800; line-height: 1.35; }
.sum-band-item small:first-of-type { color: var(--navy); font-weight: 950; }
.sum-band-item.is-leading { background: #fff1cb; }

.sum-band-records { margin-top: 9px; }
.sum-band-records-head { justify-content: space-between; color: var(--muted); font-size: 11px; }
.sum-band-records-head strong { color: var(--navy); font-size: 12px; }
.sum-band-records-head strong small { color: var(--muted); font-size: 10px; font-weight: 750; }
.sum-band-records-head span { color: #0b625b; font-weight: 950; }
.sum-band-records-head a { color: var(--navy); text-decoration: underline; text-underline-offset: 2px; }
.sum-band-record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: space-between;
  gap: 0 16px;
  margin-top: 4px;
}
.sum-band-record {
  display: grid;
  grid-template-columns: 64px 80px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
  color: #536077;
  font-size: 11px;
  font-weight: 750;
}
.sum-band-record b { color: var(--navy); }
.sum-band-record > span { white-space: nowrap; }
.sum-band-record > strong { justify-self: end; white-space: nowrap; }
.sum-band-record.is-hit > strong { color: #0b625b; }
.sum-band-record.is-miss > strong { color: var(--red); }

.current-prediction-role em {
  min-width: 42px;
  min-height: 28px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 6px;
  background: #fde1e3;
  color: var(--red);
  font-style: normal;
  font-size: 12px;
  font-weight: 950;
}

.current-prediction-role.is-defense em {
  background: #fff0c2;
  color: #865a00;
}

.current-prediction-role .mini-ball {
  width: 36px;
  height: 36px;
  border-width: 3px;
  font-size: 13px;
}

.sum-group {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.sum-group.is-main {
  border-color: rgba(215, 25, 32, 0.3);
  background: #fff8f8;
}

.sum-group.is-defense {
  border-color: rgba(213, 154, 18, 0.35);
  background: #fffdf6;
}

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

.sum-group-head > div {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sum-role {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 13px;
  font-weight: 950;
}

.sum-group.is-defense .sum-role {
  background: var(--gold);
}

.sum-group-head small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sum-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 9px;
}

.sum-pick-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 78px;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: 8px;
  background: #fff;
}

.sum-pick-card.is-defense {
  border-left-color: var(--gold);
}

.sum-pick-body {
  min-width: 0;
}

.wait-picks {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #f8fbff;
  text-align: left;
  font-weight: 850;
  line-height: 1.6;
}

.wait-picks strong {
  flex: 0 0 auto;
  color: var(--navy);
  font-size: 13px;
}

.wait-picks span {
  font-size: 11px;
}

.signal-replay {
  overflow: hidden;
  border: 1px solid #b8c7e2;
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 0 0 2px rgba(7, 28, 93, 0.025);
}

.replay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(135deg, var(--navy), #1552a5);
  color: #fff;
}

.replay-head > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 220px;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.replay-head strong {
  color: #fff;
  font-size: 13px;
}

.replay-head small {
  color: rgba(255, 255, 255, 0.72);
  font-size: 9px;
}

.replay-summary {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.replay-summary span {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 6px;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  font-size: 9px;
  font-weight: 850;
}

.replay-legend {
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: #fff9e9;
  font-size: 9px;
  font-weight: 750;
}

.replay-legend b,
.prediction-number i {
  display: inline-grid;
  place-items: center;
  border-radius: 4px;
  background: var(--gold);
  color: #fff;
  font-style: normal;
  font-weight: 950;
}

.replay-legend b {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.replay-grid {
  display: grid;
  grid-template-columns: 72px minmax(220px, 1fr) 52px 108px 68px;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.replay-grid-head {
  min-height: 30px;
  padding: 0 10px;
  border-bottom: 1px solid #c9d4e8;
  color: var(--muted);
  background: #f7f9fd;
  font-size: 10px;
  font-weight: 900;
  text-align: center;
}

.replay-row {
  min-height: 56px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

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

.replay-issue {
  color: var(--navy);
  font-size: 12px;
  font-weight: 900;
}

.replay-body {
  max-height: 176px;
  overflow-y: auto;
  overscroll-behavior-y: auto;
  scrollbar-gutter: stable;
}

.replay-body::-webkit-scrollbar {
  width: 8px;
}

.replay-body::-webkit-scrollbar-thumb {
  border: 2px solid #fff;
  border-radius: 999px;
  background: #aab7cf;
}

.replay-predictions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}

.replay-predictions > div {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  min-width: 0;
  border-radius: 6px;
  background: #fff4f4;
}

.replay-predictions > div:nth-child(2) {
  background: #fff8e7;
}

.replay-predictions em {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 5px;
  background: #fde6e7;
  color: var(--red);
  font-style: normal;
  font-size: 10px;
  font-weight: 950;
}

.replay-predictions > div:nth-child(2) em {
  background: #fff1c9;
  color: #895c00;
}

.prediction-numbers {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  flex-wrap: wrap;
}

.prediction-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-width: 27px;
  min-height: 24px;
  padding: 0 3px;
  border-radius: 5px;
  color: var(--navy);
  background: #eef4ff;
  font-size: 13px;
  font-weight: 950;
}

.replay-role-main .prediction-number,
.current-prediction-role.is-main .prediction-number {
  color: var(--red);
  background: #fde8ea;
}

.current-prediction-role.is-main .prediction-number.is-featured {
  min-width: 39px;
  min-height: 39px;
  padding: 0 6px;
  background: var(--red);
  color: #fff;
  font-size: 19px;
}

.replay-role-defense .prediction-number,
.current-prediction-role.is-defense .prediction-number {
  color: #895c00;
  background: #fff0c6;
}

.prediction-number.is-cross {
  outline: 1px solid rgba(213, 154, 18, 0.72);
}

.prediction-number i {
  position: absolute;
  right: -2px;
  top: -4px;
  z-index: 4;
  width: 13px;
  height: 13px;
  font-size: 7px;
}

.prediction-separator {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.replay-actual,
.replay-relations,
.replay-result {
  display: flex;
  align-items: center;
  justify-content: center;
}

.replay-result-ball {
  width: 30px;
  height: 30px;
}

.replay-relations .relation-list {
  flex-wrap: wrap;
}

.replay-result .sum-result-badge {
  min-width: 60px;
  padding: 0 6px;
  font-size: 10px;
}

.replay-empty-state {
  min-height: 110px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 850;
}

.empty-state {
  min-height: 74px;
  display: grid;
  place-items: center;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #f8fbff;
  font-weight: 850;
  text-align: center;
}

.empty-state.wide {
  grid-column: 1 / -1;
}

.gate-card {
  min-height: 108px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.gate-card.is-main {
  background: linear-gradient(145deg, var(--navy), #124da0);
  color: #fff;
  box-shadow: 0 12px 24px rgba(7, 28, 93, 0.18);
}

.gate-card.is-second {
  background: linear-gradient(145deg, #fff9ec, #ffffff);
  border-color: rgba(213, 154, 18, 0.42);
}

.gate-card.is-reserve {
  border-color: rgba(43, 103, 180, 0.8);
  background: linear-gradient(145deg, #173b7f, #2a68b7);
  color: #fff;
  box-shadow: 0 10px 22px rgba(7, 28, 93, 0.16);
}

.gate-card.is-reserve .gate-role {
  background: #ffd76b;
  color: #5c3900;
}

.gate-card.is-reserve .gate-meta,
.gate-card.is-reserve .pick-note,
.gate-card.is-reserve .rank {
  color: rgba(255, 255, 255, 0.86);
}

.gate-card.is-reserve .bar {
  background: rgba(255, 255, 255, 0.2);
}

.gate-card.is-reserve .bar span {
  min-width: 8px;
  background: linear-gradient(90deg, #f5b400, #ffd86e);
}

.gate-card-top,
.gate-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.gate-role {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(215, 25, 32, 0.1);
  color: var(--red);
  font-size: 13px;
  font-weight: 950;
}

.gate-card.is-main .gate-role {
  background: var(--red);
  color: #fff;
}

.gate-name {
  margin-top: 5px;
  font-size: 30px;
  line-height: 1;
  font-weight: 950;
  letter-spacing: 0;
}

.gate-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.gate-card.is-main .gate-meta,
.gate-card.is-main .pick-note,
.gate-card.is-main .rank {
  color: rgba(255, 255, 255, 0.82);
}

.gate-card.is-main .bar {
  background: rgba(255, 255, 255, 0.18);
}

.gate-card .gate-share-bar {
  flex: 0 0 5px;
  min-height: 5px;
  height: 5px;
  margin-top: 5px;
  background: #dce4f0;
}

.gate-card.is-main .gate-share-bar,
.gate-card.is-reserve .gate-share-bar {
  background: rgba(255, 255, 255, 0.42);
}

.gate-card .gate-share-bar span,
.gate-card.is-reserve .gate-share-bar span {
  min-width: 5px;
  background: #f23a42;
}

.pick-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.pick-badge {
  display: grid;
  place-items: center;
  position: relative;
  isolation: isolate;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  overflow: hidden;
  border: 4px solid #fff;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 23%),
    linear-gradient(145deg, var(--ball-1), var(--ball-2) 54%, var(--ball-3));
  color: var(--ball-text);
  font-weight: 900;
  font-size: 18px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 4px 8px rgba(255, 255, 255, 0.45), inset 0 -7px 10px rgba(0, 0, 0, 0.18), 0 8px 16px rgba(7, 28, 93, 0.12);
}

.pick-badge::before,
.pick-badge::after,
.mini-ball::before,
.mini-ball::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.pick-badge::before {
  inset: 6px;
  z-index: 1;
  background: var(--ball-inner);
  border: 1px solid rgba(12, 24, 42, 0.72);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.32), inset 0 2px 4px rgba(7, 28, 93, 0.16);
}

.pick-badge::after {
  top: 7px;
  left: 11px;
  z-index: 2;
  width: 13px;
  height: 13px;
  background: rgba(255, 255, 255, 0.46);
  filter: blur(0.8px);
}

.pick-badge span,
.mini-ball span {
  position: relative;
  z-index: 3;
}

.pick-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pick-title strong {
  font-size: 15px;
}

.pick-title span,
.pick-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.bar {
  height: 8px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--soft);
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--red));
}

.rank {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: right;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 15px;
}

.stat-group {
  min-width: 0;
}

.stat-group-head {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-left: 4px solid var(--navy);
  background: #eef3fb;
}

.stat-group-head strong {
  color: var(--navy);
  font-size: 16px;
  font-weight: 950;
}

.stat-group-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.stat-group-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.stat-card {
  min-height: 96px;
  height: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stat-card strong {
  display: block;
  margin-top: 7px;
  font-size: clamp(16px, 1.35vw, 21px);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.stat-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  height: 1017px;
  max-height: 1017px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: auto;
  touch-action: pan-y;
  scrollbar-gutter: stable;
  background: #fff;
}

.table-wrap::-webkit-scrollbar {
  width: 10px;
}

.table-wrap::-webkit-scrollbar-thumb {
  border: 2px solid #fff;
  border-radius: 999px;
  background: #aeb9cc;
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 13px;
}

th:nth-child(1),
td:nth-child(1) {
  width: 6%;
}

th:nth-child(2),
td:nth-child(2) {
  width: 18%;
}

th:nth-child(3),
td:nth-child(3) {
  width: 8%;
  text-align: center;
}

th:nth-child(4),
td:nth-child(4) {
  width: 8%;
  text-align: center;
}

th:nth-child(5),
td:nth-child(5) {
  width: 8%;
  text-align: center;
}

th:nth-child(6),
td:nth-child(6) {
  width: 17%;
}

th:nth-child(7),
td:nth-child(7) {
  width: 6%;
  text-align: center;
}

th:nth-child(8),
td:nth-child(8) {
  width: 10%;
}

th:nth-child(9),
td:nth-child(9) {
  width: 14%;
}

th:nth-child(10),
td:nth-child(10) {
  width: 5%;
  text-align: center;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

#historyRows tr {
  height: 65px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--navy);
  color: #fff;
  font-size: 12px;
}

.numbers-cell {
  font-weight: 900;
}

.cell-value,
.number-expression,
.shape-expression {
  min-width: 0;
}

.number-expression,
.shape-expression {
  display: inline-flex;
  align-items: center;
}

.history-mobile-numbers {
  display: none;
}

.numbers-cell b {
  margin: 0 2px;
  color: var(--ink);
}

.numbers-cell strong {
  color: var(--ink);
  font-size: 15px;
}

.actual-sum-ball {
  display: inline-grid;
  place-items: center;
  position: relative;
  isolation: isolate;
  width: 38px;
  height: 38px;
  overflow: hidden;
  border: 3px solid #fff;
  border-radius: 999px;
  background: linear-gradient(145deg, var(--ball-1), var(--ball-2) 54%, var(--ball-3));
  color: var(--ball-text);
  font-size: 14px;
  font-weight: 950;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.28), inset 0 -5px 7px rgba(0, 0, 0, 0.2), 0 3px 7px rgba(7, 28, 93, 0.16);
}

.actual-sum-ball span {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 999px;
  background: var(--ball-inner);
  border: 1px solid rgba(12, 24, 42, 0.72);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.32), inset 0 1px 3px rgba(7, 28, 93, 0.14);
}

.table-empty {
  height: 74px;
  color: var(--muted);
  font-weight: 850;
  text-align: center;
}

.mini-ball {
  display: inline-grid;
  place-items: center;
  position: relative;
  isolation: isolate;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  overflow: hidden;
  color: var(--ball-text);
  border: 2px solid #fff;
  background:
    radial-gradient(circle at 33% 24%, rgba(255, 255, 255, 0.52), rgba(255, 255, 255, 0) 24%),
    linear-gradient(145deg, var(--ball-1), var(--ball-2) 54%, var(--ball-3));
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.42), inset 0 -4px 7px rgba(0, 0, 0, 0.16);
  font-size: 16px;
  font-weight: 950;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
}

.mini-ball::before {
  inset: 6px;
  z-index: 1;
  background: var(--ball-inner);
  border: 1px solid rgba(12, 24, 42, 0.68);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3), inset 0 1px 2px rgba(7, 28, 93, 0.16);
}

.mini-ball::after {
  top: 5px;
  left: 8px;
  z-index: 2;
  width: 10px;
  height: 10px;
  background: rgba(255, 255, 255, 0.44);
  filter: blur(0.5px);
}

th.actual-head,
td.actual-cell {
  text-align: center;
}

td.actual-cell {
  display: table-cell;
}

.actual-cell small {
  display: inline-block;
  width: 44px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.shape-token {
  display: inline-block;
  width: 28px;
  font-weight: 950;
  font-size: 16px;
  text-align: center;
}

.shape-token.big,
.shape-token.odd {
  color: var(--red);
}

.shape-token.small,
.shape-token.even {
  color: var(--blue);
}

.predict-cell {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-band-cell {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  line-height: 1.25;
}

.history-band-cell > span,
.history-band-cell > strong {
  display: block;
}

.history-band-prediction { color: var(--navy); }
.history-band-result.is-hit { color: #0b625b; }
.history-band-result.is-miss { color: var(--red); }

.history-gate-order {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-weight: 900;
}

.history-gate-order em {
  margin-right: 4px;
  font-size: 11px;
  font-style: normal;
  font-weight: 950;
}

.history-gate-primary {
  color: var(--red);
}

.history-gate-defense {
  color: #8b6100;
}

.history-gate-option.is-hit {
  color: #087a3e;
  font-weight: 1000;
}

.history-gate-slash {
  color: currentColor;
  font-weight: 750;
}

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

.sum-predict-cell {
  overflow: hidden;
  color: var(--ink);
  font-weight: 850;
  text-overflow: ellipsis;
}

.history-predictions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.history-prediction-role {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 4px 6px;
  border-radius: 6px;
  background: #fff4f4;
}

.history-prediction-role.is-defense {
  background: #fff8e7;
}

.history-prediction-role em {
  display: inline-grid;
  place-items: center;
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  border-radius: 5px;
  background: #fde1e3;
  color: var(--red);
  font-style: normal;
  font-size: 10px;
  font-weight: 950;
}

.history-prediction-role.is-defense em {
  background: #ffeebd;
  color: #865a00;
}

.history-prediction-role strong {
  color: var(--red);
  font-size: 13px;
  letter-spacing: 0;
}

.history-prediction-role.is-defense strong {
  color: #895c00;
}

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

.result-sum-ball {
  width: 40px;
  height: 40px;
  margin-left: 1px;
  border-color: #ffe8e9;
  font-size: 16px;
}

.result-sum-ball::before {
  inset: 6px;
}

.relation-list {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.relation-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #f7f9fc;
  font-size: 10px;
  font-weight: 900;
}

.relation-chip.same {
  border-color: #ef9ba0;
  color: var(--red);
  background: #fff0f1;
}

.relation-chip.tight {
  border-color: #86b8ec;
  color: #075d9d;
  background: #eef7ff;
}

.relation-chip.near {
  border-color: #e2bd61;
  color: #835600;
  background: #fff8e5;
}

.relation-chip.wide,
.relation-empty {
  color: #9ba6b8;
}

.hit-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 0;
  font-size: 21px;
  font-weight: 900;
  line-height: 1;
  background: transparent;
  filter: drop-shadow(0 2px 2px rgba(7, 28, 93, 0.12));
}

.hit-badge.ok {
  color: inherit;
}

.hit-badge.bad {
  color: inherit;
}

.hit-badge.neutral {
  color: var(--muted);
  font-size: 13px;
  filter: none;
}

.sum-result-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 66px;
  min-height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 950;
}

.sum-result-badge.main {
  background: #fde6e7;
  color: var(--red);
}

.sum-result-badge.defense {
  background: #fff1c9;
  color: #8b5d00;
}

.sum-result-badge.miss {
  background: #f2f4f8;
  color: var(--muted);
}

.signal-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  min-height: 30px;
  padding: 0 9px;
  gap: 5px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 900;
}

.signal-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 2px;
  background: currentColor;
}

.signal-state {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  max-width: 100%;
}

.signal-state small {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-overflow: ellipsis;
}

.signal-chip.strong {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

.signal-chip.watch {
  border-color: #d59a12;
  background: #fff1c9;
  color: #855900;
}

.signal-chip.wait {
  border-color: #d8e0ea;
  background: #eef3f7;
  color: var(--muted);
}

.history-row.signal-strong > td {
  background: #fff7f7;
}

.history-row.signal-watch > td {
  background: #fffcf3;
}

.history-row.signal-strong > td:first-child {
  box-shadow: inset 4px 0 var(--red);
}

.history-row.signal-watch > td:first-child {
  box-shadow: inset 4px 0 var(--gold);
}

.history-row.signal-wait > td:first-child {
  box-shadow: inset 4px 0 #cfd7e3;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 20;
  transform: translate(-50%, 16px);
  max-width: min(560px, calc(100% - 32px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.is-hidden {
  display: none !important;
}

.back-top-button {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 18;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 10px 24px rgba(7, 28, 93, 0.3);
  font-size: 25px;
  font-weight: 950;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.back-top-button:hover {
  background: #124da0;
}

.back-top-button.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .hero-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .risk-card {
    grid-column: 1 / -1;
  }

  .main-grid {
    grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.8fr);
    grid-template-areas:
      "predictions gates"
      "history history"
      "stats stats";
  }

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

}

@media (max-width: 1450px) {
  .prediction-observations { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .prediction-observation.is-cold { display: none; }
}

@media (max-width: 900px) {
  .manual-chase-numbers { grid-template-columns: repeat(10, minmax(0, 1fr)); }
  .main-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "predictions"
      "gates"
      "history"
      "stats";
  }

  .sum-band-record-grid { grid-template-columns: 1fr; }

  .chase-intro { grid-template-columns: 1fr; }

  .sum-band-heading { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sum-band-pick { grid-column: 1 / -1; }

  .focus-panel {
    height: auto;
  }

  .sum-list.is-active {
    max-height: none;
  }

  .gate-list {
    grid-template-rows: repeat(3, minmax(142px, auto));
  }

  .single-gate-content {
    display: block;
  }

  .single-money-block {
    grid-column: 1 / -1;
  }

  .single-backtest-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sum-list.is-inactive {
    grid-template-rows: auto auto;
    align-content: start;
  }

  .sum-list.is-inactive > .signal-replay > .replay-body {
    min-height: 0;
    max-height: 310px;
    flex: none;
  }
}

@media (max-width: 760px) {
  .manual-chase-numbers { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .prediction-observations { grid-template-columns: 1fr; }
  .single-compact-rates { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-shell {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
  }

  .hero-grid,
  .main-grid {
    grid-template-columns: 1fr;
  }

  .hero-grid {
    gap: 12px;
  }

  .main-grid {
    grid-template-areas:
      "predictions"
      "gates"
      "history"
      "stats";
    gap: 12px;
  }

  .prediction-stack {
    gap: 12px;
  }

  .chase-body { padding: 12px; }
  .chase-number-list { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .chase-number-list > div { padding: 8px 5px; text-align: center; }
  .chase-metrics { grid-template-columns: 1fr; }
  .chase-record-list { grid-template-columns: 1fr; }
  .chase-record { grid-template-columns: minmax(0, 1fr) auto; }
  .chase-record span:nth-child(2) { grid-column: 1; }
  .chase-record strong { grid-column: 2; grid-row: 1 / 3; }
  .chase-status em { margin-left: 0; }

  .risk-card {
    grid-column: auto;
  }

  .hero-card {
    min-height: 118px;
  }

  .draw-template {
    grid-template-columns: 1fr;
    row-gap: 8px;
  }

  .template-time {
    justify-self: start;
    font-size: 16px;
  }

  .ball {
    width: 52px;
    min-width: 52px;
    height: 52px;
    flex-basis: 52px;
    font-size: 22px;
  }

  .balls {
    gap: 5px;
  }

  .template-balls {
    flex-wrap: nowrap;
  }

  .template-balls i {
    font-size: 24px;
  }

  .gate-name {
    font-size: 27px;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    padding: 12px;
  }

  .panel h3,
  .sum-panel > .panel-head h3,
  .gate-panel > .panel-head h3 {
    font-size: 18px;
    line-height: 1.2;
  }

  .sum-panel > .panel-head,
  .gate-panel > .panel-head {
    min-height: 0;
  }

  .section-kicker,
  .sum-panel > .panel-head .section-kicker,
  .gate-panel > .panel-head .section-kicker {
    font-size: 11px;
  }

  .stats-panel > .panel-head #rebatePill {
    white-space: normal;
  }

  .stat-group-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .stat-group-head span {
    text-align: left;
  }

  .sum-panel > .panel-head > div:first-child,
  .gate-panel > .panel-head > div:first-child {
    width: 100%;
    min-width: 0;
  }

  .gate-heading-row {
    width: 100%;
  }

  .gate-rate-group {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr;
    justify-content: stretch;
    gap: 4px;
    text-align: left;
  }

  .gate-panel > .panel-head .score-pill {
    justify-content: flex-start;
    width: 100%;
    white-space: normal;
  }

  .gate-rate-group #gateHitRate {
    text-align: left;
  }

  .gate-break-even {
    grid-column: 1 / -1;
  }

  .stage-help-dialog {
    border-radius: 16px;
  }

  .stage-help-head {
    padding: 18px 18px 16px;
  }

  .stage-help-head h2 {
    font-size: 22px;
  }

  .stage-help-body {
    padding: 4px 18px 0;
  }

  .stage-help-item {
    grid-template-columns: 1fr;
    gap: 5px;
    padding: 12px 0;
  }

  .stage-help-done {
    margin: 14px 18px 18px;
  }

  .gate-list,
  .sum-list {
    padding: 12px;
  }

  .gate-list {
    grid-template-rows: none;
    grid-auto-rows: minmax(112px, auto);
  }

  .sum-list.is-active {
    max-height: none;
  }

  .current-prediction-groups {
    grid-template-columns: 1fr;
  }

  .sum-band-forecast { grid-template-columns: 1fr; }

  .sum-band-item {
    grid-template-columns: 65px minmax(0, 1fr);
    align-items: center;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .sum-band-item:first-child { border-top: 0; }
  .sum-band-item b { grid-row: 1 / 3; }
  .sum-band-item small { font-size: 12px; }
  .sum-band-record { grid-template-columns: 64px 73px minmax(0, 1fr) 30px; }

  .history-pills {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 5px;
  }

  .history-pills .score-pill {
    justify-content: flex-start;
    min-height: 26px;
    padding: 3px 7px;
    font-size: 10px;
    line-height: 1.15;
  }

  .single-head-pills {
    justify-content: flex-start;
  }

  .single-gate-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .single-gate-content {
    display: block;
  }

  .single-metrics span,
  .single-proof-grid span {
    font-size: 12px;
  }

  .single-metrics b {
    font-size: 16px;
  }

  .single-proof p,
  .single-footnote {
    font-size: 12px;
  }

  .single-money-block {
    grid-column: auto;
  }

  .single-backtest-strip {
    grid-column: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .replay-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .replay-body {
    max-height: 310px;
  }

  .replay-summary {
    justify-content: flex-start;
  }

  .replay-grid-head {
    display: none;
  }

  .replay-row {
    grid-template-columns: minmax(0, 1fr) 62px 76px;
    grid-template-areas:
      "issue actual result"
      "picks picks picks"
      "relations relations relations";
    gap: 7px 8px;
    padding: 10px;
  }

  .replay-issue {
    grid-area: issue;
  }

  .replay-predictions {
    grid-area: picks;
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .replay-actual {
    grid-area: actual;
  }

  .replay-relations {
    grid-area: relations;
    justify-content: flex-start;
    padding-left: 28px;
  }

  .replay-result {
    grid-area: result;
  }

  .table-wrap {
    height: 72vh;
    max-height: 72vh;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #eef3f8;
  }

  table {
    display: block;
    width: 100%;
    min-width: 0;
  }

  tbody {
    display: grid;
    width: 100%;
    min-width: 0;
    gap: 0;
  }

  thead {
    display: none;
  }

  tbody tr {
    height: auto;
    display: grid;
    grid-template-columns: 55px 88px 39px 33px minmax(0, 1fr) 24px;
    grid-template-areas: "issue numbers shape sumhit gates gatehit";
    gap: 0;
    align-items: stretch;
    padding: 0;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-left: 4px solid #cfd7e3;
    border-radius: 0;
    background: #fff;
    box-shadow: none;
  }

  #historyRows tr {
    height: auto;
  }

  tbody td,
  tbody td:nth-child(n) {
    display: flex;
    align-items: center;
    gap: 0;
    width: auto;
    min-width: 0;
    min-height: 43px;
    padding: 3px 2px;
    border: 0;
    text-align: left;
    white-space: normal;
  }

  tbody td::before {
    display: none;
  }

  tbody td:nth-child(1) {
    grid-area: issue;
    padding-left: 4px;
  }

  tbody td:nth-child(1) .cell-value {
    color: var(--navy);
    font-size: 10px;
    font-weight: 950;
  }

  tbody td:nth-child(2) {
    grid-area: numbers;
    font-size: 11px;
    font-weight: 900;
  }

  tbody td:nth-child(1)::before,
  tbody td:nth-child(2)::before {
    display: none;
  }

  tbody td:nth-child(1),
  tbody td:nth-child(2) {
    border-top: 0;
    background: transparent;
  }

  tbody td:nth-child(3) {
    grid-area: relation;
  }

  tbody td:nth-child(4) {
    grid-area: shape;
  }

  tbody td:nth-child(5) {
    grid-area: signal;
  }

  tbody td:nth-child(6) {
    grid-area: sums;
  }

  tbody td:nth-child(7) {
    grid-area: sumhit;
  }

  tbody td:nth-child(8) {
    grid-area: band;
  }

  tbody td:nth-child(3),
  tbody td:nth-child(5),
  tbody td:nth-child(6),
  tbody td:nth-child(8) {
    display: none;
  }

  tbody td:nth-child(9) {
    grid-area: gates;
  }

  tbody td:nth-child(10) {
    grid-area: gatehit;
  }

  tbody td:nth-child(4),
  tbody td:nth-child(7),
  tbody td:nth-child(10) {
    flex-direction: row;
    align-items: center;
    justify-content: center;
  }

  tbody td:nth-child(3)::before,
  tbody td:nth-child(4)::before,
  tbody td:nth-child(7)::before,
  tbody td:nth-child(10)::before {
    flex: none;
  }

  tbody td:nth-child(4),
  tbody td:nth-child(10) {
    border-left: 0;
  }

  .history-band-cell > span,
  .history-band-cell > strong {
    display: inline;
  }

  .history-row.signal-strong,
  .history-row.signal-watch,
  .history-row.signal-wait {
    border-left-width: 4px;
  }

  .history-row.signal-strong {
    border-left-color: var(--red);
  }

  .history-row.signal-watch {
    border-left-color: var(--gold);
  }

  .history-row.signal-wait {
    border-left-color: #cfd7e3;
  }

  .history-row.signal-strong > td:first-child,
  .history-row.signal-watch > td:first-child,
  .history-row.signal-wait > td:first-child {
    box-shadow: none;
  }

  .numbers-cell .number-expression {
    display: none;
  }

  .history-mobile-numbers {
    display: inline;
    white-space: nowrap;
    color: var(--navy);
    font-size: 11px;
    font-weight: 950;
  }

  .actual-cell .shape-expression {
    display: grid;
    grid-template-columns: repeat(2, 11px);
    justify-content: center;
    line-height: 1.05;
  }

  .actual-cell .shape-token {
    width: auto;
    font-size: 11px;
  }

  .actual-cell small {
    grid-column: 1 / -1;
    width: auto;
    margin-top: 2px;
    font-size: 9px;
  }

  tbody td:nth-child(7) .sum-result-badge {
    min-width: 0;
    min-height: 22px;
    padding: 1px 2px;
    border-radius: 3px;
    font-size: 9px;
    line-height: 1.05;
    text-align: center;
    overflow-wrap: anywhere;
  }

  tbody td:nth-child(7) .hit-badge,
  tbody td:nth-child(10) .hit-badge {
    min-width: 18px;
    min-height: 18px;
    font-size: 14px;
  }

  .predict-cell {
    overflow: hidden;
    text-overflow: clip;
    font-size: 10px;
    line-height: 1.15;
  }

  .history-gate-order {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    white-space: normal;
  }

  .history-gate-order em { margin-right: 2px; font-size: 9px; }
  .history-gate-separator { display: none; }
  .history-gate-primary,
  .history-gate-defense { white-space: nowrap; }

  .history-predictions {
    flex-wrap: wrap;
  }
}

@media (max-width: 420px) {
  .brand h1 {
    font-size: 22px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .back-top-button {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    width: 44px;
    height: 44px;
  }

  .stat-group-grid {
    grid-template-columns: 1fr;
  }

  .sum-card-grid {
    grid-template-columns: 1fr;
  }

  .current-prediction-head span {
    font-size: 14px;
  }

  .single-compact-rates b {
    font-size: 15px;
  }

  .current-prediction-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .current-prediction-head > div {
    flex-wrap: wrap;
  }

  .gate-break-even {
    grid-column: auto;
  }

  #historyRows tr { grid-template-columns: 51px 78px 35px 30px minmax(0, 1fr) 22px; }
  .history-mobile-numbers { font-size: 10px; }
  .predict-cell { font-size: 9px; }
  .history-gate-order em { font-size: 8px; }

  .pick-row {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .rank {
    grid-column: 2;
    text-align: left;
  }

}

@media (max-width: 340px) {
  .template-issue {
    gap: 4px;
    font-size: 21px;
  }

  .canada-flag {
    width: 40px;
    height: 36px;
    margin-right: 2px;
    font-size: 23px;
  }

  .ball {
    width: 44px;
    min-width: 44px;
    height: 44px;
    flex-basis: 44px;
    font-size: 19px;
  }

  .balls {
    gap: 3px;
  }

  .template-balls i {
    font-size: 20px;
  }

  tbody tr {
    grid-template-columns: 1fr;
    grid-template-areas:
      "issue"
      "numbers"
      "shape"
      "signal"
      "sums"
      "band"
      "sumhit"
      "gates"
      "gatehit";
  }

  tbody td,
  tbody td:nth-child(n) {
    grid-column: 1;
  }

  tbody td:nth-child(4),
  tbody td:nth-child(10) {
    border-left: 0;
  }
}
