:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242736;
  --border: #2e3248;
  --accent: #4f6ef7;
  --accent-hover: #6b85f9;
  --danger: #e05252;
  --text: #e8eaf0;
  --text-muted: #7a80a0;
  --tag-hit: #2d6a4f;
  --tag-hr: #c94444;
  --tag-bb: #2d5d8a;
  --tag-k: #7a3c3c;
  --tag-out: #4a4060;
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard', 'Noto Sans KR', system-ui, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

#app { max-width: 1280px; margin: 0 auto; padding: 0 16px 80px; }

/* Pages */
.page { display: none; }
.page.active { display: block; }

/* Header */
.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.app-header h1 { font-size: 20px; font-weight: 700; flex: 1; }

/* Buttons */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
}
.btn-danger:hover { background: rgba(224,82,82,0.1); }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}
.btn-icon:hover { color: var(--text); }

.btn-sm { font-size: 12px; padding: 5px 10px; }

/* Banner */
.banner {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.hidden { display: none !important; }

/* Main tabs */
.main-tabs {
  display: flex;
  gap: 4px;
  margin-top: 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
}

/* Video 페이지 상단 고정 영역 (앱 헤더 + 연도 탭) */
.video-sticky-header {
  position: sticky;
  top: var(--main-tabs-height, 0px);
  z-index: 25;
  background: var(--bg);
}

/* 기록 보기 상단 고정 영역 (앱 헤더 + 타자/투수 탭 + 필터) */
.records-sticky-header {
  position: sticky;
  top: var(--main-tabs-height, 0px);
  z-index: 25;
  background: var(--bg);
}

/* 경기 상세(영상 목록) 상단 고정 영역 (뒤로가기 + 대진팀/날짜/장소) */
.game-sticky-header {
  position: sticky;
  top: var(--main-tabs-height, 0px);
  z-index: 25;
  background: var(--bg);
}
.main-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
  padding: 14px 20px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.main-tab:hover { color: var(--text); }
.main-tab.active { color: var(--text); border-bottom-color: var(--accent); }

.main-tab-panel { display: none; }
.main-tab-panel.active { display: block; }

/* Records */
.player-team-abbr {
  font-weight: 800;
  -webkit-text-stroke: 0.3px #fff;
  text-shadow: -0.5px -0.5px 0 #fff, 0.5px -0.5px 0 #fff, -0.5px 0.5px 0 #fff, 0.5px 0.5px 0 #fff;
}
.player-team-sep { color: var(--text-muted); font-weight: 400; }
.team-cell-sep { color: var(--text-muted); font-weight: 400; margin: 0 2px; font-size: 11px; }

/* Records: 타자/투수 세부 탭 */
.record-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.record-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.record-tab:hover { color: var(--text); }
.record-tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* Records: 필터 섹션 (연도 등, 추후 확장 예정) */
.record-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.record-filter-label {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.filter-pill-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.filter-pill {
  padding: 4px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}
.filter-pill:hover { color: var(--text); }
.filter-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Records: 선수 스탯 표 */
.stats-table-wrap {
  overflow: auto;
  max-width: 100%;
  /* 가로 스크롤(overflow-x)이 있으면 overflow-y도 강제로 스크롤 컨테이너가 되므로
     (visible로 두어도 스펙상 auto로 취급됨), thead의 sticky가 실제로 이 래퍼 내부에서
     동작하도록 세로 스크롤도 이 래퍼 안에서 일어나게 높이를 제한한다. */
  max-height: calc(100vh - var(--records-sticky-height, 0px) - 16px);
  min-height: 200px;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
}
.stats-table {
  width: max-content;
  min-width: 100%;
  /* sticky thead/frozen 컬럼이 border-collapse: collapse에서는 동작하지 않아 separate로 변경 */
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  white-space: nowrap;
}
.stats-table th,
.stats-table td {
  padding: 8px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.stats-table th:nth-child(1), .stats-table td:nth-child(1),
.stats-table th:nth-child(2), .stats-table td:nth-child(2) {
  text-align: left;
}
.stats-table thead th {
  background: var(--surface2);
  color: var(--text-muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 15;
}
.stats-table thead th.sortable-th {
  cursor: pointer;
  user-select: none;
}
.stats-table thead th.sortable-th:hover { color: var(--text); }
.stats-table thead th.sortable-th.active { color: var(--accent); }
.stats-table thead th .sort-arrow {
  margin-left: 4px;
  font-size: 10px;
}
.stats-table tbody tr:hover { background: var(--surface2); }
.stats-table tbody tr:last-child td { border-bottom: none; }
.stats-table .player-name-cell {
  font-weight: 600;
  cursor: pointer;
}
.stats-table .player-name-cell:hover { color: var(--accent); }
.stats-table .team-cell .player-team-sep { display: none; }

/* 가로 스크롤 시 팀명/선수명 컬럼 좌측 고정 */
.stats-table th:nth-child(1),
.stats-table td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 5;
  background: var(--bg);
}
.stats-table th:nth-child(2),
.stats-table td:nth-child(2) {
  position: sticky;
  left: var(--col1-width, 60px);
  z-index: 5;
  background: var(--bg);
  border-right: 1px solid var(--border);
}
.stats-table thead th:nth-child(1),
.stats-table thead th:nth-child(2) {
  z-index: 20;
  background: var(--surface2);
}
.stats-table tbody tr:hover td:nth-child(1),
.stats-table tbody tr:hover td:nth-child(2) {
  background: var(--surface2);
}

/* 정렬 기준 컬럼 전체 강조 (헤더는 기존 active 텍스트색과 함께, 본문은 col-sorted 클래스) */
.stats-table thead th.sortable-th.active {
  background: #2a3253;
}
.stats-table tbody td.col-sorted {
  background: rgba(79, 110, 247, 0.1);
}

/* Player detail */
.player-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.player-detail-header .btn-secondary { margin-left: auto; }
.player-detail-header h2 { font-size: 18px; display: inline; }
.player-detail-role {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  margin-left: 6px;
}
.player-detail-totals { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.stat-highlight { font-weight: 700; color: var(--text); }

.result-chips.result-breakdown { margin-bottom: 20px; }
.chip.static { cursor: default; }
.chip.static:hover { border-color: var(--border); color: inherit; }

.atbat-history-list { display: flex; flex-direction: column; gap: 8px; }
.atbat-history-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.atbat-history-line1 { font-weight: 600; font-size: 13px; }
.atbat-history-line2 { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.atbat-history-comment { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-style: italic; }

/* Player detail — batter: section titles */
.detail-section { margin-bottom: 24px; }
.detail-section h3 { font-size: 15px; margin-bottom: 10px; color: var(--text-muted); }

/* Player detail — batter: result donut chart */
.result-donut-wrap { position: relative; margin: 0 auto 8px; max-width: 100%; overflow-x: auto; }
.result-donut { position: absolute; top: 0; width: 220px; height: 220px; border-radius: 50%; }
.result-donut-hole {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 130px; height: 130px; border-radius: 50%; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.result-donut-total { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.2; }
.result-donut-total-label { font-size: 12px; color: var(--text-muted); }
.result-donut-empty { color: var(--text-muted); font-size: 13px; padding: 20px 0; }
.result-donut-label {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center;
  pointer-events: none; text-align: center;
}
.result-donut-label-name { font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.6); line-height: 1.3; }
.result-donut-label-count { font-size: 10px; color: rgba(255,255,255,0.85); text-shadow: 0 1px 2px rgba(0,0,0,0.6); line-height: 1.3; }

.result-donut-callout-svg { position: absolute; top: 0; left: 0; pointer-events: none; }
.result-donut-callout-svg polyline { fill: none; stroke: var(--border); stroke-width: 1.5; }
.result-donut-callout-label {
  position: absolute; font-size: 11px; color: var(--text-muted); white-space: nowrap; pointer-events: none;
}
.result-donut-callout-left { transform: translate(-100%, -50%); text-align: right; }
.result-donut-callout-right { transform: translate(0, -50%); text-align: left; }

/* Player detail — batter: per-game record cards */
.game-record-list { display: flex; flex-wrap: wrap; gap: 10px; }
.game-record-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px;
  width: 260px; flex: 0 0 auto;
}
.game-record-line1 { text-align: center; font-size: 13px; color: var(--text-muted); }
.game-record-line2 { text-align: center; font-size: 14px; font-weight: 700; margin-top: 2px; }
.game-record-divider { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.game-record-results { display: flex; flex-direction: column; gap: 6px; }
.game-record-result-row { display: flex; align-items: center; gap: 8px; font-size: 12px; flex-wrap: wrap; }
.game-record-inning { color: var(--text-muted); min-width: 56px; }
.game-record-comment { color: var(--text-muted); font-style: italic; }
.game-record-inning-block { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.game-record-inning-tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* 기존 .result-* 팔레트에 없던 빈 결과 폴백 */
.result-미입력 { background: var(--surface2); color: var(--text-muted); }

/* Year tabs */
.year-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.year-tab {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.year-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Game list */
.game-list { display: flex; flex-direction: column; gap: 10px; }

.game-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color 0.15s, background 0.15s;
}
.game-card:hover { border-color: var(--accent); background: var(--surface2); }
.game-card.ssg-win { background: #3a1a1a; border-color: var(--tag-hr); }
.game-card.ssg-win:hover { background: #4a2222; }

.game-date {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 64px;
}
.game-matchup {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.team-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  vertical-align: middle;
  flex-shrink: 0;
}
.game-matchup .venue {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 8px;
}
.card-score {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  min-width: 14px;
  text-align: center;
}
.game-stats {
  display: flex;
  gap: 10px;
  align-items: center;
}
.stat-badge {
  background: var(--surface2);
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.stat-badge.has-data { color: var(--accent); }
.stat-badge.rbi-warning-badge {
  background: rgba(201,68,68,0.15);
  color: var(--tag-k, #c94444);
}

.game-team-rows { display: none; }
.game-mobile-side { display: none; }

/* Game badges */
.game-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
  margin-left: 5px;
  vertical-align: middle;
}
.dh-badge    { background: #7c4daa; color: #fff; }
.series-badge { background: #c94444; color: #fff; }
.futures-badge { background: #2d6a4f; color: #fff; }
.preseason-badge { background: #2c6e8a; color: #fff; }

/* Game content layout */
.game-content { display: block; }
#page-game.panel-open { padding-right: 420px; }

/* Side panel — fixed drawer from right */
.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 92vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 24px 20px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: -4px 0 24px rgba(0,0,0,0.4);
}
.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.side-panel-header h2 {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 8px;
}
.side-panel input[type="text"],
.side-panel input[type="number"],
.side-panel select,
.side-panel textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  margin-top: 4px;
}
.side-panel input:focus,
.side-panel select:focus,
.side-panel textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.side-panel label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.panel-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  align-items: center;
}

/* Video list */
.video-list { display: flex; flex-direction: column; gap: 10px; }

.video-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.video-card:hover { border-color: var(--accent); }
.video-card.expanded { border-color: var(--accent); }
.video-card.tb-top { background: #1a2233; }
.video-card.tb-bottom { background: #26201a; }

.video-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.video-icon { font-size: 20px; flex-shrink: 0; }
.video-info { flex: 1; min-width: 0; }
.video-filename {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.video-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}
.video-meta.empty { color: var(--border); font-style: italic; }
.atbat-summary-row + .atbat-summary-row {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.atbat-summary-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.atbat-summary-main .video-meta {
  margin-top: 0;
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.atbat-summary-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.atbat-summary-row .atbat-comment { padding-left: 0; }
.atbat-mobile-row { display: none; }
.video-card-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.expand-icon { color: var(--text-muted); font-size: 11px; }

/* Player tags (pitcher / batter) */
.player-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}
.tag-pitcher { background: #1a3a5c; color: #74b0e8; }
.tag-batter  { background: #3a2010; color: #e8a040; }
.vs-sep { color: var(--text-muted); font-size: 11px; font-weight: 400; }

/* Autocomplete */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: 1000px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 2px;
  padding: 4px 0;
  list-style: none;
  z-index: 200;
  max-height: 200px;
  overflow-y: auto;
}
.autocomplete-list li {
  padding: 7px 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}
.autocomplete-list li:hover,
.autocomplete-list li.active { background: var(--surface3); }
.autocomplete-list li.autocomplete-add-new {
  color: var(--accent, #4a90d9);
  border-top: 1px solid var(--border);
}

/* Score tag */
.score-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.score-tag .team-logo { width: 18px; height: 18px; }
.score-numbers { color: var(--text); letter-spacing: 1px; }

.video-inline-wrap {
  margin-top: 12px;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.video-inline-wrap video {
  width: 100%;
  max-height: 380px;
  display: block;
}
.video-inline-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* At-bat list (legacy, kept for compat) */
.atbat-list { display: flex; flex-direction: column; gap: 10px; }

.atbat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.atbat-card:hover { border-color: var(--accent); }

.atbat-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.atbat-inning {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 56px;
}
.atbat-players {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
}
.atbat-result-tag {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.result-안타, .result-2루타, .result-3루타 { background: var(--tag-hit); }
.result-홈런 { background: var(--tag-hr); }
.result-볼넷, .result-몸에맞는공 { background: var(--tag-bb); }
.result-삼진 { background: var(--tag-k); }
.result-내야뜬공, .result-외야뜬공, .result-땅볼, .result-병살, .result-희생번트, .result-희생플라이, .result-야수선택 { background: var(--tag-out); }
.result-실책 { background: #5a3a1a; }

.extra-outs-tag {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  background: var(--tag-out);
  white-space: nowrap;
}

.atbat-count { font-size: 12px; color: var(--text-muted); }
.atbat-comment {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  padding-left: 66px;
  white-space: pre-wrap;
}

/* Inline video player inside atbat card */
.atbat-video-wrap {
  margin-top: 12px;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.atbat-video-wrap video {
  width: 100%;
  max-height: 360px;
  display: block;
}
.atbat-video-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* Game header */
#game-header-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}
#game-header-info .matchup {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
#game-header-info .matchup .team-logo { width: 32px; height: 32px; }
#game-header-info .game-detail { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .emoji { font-size: 40px; margin-bottom: 12px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-wide { max-width: 640px; }
.modal h2 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.modal input[type="text"],
.modal input[type="number"],
.modal select,
.modal textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  margin-top: 4px;
}
.modal input:focus,
.modal select:focus,
.modal textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.modal label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  align-items: center;
}
.hint { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.6; }
.hint code { background: var(--surface2); padding: 1px 4px; border-radius: 3px; }
.nas-path-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.nas-path-row .input-nas-path { margin-top: 0; flex: 1; }
.nas-path-row .btn-icon { flex-shrink: 0; }
.btn-add-nas { width: 100%; margin-bottom: 4px; }

.rename-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.rename-row label { flex: 1; margin-bottom: 0; }

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 6px;
  margin-top: -4px;
}
.checkbox-label input[type="checkbox"] { width: auto; margin: 0; }

/* Form grid */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.full-width { grid-column: 1 / -1; }

/* At-bat sets (repeatable groups in side panel) */
.atbat-set {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 4px;
  margin-bottom: 14px;
}
.atbat-set-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.atbat-set-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.atbat-set-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 6px;
}
.atbat-set-remove:hover { color: var(--tag-k, #c94444); }
#btn-add-set { width: 100%; margin-bottom: 16px; }

/* Result chips */
.result-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  margin-bottom: 6px;
}
.chip {
  padding: 5px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface2);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
  user-select: none;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.selected { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 타점/자책점 섹션 (득점이 기록된 타석에서만 표시) */
.score-detail-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 4px 0 10px;
  background: var(--surface2);
}
.er-entries-wrap { margin-top: 10px; }
.er-entries-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.er-entries { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.er-entry {
  display: flex;
  align-items: center;
  gap: 8px;
}
.side-panel .er-entry .f-er-pitcher {
  width: auto;
  flex: 1;
  min-width: 0;
}
.er-earned-toggle {
  padding: 5px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
  user-select: none;
  flex-shrink: 0;
}
.er-earned-toggle.earned { background: var(--accent); border-color: var(--accent); color: #fff; }
.er-earned-toggle.unearned { background: var(--surface2); border-color: var(--tag-k, #c94444); color: var(--tag-k, #c94444); }
.side-panel .er-entry .f-er-count {
  width: 52px;
  flex: 0 0 52px;
  text-align: center;
}
.er-entry-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 6px;
  flex-shrink: 0;
}
.er-entry-remove:hover { color: var(--tag-k, #c94444); }

/* Video section in modal */
.video-section { margin-bottom: 14px; }

/* Loader */
.loader { text-align: center; padding: 40px; color: var(--text-muted); }

/* Login */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.login-logo { font-size: 48px; }
.login-box h1 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.login-box form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-box input[type="password"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
}
.login-box input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
}
.login-box .btn-primary { width: 100%; padding: 10px; font-size: 14px; }
.login-error { font-size: 12px; color: var(--danger); text-align: center; }

/* Mobile layout */
@media (max-width: 720px) {
  #app { padding: 0 12px 80px; }

  .app-header { padding: 16px 0 12px; }
  .app-header h1 { font-size: 17px; }

  .main-tab { padding: 10px 14px; font-size: 14px; }

  .game-card { padding: 12px 14px; gap: 10px; }
  .video-card { padding: 12px 14px; }

  .team-logo { width: 22px; height: 22px; }
  #game-header-info .matchup .team-logo { width: 26px; height: 26px; }

  /* Game list: date column left, away/home team rows middle, venue+count right */
  .game-date { flex-shrink: 0; width: 46px; min-width: 46px; font-size: 11px; line-height: 1.4; }
  .game-matchup { display: none; }
  .game-stats { display: none; }
  .game-team-rows { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
  .game-team-row { display: flex; align-items: center; gap: 7px; }
  .game-team-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
  }
  .game-team-score {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    min-width: 14px;
    text-align: right;
  }
  .game-mobile-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    flex-shrink: 0;
  }

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

  .autocomplete-list { max-width: calc(100vw - 32px); }

  /* Side panel becomes a full-screen sheet instead of a fixed-width drawer */
  #page-game.panel-open { padding-right: 0; }
  .side-panel {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
  }

  /* Video list rows: 2-3 line stacked layout instead of one truncated line */
  .video-card.has-summary .video-filename { display: none; }
  .atbat-summary-main { display: none; }
  .atbat-mobile-row {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .atbat-mobile-lines { flex: 1 1 auto; min-width: 0; }
  .m-line1 {
    display: flex;
    align-items: baseline;
    gap: 4px;
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
  }
  .m-filename {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1 1 auto;
  }
  .m-inning-suffix, .m-inning-only {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 12px;
    white-space: nowrap;
  }
  .m-inning-suffix { flex-shrink: 0; }
  .m-line2 {
    font-size: 12px;
    color: var(--text);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .m-line3-score { margin-top: 4px; }
  .atbat-mobile-result { flex-shrink: 0; }
}
