/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #2E7D32;
  --primary-light: #43A047;
  --primary-dark: #1B5E20;
  --accent: #C8E600;
  --accent-light: #D4E157;
  --success: #4CAF50;
  --warning: #FF9800;
  --danger: #F44336;
  --bg: #1B5E20;
  --bg-light: #2E7D32;
  --bg-card: #FFFFFF;
  --text: #1A1A1A;
  --text-light: #4E6B50;
  --text-muted: #8FA891;
  --border: #C8E6C9;
  --court-line: #FFFFFF;
  --shadow: 0 2px 12px rgba(27, 94, 32, 0.2);
  --shadow-lg: 0 8px 30px rgba(27, 94, 32, 0.25);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  position: relative;
}

/* テニスコート背景画像 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: url('/images/court-bg.jpg') center top / cover no-repeat;
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}

/* ダークオーバーレイ（画像の上にかぶせてコンテンツを読みやすく） */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(27, 94, 32, 0.3) 0%,
    rgba(27, 94, 32, 0.6) 40%,
    rgba(27, 94, 32, 0.8) 100%
  );
  pointer-events: none;
  z-index: 0;
}

/* === Layout === */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  position: relative;
  z-index: 1;
}

/* === Header === */
.header {
  text-align: center;
  padding: 24px 0 20px;
  position: relative;
}

/* コートライン装飾 */
.header::after {
  content: '';
  display: block;
  width: 120px;
  height: 2px;
  background: var(--court-line);
  margin: 12px auto 0;
  opacity: 0.4;
}

.header-logo {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--court-line);
  letter-spacing: 0.02em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.header-sub {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 2px;
}

/* === Card === */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px;
  margin-bottom: 16px;
  border-top: 3px solid var(--primary);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary-dark);
}

.card-title .icon {
  font-size: 1.2rem;
}

/* === Form === */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--danger);
  margin-left: 4px;
  font-size: 0.75rem;
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: #F9FBF2;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

/* === Date List === */
.date-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.date-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #F1F8E9;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  border-left: 3px solid var(--primary);
}

.date-item-new {
  border: 2px solid var(--primary);
  background: rgba(46, 125, 50, 0.12);
  animation: highlight-fade 2s ease-out forwards;
}

@keyframes highlight-fade {
  0% { border-color: var(--primary); background: rgba(46, 125, 50, 0.12); }
  100% { border-color: transparent; background: #F1F8E9; }
}

.date-item .date-text {
  flex: 1;
  font-weight: 500;
}

.date-item .day-label {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-left: 4px;
}

.date-item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.date-item-copy,
.date-item-edit {
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.7rem;
  padding: 2px 6px;
  color: #2E7D32;
}
.date-item-copy:hover,
.date-item-edit:hover {
  background: #c8e6c9;
}

.date-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  line-height: 1;
}

.date-remove:hover {
  color: var(--danger);
  background: rgba(244, 67, 54, 0.1);
}

.date-add-row {
  display: flex;
  gap: 8px;
}

.date-add-row .form-input {
  flex: 1;
}

.date-add-row .capacity-input {
  flex: 0 0 80px;
  text-align: center;
}

.time-select {
  flex: 0 0 80px !important;
  padding: 10px 4px !important;
  text-align: center;
  appearance: auto;
  font-size: 0.9rem !important;
}

.time-separator {
  display: flex;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.date-add-area {
  margin-bottom: 4px;
}

/* === Date Detail Display === */
.detail-location {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--primary-dark);
  background: rgba(46, 125, 50, 0.08);
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
  font-weight: 500;
}

.detail-time {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--text-light);
  margin-left: 4px;
  font-weight: 400;
}

/* === Recurring Date Section === */
.recurring-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.recurring-toggle {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  font-family: inherit;
}

.recurring-toggle:hover {
  text-decoration: underline;
}

.recurring-form {
  margin-top: 12px;
}

.recurring-period-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.recurring-period-row .form-input {
  flex: 1;
}

.recurring-preview {
  margin-top: 8px;
  padding: 10px 14px;
  background: #F1F8E9;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  max-height: 150px;
  overflow-y: auto;
}

.recurring-preview .preview-count {
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
}

.recurring-preview .preview-list {
  color: var(--text-light);
  font-size: 0.8rem;
  line-height: 1.8;
}

.recurring-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
  font-family: inherit;
  text-decoration: none;
  line-height: 1.4;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 16px rgba(46, 125, 50, 0.4);
}

/* メインCTA: 予定を作成する（ジェネレーターより目立たせる） */
#create-btn {
  padding: 16px 24px;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 20px rgba(46, 125, 50, 0.35), 0 2px 4px rgba(46, 125, 50, 0.2);
}

#create-btn:hover:not(:disabled) {
  box-shadow: 0 10px 28px rgba(46, 125, 50, 0.45), 0 2px 4px rgba(46, 125, 50, 0.2);
  transform: translateY(-1px);
}

#create-btn::before {
  content: "🎾 ";
  margin-right: 2px;
}

/* 入力不足エラー（予定作成ボタン下） */
.create-error {
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--danger);
  text-align: center;
  padding: 8px 12px;
  background: #FFEBEE;
  border: 1px solid #FFCDD2;
  border-radius: var(--radius-sm);
}

.btn-secondary {
  background: #F1F8E9;
  color: var(--primary);
  border: 2px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary-light);
  background: rgba(46, 125, 50, 0.05);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  padding: 8px;
  min-width: 36px;
}

/* === Answer Buttons === */
.answer-btn-group {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.answer-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
}

.answer-btn:hover {
  border-color: var(--primary-light);
}

.answer-btn.selected-maru {
  background: #E8F5E9;
  border-color: var(--success);
  color: var(--success);
}

.answer-btn.selected-sankaku {
  background: #FFF3E0;
  border-color: var(--warning);
  color: var(--warning);
}

.answer-btn.selected-batsu {
  background: #FFEBEE;
  border-color: var(--danger);
  color: var(--danger);
}

/* === Schedule Table === */
.table-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 60vh;
  -webkit-overflow-scrolling: touch;
  isolation: isolate;
}

/* Sticky first column — must always have opaque background to prevent content bleed-through */
.schedule-table th:first-child,
.schedule-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #FFFFFF !important;
  color: var(--text) !important;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.06);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
}

.schedule-table thead th:first-child {
  z-index: 6;
  background: #F1F8E9 !important;
}

.schedule-table .summary-row td:first-child {
  background: #F1F8E9 !important;
}

/* Toggle button */
.toggle-table-btn {
  margin-left: auto;
  padding: 3px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--primary);
  background: rgba(46, 125, 50, 0.08);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.toggle-table-btn:hover {
  background: rgba(46, 125, 50, 0.15);
}

/* Transposed table */
.schedule-table.transposed td:first-child {
  text-align: left;
  padding-left: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.schedule-table.transposed .summary-col {
  background: #F1F8E9;
  font-weight: 600;
  font-size: 0.8rem;
  border-left: 2px solid var(--border);
  position: sticky;
  left: var(--first-col-width, 80px);
  z-index: 2;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.06);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.schedule-table.transposed .summary-col.cell-capacity-over {
  background: #F2D4C5;
}

.schedule-table.transposed .summary-col.cell-capacity-near {
  background: #F3ECCD;
}

.schedule-table.transposed .summary-col-header {
  background: #F1F8E9;
  position: sticky;
  left: var(--first-col-width, 80px);
  z-index: 6;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.06);
}

.trans-detail {
  font-size: 0.7rem;
  color: var(--text-light);
  font-weight: 500;
  white-space: nowrap;
}

.schedule-table {
  width: 100%;
  min-width: 320px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
}

.schedule-table th,
.schedule-table td {
  padding: 8px 6px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.schedule-table thead th {
  background: #F1F8E9;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-light);
  position: sticky;
  top: 0;
  z-index: 5;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.schedule-table thead th:first-child {
  z-index: 6;
  text-align: left;
  padding-left: 12px;
}

.schedule-table tbody td:first-child {
  text-align: left;
  padding-left: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* 氏名：全角7文字まで表示、超過は省略（通常・転置テーブル共通） */
.schedule-table .response-name {
  display: block;
  min-width: 7em;
  max-width: 7em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.schedule-table .date-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.schedule-table .date-header .month-day {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.schedule-table .date-header .weekday {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: 1px;
}

.schedule-table .date-header .weekday.sun,
.schedule-table .date-header .month-day.sun {
  color: var(--danger);
}

.schedule-table .date-header .weekday.sat,
.schedule-table .date-header .month-day.sat {
  color: #2196F3;
}

.schedule-table .cell-maru {
  color: var(--success);
  font-weight: 700;
  font-size: 1.1rem;
}

.schedule-table .cell-sankaku {
  color: var(--warning);
  font-weight: 700;
  font-size: 1.1rem;
}

.schedule-table .cell-batsu {
  color: var(--danger);
  font-weight: 700;
  font-size: 1.1rem;
}

/* Summary Row (sticky below header) */
.schedule-table .summary-row td {
  background: #F1F8E9;
  font-weight: 600;
  font-size: 0.8rem;
  border-bottom: 2px solid var(--border);
  position: sticky;
  z-index: 3;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.schedule-table .summary-row td:first-child {
  z-index: 4;
}

.schedule-table .summary-row .count-maru {
  color: var(--success);
}

.schedule-table .summary-row .count-sankaku {
  color: var(--warning);
}

.schedule-table .summary-row .count-batsu {
  color: var(--danger);
}

/* Column capacity highlight（定員到達/超過の列全体をハイライト） */
.schedule-table .col-capacity-over {
  background: #FFF5F5;
}

.schedule-table thead .col-capacity-over {
  background: #FDEAEA;
}

.schedule-table .summary-row .col-capacity-over {
  background: #FDEAEA;
}

.schedule-table .col-capacity-near {
  background: #FFFBF0;
}

.schedule-table thead .col-capacity-near {
  background: #FFF3D6;
}

.schedule-table .summary-row .col-capacity-near {
  background: #FFF3D6;
}

/* Transposed: first column (date) with capacity status */
.schedule-table.transposed td:first-child.col-capacity-over {
  background: #FFF5F5;
}

.schedule-table.transposed td:first-child.col-capacity-near {
  background: #FFFBF0;
}

/* Cancelled date columns */
.schedule-table .col-cancelled {
  background: #F5F5F5;
  color: #999;
}

.schedule-table thead .col-cancelled {
  background: #EEEEEE;
}

.schedule-table .summary-row .col-cancelled {
  background: #EEEEEE;
}

.schedule-table.transposed td:first-child.col-cancelled {
  background: #F5F5F5 !important;
}

.schedule-table.transposed .row-cancelled td {
  color: #999;
}

/* Cancelled in answer form */
.answer-row-cancelled {
  background: #F5F5F5 !important;
}

.answer-row-cancelled .date-cell {
  color: #999;
  text-decoration: line-through;
  text-decoration-color: #CCC;
}

/* Cancelled in date management */
.date-manage-cancelled {
  background: #F5F5F5 !important;
  border-left-color: #BDBDBD !important;
}

.date-manage-cancelled .date-text {
  color: #999;
}

/* Header detail display */
.header-location {
  display: block;
  font-size: 0.6rem;
  color: var(--primary-dark);
  font-weight: 500;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

.header-time {
  display: block;
  font-size: 0.7rem;
  color: var(--text-light);
  font-weight: 500;
}

.header-capacity {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 1px;
}

/* === Answer Form Table === */
.answer-form-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.answer-form-table th {
  padding: 8px 4px;
  font-size: 0.8rem;
  color: var(--text-light);
  font-weight: 600;
}

.answer-form-table td {
  padding: 6px 4px;
  text-align: center;
}

.answer-form-table .date-cell {
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.form-date-location {
  font-size: 0.65rem;
  color: var(--primary-dark);
  margin-top: 1px;
}

.form-date-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.form-date-cap {
  font-size: 0.65rem;
  color: var(--text-light);
  font-weight: 600;
  margin-top: 2px;
}

.form-date-cap.cap-over {
  color: var(--danger);
}

.form-date-cap.cap-near {
  color: var(--warning);
}

.answer-form-table .answer-row-full {
  background: rgba(244, 67, 54, 0.06);
}

.answer-form-table .answer-row-near {
  background: rgba(255, 152, 0, 0.06);
}

/* === Name Popup === */
.name-popup {
  z-index: 50;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.name-popup-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.name-popup-edit-btn {
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  background: rgba(46, 125, 50, 0.08);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
  white-space: nowrap;
}

.name-popup-edit-btn:hover {
  background: rgba(46, 125, 50, 0.15);
}

/* === Date Management (Admin) === */
.date-manage-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.date-manage-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #F1F8E9;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border-left: 3px solid var(--primary);
}

.date-manage-item .date-text {
  flex: 1;
  font-weight: 500;
}

.date-manage-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.date-manage-edit,
.date-manage-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  line-height: 1;
}

.date-manage-edit:hover {
  color: var(--primary);
  background: rgba(46, 125, 50, 0.1);
}

.date-manage-delete:hover {
  color: var(--danger);
  background: rgba(244, 67, 54, 0.1);
}

.btn-cancel-toggle {
  background: #FFF3E0;
  border: 1px solid #FFB74D;
  color: #E65100;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.btn-cancel-toggle:hover {
  background: #FFE0B2;
}

.date-manage-divider {
  border: none;
  border-top: 1px dashed var(--border);
  margin: 16px 0;
}

/* === Admin Key Display (create page) === */
.admin-key-display {
  display: flex;
  gap: 8px;
  align-items: center;
}

.admin-key-code {
  flex: 1;
  padding: 8px 12px;
  background: #F5F5F5;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.5px;
  word-break: break-all;
  user-select: all;
}

/* === Admin Login (event page) === */
.admin-login-toggle {
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  padding: 4px 0;
}

.admin-login-toggle:hover {
  color: var(--primary);
}

/* === Share Section === */
.share-url {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.share-url-input {
  flex: 1;
  padding: 10px 14px;
  font-size: 0.85rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: #F1F8E9;
  color: var(--text);
  font-family: monospace;
}

.share-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-line {
  background: #06C755;
  color: #fff;
}

.btn-copy {
  background: var(--primary);
  color: #fff;
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1A1A1A;
  color: #fff;
  padding: 12px 24px;
  border-radius: 100px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* === Loading === */
.loading {
  text-align: center;
  padding: 40px 0;
  color: rgba(255, 255, 255, 0.6);
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

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

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

/* === Error === */
.error-state {
  text-align: center;
  padding: 40px 16px;
  color: rgba(255, 255, 255, 0.8);
}

.error-hint {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 8px;
  line-height: 1.6;
}

/* === Comment === */
.comment-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comment-item {
  padding: 10px 14px;
  background: #F1F8E9;
  border-radius: var(--radius-sm);
}

.comment-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 2px;
}

.comment-text {
  font-size: 0.9rem;
  color: var(--text);
}

/* === Comment Stamps === */
.stamp-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.stamp-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  font-family: inherit;
  line-height: 1;
}

.stamp-btn:hover {
  background: #fff;
  border-color: var(--primary-light);
}

.stamp-btn:active {
  transform: scale(0.92);
}

.stamp-btn.stamp-has-count {
  background: #fff;
  border-color: var(--primary-light);
}

.stamp-emoji {
  font-size: 0.85rem;
  line-height: 1;
}

.stamp-count {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--primary);
  min-width: 12px;
  text-align: center;
}

/* === Random Table (乱数表) === */
.random-table-toggle {
  cursor: pointer;
  user-select: none;
}

.toggle-arrow {
  font-size: 0.7rem;
  margin-left: 4px;
  color: var(--text-light);
}

.random-table-controls {
  margin-bottom: 12px;
}

.random-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.random-input-row .form-input {
  width: 80px;
}

.random-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.random-table {
  border-collapse: collapse;
  font-size: 0.8rem;
  width: auto;
  min-width: 100%;
}

.random-table th,
.random-table td {
  padding: 4px 8px;
  text-align: center;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.random-table thead th {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  position: sticky;
  top: 0;
}

.random-round {
  font-weight: 600;
  color: var(--text-light);
  background: #FAFAFA;
  min-width: 30px;
}

.random-cell.court-border {
  border-left: 2px solid var(--primary);
}

.random-table thead th.court-border {
  border-left: 2px solid rgba(255, 255, 255, 0.5);
}

.random-cell.pair-a {
  background: #F1F8E9;
}

.random-cell.pair-b {
  background: #fff;
}

.random-rest {
  background: #ECEFF1;
  color: #455A64;
  font-weight: 500;
}

.random-rest-header {
  background: #757575 !important;
  font-size: 0.7rem;
}

.random-time-line-row td {
  border-top: 3px solid #E53935;
}

/* === Export === */
.export-area {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(27, 94, 32, 0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px 20px;
  width: 100%;
  max-width: 480px;
  max-height: 85dvh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.2s;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* === Created Success === */
.created-success {
  text-align: center;
  padding: 20px 0;
}

.created-success .checkmark {
  font-size: 3rem;
  margin-bottom: 12px;
}

.created-success h2 {
  font-size: 1.2rem;
  margin-bottom: 16px;
}

/* === Capacity === */
.capacity-badge {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--primary);
  background: rgba(46, 125, 50, 0.08);
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
  font-weight: 600;
}

.count-capacity {
  font-size: 0.75rem;
  font-weight: 700;
  margin-top: 2px;
  display: inline-block;
}

.count-capacity.capacity-over {
  color: #fff;
}

.count-capacity.capacity-near {
  color: var(--warning);
}

/* Capacity cell backgrounds (opaque to prevent bleed-through on sticky rows) */
.cell-capacity-over {
  background-color: #FDD9D7;
}

.cell-capacity-near {
  background-color: #FFF3E0;
}

/* Summary row capacity (opaque on green #F1F8E9 base) */
.schedule-table .summary-row .cell-capacity-over {
  background: #F2D4C5;
}

.schedule-table .summary-row .cell-capacity-near {
  background: #F3ECCD;
}

/* === Waitlist (キャンセル待ち) === */
.waitlist-badge {
  display: inline-block;
  font-size: 0.55rem;
  font-weight: 700;
  color: #fff;
  background: #FF7043;
  border-radius: 8px;
  padding: 0 4px;
  margin-left: 1px;
  line-height: 1.4;
  vertical-align: top;
}

.cell-waitlist {
  position: relative;
}

.count-waitlist {
  font-size: 0.7rem;
  font-weight: 700;
  color: #FF7043;
}

.form-date-cap.cap-waitlist {
  color: #FF7043;
  font-size: 0.6rem;
  font-weight: 500;
}

/* === Table Hint === */
.table-hint {
  text-align: left;
  font-size: 0.7rem;
  color: #999;
  letter-spacing: 0.02em;
  padding: 6px 0;
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
}

/* === Responsive === */
@media (max-width: 480px) {
  .container {
    padding: 12px 12px 32px;
  }

  .card {
    padding: 20px 16px;
  }

  .answer-btn {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }

  .schedule-table {
    font-size: 0.8rem;
  }

  .schedule-table th,
  .schedule-table td {
    padding: 6px 4px;
  }

  .time-select {
    flex: 0 0 72px !important;
  }
}

/* === Utility === */
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.hidden { display: none !important; }

/* === Tool Card (コート割り振りジェネレーター) === */
.tool-section {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 24px;
  position: relative;
  z-index: 1;
}

.tool-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.tool-card-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.tool-card-icon {
  font-size: 1.7rem;
  line-height: 1;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0faf0;
  border-radius: 10px;
  border: 1px solid #c8e6c9;
}

.tool-card-heading {
  flex: 1;
  min-width: 0;
}

.tool-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 3px;
  line-height: 1.3;
}

.tool-card-subtitle {
  font-size: 0.82rem;
  color: var(--text-light);
  margin: 0;
  line-height: 1.4;
}

.tool-card-desc {
  font-size: 0.82rem;
  color: #555;
  line-height: 1.7;
  margin: 8px 0 16px;
}

.tool-card-body .random-input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  justify-content: flex-start;
}

.tool-input-group {
  flex: 1 1 auto;
  min-width: 0;
}

.tool-input-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

.tool-input-inline {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tool-input-inline .form-input {
  flex: 1;
  min-width: 0;
}

.tool-input-unit {
  font-size: 0.85rem;
  color: var(--text-light);
  white-space: nowrap;
}

.tool-card-hint {
  font-size: 0.72rem;
  color: var(--text-light);
  text-align: center;
  margin: 8px 0 0;
}

/* === SEO Content === */
.seo-content {
  max-width: 600px;
  margin: 24px auto;
  padding: 0 16px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.8rem;
  line-height: 1.7;
}
.seo-content details {
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.seo-content summary {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.seo-content summary::-webkit-details-marker { display: none; }
.seo-content summary::after {
  content: '\25BC';
  font-size: 0.6rem;
  transition: transform 0.2s;
  opacity: 0.5;
}
.seo-content details[open] summary::after {
  transform: rotate(180deg);
}
.seo-content-body {
  padding: 0 14px 14px;
}
.seo-content h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 12px 0 4px;
  color: rgba(255, 255, 255, 0.85);
}
.seo-content ul,
.seo-content ol {
  padding-left: 20px;
  margin-bottom: 8px;
}
.seo-content li {
  margin-bottom: 3px;
}
.seo-content p {
  margin-bottom: 6px;
}

/* === Viral CTA === */
.cta-viral {
  text-align: center;
  background: linear-gradient(135deg, #f0faf0, #e8f5e9);
  border: 2px solid #a5d6a7;
  margin-top: 16px;
}
.cta-viral-icon {
  font-size: 2rem;
  margin-bottom: 4px;
}
.cta-viral-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.cta-viral-desc {
  font-size: 0.82rem;
  color: #666;
  line-height: 1.7;
  margin-bottom: 16px;
}

/* === Promotion Banner === */
.promo-banner {
  max-width: 640px;
  margin: 24px auto 0;
  padding: 0 16px;
  position: relative;
  z-index: 1;
}

.promo-link {
  display: block;
  text-decoration: none;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.15s;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  aspect-ratio: 16 / 6;
  min-height: 120px;
}

.promo-link:hover {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
}

.promo-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
}

.promo-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(10, 10, 30, 0.75) 0%, rgba(10, 10, 30, 0.3) 50%, rgba(10, 10, 30, 0.6) 100%);
}

.promo-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  height: 100%;
  padding: 16px 20px;
  gap: 6px;
}

.promo-label {
  font-size: 0.55rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 3px;
  padding: 1px 6px;
  letter-spacing: 0.08em;
}

.promo-text {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.promo-title {
  font-size: 1.1rem;
  font-weight: 300;
  color: #fff;
  letter-spacing: 0.15em;
  font-family: 'Georgia', 'Times New Roman', serif;
}

.promo-subtitle {
  font-size: 0.85rem;
  font-weight: 600;
  color: #d4af37;
  letter-spacing: 0.05em;
}

.promo-tags {
  display: flex;
  gap: 6px;
}

.promo-tag {
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.12);
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.05em;
  backdrop-filter: blur(4px);
}

.promo-cta {
  font-size: 0.65rem;
  color: #d4af37;
  letter-spacing: 0.12em;
  font-weight: 600;
  margin-top: 2px;
}

@media (max-width: 480px) {
  .promo-link {
    aspect-ratio: 16 / 7;
  }
  .promo-title {
    font-size: 0.95rem;
  }
  .promo-subtitle {
    font-size: 0.75rem;
  }
}

/* ============================================
   自分の回答ハイライト
   ============================================ */
.my-answer-row > td {
  background: #F2F8F2 !important;
}
.my-answer-row > td:first-child {
  background: #EDF5ED !important;
  color: var(--text) !important;
  border-left: 3px solid var(--primary);
}
.my-answer-col {
  background: #F2F8F2 !important;
}
thead .my-answer-col {
  background: #E8F0E8 !important;
  border-bottom: 3px solid var(--primary);
}

/* ============================================
   日程フィルタボタン
   ============================================ */
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.filter-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 16px;
  border: 1px solid #ddd;
  background: #fff;
  color: #666;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.filter-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.filter-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.past-dates-toggle {
  display: block;
  width: 100%;
  padding: 6px;
  background: #f5f5f5;
  border: none;
  border-radius: 4px;
  color: #888;
  font-size: 0.78rem;
  cursor: pointer;
  text-align: center;
  margin: 4px 0;
}
.past-dates-toggle:hover {
  background: #eee;
}

/* ============================================
   日程複製ボタン
   ============================================ */
.date-manage-copy {
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.7rem;
  padding: 2px 6px;
  color: #2E7D32;
}
.date-manage-copy:hover {
  background: #c8e6c9;
}

/* ============================================
   コート名チップ
   ============================================ */
.court-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.court-chip {
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 2px 10px;
  color: #555;
  white-space: nowrap;
}
.court-chip:hover {
  background: #e8f5e9;
  border-color: #a5d6a7;
  color: #2E7D32;
}

/* === Site Footer === */
.site-footer {
  max-width: 640px;
  margin: 32px auto 0;
  padding: 16px 16px 24px;
  text-align: center;
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.7rem;
  line-height: 1.8;
}

.site-footer a {
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
}

.site-footer a:hover {
  color: rgba(255, 255, 255, 0.8);
  text-decoration: underline;
}

/* === Privacy Policy === */
.privacy-page {
  padding: 0 !important;
  overflow: hidden;
}

.privacy-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  padding: 28px 24px 20px;
}

.privacy-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: 0.03em;
}

.privacy-lead {
  font-size: 0.8rem;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.85);
}

.privacy-content {
  padding: 8px 24px 24px;
}

.privacy-section {
  padding: 16px 0;
  border-bottom: 1px solid #f0f0f0;
}

.privacy-section:last-of-type {
  border-bottom: none;
}

.privacy-content h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #222;
}

.section-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.privacy-content p,
.privacy-content ul,
.privacy-content li {
  font-size: 0.83rem;
  line-height: 1.75;
  color: #555;
}

.privacy-content ul {
  padding-left: 1.2em;
  margin: 8px 0;
}

.privacy-content li {
  margin-bottom: 4px;
}

.privacy-content a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.privacy-info-box {
  background: #f8faf8;
  border-radius: 8px;
  padding: 12px 16px;
  margin: 10px 0;
}

.info-item {
  display: flex;
  gap: 8px;
  padding: 6px 0;
}

.info-item + .info-item {
  border-top: 1px solid #e8ece8;
}

.info-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #333;
  min-width: 6em;
  flex-shrink: 0;
}

.info-value {
  font-size: 0.8rem;
  color: #555;
}

.privacy-note {
  font-size: 0.78rem !important;
  color: #888 !important;
  margin-top: 8px;
}

.privacy-ref {
  font-size: 0.78rem !important;
  margin-top: 6px;
}

.privacy-legal-ref {
  font-size: 0.72rem !important;
  color: #999 !important;
  background: #f5f5f5;
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 10px;
}

.privacy-ext-card {
  background: #f8faf8;
  border: 1px solid #e0e8e0;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 10px 0;
}

.ext-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.ext-card-icon {
  font-size: 1.3rem;
}

.ext-card-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #333;
}

.ext-card-desc {
  font-size: 0.75rem;
  color: #888;
}

.ext-card-data {
  font-size: 0.8rem;
  color: #555;
  padding-top: 8px;
  border-top: 1px solid #e8ece8;
}

.ext-data-label {
  font-weight: 600;
  color: #666;
}

.privacy-security-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.security-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8faf8;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.83rem;
  color: #444;
}

.security-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.privacy-contact-box {
  background: #f8faf8;
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 10px;
  text-align: center;
}

.contact-company {
  font-size: 0.85rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
}

.contact-email {
  font-size: 0.83rem;
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.privacy-footer-meta {
  text-align: right;
  font-size: 0.72rem;
  color: #bbb;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #f0f0f0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
