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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f7fa;
  color: #333;
  min-height: 100vh;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  padding: 40px 0 30px;
}

header h1 {
  font-size: 28px;
  color: #1a1a2e;
}

.subtitle {
  color: #888;
  font-size: 14px;
  margin-top: 4px;
}

.user-bar {
  margin-top: 12px;
  font-size: 14px;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Main Menu */
.main-menu {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 20px;
}

.menu-card {
  background: #fff;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.menu-card:hover {
  border-color: #4a90d9;
  box-shadow: 0 4px 12px rgba(74, 144, 217, 0.15);
  transform: translateY(-2px);
}

.menu-card.public { border-color: #4caf50; }
.menu-card.public:hover { border-color: #2e7d32; box-shadow: 0 4px 12px rgba(76, 175, 80, 0.15); }

.menu-icon { font-size: 48px; margin-bottom: 12px; }

.menu-card h2 { font-size: 18px; margin-bottom: 8px; }

.menu-card p { font-size: 13px; color: #888; margin-bottom: 12px; }

.lock { font-size: 12px; color: #e67e22; }
.open { font-size: 12px; color: #4caf50; font-weight: 600; }

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 30px;
  width: 360px;
  max-width: 90vw;
}

.modal h3 {
  margin-bottom: 20px;
  text-align: center;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: #555;
}

.form-group input, .form-row input, .form-row select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.form-group input:focus, .form-row input:focus {
  outline: none;
  border-color: #4a90d9;
}

.error {
  color: #e74c3c;
  font-size: 13px;
  margin-bottom: 10px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}

.btn:hover { background: #f0f0f0; }

.btn-primary {
  background: #4a90d9;
  color: #fff;
  border-color: #4a90d9;
  flex: 1;
}

.btn-primary:hover { background: #357abd; }

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

.btn-danger { color: #e74c3c; border-color: #e74c3c; }
.btn-danger:hover { background: #fde8e8; }

.btn-back { font-size: 14px; }

/* Badge */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: #e8f0fe;
  color: #4a90d9;
}

/* Page Header */
.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-top: 10px;
}

.page-header h2 { font-size: 22px; }

/* League Cards */
.league-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.league-card {
  display: block;
  background: #fff;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  padding: 24px 16px;
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
}

.league-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.league-card h3 { font-size: 17px; margin-bottom: 6px; }
.league-card p { font-size: 12px; color: #888; }

.league-card.elementary { border-left: 4px solid #4caf50; }
.league-card.university { border-left: 4px solid #2196f3; }
.league-card.ktta { border-left: 4px solid #ff9800; }

/* Notice */
.notice {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  color: #856404;
}

/* Admin Table */
.admin-section { margin-top: 10px; }
.admin-section h3 { margin: 20px 0 10px; font-size: 16px; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
}

.admin-table th, .admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  text-align: left;
  font-size: 14px;
}

.admin-table th { background: #f8f9fa; font-weight: 600; font-size: 13px; }

.form-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.form-row input, .form-row select {
  width: auto;
  flex: 1;
  min-width: 100px;
}

/* Tournament List */
.tournament-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tournament-item {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 10px;
  padding: 16px 20px;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s;
}

.tournament-item:hover {
  border-color: #4a90d9;
  box-shadow: 0 2px 8px rgba(74, 144, 217, 0.1);
}

.t-status {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  min-width: 52px;
}

.t-status.completed { background: #e8f5e9; color: #2e7d32; }
.t-status.in_progress { background: #fff3e0; color: #e65100; }
.t-status.upcoming { background: #e3f2fd; color: #1565c0; }

.t-info { flex: 1; }
.t-info h4 { font-size: 16px; margin-bottom: 4px; }
.t-meta { font-size: 13px; color: #888; }
.t-desc { font-size: 12px; color: #aaa; margin-top: 4px; }

.t-arrow { font-size: 20px; color: #ccc; flex-shrink: 0; }

.page-header.sub { margin-bottom: 16px; }
.page-header.sub h3 { font-size: 18px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 2px solid #e0e0e0;
  padding-bottom: 0;
}

.tabs button {
  padding: 10px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  color: #888;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}

.tabs button.active { color: #4a90d9; border-bottom-color: #4a90d9; }

/* Category & Group Selectors */
.category-selector, .group-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.cat-btn, .grp-btn {
  padding: 6px 14px;
  border: 1px solid #ddd;
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

.cat-btn.active { background: #4a90d9; color: #fff; border-color: #4a90d9; }
.grp-btn.active { background: #2e7d32; color: #fff; border-color: #2e7d32; }

/* Data Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
  font-size: 14px;
}

.data-table th, .data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #eee;
  text-align: center;
}

.data-table th { background: #f8f9fa; font-weight: 600; font-size: 12px; color: #666; }
.data-table td:nth-child(3), .data-table td:nth-child(4) { text-align: left; }

.data-table.compact td { padding: 6px 8px; font-size: 13px; }

.team-label { display: block; font-size: 11px; color: #999; }
.winner-name { color: #2e7d32; font-weight: 600; }
.section-title { font-size: 16px; margin: 20px 0 10px; }

tr.qualified { background: #f0f9f0; }

/* Bracket Display (세로 배열) */
.bracket-round { margin-bottom: 24px; }
.round-title { font-size: 16px; margin-bottom: 10px; color: #4a90d9; }

.bracket-matches {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.match-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.match-card.completed { border-left: 3px solid #4caf50; }

.match-num { font-size: 11px; color: #aaa; min-width: 28px; }

.match-player {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.match-player.winner .p-name { font-weight: 700; color: #2e7d32; }

.p-name { font-size: 14px; }
.p-team { font-size: 11px; color: #999; }
.p-score { font-size: 14px; font-weight: 700; margin-left: auto; min-width: 16px; text-align: center; }
.match-vs { font-size: 11px; color: #ccc; }
.match-reason { font-size: 11px; color: #e67e22; }

.champion-box {
  background: #fff8e1;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 15px;
}

.champion-box strong { color: #e65100; }

/* Ranking Group */
.ranking-group { margin-bottom: 20px; }
.ranking-group h4 { font-size: 14px; margin-bottom: 6px; color: #555; }

/* Responsive */
@media (max-width: 640px) {
  .main-menu, .league-cards { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .form-row input, .form-row select { width: 100%; }
}
