/* 出目予想ページ */

.prediction-shell {
  display: grid;
  gap: 1rem;
}

.analytics-message[hidden] {
  display: none;
}

.prediction-shell .analytics-hero {
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr);
}

.prediction-shell .analytics-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.prediction-shell .analytics-summary-card:nth-child(2) {
  grid-column: 1 / -1;
  order: -1;
}

.prediction-shell .analytics-summary-card strong {
  font-size: 1rem;
  line-height: 1.4;
}

.prediction-shell .analytics-summary-card .summary-label {
  margin-bottom: 0.5rem;
}

.prediction-panel {
  padding: 1.6rem;
  min-width: 0;
}

.prediction-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.prediction-toc a {
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-decoration: none;
}

.prediction-toc a:hover,
.prediction-toc a:focus-visible {
  border-color: var(--line-strong);
  color: var(--gold);
  outline: none;
}

.prediction-shell section[id] {
  scroll-margin-top: 88px;
}

.prediction-caption {
  margin-top: 0.4rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.6;
}

.prediction-subtitle {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
}

.prediction-subtitle--spaced {
  margin-top: 1.4rem;
}

.prediction-subsection {
  margin-top: 1.6rem;
}

/* ---------- ボール ---------- */

.prediction-ball-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.prediction-ball-row--compact {
  gap: 0.3rem;
}

.prediction-ball {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.prediction-ball-row--compact .prediction-ball,
.prediction-ball.is-small {
  width: 30px;
  height: 30px;
  font-size: 0.78rem;
}

.prediction-ball.is-carry {
  border: 2px dashed var(--gold);
}

.prediction-ball.is-hit {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  border-color: var(--gold);
  color: #081019;
}

.prediction-ball.is-miss {
  opacity: 0.45;
}

/* ---------- 予想5口 ---------- */

.prediction-ticket-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.8rem;
}

.prediction-ticket {
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  display: grid;
  gap: 0.85rem;
  min-width: 0;
}

.prediction-ticket-head {
  display: flex;
  gap: 0.7rem;
  align-items: center;
}

.prediction-ticket-head strong {
  display: block;
  font-size: 0.95rem;
}

.prediction-ticket-head span:not(.prediction-ticket-index) {
  display: block;
  margin-top: 0.15rem;
  color: var(--text-secondary);
  font-size: 0.78rem;
}

.prediction-ticket-index {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(245, 197, 66, 0.14);
  border: 1px solid var(--line-strong);
  color: var(--gold);
  font-family: var(--font-mono);
  font-weight: 800;
}

.prediction-ticket-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.prediction-ticket-link {
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
}

.prediction-ticket-link:hover,
.prediction-ticket-link:focus-visible {
  text-decoration: underline;
}

.prediction-ticket-note {
  grid-column: 1 / -1;
  margin-top: 0;
}

.prediction-pattern-chip {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ---------- スコア順位と重み ---------- */

.prediction-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr);
  gap: 1rem;
  align-items: start;
}

.prediction-score-head,
.prediction-score-row {
  display: grid;
  grid-template-columns: 2rem 38px minmax(100px, 1fr) 3.2rem auto;
  gap: 0.7rem;
  align-items: center;
}

.prediction-score-head {
  margin-top: 1rem;
  padding: 0 0 0.4rem;
  border-bottom: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 0.72rem;
}

.prediction-score-list {
  display: grid;
}

.prediction-score-row {
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.prediction-score-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.prediction-score-rank {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  text-align: right;
}

.prediction-score-bar-track {
  position: relative;
  height: 26px;
}

.prediction-score-axis {
  position: absolute;
  left: 50%;
  top: 2px;
  bottom: 2px;
  width: 1px;
  background: rgba(255, 255, 255, 0.18);
}

.prediction-score-bar {
  position: absolute;
  top: 7px;
  height: 12px;
}

.prediction-score-bar.is-positive {
  background: var(--gold);
  border-radius: 0 4px 4px 0;
}

.prediction-score-bar.is-negative {
  background: var(--cyan);
  border-radius: 4px 0 0 4px;
}

.prediction-score-value {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

.prediction-factor-cells {
  display: flex;
  gap: 0.25rem;
}

.prediction-factor-cell {
  min-width: 3.1rem;
  padding: 0.15rem 0.3rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-align: center;
  color: var(--text-secondary);
}

.prediction-factor-cell.is-positive {
  background: rgba(245, 197, 66, 0.16);
  color: var(--text-primary);
}

.prediction-factor-cell.is-negative {
  background: rgba(93, 214, 255, 0.14);
  color: var(--text-primary);
}

.prediction-factor-cell.is-zero {
  color: var(--text-muted);
}

.prediction-weight-list {
  margin-top: 1rem;
  display: grid;
  gap: 1rem;
}

.prediction-weight {
  display: grid;
  gap: 0.35rem;
}

.prediction-weight-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.88rem;
}

.prediction-weight-short {
  margin-left: 0.4rem;
  padding: 0.05rem 0.35rem;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  font-size: 0.7rem;
}

.prediction-weight-head output {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--gold);
}

.prediction-weight input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}

.prediction-weight-desc {
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

.prediction-weight-actions {
  margin-top: 1.2rem;
}

/* ---------- ブロック統計 ---------- */

.prediction-period-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
}

.prediction-select-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 700;
}

.prediction-select {
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font: inherit;
}

.prediction-block-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.7rem;
}

.prediction-block-card {
  padding: 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  min-width: 0;
}

.prediction-block-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.prediction-block-head strong {
  display: block;
}

.prediction-block-head div span {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.prediction-deviation {
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 800;
}

.prediction-block-meta {
  margin: 0.4rem 0 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 0.74rem;
}

.prediction-block-ranking {
  list-style: none;
  display: grid;
  gap: 0.3rem;
}

.prediction-block-ranking li {
  display: grid;
  grid-template-columns: 1.1rem 30px minmax(0, 1fr) 2.2rem;
  gap: 0.4rem;
  align-items: center;
}

.prediction-block-rank {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-align: right;
}

.prediction-mini-track {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.prediction-mini-track span {
  display: block;
  height: 100%;
  border-radius: 0 4px 4px 0;
  background: var(--gold);
}

.prediction-block-count {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-align: right;
}

/* ---------- 表 ---------- */

.prediction-table-scroll {
  margin-top: 0.6rem;
  overflow-x: auto;
}

.prediction-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 2px;
  font-size: 0.82rem;
}

.prediction-table th,
.prediction-table td {
  padding: 0.45rem 0.6rem;
  text-align: right;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.prediction-table thead th {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.74rem;
  font-weight: 700;
}

.prediction-table tbody th {
  text-align: left;
  color: var(--text-primary);
}

.prediction-table td {
  border-radius: 4px;
}

.prediction-table .is-muted {
  color: var(--text-muted);
}

.prediction-heatmap thead th:nth-child(n + 3) {
  text-align: center;
}

.prediction-heatmap td {
  min-width: 4.2rem;
  text-align: center;
  font-weight: 700;
}

.prediction-col-bar {
  width: 40%;
  min-width: 120px;
}

/* ---------- 分布バー（実測バー + 理論目盛り） ---------- */

.prediction-pattern-grid,
.prediction-backtest-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.6rem;
}

.prediction-distribution {
  margin-top: 0.6rem;
  display: grid;
  gap: 0.9rem;
}

.prediction-dist-title {
  margin-bottom: 0.3rem;
  font-size: 0.84rem;
  font-weight: 700;
}

.prediction-dist-title span {
  margin-left: 0.5rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.prediction-dist-row {
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr) 7.5rem;
  gap: 0.6rem;
  align-items: center;
  padding: 0.12rem 0;
}

.prediction-dist-label {
  color: var(--text-secondary);
  font-size: 0.76rem;
}

.prediction-dist-label--wide {
  font-size: 0.8rem;
}

.prediction-distribution > .prediction-dist-row {
  grid-template-columns: 6.5rem minmax(0, 1fr) 4.5rem;
}

.prediction-dist-track {
  position: relative;
  display: block;
  height: 14px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
}

.prediction-dist-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 0 4px 4px 0;
  background: var(--gold);
  opacity: 0.85;
}

.prediction-dist-marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  margin-left: -1px;
  background: var(--text-primary);
  box-shadow: 0 0 0 1px var(--bg-base);
}

.prediction-dist-value {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-align: right;
}

.prediction-dist-value small {
  display: block;
  color: var(--text-muted);
  font-size: 0.68rem;
}

/* ---------- 統計タイル ---------- */

.prediction-stat-row {
  margin-top: 1.4rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.7rem;
}

.prediction-stat strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.45rem;
  color: var(--gold);
}

.prediction-stat-note {
  display: block;
  margin-top: 0.25rem;
  color: var(--text-secondary);
  font-size: 0.76rem;
}

/* ---------- 折れ線 ---------- */

.prediction-line-chart {
  position: relative;
  margin-top: 0.6rem;
}

.prediction-line-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid {
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 1;
}

.chart-axis-label {
  fill: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.chart-reference {
  stroke: var(--text-secondary);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}

.chart-reference-label {
  fill: var(--text-secondary);
  font-size: 11px;
}

.chart-line {
  fill: none;
  stroke: var(--gold);
  stroke-width: 2;
  stroke-linejoin: round;
}

.chart-crosshair {
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 1;
}

.chart-dot {
  fill: var(--gold);
  stroke: var(--bg-base);
  stroke-width: 2;
}

.chart-hit {
  fill: transparent;
  cursor: crosshair;
}

.chart-tooltip {
  position: absolute;
  transform: translate(-50%, calc(-100% - 12px));
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-deep);
  font-size: 0.76rem;
  white-space: nowrap;
  pointer-events: none;
}

.chart-tooltip strong,
.chart-tooltip span {
  display: block;
}

.chart-tooltip span {
  color: var(--text-secondary);
}

/* ---------- 直近の予想と結果 ---------- */

.prediction-recent-list {
  margin-top: 0.6rem;
  display: grid;
  gap: 0.5rem;
}

.prediction-recent-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
}

.prediction-recent-item summary {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: center;
  padding: 0.6rem 0.8rem;
  cursor: pointer;
  list-style: none;
}

.prediction-recent-item summary::-webkit-details-marker {
  display: none;
}

.prediction-recent-no {
  font-weight: 700;
  font-size: 0.86rem;
}

.prediction-recent-no small {
  display: block;
  margin-top: 0.2rem;
  line-height: 1.3;
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.72rem;
}

.prediction-recent-best {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.prediction-recent-tickets {
  display: grid;
  gap: 0.45rem;
  padding: 0.2rem 0.8rem 0.8rem;
}

.prediction-recent-ticket {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr) 3rem;
  gap: 0.6rem;
  align-items: center;
}

.prediction-recent-profile {
  color: var(--text-secondary);
  font-size: 0.78rem;
}

.prediction-recent-hits {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  text-align: right;
}

/* ---------- レスポンシブ ---------- */

@media (max-width: 900px) {
  .prediction-shell .analytics-hero {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1100px) {
  .prediction-columns {
    grid-template-columns: minmax(0, 1fr);
  }

  .prediction-block-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (max-width: 820px) {
  .prediction-pattern-grid,
  .prediction-backtest-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .prediction-score-head,
  .prediction-score-row {
    grid-template-columns: 1.6rem 38px minmax(0, 1fr) 3.2rem;
  }

  .prediction-score-head span:last-child {
    display: none;
  }

  .prediction-factor-cells {
    grid-column: 2 / -1;
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .prediction-shell {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .prediction-panel {
    padding: 1.1rem;
  }

  .prediction-ticket-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .prediction-recent-item summary {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .prediction-recent-item summary .prediction-ball-row {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .prediction-recent-ticket {
    grid-template-columns: minmax(0, 1fr) 3rem;
  }

  .prediction-recent-ticket .prediction-ball-row {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .prediction-dist-row {
    grid-template-columns: 3.4rem minmax(0, 1fr) 6.4rem;
  }

  .prediction-distribution > .prediction-dist-row {
    grid-template-columns: 5.6rem minmax(0, 1fr) 4rem;
  }
}
