/* ============================================
   EQ SPORTS - 共通レイアウトCSS
   全ページで使うヘッダー・ナビ・カード等
   ============================================ */

:root {
  --bg-primary: #f5f7fa;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --accent: #16a34a;
  --accent-light: #22c55e;
  --accent-blue: #2563eb;
  --accent-orange: #d97706;
  --danger: #dc2626;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

/* Header */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--accent-blue);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-user {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
  text-decoration: none;
}

/* Nav */
.nav {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 10px 14px;
  font-size: 0.85rem;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.nav a:hover { color: var(--text-primary); text-decoration: none; }

.nav a.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-blue);
}

.nav a.admin-link {
  color: var(--accent-orange);
}

/* Player Selector */
.player-selector {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: none;
}

.player-selector.visible { display: flex; align-items: center; gap: 12px; }

.player-selector label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.player-selector select {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}

/* Main Content Area */
.main {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px;
  padding-bottom: 100px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Page Title */
.page-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 20px;
  color: var(--text-primary);
}

/* Form Elements */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.9rem;
  box-sizing: border-box;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-group textarea { min-height: 80px; resize: vertical; }

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}
.tab-btn {
  padding: 12px 20px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  font-weight: 600;
}
.tab-btn.active {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Submit Button */
.submit-btn {
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  border: none;
  background: var(--accent-blue);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 12px;
  transition: background 0.2s;
}
.submit-btn:hover { background: #1d4ed8; }
.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Success Message */
.success-msg {
  display: none;
  padding: 12px;
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  text-align: center;
  margin-top: 12px;
  font-size: 0.85rem;
  font-weight: 600;
}
.success-msg.show { display: block; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* Slider */
.slider-group { display: flex; align-items: center; gap: 12px; }
.slider-group input[type="range"] { flex: 1; accent-color: var(--accent-blue); }
.slider-val { min-width: 50px; text-align: center; color: var(--accent-blue); font-weight: bold; font-size: 0.95rem; }
.form-help-text { margin-top: 8px; color: var(--text-secondary); font-size: 0.78rem; line-height: 1.6; }
.media-preview-card {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-primary);
}
.media-preview-card video,
.media-preview-card img {
  width: 100%;
  max-width: 320px;
  border-radius: 10px;
  border: 1px solid #dbe3f0;
  background: #0f172a;
  object-fit: contain;
}
.media-preview-card img {
  background: #fff;
}
.media-preview-meta {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 0.78rem;
}

/* Choice Buttons */
.btn-group { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-choice {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.btn-choice.selected { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }

/* Toggle */
.toggle-row { display: flex; align-items: center; gap: 12px; }
.toggle-row label { color: var(--text-primary); font-size: 0.9rem; margin: 0; }
.toggle-switch { position: relative; width: 48px; height: 26px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch .slider {
  position: absolute; inset: 0; background: var(--border); border-radius: 13px; cursor: pointer; transition: 0.3s;
}
.toggle-switch .slider::before {
  content: ''; position: absolute; width: 20px; height: 20px; left: 3px; bottom: 3px;
  background: #94a3b8; border-radius: 50%; transition: 0.3s;
}
.toggle-switch input:checked + .slider { background: var(--accent-blue); }
.toggle-switch input:checked + .slider::before { transform: translateX(22px); background: #fff; }

/* Checkbox */
.checkbox-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.checkbox-row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent-blue); }
.checkbox-row label { color: var(--text-primary); font-size: 0.9rem; margin: 0; }

/* Inline Fields Grid */
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .inline-fields { grid-template-columns: 1fr; } }

/* Result Buttons */
.result-btns { display: flex; gap: 8px; }
.result-btn {
  flex: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-secondary); color: var(--text-secondary);
  cursor: pointer; font-size: 0.9rem; text-align: center; transition: all 0.2s;
}
.result-btn.selected-win { background: #f0fdf4; color: #16a34a; border-color: #22c55e; }
.result-btn.selected-lose { background: #fef2f2; color: #dc2626; border-color: #ef4444; }
.result-btn.selected-draw { background: #fff7ed; color: #d97706; border-color: #f59e0b; }

/* Pitching Section */
.pitching-section { display: none; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.pitching-section.show { display: block; }

/* Quick game input */
.quick-mode-shell {
  margin-bottom: 20px;
  border: 1px solid #dbe3f0;
  border-radius: 16px;
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
  overflow: hidden;
}

.quick-mode-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid #e5edf6;
}

.quick-mode-kicker {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-blue);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.quick-mode-header h3 {
  font-size: 1rem;
  margin: 0;
}

.batting-side-control {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-bottom: 1px solid #e5edf6;
  background: #fff;
}

.batting-side-label {
  color: #475569;
  font-size: 0.78rem;
  font-weight: 800;
}

.batting-side-options {
  display: inline-flex;
  gap: 6px;
}

.batting-side-option {
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #475569;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.batting-side-option.selected {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
}

.batting-side-hint {
  color: #64748b;
  font-size: 0.72rem;
}

.quick-mode-toggle {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.quick-mode-toggle.active {
  background: #1d4ed8;
  color: #fff;
  border-color: #1d4ed8;
}

.quick-game-panel {
  padding: 18px;
  max-width: 100%;
  overflow-x: hidden;
}

.quick-summary-card,
.quick-input-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px;
  min-width: 0;
}

.quick-summary-card {
  margin-bottom: 16px;
}

.quick-summary-label {
  display: block;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.quick-score-grid,
.quick-game-grid,
.quick-stat-grid {
  display: grid;
  gap: 12px;
}

.quick-score-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.quick-game-grid {
  grid-template-columns: 1fr;
}

.quick-counter-card,
.quick-stat-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
}

.quick-counter-card strong,
.quick-stat-card strong {
  min-width: 24px;
  text-align: center;
  font-size: 1.2rem;
  color: var(--text-primary);
}

.quick-counter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.quick-stepper {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

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

.quick-input-card h4 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.quick-link-btn {
  border: none;
  background: transparent;
  color: var(--accent-blue);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.quick-outcome-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.quick-outcome-btn {
  border: 1px solid #dbe3f0;
  background: #fff;
  color: var(--text-primary);
  border-radius: 12px;
  padding: 12px 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.quick-outcome-btn.hit {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
}

.quick-outcome-btn:active {
  transform: scale(0.98);
}

.quick-at-bat-status {
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 700;
}

.quick-at-bat-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.quick-at-bat-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: #eef4ff;
  color: #1e3a8a;
  font-size: 0.78rem;
  font-weight: 700;
}

.quick-at-bat-chip button {
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-size: 0.9rem;
}

.direction-picker-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(15, 23, 42, 0.45);
  padding: 20px;
  align-items: center;
  justify-content: center;
}

.direction-picker-overlay.show {
  display: flex;
}

.direction-picker-panel {
  width: min(720px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  border-radius: 20px;
  padding: 20px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.18);
}

.direction-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.direction-picker-head h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.05rem;
}

.direction-picker-copy {
  margin: 10px 0 16px;
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.modal-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid #dbe3f0;
  background: #fff;
  color: #475569;
  font-size: 1.1rem;
  cursor: pointer;
}

.direction-picker-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.direction-map {
  position: relative;
  width: min(100%, 480px);
  aspect-ratio: 1.35 / 1;
  margin-inline: auto;
  overflow: hidden;
  border: 1px solid #b7d9b8;
  border-radius: 18px 18px 34% 34%;
  background:
    radial-gradient(circle at 50% 88%, rgba(255,255,255,0.55) 0 3%, transparent 3.5%),
    linear-gradient(135deg, rgba(255,255,255,0.36) 25%, transparent 25%) 0 0 / 18px 18px,
    #dff2df;
}

.direction-map::before {
  content: '';
  position: absolute;
  z-index: 0;
  width: 42%;
  aspect-ratio: 1;
  left: 29%;
  bottom: 9%;
  transform: rotate(45deg);
  border: 2px solid rgba(146, 96, 47, 0.42);
  background: rgba(225, 190, 145, 0.82);
  box-shadow: 0 0 0 28px rgba(255,255,255,0.08);
}

.direction-map::after {
  content: '⌂';
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 2.5%;
  transform: translateX(-50%);
  color: #8c5a2b;
  font-size: 1rem;
  font-weight: 800;
}

.direction-zone {
  position: absolute;
  z-index: 2;
  width: clamp(56px, 21%, 94px);
  min-height: 44px;
  padding: 6px 5px;
  border: 1px solid #b8cedd;
  border-radius: 999px;
  background: rgba(255,255,255,0.94);
  color: #334155;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.direction-zone:hover {
  border-color: #60a5fa;
  box-shadow: 0 5px 12px rgba(37, 99, 235, 0.16);
  transform: translate(-50%, calc(-50% - 2px));
}

.direction-zone.selected {
  border-color: #2563eb;
  background: #dbeafe;
  color: #1d4ed8;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.1);
}

.direction-left_line { left: 10%; top: 59%; }
.direction-left_over { left: 17%; top: 31%; }
.direction-left_center { left: 33%; top: 18%; }
.direction-center { left: 50%; top: 12%; }
.direction-right_center { left: 67%; top: 18%; }
.direction-right_over { left: 83%; top: 31%; }
.direction-right_line { left: 90%; top: 59%; }
.direction-infield_left { left: 33%; top: 68%; }
.direction-infield_center { left: 50%; top: 76%; }
.direction-infield_right { left: 67%; top: 68%; }

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

/* Loading */
.loading {
  display: flex;
  justify-content: center;
  padding: 20px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

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

/* Responsive */
@media (max-width: 600px) {
  .main { padding: 12px; padding-bottom: 100px; }
  .card { padding: 14px; }
  .header { padding: 0 12px; }
  .nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 120;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    border-bottom: 0;
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
    overflow: visible;
  }
  .nav a {
    min-width: 0;
    padding: 9px 4px;
    border-bottom: 0;
    border-radius: 10px;
    font-size: 0.72rem;
    line-height: 1.2;
    white-space: normal;
    text-align: center;
    font-weight: 700;
  }
  .nav a.admin-link {
    display: none !important;
  }
  .nav a.active {
    background: #eff6ff;
    color: var(--accent-blue);
    border-bottom-color: transparent;
  }
  .quick-mode-header {
    flex-direction: column;
    align-items: stretch;
  }
  .quick-score-grid,
  .quick-stat-grid {
    grid-template-columns: 1fr;
  }
  .quick-outcome-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .batting-side-control { align-items: flex-start; }
  .batting-side-hint { flex-basis: 100%; }
  .direction-picker-overlay {
    padding: 12px;
    align-items: flex-end;
  }
  .direction-picker-panel {
    padding: 16px;
    border-radius: 18px 18px 0 0;
    width: 100%;
    max-height: 85vh;
  }
  .direction-map {
    width: 100%;
    aspect-ratio: 1.06 / 1;
  }
  .direction-zone {
    width: clamp(54px, 25%, 82px);
    min-height: 44px;
    font-size: 0.63rem;
  }
}
