:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #0f172a;
  --soft: #f1f5f9;
  --soft-2: #e2e8f0;
  --accent: #111827;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --radius: 18px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.2;
}

.subtitle {
  color: var(--muted);
  margin-top: 8px;
  font-size: 14px;
}

.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 14px;
  transition: 0.15s ease;
}
.btn:hover { background: #f8fafc; }
.btn.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn.success {
  background: #047857;
  color: white;
  border-color: #047857;
}
.btn.success:hover {
  background: #065f46;
  border-color: #065f46;
}
.btn.icon {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.save-message {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
  min-height: 18px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 18px;
}
.stat-label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; }

.main {
  display: grid;
  grid-template-columns: 1.45fr 0.95fr;
  gap: 22px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
}

.badge {
  background: var(--soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  white-space: nowrap;
}

.court-list, .participant-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.court-card-header, .panel-header {
  padding: 18px 18px 0 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.court-card-body, .panel-body {
  padding: 18px;
}

.court-subtitle, .helper {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.court-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.slot {
  border: 1px solid var(--border);
  background: white;
  border-radius: 16px;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: 0.15s ease;
}
.slot:hover { background: #f8fafc; }
.slot.active {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}
.slot.empty { color: #94a3b8; }
.slot-player { font-weight: 600; }
.slot-remove {
  color: #94a3b8;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
}
.slot-remove:hover { color: var(--danger); }

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

textarea, input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: white;
}
textarea:focus, input:focus { border-color: #94a3b8; }

.participant-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
}

.participant-main {
  border: 1px solid var(--border);
  background: white;
  border-radius: 16px;
  padding: 12px 14px;
  cursor: pointer;
  transition: 0.15s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.participant-main:hover { background: #f8fafc; }
.participant-main.selected {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.participant-main.placed:not(.selected) {
  background: #f1f5f9;
  color: #64748b;
}
.participant-meta { min-width: 0; }
.participant-count {
  font-size: 12px;
  opacity: 0.8;
  margin-bottom: 4px;
}
.participant-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.placed-badge {
  font-size: 12px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  border-radius: 999px;
  padding: 5px 10px;
  white-space: nowrap;
}
.participant-main.selected .placed-badge {
  background: rgba(255,255,255,0.12);
  color: white;
  border-color: rgba(255,255,255,0.25);
}

.empty-text {
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .stats { grid-template-columns: 1fr; }
  .court-grid { grid-template-columns: 1fr; }
  .participant-item { grid-template-columns: 1fr auto auto auto; }
  h1 { font-size: 28px; }
}
