@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-dark: #0a0d14;
  --bg-panel: rgba(18, 24, 38, 0.75);
  --bg-panel-solid: #121826;
  --bg-panel-light: rgba(30, 39, 61, 0.5);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(0, 229, 255, 0.2);
  
  --color-primary: #00e5ff; /* Cyan */
  --color-secondary: #c51162; /* Neon Pink/Rose */
  --color-accent: #7c4dff; /* Purple */
  --color-success: #00e676; /* Green */
  --color-warning: #ffd600; /* Yellow */
  --color-danger: #ff1744; /* Red */
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dark: #475569;
  
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 15px rgba(0, 229, 255, 0.15);
}

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

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, rgba(124, 77, 255, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(0, 229, 255, 0.08) 0px, transparent 50%),
    radial-gradient(at 50% 0%, rgba(197, 17, 98, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #000;
  box-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
}

.brand-title h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 1px;
  background: linear-gradient(to right, #fff, var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-title span {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--color-primary);
  letter-spacing: 2px;
  font-weight: 600;
}

.system-status {
  text-align: right;
}

.time-display {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--color-primary);
}

.r4-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid var(--color-primary);
  color: var(--color-primary);
  border-radius: 4px;
  margin-top: 0.25rem;
}

/* Tabs Navigation */
.tabs-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  background: var(--bg-panel-light);
  padding: 0.35rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  width: fit-content;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.75rem 1.5rem;
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
  color: #000;
  background: var(--color-primary);
  box-shadow: 0 0 15px rgba(0, 229, 255, 0.3);
}

/* Tab Content Visibility */
.tab-content {
  display: none;
  animation: fadeIn 0.4s ease;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Glassmorphism Panel */
.panel {
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.panel-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-title span {
  color: var(--color-primary);
}

/* Form Styles */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-control {
  background: rgba(10, 13, 20, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-family: var(--font-family);
  font-size: 0.9rem;
  transition: var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.2);
}

/* Buttons */
.btn {
  background: var(--bg-panel-light);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  color: #000;
  border: none;
  font-weight: 700;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(0, 229, 255, 0.3);
}

.btn-secondary {
  background: rgba(124, 77, 255, 0.15);
  border: 1px solid rgba(124, 77, 255, 0.3);
  color: #d1c4e9;
}

.btn-secondary:hover {
  background: rgba(124, 77, 255, 0.25);
  color: #fff;
}

.btn-success {
  background: rgba(0, 230, 118, 0.15);
  border: 1px solid rgba(0, 230, 118, 0.3);
  color: #b9f6ca;
}

.btn-success:hover {
  background: rgba(0, 230, 118, 0.25);
}

.btn-danger {
  background: rgba(255, 23, 68, 0.15);
  border: 1px solid rgba(255, 23, 68, 0.3);
  color: #ff8a80;
}

.btn-danger:hover {
  background: rgba(255, 23, 68, 0.25);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

/* Time Slot Selection Buttons (Multiple Choices) */
.time-slots-container {
  display: flex;
  gap: 0.5rem;
}

.time-slot-btn {
  flex: 1;
  background: rgba(10, 13, 20, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition-fast);
  text-align: center;
}

.time-slot-btn.selected {
  background: rgba(0, 229, 255, 0.1);
  border-color: var(--color-primary);
  color: var(--color-primary);
  font-weight: 600;
}

/* Database Table Styles */
.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  background: var(--bg-panel-light);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
  color: var(--text-main);
  background: rgba(18, 24, 38, 0.3);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.sortable {
  cursor: pointer;
  user-select: none;
}

.sortable::after {
  content: ' ↕';
  font-size: 0.75rem;
  color: var(--text-muted);
}

.vote-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 4px;
  margin-right: 0.25rem;
  margin-bottom: 0.25rem;
}

.badge-9 {
  background: rgba(124, 77, 255, 0.15);
  color: #b388ff;
  border: 1px solid rgba(124, 77, 255, 0.3);
}

.badge-18 {
  background: rgba(0, 229, 255, 0.15);
  color: #84ffff;
  border: 1px solid rgba(0, 229, 255, 0.3);
}

.badge-23 {
  background: rgba(197, 17, 98, 0.15);
  color: #ff80ab;
  border: 1px solid rgba(197, 17, 98, 0.3);
}

/* Matchmaker Setup Banner Layout (Wide) */
.matchmaker-setup-panel {
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.setup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .setup-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}

.setup-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Matchmaker Workspace (3 Columns) */
.matchmaker-board {
  display: grid;
  grid-template-columns: 320px 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .matchmaker-board {
    grid-template-columns: 1fr;
  }
}

/* Filter controls inside Matchmaker */
.filter-card {
  background: rgba(30, 39, 61, 0.35);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
}

.filter-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Player Pool Selection List (Vertical) */
.player-pool-list {
  max-height: 500px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-right: 0.25rem;
}

.pool-player-card {
  background: rgba(10, 13, 20, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition-fast);
  cursor: grab;
}

.pool-player-card:hover {
  border-color: rgba(0, 229, 255, 0.3);
  background: rgba(0, 229, 255, 0.02);
}

.pool-player-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.pool-player-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.pool-player-stats {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.5rem;
}

.pool-player-stats span strong {
  color: var(--text-main);
}

.pool-player-actions {
  display: flex;
  gap: 0.35rem;
}

/* Teams Columns */
.teams-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .teams-container {
    grid-template-columns: 1fr;
  }
}

.team-panel {
  display: flex;
  flex-direction: column;
  min-height: 400px;
}

.team-header-1 {
  background: linear-gradient(to right, rgba(0, 229, 255, 0.15), transparent);
  border-left: 4px solid var(--color-primary);
}

.team-header-2 {
  background: linear-gradient(to right, rgba(124, 77, 255, 0.15), transparent);
  border-left: 4px solid var(--color-accent);
}

.team-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  background: rgba(10, 13, 20, 0.3);
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
  text-align: center;
}

.team-summary-item {
  display: flex;
  flex-direction: column;
}

.team-summary-label {
  color: var(--text-muted);
}

.team-summary-val {
  font-weight: 700;
  color: var(--text-main);
  font-size: 0.9rem;
}

.team-players-list {
  flex-grow: 1;
  background: rgba(10, 13, 20, 0.2);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 500px;
  overflow-y: auto;
}

.team-player-row {
  background: var(--bg-panel-light);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.team-player-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.team-player-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* History Cards styling */
.history-timeline {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.history-card {
  position: relative;
  overflow: hidden;
}

.history-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(to bottom, var(--color-primary), var(--color-accent));
}

.history-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border-color);
}

.history-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.history-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.history-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .history-details-grid {
    grid-template-columns: 1fr;
  }
}

.history-team-col h4 {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.history-team-summary {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(10, 13, 20, 0.4);
  padding: 0.4rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.history-team-summary span {
  margin-right: 0.75rem;
}

.history-team-summary strong {
  color: var(--text-main);
}

.history-team-players {
  font-size: 0.85rem;
  color: var(--text-main);
  line-height: 1.6;
}

.result-tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 4px;
  text-transform: uppercase;
}

.result-win-1 {
  background: rgba(0, 230, 118, 0.15);
  color: #00e676;
  border: 1px solid rgba(0, 230, 118, 0.3);
}

.result-win-2 {
  background: rgba(124, 77, 255, 0.15);
  color: #b388ff;
  border: 1px solid rgba(124, 77, 255, 0.3);
}

.result-draw {
  background: rgba(255, 214, 0, 0.15);
  color: #ffd600;
  border: 1px solid rgba(255, 214, 0, 0.3);
}

.result-none {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

/* Modal styling (For history record result, etc.) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-fast);
}

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

.modal-box {
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  transform: scale(0.9);
  transition: var(--transition-normal);
}

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

.modal-header {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Info Banner */
.info-banner {
  background: rgba(0, 229, 255, 0.05);
  border: 1px solid rgba(0, 229, 255, 0.15);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.info-banner i {
  color: var(--color-primary);
  font-style: normal;
  font-weight: bold;
}

/* Utility classes */
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.gap-05 { gap: 0.5rem; }
.gap-1 { gap: 1rem; }

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--color-primary); }

.badge {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 4px;
}

.stat-glow-power {
  color: var(--color-warning);
  text-shadow: 0 0 8px rgba(255, 214, 0, 0.2);
}

.stat-glow-vs {
  color: var(--color-primary);
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.2);
}

.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border-color);
  border-radius: 12px;
}

/* ─── Weekly Votes Stats Cards ─────────────────── */
.votes-stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
  .votes-stats-row {
    grid-template-columns: 1fr;
  }
}

.vote-stat-card {
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.25rem;
  transition: var(--transition-fast);
}

.vote-stat-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-md);
}

.vote-stat-time {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  display: inline-block;
  margin-bottom: 1rem;
}

.badge-9-card {
  background: rgba(124, 77, 255, 0.15);
  color: #b388ff;
  border: 1px solid rgba(124, 77, 255, 0.35);
}

.badge-18-card {
  background: rgba(0, 229, 255, 0.12);
  color: #84ffff;
  border: 1px solid rgba(0, 229, 255, 0.3);
}

.badge-23-card {
  background: rgba(197, 17, 98, 0.12);
  color: #ff80ab;
  border: 1px solid rgba(197, 17, 98, 0.3);
}

.vote-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.vote-stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.vote-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.vote-stat-val {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

/* ─── Login Overlay ───────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: radial-gradient(ellipse at 30% 40%, rgba(124, 77, 255, 0.18) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 70%, rgba(0, 229, 255, 0.12) 0%, transparent 50%),
              #0a0d14;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.4s ease;
}

.login-overlay.hidden {
  display: none;
}

.login-card {
  background: rgba(18, 24, 38, 0.9);
  border: 1px solid rgba(0, 229, 255, 0.15);
  border-radius: 20px;
  padding: 2.5rem 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6),
              0 0 0 1px rgba(255,255,255,0.04),
              0 0 40px rgba(124, 77, 255, 0.08);
  backdrop-filter: blur(20px);
  text-align: center;
  animation: slideUp 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #7c4dff, #00e5ff);
  border-radius: 16px;
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  box-shadow: 0 8px 24px rgba(124, 77, 255, 0.35);
}

.login-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: 2px;
  margin: 0 0 0.25rem;
}

.login-subtitle {
  font-size: 0.78rem;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin: 0 0 0.5rem;
}

.login-sub2 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 1.75rem;
}

.login-field {
  text-align: left;
  margin-bottom: 0.75rem;
}

.login-field label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 0.4rem;
}

.login-input-wrap {
  position: relative;
}

.login-input {
  width: 100%;
  padding-right: 2.8rem !important;
  font-size: 1rem;
  letter-spacing: 2px;
}

.btn-eye {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  line-height: 1;
  transition: color var(--transition-fast);
}

.btn-eye:hover { color: var(--color-primary); }

.login-error {
  font-size: 0.82rem;
  color: var(--color-danger);
  background: rgba(255, 23, 68, 0.1);
  border: 1px solid rgba(255, 23, 68, 0.25);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  text-align: left;
  animation: shakeX 0.4s ease;
}

@keyframes shakeX {
  0%,100% { transform: translateX(0); }
  20%,60%  { transform: translateX(-6px); }
  40%,80%  { transform: translateX(6px); }
}

.login-btn {
  width: 100%;
  padding: 0.85rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 1px;
  margin-top: 0.25rem;
}

.login-footer {
  margin-top: 1.75rem;
  font-size: 0.75rem;
  color: var(--text-dark);
}

/* ─── Sync Status Badge ───────────────────────────── */
.sync-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.28rem 0.65rem;
  border-radius: 20px;
  letter-spacing: 0.3px;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: all 0.3s ease;
}

.sync-ok      { background: rgba(0,230,118,0.1);    color: #69f0ae; border-color: rgba(0,230,118,0.25); }
.sync-saving  { background: rgba(0,229,255,0.1);    color: #80deea; border-color: rgba(0,229,255,0.25); animation: pulse 1s infinite; }
.sync-loading { background: rgba(255,214,0,0.08);   color: #ffd740; border-color: rgba(255,214,0,0.2);  animation: pulse 1s infinite; }
.sync-warn    { background: rgba(255,145,0,0.1);    color: #ffcc80; border-color: rgba(255,145,0,0.25); }
.sync-local   { background: rgba(148,163,184,0.08); color: #94a3b8; border-color: rgba(148,163,184,0.15); }

@keyframes pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* ─── Role Badges ─── */
.badge-owner {
  background: rgba(197, 17, 98, 0.15) !important;
  border: 1px solid var(--color-secondary) !important;
  color: #ff4081 !important;
}

.badge-r4 {
  background: rgba(0, 229, 255, 0.1) !important;
  border: 1px solid var(--color-primary) !important;
  color: var(--color-primary) !important;
}

.badge-owner, .badge-r4 {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* Hide elements with owner-only class when not owner */
.owner-only {
  display: none !important;
}

/* Show them only when owner-only and body has owner class */
body.role-owner .owner-only {
  display: block !important;
}
/* For tab-btn which uses flex display */
body.role-owner button.tab-btn.owner-only {
  display: inline-flex !important;
}
/* For table columns or rows */
body.role-owner tr.owner-only,
body.role-owner th.owner-only,
body.role-owner td.owner-only {
  display: table-cell !important;
}

/* Users tab styles */
.users-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
@media (min-width: 768px) {
  .users-grid {
    grid-template-columns: 1fr 2fr;
  }
}

/* Activity Log styles */
.log-timestamp {
  font-family: monospace;
  color: var(--color-primary);
  font-size: 0.85rem;
}

.log-user {
  font-weight: 600;
  color: var(--text-main);
}

.log-action {
  color: var(--text-muted);
}

/* ─── Backups Grid (similar to users-grid but equal columns) ─── */
.backups-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
@media (min-width: 768px) {
  .backups-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ─── User Menu Dropdown ─── */
.user-menu-container {
  position: relative;
  display: inline-block;
}

.user-menu-trigger {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-family: var(--font-family);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition-fast);
  user-select: none;
}

.user-menu-trigger:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.user-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 200px;
  box-shadow: var(--shadow-lg);
  padding: 0.4rem;
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 10000;
}

.user-menu-dropdown.active {
  display: flex;
}

.dropdown-header {
  padding: 0.4rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.25rem;
  display: flex;
  justify-content: center;
}

.dropdown-item {
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 0.5rem 0.6rem;
  text-align: left;
  font-family: var(--font-family);
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition-fast);
  width: 100%;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.dropdown-item.danger {
  color: var(--color-danger);
}

.dropdown-item.danger:hover {
  background: rgba(255, 23, 68, 0.1);
}

/* ─── Matchmaker Setup Buttons ─── */
.setup-actions-row {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.5rem;
  width: 100%;
}
.setup-actions-row button {
  font-size: 0.8rem;
  padding: 0.4rem 0.5rem;
}

/* ═══════════════════════════════════════════════════════
   MOBILE RESPONSIVENESS & OPTIMIZATION
   ═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* ── Global Container ── */
  .app-container {
    padding: 0.5rem;
  }

  /* ── Compact Header ── */
  header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.6rem;
    margin-bottom: 0.75rem;
    gap: 0;
  }
  .brand-section {
    flex-direction: row;
    gap: 0.5rem;
  }
  .brand-logo {
    width: 30px;
    height: 30px;
    font-size: 1rem;
    border-radius: 6px;
  }
  .brand-title h1 {
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    line-height: 1.2;
  }
  .brand-title span {
    font-size: 0.55rem;
    letter-spacing: 1px;
  }
  .system-status {
    width: auto;
  }
  .time-display {
    display: none;
  }

  /* ── Scrolling Tab Bar (Compact Pills) ── */
  .tabs-nav {
    display: flex;
    overflow-x: auto;
    max-width: 100%;
    width: 100%;
    white-space: nowrap;
    padding: 0.3rem;
    border-radius: 10px;
    gap: 0.25rem;
    margin-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs-nav::-webkit-scrollbar {
    display: none;
  }
  .tab-btn {
    flex-shrink: 0;
    padding: 0.45rem 0.7rem;
    font-size: 0.75rem;
    gap: 0.25rem;
  }
  .tab-btn svg {
    width: 13px;
    height: 13px;
  }

  /* ── Info Banner ── */
  .info-banner {
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
  }

  /* ── Panels ── */
  .panel {
    padding: 0.75rem;
    border-radius: 10px;
    margin-bottom: 0.75rem;
  }
  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
  }
  .panel-title {
    font-size: 1rem;
  }
  .panel-header .gap-05 {
    width: 100%;
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
  }
  .panel-header .gap-05 button {
    font-size: 0.72rem;
    padding: 0.45rem 0.4rem;
    width: 100%;
    text-align: center;
    white-space: nowrap;
  }

  /* ── Form Grid ── */
  .form-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
  }
  .form-control {
    padding: 0.55rem 0.65rem;
    font-size: 0.85rem;
  }
  .form-group label {
    font-size: 0.78rem;
  }

  /* ── Buttons (Larger Touch Targets) ── */
  .btn {
    padding: 0.55rem 0.9rem;
    font-size: 0.82rem;
    min-height: 40px;
  }
  .btn-sm {
    padding: 0.45rem 0.6rem;
    font-size: 0.75rem;
    min-height: 36px;
  }

  /* ── Matchmaker Setup Panel ── */
  .matchmaker-setup-panel {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
  }
  .setup-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .setup-actions-row {
    flex-direction: column;
    gap: 0.35rem;
  }
  .setup-actions-row button {
    width: 100%;
    padding: 0.55rem;
    font-size: 0.82rem;
    min-height: 42px;
  }

  /* ── Matchmaker Board (Stack 3 Columns) ── */
  .matchmaker-board {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .team-panel {
    min-height: 200px;
  }

  /* ── Team Summary (2x2 Grid) ── */
  .team-summary {
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
    padding: 0.5rem;
    font-size: 0.75rem;
  }

  /* ── Player Pool Cards ── */
  .player-pool-list {
    max-height: 350px;
    gap: 0.35rem;
  }
  .pool-player-card {
    padding: 0.6rem;
    border-radius: 8px;
  }
  .pool-player-name {
    font-size: 0.85rem;
  }
  .pool-player-stats {
    font-size: 0.7rem;
    gap: 0.3rem;
  }
  .pool-player-actions {
    gap: 0.25rem;
  }
  .pool-player-actions button {
    min-width: 32px;
    min-height: 32px;
    font-size: 0.75rem;
    padding: 0.3rem;
  }

  /* ── Tables → Responsive Card Layout ── */
  .table-wrapper {
    border: none;
    border-radius: 0;
    overflow-x: visible;
  }
  .table-wrapper table {
    border: none;
  }
  .table-wrapper thead {
    display: none;
  }
  .table-wrapper tbody {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  .table-wrapper tr {
    display: flex;
    flex-wrap: wrap;
    background: rgba(18, 24, 38, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.6rem;
    gap: 0.3rem 0.5rem;
    align-items: center;
  }
  .table-wrapper tr:hover {
    border-color: rgba(0, 229, 255, 0.2);
  }
  .table-wrapper td {
    padding: 0;
    border: none;
    background: transparent;
    font-size: 0.82rem;
  }
  /* First cell (Name) → full width, bold */
  .table-wrapper td:first-child {
    width: 100%;
    font-weight: 700;
    font-size: 0.9rem;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.15rem;
  }
  /* Data cells → show inline with labels */
  .table-wrapper td::before {
    content: attr(data-label);
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: block;
    margin-bottom: 0.1rem;
  }
  .table-wrapper td:first-child::before {
    content: none;
  }
  /* Actions cell → full width row at bottom */
  .table-wrapper td:last-child {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    gap: 0.35rem;
    padding-top: 0.3rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.15rem;
  }
  .table-wrapper td:last-child::before {
    content: none;
  }

  /* ── Database Filter Row ── */
  #database .panel > div[style*="display: flex"] {
    flex-direction: column;
    gap: 0.5rem;
  }
  #database #registry-time-filter {
    width: 100% !important;
  }

  /* ── Votes Table Overrides (checkboxes, not action buttons) ── */
  #votes .table-wrapper td:last-child {
    width: auto;
    border-top: none;
    margin-top: 0;
    padding-top: 0;
    justify-content: center;
  }
  #votes .table-wrapper td:last-child::before {
    content: attr(data-label);
    display: block;
  }
  /* Group the 3 vote checkboxes in a row at the bottom */
  #votes .table-wrapper tr {
    padding-bottom: 0.5rem;
  }
  #votes .table-wrapper td:nth-child(5),
  #votes .table-wrapper td:nth-child(6),
  #votes .table-wrapper td:nth-child(7) {
    flex: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding-top: 0.3rem;
  }
  #votes .table-wrapper td:nth-child(5) {
    border-top: 1px solid var(--border-color);
    margin-top: 0.15rem;
  }
  /* Make checkboxes larger for touch */
  #votes .vote-checkbox {
    width: 24px !important;
    height: 24px !important;
  }

  /* ── Votes Filter Row ── */
  #votes .panel > div[style*="display: flex"] {
    flex-direction: column;
    gap: 0.5rem;
  }

  /* ── Weekly Votes Stats Row ── */
  .votes-stats-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  .vote-stat-card {
    padding: 0.75rem;
    border-radius: 10px;
  }
  .vote-stat-time {
    font-size: 0.72rem;
    padding: 0.25rem 0.6rem;
    margin-bottom: 0.6rem;
  }
  .vote-stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  .vote-stat-val {
    font-size: 1rem;
  }

  /* ── Weekly History ── */
  .history-details-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* ── Backups Grid ── */
  .backups-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* ── Users Grid ── */
  .users-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* ── Teams Container ── */
  .teams-container {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* ── Login Card ── */
  .login-card {
    padding: 1.5rem 1.25rem 1.25rem;
    max-width: 95%;
    border-radius: 16px;
  }
  .login-logo {
    width: 48px;
    height: 48px;
    font-size: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1rem;
  }
  .login-title {
    font-size: 1.15rem;
    letter-spacing: 1.5px;
  }
  .login-subtitle {
    font-size: 0.7rem;
  }
  .login-sub2 {
    font-size: 0.78rem;
    margin-bottom: 1.25rem;
  }

  /* ── Modals → Full-Screen on Mobile ── */
  .modal-box {
    max-width: 95%;
    border-radius: 14px;
    max-height: 90vh;
    overflow-y: auto;
  }
  .modal-body {
    padding: 0.75rem;
  }
  .modal-footer {
    padding: 0.5rem 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .modal-footer button {
    flex: 1 1 auto;
    min-height: 40px;
  }

  /* ── User Menu Dropdown ── */
  .user-menu-dropdown {
    width: 180px;
    border-radius: 10px;
  }

  /* ── Vote Table Specific ── */
  #votes .table-wrapper td[style*="text-align: center"] {
    text-align: left;
  }

  /* ── Empty States ── */
  .empty-state {
    padding: 2rem 1rem;
    font-size: 0.85rem;
  }

  /* ── Filter Card ── */
  .filter-card {
    padding: 0.75rem;
  }
  .filter-title {
    font-size: 0.82rem;
    margin-bottom: 0.5rem;
  }

  /* ── Flex-Between util ── */
  .flex-between {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
  }
  .flex-between .text-muted {
    text-align: center;
    font-size: 0.78rem;
  }
  .flex-between .btn {
    width: 100%;
  }
}

/* ═══════════════════════════════════════════════════════
   EXTRA SMALL SCREENS (< 480px)
   ═══════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .app-container {
    padding: 0.35rem;
  }

  /* Header ultra-compact */
  .brand-title h1 {
    font-size: 0.8rem;
  }
  .brand-title span {
    display: none;
  }
  .brand-logo {
    width: 26px;
    height: 26px;
    font-size: 0.85rem;
    border-radius: 5px;
  }
  .user-menu-trigger {
    padding: 0.3rem 0.45rem;
    font-size: 0.7rem;
  }

  /* Tabs even smaller */
  .tab-btn {
    padding: 0.4rem 0.55rem;
    font-size: 0.7rem;
    gap: 0.2rem;
  }
  .tab-btn svg {
    width: 11px;
    height: 11px;
  }

  /* Form fields full width */
  .form-grid {
    grid-template-columns: 1fr;
  }

  /* Panels even tighter */
  .panel {
    padding: 0.6rem;
    border-radius: 8px;
  }

  /* Panel header buttons single column */
  .panel-header .gap-05 {
    grid-template-columns: 1fr;
  }

  /* Team summary single column on very small */
  .team-summary {
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem;
    padding: 0.4rem;
    font-size: 0.7rem;
  }

  /* Vote stat card ultra-compact */
  .vote-stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
  }
  .vote-stat-val {
    font-size: 0.9rem;
  }
  .vote-stat-label {
    font-size: 0.65rem;
  }

  /* Card layout text smaller */
  .table-wrapper td {
    font-size: 0.78rem;
  }
  .table-wrapper td:first-child {
    font-size: 0.85rem;
  }
}

