:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --bg: #f1f5f9;
  --white: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 2px 16px rgba(0,0,0,0.08);
}

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

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

/* ヘッダー */
header {
  background: var(--primary);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}
header h1 { font-size: 1.2rem; font-weight: 700; }
header .subtitle { font-size: 0.8rem; opacity: 0.85; }

/* メインコンテナ */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* ステップインジケーター */
.steps {
  display: flex;
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.step {
  flex: 1;
  text-align: center;
  padding: 12px 4px;
  font-size: 0.75rem;
  color: var(--text-light);
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}
.step.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.step.done {
  color: var(--success);
  border-bottom-color: var(--success);
}

/* セクション */
section { display: none; }
section.active { display: block; }

/* カード */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* グランド情報カード */
.ground-info {
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: white;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.ground-info h2 { font-size: 1.3rem; margin-bottom: 8px; }
.ground-info .meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.85rem; opacity: 0.9; }
.ground-info .meta span { display: flex; align-items: center; gap: 4px; }

/* カレンダー */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.calendar-header h3 { font-size: 1rem; font-weight: 600; }
.cal-nav {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
  transition: background 0.2s;
}
.cal-nav:hover { background: var(--bg); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day-label {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-light);
  padding: 4px 0;
  font-weight: 600;
}
.cal-day-label:first-child { color: #dc2626; }
.cal-day-label:last-child { color: var(--primary); }

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  border: 2px solid transparent;
  position: relative;
}
.cal-day:hover:not(.disabled):not(.empty) { background: #dbeafe; }
.cal-day.today { font-weight: 700; color: var(--primary); }
.cal-day.selected { background: var(--primary); color: white; border-color: var(--primary-dark); }
.cal-day.disabled { color: #cbd5e1; cursor: not-allowed; }
.cal-day.empty { cursor: default; }
.cal-day.sunday { color: #dc2626; }
.cal-day.saturday { color: var(--primary); }
.cal-day.selected.sunday, .cal-day.selected.saturday { color: white; }

/* タイムスロット */
.slots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.slot {
  padding: 12px 8px;
  border: 2px solid var(--border);
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.85rem;
  background: white;
}
.slot:hover:not(.taken) { border-color: var(--primary); background: #dbeafe; }
.slot.selected { border-color: var(--primary); background: var(--primary); color: white; }
.slot.taken { background: #f1f5f9; color: #94a3b8; cursor: not-allowed; text-decoration: line-through; }
.slot .slot-time { font-weight: 600; }
.slot .slot-status { font-size: 0.7rem; margin-top: 2px; }
.slot.taken .slot-status { color: #94a3b8; }
.slot.selected .slot-status { color: rgba(255,255,255,0.8); }

/* コート選択テーブル */
.court-table {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.court-header {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  background: #f1f5f9;
  border-bottom: 2px solid var(--border);
}
.court-time-col {
  padding: 10px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-light);
  text-align: center;
  border-right: 1px solid var(--border);
}
.court-col {
  padding: 10px 8px;
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
}
.court-col:first-of-type { border-left: 1px solid var(--border); }
.court-col:not(:last-child) { border-right: 1px solid var(--border); }
.court-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  border-bottom: 1px solid var(--border);
}
.court-row:last-child { border-bottom: none; }
.court-time {
  padding: 12px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  color: var(--text);
  background: #f8fafc;
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.court-cell {
  padding: 12px 8px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--border);
}
.court-cell:last-child { border-right: none; }
.court-cell.available { cursor: pointer; color: var(--success); }
.court-cell.available:hover { background: #dcfce7; }
.court-cell.selected { background: var(--primary); color: white; }
.court-cell.taken { color: #94a3b8; cursor: not-allowed; background: #f1f5f9; }

/* フォーム */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.form-group label .required {
  color: var(--danger);
  margin-left: 4px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s;
  background: white;
  color: var(--text);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.form-group textarea { height: 80px; resize: vertical; }

/* 確認テーブル */
.confirm-table { width: 100%; border-collapse: collapse; }
.confirm-table tr { border-bottom: 1px solid var(--border); }
.confirm-table tr:last-child { border-bottom: none; }
.confirm-table th {
  text-align: left;
  padding: 10px 0;
  font-size: 0.82rem;
  color: var(--text-light);
  width: 35%;
  font-weight: 600;
}
.confirm-table td {
  padding: 10px 0;
  font-size: 0.9rem;
  font-weight: 500;
}

/* ボタン */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 24px;
  border-radius: 10px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-primary { background: var(--primary); color: white; width: 100%; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; transform: none; }
.btn-outline { background: white; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: #dbeafe; }
.btn-back { background: white; color: var(--text-light); border: 2px solid var(--border); }
.btn-back:hover { background: var(--bg); }
.btn-group { display: flex; gap: 10px; margin-top: 16px; }
.btn-group .btn-back { flex: 1; }
.btn-group .btn-primary { flex: 2; }

/* 完了画面 */
.complete-box {
  text-align: center;
  padding: 32px 16px;
}
.complete-icon { font-size: 4rem; margin-bottom: 16px; }
.complete-box h2 { font-size: 1.4rem; margin-bottom: 8px; color: var(--success); }
.complete-box p { color: var(--text-light); margin-bottom: 24px; font-size: 0.9rem; }
.reservation-number {
  background: #f0fdf4;
  border: 2px dashed var(--success);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
}
.reservation-number .label { font-size: 0.8rem; color: var(--text-light); }
.reservation-number .number { font-size: 1.6rem; font-weight: 700; color: var(--success); letter-spacing: 3px; }

/* キャンセル検索 */
.cancel-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* バッジ */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-confirmed { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }

/* ローディング */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  color: var(--text-light);
  font-size: 0.9rem;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* アラート */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.875rem;
  display: none;
}
.alert.show { display: block; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* 選択済み日時表示 */
.selected-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.875rem;
  color: var(--primary);
  font-weight: 500;
}

/* レスポンシブ */
@media (max-width: 480px) {
  .slots-grid { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 16px; }
  .btn { padding: 11px 20px; }
}

/* ========== 料金バッジ ========== */
.price-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}
.price-badge.member  { background: #dbeafe; color: #1d4ed8; }
.price-badge.visitor { background: #fef3c7; color: #92400e; }
.price-badge.note    { background: #f1f5f9; color: #64748b; font-weight: 400; }

/* ========== ナビタブ ========== */
.nav-tabs {
  display: flex;
  background: white;
  border-bottom: 2px solid var(--border);
}
.nav-tab {
  flex: 1;
  padding: 13px;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.nav-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.nav-tab:hover:not(.active) { background: #f8fafc; }

/* ========== 予約状況カレンダー ========== */
.status-day { position: relative; flex-direction: column; gap: 2px; }
.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.dot-green  { background: #16a34a; }
.dot-yellow { background: #d97706; }
.dot-red    { background: #dc2626; }
.status-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--text-light);
}
.status-legend span { display: flex; align-items: center; gap: 5px; }

/* ========== 管理画面 ========== */
.admin-login {
  max-width: 400px;
  margin: 60px auto;
  padding: 0 16px;
}
.admin-header {
  background: #1e293b;
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.admin-header h1 { font-size: 1.1rem; font-weight: 700; }
.admin-container { max-width: 1000px; margin: 0 auto; padding: 20px 16px; }

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filters select, .filters input {
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  font-family: inherit;
  background: white;
}

.table-wrap { overflow-x: auto; }
table.reservations {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
table.reservations th {
  background: #1e293b;
  color: white;
  padding: 12px 16px;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
table.reservations td {
  padding: 12px 16px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.reservations tr:last-child td { border-bottom: none; }
table.reservations tr:hover td { background: #f8fafc; }

.action-btn {
  padding: 5px 12px;
  border-radius: 6px;
  border: none;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  margin: 2px;
  font-family: inherit;
  transition: opacity 0.2s;
}
.action-btn:hover { opacity: 0.8; }
.btn-confirm { background: #dcfce7; color: #166534; }
.btn-cancel-action { background: #fee2e2; color: #991b1b; }
.btn-detail { background: #dbeafe; color: #1e40af; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-card .num { font-size: 1.8rem; font-weight: 700; }
.stat-card .label { font-size: 0.75rem; color: var(--text-light); margin-top: 4px; }
.stat-card.total .num { color: var(--text); }
.stat-card.pending .num { color: var(--warning); }
.stat-card.confirmed .num { color: var(--success); }
.stat-card.cancelled .num { color: var(--danger); }

/* モーダル */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  display: none;
}
.modal-overlay.show { display: flex; }
.modal {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.modal-close {
  float: right;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-light);
}

@media (max-width: 640px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}
