/* ===== リセット・ベース ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue-dark: #0a1628;
  --blue-mid:  #0d2244;
  --blue-acc:  #1a6fc4;
  --blue-light: #2d9cdb;
  --teal:      #00b4d8;
  --white:     #ffffff;
  --off-white: #f0f4f8;
  --gray-100:  #e8edf2;
  --gray-300:  #b0bec5;
  --gray-600:  #546e7a;
  --text:      #1a2332;
  --text-muted: #607d8b;
  --gold:      #f4a030;
  --gold-light: #ffd166;
  --green:     #27ae60;
  --red:       #e74c3c;
  --shadow:    0 2px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.15);
  --radius:    12px;
  --radius-sm: 8px;
}

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--off-white);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== レイアウト ===== */
.app {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 16px 64px;
}

/* ===== ヘッダー ===== */
.header {
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue-mid) 60%, #0d3060 100%);
  margin: 0 -16px;
  padding: 32px 24px;
  text-align: center;
  color: var(--white);
  border-bottom: 3px solid var(--teal);
}

.header-inner { max-width: 760px; margin: 0 auto; }

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

.logo-icon { font-size: 2rem; }
.logo-text  { font-size: 1.8rem; font-weight: 700; letter-spacing: 0.02em; }
.header-sub { font-size: 0.9rem; color: var(--teal); opacity: 0.9; }

/* ===== カード ===== */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  margin-top: 20px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--blue-dark);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--gray-100);
}

/* ===== フォーム ===== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
}

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.form-select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--gray-100);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--white);
  cursor: pointer;
  transition: border-color 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23607d8b' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-select:focus {
  outline: none;
  border-color: var(--blue-acc);
}

.search-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--blue-acc), var(--blue-light));
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  letter-spacing: 0.03em;
}

.search-btn:disabled {
  background: var(--gray-300);
  cursor: not-allowed;
}

.search-btn:not(:disabled):hover { opacity: 0.9; }
.search-btn:not(:disabled):active { transform: scale(0.99); }

/* ===== 結果 ===== */
.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--gray-100);
}

.result-header .card-title { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }

.result-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--gray-100);
  padding: 4px 12px;
  border-radius: 20px;
}

.warning {
  background: #fff8e1;
  border-left: 4px solid var(--gold);
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #7a6000;
  margin-bottom: 16px;
}

.table-wrap {
  overflow-x: auto;
  margin: 0 -4px;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.result-table th {
  background: var(--blue-dark);
  color: var(--white);
  padding: 10px 12px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.th-rank  { width: 48px; text-align: center; }
.th-combo { min-width: 90px; }
.th-count { width: 60px; text-align: right; }
.th-prob  { width: 70px; text-align: right; }
.th-pay   { width: 90px; text-align: right; }
.th-ev    { width: 90px; text-align: right; }

.th-note {
  display: block;
  font-size: 0.65rem;
  font-weight: 400;
  opacity: 0.75;
  letter-spacing: 0;
}

.result-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
}

.result-table tr:hover td { background: #f7fafc; }
.result-table tr:last-child td { border-bottom: none; }

/* ランク別色分け */
.result-table tr.rank-1 td { background: #fffde7; }
.result-table tr.rank-2 td { background: #f3f9ff; }
.result-table tr.rank-3 td { background: #f5fff5; }
.result-table tr.rank-1:hover td { background: #fff9c4; }
.result-table tr.rank-2:hover td { background: #e8f4fd; }
.result-table tr.rank-3:hover td { background: #eafbea; }

.td-rank {
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.rank-medal-1 { color: var(--gold); }
.rank-medal-2 { color: var(--gray-600); }
.rank-medal-3 { color: #cd7f32; }

.td-combo {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-weight: 700;
  font-size: 1rem;
  color: var(--blue-dark);
}

.td-right { text-align: right; }

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

.bar {
  width: 60px;
  height: 6px;
  background: var(--gray-100);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-acc), var(--teal));
  border-radius: 3px;
}

.ev-positive { color: var(--green); font-weight: 700; }
.ev-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-100);
}

/* ===== 情報カード ===== */
.info-list {
  list-style: none;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-list li {
  counter-increment: step;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.95rem;
}

.info-list li::before {
  content: counter(step);
  min-width: 28px;
  height: 28px;
  background: var(--blue-acc);
  color: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.info-disclaimer {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ===== 決まり手カード ===== */
.kimarite-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 480px) { .kimarite-grid { grid-template-columns: 1fr; } }

.kimarite-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
}

.ki-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--blue-dark);
}

.ki-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ===== フッター ===== */
.footer {
  text-align: center;
  padding: 32px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-small { font-size: 0.72rem; margin-top: 4px; }

/* ===== タブナビ ===== */
.tab-nav {
  display: flex;
  gap: 4px;
  margin-top: 16px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  min-width: 120px;
  padding: 10px 16px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--blue-dark);
  color: var(--white);
}

.tab-btn:not(.active):hover {
  background: var(--gray-100);
  color: var(--text);
}

/* ===== チャート ===== */
.chart-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.chart-wrap {
  position: relative;
  max-height: 320px;
}

.chart-wrap-tall {
  max-height: 560px;
}

.venue-detail-table { overflow-x: auto; }

/* ===== ヒートマップ ===== */
.heatmap-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.heatmap-table th {
  background: var(--blue-dark);
  color: var(--white);
  padding: 8px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  text-align: center;
}

.heatmap-boat {
  padding: 8px 10px;
  white-space: nowrap;
  border-bottom: 1px solid var(--gray-100);
  font-weight: 700;
}

.heatmap-cell {
  padding: 8px 10px;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.3);
  cursor: default;
  transition: opacity 0.15s;
  min-width: 80px;
}

.heatmap-cell:hover { opacity: 0.8; }

.hm-pay {
  display: block;
  font-weight: 700;
  font-size: 0.82rem;
}

.hm-rate {
  display: block;
  font-size: 0.7rem;
  opacity: 0.8;
  margin-top: 2px;
}

.boat-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--white);
}
.boat-1 { background: #1565c0; }
.boat-2 { background: #b71c1c; }
.boat-3 { background: #e65100; }
.boat-4 { background: #555; }
.boat-5 { background: #1b5e20; }
.boat-6 { background: #4a148c; }

/* ===== 決まり手EVテーブル ===== */
.kimarite-ev-table { margin-top: 8px; overflow-x: auto; }

/* ===== 分析タブ 会場フィルター ===== */
.venue-filter-card {
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue-mid) 100%);
  border: none;
}
.venue-filter-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.venue-filter-row .form-label {
  color: var(--teal);
  white-space: nowrap;
  flex-shrink: 0;
}
.venue-filter-select {
  flex: 1;
  min-width: 140px;
  max-width: 240px;
  background-color: rgba(255,255,255,0.12);
  color: var(--white);
  border-color: rgba(255,255,255,0.25);
}
.venue-filter-select option {
  background: var(--blue-dark);
  color: var(--white);
}
.venue-filter-hint {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.55);
}

/* ===== 分析タブ カードヘッダー + コントロール ===== */
.card-ctrl-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--gray-100);
}
.card-ctrl-row .card-title {
  flex: 1;
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.ctrl-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.ctrl-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}
.ctrl-select {
  padding: 6px 28px 6px 10px;
  border: 2px solid var(--gray-100);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--off-white);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23607d8b' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color 0.2s;
}
.ctrl-select:focus {
  outline: none;
  border-color: var(--blue-acc);
}

/* ===== ユーティリティ ===== */
.hidden { display: none !important; }

/* ===== 公式サイトバー（ヘッダー直下） ===== */
.official-bar {
  background: var(--white);
  border-bottom: 3px solid var(--teal);
  padding: 10px 16px;
  text-align: center;
  margin: 0 -16px;
}
.official-bar-link {
  display: inline-block;
  color: var(--blue-acc);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.01em;
}
.official-bar-link:hover { text-decoration: underline; }

/* ===== チェックボックス列 ===== */
.th-sel { width: 36px; text-align: center; padding: 10px 6px !important; }
.td-sel { text-align: center; padding: 8px 6px !important; }
.bet-checkbox { width: 16px; height: 16px; cursor: pointer; accent-color: var(--blue-acc); }

/* ===== シミュレーターカード ===== */
.simulator-card { border: 2px solid var(--blue-acc); }

.sim-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--gray-100);
}
.sim-header-row .card-title { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }

.sim-disclaimer {
  background: #fff8e1;
  border-left: 4px solid var(--gold);
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: #7a6000;
}

.sim-clear-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  background: transparent;
  border: 2px solid var(--gray-300);
  border-radius: 20px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.sim-clear-btn:hover { border-color: var(--red); color: var(--red); }

.sim-amount-input {
  width: 76px;
  padding: 4px 6px;
  border: 2px solid var(--gray-100);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  text-align: right;
  color: var(--text);
}
.sim-amount-input:focus { outline: none; border-color: var(--blue-acc); }

.sim-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 20px;
}
@media (max-width: 580px) { .sim-stats { grid-template-columns: 1fr 1fr; } }

.sim-stat-item {
  background: var(--off-white);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
}

.sim-stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  line-height: 1.4;
}

.sim-stat-note {
  display: block;
  font-size: 0.62rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  margin-top: 2px;
}

.sim-stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--blue-dark);
}
.sim-positive { color: var(--green) !important; }
.sim-negative { color: var(--red) !important; }

/* ===== フォーメーション参考 ===== */
.sim-formation {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.sim-formation-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: 12px;
}
.sim-formation-rows { display: flex; flex-direction: column; gap: 8px; }
.sim-formation-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sim-formation-pos {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-sub);
  width: 2.2rem;
  flex-shrink: 0;
}
.sim-formation-arrow {
  color: var(--text-muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}
.sim-formation-cnt {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-sub);
  white-space: nowrap;
}
.sim-formation-count {
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}
.sim-formation-note {
  margin-top: 8px;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ===== テレボートリンク ===== */
.sim-teleboat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-100);
  flex-wrap: wrap;
}

.teleboat-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.teleboat-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  background: linear-gradient(135deg, #005bac, #0082c8);
  color: var(--white);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.02em;
  transition: opacity 0.2s;
}
.teleboat-btn:hover { opacity: 0.85; }
.teleboat-btn-sp {
  background: linear-gradient(135deg, #1a7a4a, #22a860);
}

.teleboat-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex: 1;
  min-width: 120px;
}

/* ===== 著者・サイト説明 ===== */
.about-body p {
  margin: 0 0 14px;
  line-height: 1.8;
  font-size: 0.95rem;
  color: var(--text);
}
.about-body p:last-child { margin-bottom: 0; }
.about-body a { color: var(--blue-acc); }
.about-author {
  font-size: 0.85rem !important;
  color: var(--text-muted) !important;
  padding-top: 12px;
  border-top: 1px solid var(--gray-100);
  margin-top: 4px;
}
