*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* モバイルのプルトゥリフレッシュを無効化 */
html { overscroll-behavior-y: none; }

/* ── Design tokens ── */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --border: #e5e5e5;
  --text: #111111;
  --muted: #888888;
  --accent: #5b8def;        /* 比較機能のアクセント色（相手・共通） */
  --accent-strong: #3b6fdf; /* アクセント色の濃いバリエーション（強調数値・ラベル） */
  --brand: #2c3e50;         /* ブランドカラー（ヘッダー・地図ホバー） */
  --danger: #d93025;        /* エラー・削除・日曜の赤 */
  --radius: 12px;
  --tab-h: 64px;    /* モバイル下部タブバーの高さ */
  --header-h: 52px; /* ヘッダーの高さ */
  --filter-h: 44px; /* 年フィルターバーの高さ */
  --search-h: 52px; /* イベント検索バーの高さ */
}

* { -webkit-tap-highlight-color: transparent; }
body {
  font-family: 'Noto Sans JP', 'Hiragino Sans', -apple-system, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  /* タブバー分の余白（PCでは上書きして0にする） */
  padding-bottom: var(--tab-h);
}

/* ── Header ── */
header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--brand);
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  transition: transform 0.25s ease;
}
/* モバイルで下スクロール時にヘッダーを隠す */
header.hidden {
  transform: translateY(-100%);
}
header h1 { font-size: 0.88rem; font-weight: 700; letter-spacing: -0.02em; flex: 1; color: #fff; display: flex; align-items: center; gap: 9px; cursor: default; line-height: 1.2; }
header h1.clickable { cursor: pointer; }
.logo-icon { flex-shrink: 0; align-self: center; }

/* ヘッダー右側のユーザーバッジ（ログイン後に表示） */
#headerUser {
  display: none;
  align-items: center;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 20px;
  padding: 4px 10px 4px 4px;
  cursor: pointer;
  transition: background 0.15s;
  max-width: 160px;
}
#headerVersion {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.75);
  font-weight: 600;
  flex-shrink: 0;
  cursor: pointer;
  background: rgba(255,255,255,0.15);
  border-radius: 999px;
  padding: 2px 8px;
  letter-spacing: 0.03em;
}
#headerUser.visible { display: flex; }
#headerUser:active { background: rgba(255,255,255,0.25); }
#headerAvatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 7px;
}
#headerUserId {
  font-size: 0.8rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
}
#headerChevron {
  margin-left: 4px;
  color: rgba(255,255,255,0.7);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

/* ── Year filter bar (モバイル・タブレット用) ── */
/* PCでは #filterBar を非表示にし、代わりに #yearPanel サイドバーを使う */
#filterBar {
  display: none;
  position: sticky;
  top: var(--header-h);
  z-index: 19;
  transition: transform 0.25s ease;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--filter-h);
  align-items: stretch;
}
#filterBar.visible { display: flex; }
#filterChips {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
}
#filterChips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.chip.active {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}
/* 年チップが多い場合に表示するプルダウン */
#filterBarMore {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  border-left: 1px solid var(--border);
  padding: 0 8px 0 12px;
  position: relative;
}
#filterBarMoreSelect {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  padding: 0 20px 0 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
}
#filterBarMoreSelect.active { color: var(--text); font-weight: 700; }

/* ── Pages ── */
/* .page はデフォルト非表示、.active クラスで表示 */
.page { display: none; }
.page.active { display: block; }

/* ── Search page（トップ・ユーザーID入力画面）── */
#page-search {
  max-width: 480px;
  margin: 0 auto;
  padding: 36px 20px 32px;
}
#page-search .headline {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
#page-search .sub {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 32px;
}
.feature-list-section {
  margin: 28px 0 20px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #f0f6ff;
  border: 1px solid #cfe0ff;
  color: #2f5aa8;
  font-size: 0.8rem;
  line-height: 1.6;
}
.feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.feature-list li {
  color: inherit;
}
.feature-list li::before {
  content: "・";
}
.id-hint {
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.6;
}
.id-hint strong {
  color: var(--text);
  font-weight: 600;
}
.input-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.input-row { display: flex; gap: 8px; }
input[type="text"] {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 16px; /* iOS でズームしないよう 16px 以上にする */
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
input[type="text"]:focus { border-color: var(--text); }
#analyzeBtn {
  padding: 12px 20px;
  background: var(--text);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}
#analyzeBtn:active { opacity: 0.7; }
#analyzeBtn:disabled { opacity: 0.35; cursor: not-allowed; }
#status { margin-top: 10px; font-size: 0.85rem; color: var(--muted); min-height: 18px; }
#status.error { color: var(--danger); }
.page-search-credit {
  margin-top: 28px;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}
.page-search-credit a { color: inherit; }

/* ── History（検索履歴）── */
.notice {
  margin-top: 24px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  line-height: 1.6;
}
.notice-warn {
  background: #fffbe6;
  border: 1px solid #ffe58f;
  color: #7c6000;
}
.notice-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  margin-bottom: 6px;
}
.notice-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.notice-list li::before {
  content: "・";
}
#historySection { margin-top: 28px; display: none; }
#historySection .section-title { margin-bottom: 12px; font-size: 0.95rem; color: var(--text); text-transform: none; letter-spacing: 0; }
.feature-list-section .section-title { margin-bottom: 6px; font-size: 0.8rem; font-weight: 600; color: inherit; text-transform: none; letter-spacing: 0; }
.feature-list-header { display: flex; align-items: center; gap: 6px; }
.history-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 12px;
  padding: 0 2px;
}
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.history-load {
  flex: 1;
  padding: 12px 14px;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}
.history-load:active { background: var(--bg); }
.history-action {
  padding: 12px 14px;
  background: none;
  border: none;
  border-left: 1px solid var(--border);
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
}
.history-action:active { color: var(--text); }
.history-action.delete:active { color: var(--danger); }
.history-userid { display: block; }
.history-ts {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 400;
  margin-top: 2px;
}

/* ── Spinner（データ取得中）── */
/* 画面全体を覆う固定オーバーレイ */
#spinner {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(245,245,247,0.8);
  z-index: 100;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  color: var(--muted);
  font-size: 0.85rem;
}
#spinner.visible { display: flex; }
/* スクロール禁止（スピナー表示中に body に付与） */
body.no-scroll { overflow: hidden; }
.spinner-ring {
  width: 28px; height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* データ取得の進捗バー（総ページ数が判明してから表示） */
#spinnerProgress {
  display: none;
  width: 180px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
#spinnerProgress.visible { display: block; }
#spinnerProgressBar {
  width: 0;
  height: 100%;
  background: var(--text);
  border-radius: 2px;
  transition: width 0.2s ease;
}

#compareTabBar {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin: 16px 0 0;
}
.compare-tab-btn {
  flex: 1;
  padding: 10px 4px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.compare-tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--text);
}
.compare-tab-panel { padding-top: 12px; }
.rank-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.compare-rank-legend {
  display: flex;
  gap: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.compare-rank-legend-self { color: var(--text); }
.compare-rank-legend-other { color: var(--accent); }

/* ── Compare page ── */

.compare-reset-btn {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  color: #6b7280;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
}
.compare-reset-btn:active { opacity: 0.7; }
#compareSelectWrap .section-title { margin-bottom: 12px; }
#compareUserList { display: flex; flex-direction: column; gap: 8px; }
.compare-user-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s;
}
.compare-user-btn:active { border-color: var(--text); }
.compare-user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.compare-user-avatar.secondary { background: var(--accent); }
.compare-user-info { flex: 1; min-width: 0; }
.compare-user-id { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.compare-user-ts { font-size: 0.75rem; color: var(--muted); }
/* ヘッダー（A vs B） */
#compareHeader {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.compare-user-badge {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.compare-user-badge.secondary { text-align: right; color: var(--accent); }
.compare-vs { font-size: 0.75rem; font-weight: 700; color: var(--muted); flex-shrink: 0; }
/* サマリー数値 */
.compare-summary-row {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.compare-summary-box {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
}
.compare-summary-box.center { background: #f0f4ff; border-color: #c7d7f9; }
.compare-summary-num { font-size: 1.4rem; font-weight: 800; }
.compare-summary-num.accent { color: var(--accent-strong); }
.compare-summary-label { font-size: 0.7rem; color: var(--muted); margin-top: 2px; }
/* 共通バッジ（イベント一覧） */

/* ── Section title ── */
.section-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 10px;
  padding: 0 2px;
}

/* ── Shared card base ── */
.card, .top-card, .chart-box, .rank-list, .event-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ── Summary cards（ホーム画面上部の3枚）── */
.cards {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}
.card {
  padding: 16px;
  cursor: pointer;
}
.card:active { background: var(--bg); }
.card .num {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}
.card .lbl { font-size: 0.72rem; color: var(--muted); margin-bottom: 5px; }

/* ── Top cards（ホーム画面のトップ会場・出演者）── */
.home-top-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 24px;
}
.top-card {
  padding: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}
.top-card:active { background: var(--bg); }
.top-card-label {
  font-size: 0.72rem;
  color: var(--muted);
}
.top-card-bottom {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}
.top-card-name {
  font-size: 0.95rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 0;
  min-width: 0;
}
.top-card-count {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  flex: 0 0 auto;
}
.top-card-unit {
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: 2px;
}

/* ── Chart box ── */
.chart-box {
  padding: 18px;
  margin-bottom: 12px;
}
.chart-wrap { position: relative; height: 220px; }

/* ── Japan map ── */
#prefMapSection { margin-top: 24px; }
#prefMapExpandBtn {
  position: absolute;
  bottom: 8px; right: 8px;
  width: 36px; height: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 11;
  color: var(--muted);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
#prefMapExpandBtn:hover { color: var(--text); background: var(--bg); }
#prefMapModal {
  display: none;
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 200;
  flex-direction: column;
  touch-action: none;
}
#prefMapModal.open { display: flex; }
#prefMapModalSvgWrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#prefMapModalSvgWrap svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  transform-origin: 0 0;
  cursor: grab;
}
#prefMapModalSvgWrap svg.dragging { cursor: grabbing; }
#prefMapModalClose {
  position: absolute;
  top: 12px; right: 12px;
  width: 36px; height: 36px;
  background: #111;
  border: 1px solid #333;
  border-radius: var(--radius);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 201;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
#prefMapModalClose:hover { color: #fff; background: #333; }
#prefMapOverlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(2px);
  border-radius: var(--radius);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--muted);
  z-index: 10;
}
#prefMapOverlay.visible { display: flex; }
#prefMapOverlay.no-spinner .pref-overlay-ring { display: none; }
.pref-overlay-ring {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--muted);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
#prefMapSvgWrap {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}
#prefMapSvgWrap svg { width: 100%; height: auto; display: block; background: #fff; border-radius: 8px; }
.pref-path {
  fill: #fff;
  cursor: default;
}
.pref-path polygon, .pref-path path {
  stroke: #111;
  stroke-width: 0.37;
}
.pref-path:hover polygon, .pref-path:hover path {
  fill: var(--brand) !important;
}
#prefTooltip {
  position: fixed;
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 9999;
  display: none;
}
#prefTooltip.touch-mode {
  pointer-events: auto;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
#prefTooltipBtn {
  background: #fff;
  color: #222;
  border: none;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
}

/* ── Rank list（会場・出演者ランキング）── */
.rank-list {
  overflow: hidden;
  margin-bottom: 12px;
}
.rank-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  cursor: pointer;
}
.rank-item:last-child { border-bottom: none; }
.rank-item:active { background: var(--bg); }
.rank-no {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.rank-no.top { color: var(--text); }
.rank-name { flex: 1; font-size: 0.9rem; font-weight: 500; min-width: 0; }
.rank-name span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-bar-wrap { width: 64px; flex-shrink: 0; display: flex; flex-direction: column; gap: 3px; justify-content: center; }
.rank-bar-bg { height: 4px; background: var(--bg); border-radius: 2px; }
.rank-bar { height: 4px; background: var(--text); border-radius: 2px; }
.rank-bar-compare-bg { height: 4px; background: var(--bg); border-radius: 2px; }
.rank-bar-compare { height: 4px; background: var(--accent); border-radius: 2px; }
.rank-count { font-size: 0.85rem; font-weight: 700; flex-shrink: 0; width: 32px; text-align: right; display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.rank-count-compare { font-size: 0.75rem; font-weight: 700; color: var(--accent); }

/* ── Empty state ── */
.empty {
  padding: 40px 16px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ── Event search bar（イベントタブ上部の検索欄）── */
/* モバイル: fixed で画面上部に固定、ヘッダー非表示時はスライドアップ */
/* PC:      sticky で main スクロールコンテナ内の先頭に追従 */
#eventSearchBarWrap {
  position: fixed;
  top: calc(var(--header-h) + var(--filter-h));
  left: 0; right: 0;
  z-index: 18;
  background: var(--bg);
  padding: 6px 12px;
  transition: transform 0.25s ease;
}
#page-events .page-content {
  /* fixed な検索バーの高さ分だけコンテンツを下げる */
  padding-top: calc(var(--search-h) + 18px);
}
#eventSearchBar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: var(--search-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}
#eventSearchBar svg { pointer-events: none; flex-shrink: 0; }
#eventSearchBar input[type="text"] {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: none;
  background: none;
  outline: none;
  font-size: 16px;
  line-height: normal;
  color: var(--text);
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
}
#eventSearchBar input::placeholder { color: var(--muted); }
#eventSearchClear {
  visibility: hidden;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
#eventSearchClear.visible { visibility: visible; }

/* ── Event list（イベント一覧）── */
.event-list {
  overflow: hidden;
  margin-bottom: 12px;
}
.event-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  cursor: pointer;
  position: relative;
}
.event-item.together::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}
.event-item:last-child { border-bottom: none; }
.event-date {
  flex-shrink: 0;
  text-align: center;
  width: 48px;
}
.event-date .year     { font-size: 0.62rem; color: var(--muted); letter-spacing: 0.02em; }
.event-date .month-day {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.event-date .weekday {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  color: #fff;
  background: var(--text);
  border-radius: 4px;
  padding: 1px 5px;
  margin-top: 3px;
}
.event-date .weekday.sat { background: #2d7dd2; }
.event-date .weekday.sun { background: var(--danger); }
.event-info { flex: 1; min-width: 0; }
.event-name, .event-venue, .event-cast { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-name  { font-size: 0.88rem; font-weight: 600; }
.event-venue { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.event-cast  { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }

#eventCount { display: flex; align-items: center; }
#eventCountNum { margin-left: auto; }
#eventCountBadge {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-strong);
  text-transform: none;
  letter-spacing: 0;
  font-family: inherit;
}
#eventCountBadge::before {
  content: '';
  display: block;
  width: 3px;
  height: 1.5em;
  background: var(--accent);
  flex-shrink: 0;
  align-self: center;
  margin-top: 2px;
}

/* ── Page content padding ── */
.page-content {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 0px;
}

/* ── Changelog modal ── */
#changelogOverlay {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
  visibility: hidden;
  transition: background 0.3s, visibility 0s 0.3s;
}
#changelogOverlay.open {
  visibility: visible;
  background: rgba(0,0,0,0.4);
  transition: background 0.3s;
}
#changelogSheet {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32,0.72,0,1);
}
#changelogOverlay.open #changelogSheet {
  transform: translateY(0);
}
.changelog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.changelog-title { font-size: 1rem; font-weight: 700; }
.changelog-close {
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
}
.changelog-body {
  overflow-y: auto;
  padding: 16px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Share（まとめ画像）── */
.home-actions {
  display: flex;
  justify-content: center;
  margin-top: -12px;   /* 上のトップ出演者カードとの間隔を詰める */
  margin-bottom: 12px;
}
#shareBtn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}
#shareBtn:active { background: var(--bg); }
#shareBtn svg { color: var(--accent-strong); flex-shrink: 0; }

#eventShareWrap {
  display: flex;
  justify-content: center;
  margin-bottom: -15px;
}
#eventShareBtn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
#eventShareBtn svg { color: var(--accent-strong); flex-shrink: 0; }
#eventShareBtn:focus { outline: none; }
#eventShareBtn:active { background: var(--bg); }
#eventShareBtn:disabled { opacity: 0.35; cursor: not-allowed; }
#shareOverlay, #shareSettingsOverlay {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
  visibility: hidden;
  transition: background 0.3s, visibility 0s 0.3s;
}
#shareOverlay.open, #shareSettingsOverlay.open {
  visibility: visible;
  background: rgba(0,0,0,0.4);
  transition: background 0.3s;
}
#shareSheet, #shareSettingsSheet {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32,0.72,0,1);
}
#shareOverlay.open #shareSheet,
#shareSettingsOverlay.open #shareSettingsSheet { transform: translateY(0); }
.share-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.share-title { font-size: 1rem; font-weight: 700; }
.share-close {
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
}
.share-preview {
  overflow-y: auto;
  padding: 16px 20px;
  text-align: center;
}
.share-preview img {
  width: 100%;
  max-width: 320px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.share-actions {
  display: flex;
  gap: 10px;
  padding: 16px 20px 24px;
}
.share-action {
  flex: 1;
  text-align: center;
  padding: 13px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.share-action.primary {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}
.share-action:active { opacity: 0.7; }

/* 共有設定モーダルはシェアモーダルの上に重ねる */
#shareSettingsOverlay { z-index: 210; }
.share-settings-body {
  padding: 16px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.share-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.share-field-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.share-field-label b { color: var(--brand); }
.share-field input[type="text"] {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.share-field input[type="text"]:focus { border-color: var(--text); }
.share-field input[type="range"] {
  width: 100%;
  accent-color: var(--brand);
}
.changelog-version {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.changelog-date {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
  margin-left: 8px;
}
.changelog-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.changelog-items li {
  font-size: 0.85rem;
  color: var(--text);
  padding-left: 1em;
  position: relative;
}
.changelog-items li::before {
  content: '・';
  position: absolute;
  left: 0;
}
.changelog-items ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  padding-left: 0.5em;
}
.changelog-items ul li::before { content: '- '; }

/* ── Modal（イベント詳細シート）── */
/* モバイル: 画面下部からスライドアップ */
/* PC:      画面右端からスライドイン（PC セクション参照） */
#modalOverlay {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
  visibility: hidden;
  transition: background 0.3s, visibility 0s 0.3s;
}
#modalOverlay.open {
  visibility: visible;
  background: rgba(0,0,0,0.4);
  transition: background 0.3s;
}
#modalSheet {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  padding: 0 0 calc(env(safe-area-inset-bottom, 0px) + 24px);
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32,0.72,0,1);
}
#modalOverlay.open #modalSheet { transform: translateY(0); }
.modal-body { padding: 24px 20px 0; }
.modal-title {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
  line-height: 1.4;
  color: var(--text);
  text-decoration: none;
}
/* URLがある場合はリンクとして表示（下線で示す） */
a.modal-title { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--text); }
a.modal-title:hover { opacity: 0.7; }
a.modal-title:active { opacity: 0.6; }
.modal-title-icon { flex-shrink: 0; margin-top: 3px; color: var(--muted); }
.modal-row {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  align-items: flex-start;
}
.modal-row-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  width: 52px;
  flex-shrink: 0;
  line-height: 1.5;
}
.modal-row-value {
  font-size: 0.88rem;
  flex: 1;
  line-height: 1.5;
}
/* 会場・出演者などのタップでイベント検索に飛ぶリンク */
.modal-link {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border);
  cursor: pointer;
}
.modal-link:active { opacity: 0.5; }

/* ── Bottom tab bar（モバイル用）── */
.tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--tab-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab-btn {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 500;
  padding: 0;
  transition: color 0.15s;
}
.tab-btn svg { width: 22px; height: 22px; }
.tab-btn.active { color: var(--text); }
.tab-btn.active::before {
  content: '';
  position: absolute;
  top: 6px; bottom: 6px; left: 8px; right: 8px;
  background: rgba(0,0,0,0.04);
  border-radius: 9999px;
  z-index: -1;
}
.tab-btn.active svg { stroke-width: 2.2; }
.tab-btn.comparing { color: var(--accent-strong); }
/* データ未取得中はタブ操作を無効化 */
.tab-bar.locked .tab-btn { opacity: 0.3; pointer-events: none; }

/* PCでは yearPanel を表示するため、モバイルではデフォルト非表示 */
#yearPanel { display: none; }
.hint-icon { vertical-align: middle; }

/* ── PC layout (1024px+) ── */
/* グリッドレイアウト: ヘッダー / 左サイドバー(タブ) / 年パネル / メインコンテンツ */
@media (min-width: 1024px) {
  :root { --header-h: 64px; }

  body {
    padding-bottom: 0;
    display: grid;
    grid-template-rows: var(--header-h) 1fr;
    grid-template-columns: 220px 140px 1fr;
    grid-template-areas:
      "header  header     header"
      "sidebar yearpanel  main";
    height: 100dvh; /* dvh: ブラウザUIの出し入れに追従する動的ビューポート高さ */
    overflow: hidden;
  }

  header {
    grid-area: header;
    height: var(--header-h);
    padding: 0 24px;
    transition: none; /* PCではヘッダー非表示アニメーション不要 */
  }
  header.hidden { transform: none; }
  header h1 { font-size: 1.05rem; }

  /* PCでは年フィルターバーを非表示（代わりに #yearPanel を使う） */
  #filterBar { display: none !important; }

  /* PCでは検索バーを sticky にして main コンテナ内の先頭に固定 */
  #eventSearchBarWrap {
    position: sticky;
    top: 0;
    padding: 16px 0;
    background: var(--bg);
    transition: none;
    left: auto; right: auto;
    z-index: 10;
  }
  #page-events .page-content {
    padding-top: 0; /* sticky のため fixed 分の余白は不要 */
  }

  main {
    grid-area: main;
    overflow-y: auto;
    min-height: 0; /* グリッド子要素で overflow-y を効かせるために必要 */
    min-width: 0;
    /* scrollbar-gutter: stable でスクロールバーの有無によるレイアウトずれを防ぐ */
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent; /* 通常時は透明 */
  }
  main:hover {
    scrollbar-color: rgba(0,0,0,0.2) transparent; /* ホバー時に薄く表示 */
  }
  main::-webkit-scrollbar { width: 6px; }
  main::-webkit-scrollbar-track { background: transparent; }
  main::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
  main:hover::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); }

  #page-search {
    max-width: 720px;
    padding: 48px 32px 32px;
  }
  .page-content {
    max-width: 720px;
    padding: 24px;
  }
  .chart-wrap { height: 360px; }

  /* 年フィルターサイドバー（#filterBar の PC 代替）*/
  #yearPanel {
    grid-area: yearpanel;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 12px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    scrollbar-width: none;
    min-height: 0;
  }
  #yearPanel::-webkit-scrollbar { display: none; }
  .year-btn {
    flex-shrink: 0;
    padding: 8px 12px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
  }
  .year-btn:disabled { opacity: 0.35; cursor: default; }
  .year-btn:hover { background: var(--bg); }
  .year-btn.active {
    background: var(--text);
    color: #fff;
  }

  /* タブバーを左サイドバーとして縦並びに変換 */
  .tab-bar {
    grid-area: sidebar;
    position: static;
    flex-direction: column;
    height: 100%;
    width: 220px;
    border-top: none;
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    align-items: stretch;
    gap: 2px;
  }
  .tab-btn {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
  }
  .tab-btn svg { width: 20px; height: 20px; flex-shrink: 0; }
  .tab-btn.active { background: var(--bg); color: var(--text); }
  .tab-btn.active::before { display: none; }
  .tab-btn.active svg { stroke-width: 2.2; }

  .tab-btn.comparing { color: var(--accent-strong); }
  .tab-bar.locked .tab-btn { opacity: 0.3; pointer-events: none; }

  .cards { grid-template-columns: 1fr 1fr 1fr; }

  /* PC ではモーダルを右端からスライドインするパネルとして表示 */
  #modalOverlay {
    position: fixed;
    inset: 0;
    align-items: stretch;
    justify-content: flex-end;
    padding: 0;
  }
  #modalSheet {
    border-radius: 0;
    width: 420px;
    max-width: 50vw;
    max-height: 100vh;
    transform: translateX(100%) translateY(0);
  }
  #modalOverlay.open #modalSheet {
    transform: translateX(0) translateY(0);
  }

  /* PC では changelog も右端からスライドイン */
  #changelogOverlay {
    align-items: stretch;
    justify-content: flex-end;
    padding: 0;
  }
  #changelogSheet {
    border-radius: 0;
    width: 360px;
    max-width: 50vw;
    max-height: 100vh;
    transform: translateX(100%) translateY(0);
  }
  #changelogOverlay.open #changelogSheet {
    transform: translateX(0) translateY(0);
  }

  /* PC では画像シェアモーダルも右端からスライドイン */
  #shareOverlay {
    align-items: stretch;
    justify-content: flex-end;
    padding: 0;
  }
  #shareSheet {
    border-radius: 0;
    width: 480px;
    max-width: 50vw;
    max-height: 100vh;
    transform: translateX(100%) translateY(0);
  }
  #shareOverlay.open #shareSheet {
    transform: translateX(0) translateY(0);
  }

  /* PC では共有設定モーダルも右端からスライドイン */
  #shareSettingsOverlay {
    align-items: stretch;
    justify-content: flex-end;
    padding: 0;
  }
  #shareSettingsSheet {
    border-radius: 0;
    width: 480px;
    max-width: 50vw;
    max-height: 100vh;
    transform: translateX(100%) translateY(0);
  }
  #shareSettingsOverlay.open #shareSettingsSheet {
    transform: translateX(0) translateY(0);
  }
}
