:root {
  --bg-dark: #0f111a;
  --bg-card: #1a1d2e;
  --bg-sub: #141724;
  --border: #2d3356;
  --text-main: #e0e0e0;
  --text-dim: #888;
  --primary: #00d2ff;
  --secondary: #bc00ff;
  --gold: #ffcc00;
  --red: #ff4d4d;
}

body.dark-mode {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Pretendard', sans-serif;
  margin: 0;
  padding: 0;
}

/* Home Navigation Button */
.home-nav { margin-bottom: 25px; text-align: left; }
.home-link {
  text-decoration: none; font-size: 13px; font-weight: bold; color: var(--gold);
  background: rgba(255, 204, 0, 0.05); border: 1px solid rgba(255, 204, 0, 0.2);
  padding: 8px 16px; border-radius: 10px; transition: all 0.2s;
  display: inline-flex; align-items: center; gap: 6px;
}
.home-link:hover { background: rgba(255, 204, 0, 0.1); transform: translateX(-3px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }

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

.hidden { display: none !important; }

/* Global Loading UI */
#loading {
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}
#loading p { color: var(--primary); font-weight: 500; }
.spinner {
  width: 40px; height: 40px; border: 4px solid rgba(0, 210, 255, 0.1); border-left-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Shared Modal Styles */
.modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); 
  display: flex; justify-content: center; align-items: center; z-index: 1000; backdrop-filter: blur(5px);
}
.modal-content {
  background: var(--bg-card); padding: 30px; border-radius: 12px; border: 1px solid var(--border); 
  width: 95%; max-width: 450px; max-height: 90vh; overflow-y: auto; text-align: center; position: relative; 
  box-shadow: 0 20px 50px rgba(0,0,0,0.5); display: flex; flex-direction: column;
}
.balancer-modal {
  max-width: 1000px !important;
  max-height: 95vh !important;
}
.modal-content h3 { margin-top: 0; color: #fff; }
.modal-content input {
  width: 100%; padding: 12px; background: var(--bg-sub); border: 1px solid var(--border); border-radius: 6px; 
  color: white; margin: 15px 0; box-sizing: border-box; font-size: 16px;
}
.modal-btns { display: flex; gap: 10px; margin-top: 20px; }
.modal-btns button { flex: 1; padding: 12px; border-radius: 6px; border: none; font-weight: bold; cursor: pointer; }
.modal-btns button.primary { background: var(--primary); color: #000; }

/* Main Search Section */
.search-section { text-align: center; padding: 50px 0; border-bottom: 1px solid #1f2233; }
.search-bar { display: flex; justify-content: center; gap: 10px; margin-top: 20px; }
.search-bar input { padding: 12px 20px; width: 300px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; color: white; font-size: 16px; }
.search-btns { display: flex; gap: 8px; }
.search-bar button { padding: 12px 25px; background: var(--primary); border: none; border-radius: 8px; color: #0f111a; font-weight: bold; cursor: pointer; transition: all 0.2s; }
.search-bar .compare-btn { background: var(--secondary); color: #fff; }
.search-bar button:hover { opacity: 0.9; transform: translateY(-1px); }

/* Recent Searches Chips */
.recent-searches {
  margin-top: 15px; display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 35px;
}
.recent-searches span { color: #666; font-size: 13px; }
.search-chip {
  background: var(--bg-card); border: 1px solid var(--border); color: #aaa; padding: 5px 12px; border-radius: 20px; font-size: 13px; cursor: pointer; transition: all 0.2s;
}
.search-chip:hover { background: var(--border); color: var(--primary); border-color: var(--primary); }

/* VS Mode Container */
.vs-container { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 30px; }
.vs-header-banner {
  background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
  padding: 15px; text-align: center; border-radius: 12px; margin-bottom: 20px; font-weight: 900; color: #fff; text-transform: uppercase; letter-spacing: 2px;
}
@media (max-width: 850px) { .vs-container { grid-template-columns: 1fr; } }

/* Common Helper Classes */
.clickable-name { cursor: pointer; transition: color 0.2s; }
.clickable-name:hover { color: var(--primary); text-decoration: underline; }
.sub-btn { background: var(--bg-card); border: 1px solid var(--border); color: var(--text-dim); padding: 8px 16px; border-radius: 6px; font-size: 13px; cursor: pointer; transition: all 0.2s; }
.sub-btn:hover { background: var(--border); color: #fff; }

/* Admin Panel UI */
.admin-section {
  background: var(--bg-card); border: 1px solid var(--gold); border-radius: 12px; padding: 25px; margin: 20px 0; box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}
.admin-section h2 { margin-top: 0; color: var(--gold); margin-bottom: 20px; }
.admin-actions-bar { display: flex; flex-direction: column; gap: 20px; margin-top: 20px; padding-top: 20px; border-top: 1px solid rgba(255,204,0,0.2); }

.admin-main-btns { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.admin-sub-btns { display: flex; gap: 10px; margin-top: 10px; }

.settle-btn {
  background: var(--gold); color: #000; border: none; padding: 12px 24px; border-radius: 8px; 
  font-weight: 900; cursor: pointer; transition: all 0.2s; font-size: 14px;
}
.settle-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(255, 204, 0, 0.3); }
.settle-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.season-date-setter { 
  display: flex; align-items: center; gap: 10px; background: rgba(255, 204, 0, 0.05); 
  padding: 8px 15px; border-radius: 8px; border: 1px solid rgba(255, 204, 0, 0.2); 
}
.season-date-setter label { font-size: 13px; font-weight: bold; color: var(--gold); white-space: nowrap; }
.season-date-setter input[type="date"] { 
  background: var(--bg-dark); border: 1px solid #333; color: #fff; padding: 5px 10px; 
  border-radius: 4px; font-size: 13px; outline: none; 
}

.admin-reset-btn { border-color: #ff4d4d !important; color: #ff4d4d !important; margin-left: auto; }
.repair-btn { border-color: #00bcd4 !important; color: #00bcd4 !important; }

.admin-member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 15px; margin-top: 20px; }
.admin-member-item { 
  background: var(--bg-sub); border: 1px solid var(--border); padding: 18px; border-radius: 12px; 
  display: flex; flex-direction: column; gap: 12px; transition: border-color 0.2s;
}
.admin-member-item:hover { border-color: var(--gold); }
.admin-member-item .m-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(255,255,255,0.03); padding-bottom: 10px; }
.admin-member-item .m-name { font-weight: bold; font-size: 16px; }
.admin-member-item .m-score { font-family: 'Roboto Mono', monospace; font-size: 14px; color: var(--gold); }
.admin-member-item .m-stats { font-size: 13px; color: var(--text-dim); }
.admin-member-item .m-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.mini-btn { 
  padding: 10px; border-radius: 6px; font-size: 12px; font-weight: bold; cursor: pointer; 
  border: 1px solid transparent; transition: all 0.2s; display: flex; align-items: center; justify-content: center; 
}
.mini-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.individual-scan-btn { background: rgba(0, 210, 255, 0.1); color: var(--primary); border-color: rgba(0, 210, 255, 0.2); grid-column: 1 / -1; font-size: 13px; }
.update-name-btn { background: #2d3356; color: #fff; }
.delete-member-btn { background: rgba(255, 77, 77, 0.1); color: #ff4d4d; border-color: rgba(255, 77, 77, 0.2); }

.admin-hint { font-size: 12px; color: var(--text-dim); font-style: italic; margin-top: 20px; }
.history-section h2 { margin-top: 40px; margin-bottom: 20px; }

/* Team Balancer UI (Inside Modal) */
.balancer-modal {
  max-width: 1000px !important;
  max-height: 95vh !important;
}
.balancer-search-input {
  width: 100%; padding: 12px 20px; margin-bottom: 15px; border: 1px solid var(--border); border-radius: 8px; 
  background: var(--bg-dark); color: var(--text-main); font-size: 15px; outline: none; box-sizing: border-box;
}
.selected-count-display {
  color: var(--gold); font-size: 15px; font-weight: bold; margin-bottom: 15px; text-align: right;
}
.balancer-member-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 20px 0; 
  max-height: 450px; overflow-y: auto; padding: 15px; background: var(--bg-sub); border-radius: 12px; border: 1px solid var(--border);
}
.balancer-item {
  display: flex; align-items: center; gap: 12px; padding: 12px; background: #1c2031; border-radius: 10px; 
  cursor: pointer; transition: all 0.2s; border: 1px solid transparent;
}
.balancer-item:hover { background: var(--border); border-color: rgba(0, 210, 255, 0.3); }
.balancer-item.selected { background: rgba(0, 210, 255, 0.1); border-color: var(--primary); }
.balancer-item input[type="checkbox"] { margin: 0; width: 18px; height: 18px; cursor: pointer; }
.balancer-item .m-name { font-size: 14px; color: #fff; font-weight: 600; flex: 1; text-align: left; }
.balancer-item .m-mmr { color: var(--text-dim); font-size: 11px; margin-right: 10px; }

.pos-select { display: flex; gap: 5px; background: rgba(0,0,0,0.2); padding: 3px; border-radius: 20px; }
.pos-select input[type="radio"] { display: none; }
.pos-select label { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 50%; font-size: 14px; transition: all 0.2s; filter: grayscale(1); opacity: 0.5; }
.pos-select input[type="radio"]:checked + label { filter: grayscale(0); opacity: 1; background: var(--border); }

@media (max-width: 768px) {
  .sa-container { padding: 0 15px; }
  .search-bar { flex-direction: column; align-items: center; }
  .search-bar input { width: 100%; max-width: 400px; }
}
