/* Player detail modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--modal-backdrop);
  backdrop-filter: blur(8px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  max-width: 700px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 32px;
  box-shadow: light-dark(0 25px 60px rgba(0, 0, 0, 0.15), 0 25px 60px rgba(0, 0, 0, 0.5));
  position: relative;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--overlay-hover);
  background: var(--overlay-faint);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--overlay-hover);
  color: var(--text-primary);
}

.modal h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--accent-gold);
}

.modal-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
}

.modal-year-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.modal-year-pill {
  background: var(--overlay-faint);
  border: 1px solid var(--overlay-medium);
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
}

.modal-year-pill:hover {
  background: var(--overlay-medium);
  color: var(--text-primary);
}

.modal-year-pill.active {
  background: light-dark(rgba(37, 99, 235, 0.15), rgba(59, 130, 246, 0.15));
  border-color: light-dark(rgba(37, 99, 235, 0.35), rgba(59, 130, 246, 0.35));
  color: var(--accent-blue);
}

.modal-year-pill:last-child.active {
  background: light-dark(rgba(217, 119, 6, 0.15), rgba(245, 158, 11, 0.15));
  border-color: light-dark(rgba(217, 119, 6, 0.3), rgba(245, 158, 11, 0.3));
  color: var(--accent-gold);
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.modal-stat {
  background: var(--overlay-weak);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.modal-stat .ms-val {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 2px;
}

.modal-stat .ms-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-chart {
  width: 100%;
  height: 250px;
}

/* Upload modal */
.upload-drop-zone {
  border: 2px dashed var(--border-card);
  border-radius: var(--radius-sm);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  margin: 20px 0 16px;
  background: var(--overlay-weak);
}

.upload-drop-zone:hover,
.upload-drop-zone.drag-over {
  border-color: var(--accent-gold);
  background: var(--glow-gold);
}

.upload-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.7;
}

.upload-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.upload-subtext {
  font-size: 12px;
  color: var(--text-muted);
}

.upload-status {
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  min-height: 20px;
}

.upload-status:empty {
  display: none;
}

.upload-status.loading {
  color: var(--accent-blue);
  background: light-dark(rgba(37, 99, 235, 0.1), rgba(59, 130, 246, 0.1));
}

.upload-status.success {
  color: var(--accent-emerald);
  background: light-dark(rgba(5, 150, 105, 0.1), rgba(16, 185, 129, 0.1));
}

.upload-status.error {
  color: var(--accent-rose);
  background: light-dark(rgba(225, 29, 72, 0.1), rgba(244, 63, 94, 0.1));
}

.upload-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.upload-btn {
  flex: 1;
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--border-card);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-btn-apply {
  background: var(--accent-gold);
  color: light-dark(#fff, #000);
  border-color: var(--accent-gold);
}

.upload-btn-apply:hover {
  background: var(--accent-gold-light);
}

.upload-btn-cancel {
  background: var(--overlay-faint);
  color: var(--text-secondary);
}

.upload-btn-cancel:hover {
  background: var(--overlay-medium);
}

.export-actions {
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 8px;
  background: light-dark(rgba(217, 119, 6, 0.08), rgba(250, 204, 21, 0.08));
  border: 1px solid light-dark(rgba(217, 119, 6, 0.2), rgba(250, 204, 21, 0.2));
}

.export-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-align: center;
}

.publish-btn {
  background: #238636 !important;
  color: #fff !important;
  border-color: #238636 !important;
  font-size: 13px !important;
  padding: 10px 12px !important;
}

.publish-btn:hover {
  background: #2ea043 !important;
}

.publish-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.publish-status {
  font-size: 12px;
  text-align: center;
  margin-top: 8px;
  min-height: 16px;
}

.publish-status.success { color: var(--accent-emerald); }
.publish-status.error { color: var(--accent-rose); }
.publish-status.loading { color: var(--text-secondary); }

.github-settings {
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--overlay-faint);
  border: 1px solid var(--border-card);
}

.github-settings-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.github-settings-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11px;
}

.github-label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  margin-top: 8px;
}

.github-input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-card);
  background: var(--overlay-faint);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  box-sizing: border-box;
}

.github-input:focus {
  outline: none;
  border-color: var(--accent-gold);
}

.upload-reset {
  text-align: center;
  padding-top: 8px;
}

.upload-reset a {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
}

.upload-reset a:hover {
  color: var(--accent-gold);
  text-decoration: underline;
}

/* Loading overlay & error states */
.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: light-dark(rgba(255,255,255,0.9), rgba(15,23,42,0.9));
  gap: 1rem;
}
.loading-spinner {
  width: 48px; height: 48px;
  border: 4px solid light-dark(#e2e8f0, #334155);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  color: light-dark(#475569, #94a3b8);
  font-size: 1.1rem;
}
.data-error {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: light-dark(rgba(255,255,255,0.95), rgba(15,23,42,0.95));
  gap: 1rem;
  text-align: center;
  padding: 2rem;
}
.data-error-icon { font-size: 3rem; }
.data-error-message {
  color: light-dark(#475569, #94a3b8);
  font-size: 1.1rem;
  max-width: 400px;
}

/* Modal trend chart */
.modal-trend {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--overlay-medium);
}

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

.modal-trend-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.modal-trend-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.modal-trend-canvas {
  width: 100%;
  height: 220px;
}

/* Modal responsive */
@media (max-width: 768px) {
  .modal-overlay { padding: 12px; }
  .modal {
    padding: 24px 16px;
    max-height: 90vh;
    border-radius: 12px;
  }
  .modal h2 { font-size: 1.3rem; padding-right: 32px; }
  .modal-stats { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .modal-stat { padding: 12px 8px; }
  .modal-stat .ms-val { font-size: 1.1rem; }
  .modal-chart { height: 200px; }
  .modal-trend-canvas { height: 180px; }
  .modal-trend-controls { font-size: 11px; }
  .modal-year-toggle { flex-wrap: wrap; gap: 4px; }
  .modal-year-pill { padding: 3px 10px; font-size: 11px; }
  .upload-drop-zone { padding: 28px 16px; }
}

@media (max-width: 480px) {
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    padding: 20px 14px;
  }
  .modal h2 { font-size: 1.2rem; }
  .modal-stat .ms-val { font-size: 1rem; }
  .modal-stat .ms-label { font-size: 10px; }
  .modal-chart { height: 180px; }
  .modal-trend-canvas { height: 160px; }
  .upload-drop-zone { padding: 24px 12px; }
  .upload-icon { font-size: 32px; }
}
