:root {
  --c-midnight: #320a28;
  --c-crimson: #511730;
  --c-reddish: #8e443d;
  --c-almond: #cb9173;
  --c-silk: #f5d0c5;

  --c-bg: #faeae3;
  --c-surface: #ffffff;
  --c-surface-2: #fff6f1;
  --c-text: #2a0a1f;
  --c-muted: #7a5a5a;
  --c-border: #ead2c8;

  --shadow-sm: 0 1px 2px rgba(50, 10, 40, 0.06);
  --shadow-md: 0 6px 24px rgba(50, 10, 40, 0.10);
  --shadow-lg: 0 16px 40px rgba(50, 10, 40, 0.14);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --font-sans: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

body {
  background:
    radial-gradient(1200px 600px at 100% 0%, rgba(203,145,115,0.25), transparent 70%),
    radial-gradient(900px 500px at 0% 100%, rgba(81,23,48,0.10), transparent 70%),
    var(--c-bg);
  min-height: 100vh;
}

h1, h2, h3, h4 {
  color: var(--c-midnight);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }

a {
  color: var(--c-reddish);
  text-decoration: none;
}
a:hover { color: var(--c-crimson); }

button, .btn {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease, color 0.15s ease, border 0.15s ease, box-shadow 0.15s ease;
  background: var(--c-midnight);
  color: var(--c-silk);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
button:hover, .btn:hover {
  background: var(--c-crimson);
}
button:active, .btn:active { transform: translateY(1px); }
button:disabled, .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--c-almond);
  color: var(--c-midnight);
}
.btn-primary:hover {
  background: var(--c-reddish);
  color: var(--c-silk);
}
.btn-ghost {
  background: transparent;
  color: var(--c-midnight);
  border: 1px solid var(--c-border);
}
.btn-ghost:hover {
  background: var(--c-silk);
  border-color: var(--c-almond);
}
.btn-danger {
  background: var(--c-reddish);
  color: var(--c-silk);
}
.btn-danger:hover { background: var(--c-crimson); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }

input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
  padding: 10px 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  color: var(--c-text);
  outline: none;
  width: 100%;
  transition: border 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--c-almond);
  box-shadow: 0 0 0 3px rgba(203, 145, 115, 0.25);
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--c-crimson);
}

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.card-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-muted);
  margin: 0 0 6px;
  font-weight: 700;
}

.stat {
  font-size: 2rem;
  font-weight: 700;
  color: var(--c-midnight);
  letter-spacing: -0.02em;
}

.tag {
  display: inline-block;
  background: var(--c-silk);
  color: var(--c-crimson);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.tag-dark {
  background: var(--c-midnight);
  color: var(--c-silk);
}
.tag-accent {
  background: var(--c-almond);
  color: var(--c-midnight);
}

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-almond);
  box-shadow: 0 0 0 0 rgba(203, 145, 115, 0.7);
  animation: pulse 1.6s infinite;
  vertical-align: middle;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(203, 145, 115, 0.6); }
  70% { box-shadow: 0 0 0 10px rgba(203, 145, 115, 0); }
  100% { box-shadow: 0 0 0 0 rgba(203, 145, 115, 0); }
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--c-silk);
  border-top-color: var(--c-reddish);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error {
  background: rgba(142, 68, 61, 0.10);
  color: var(--c-crimson);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(142, 68, 61, 0.2);
  font-size: 0.92rem;
}
.success {
  background: rgba(203, 145, 115, 0.15);
  color: var(--c-crimson);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(203, 145, 115, 0.3);
  font-size: 0.92rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-border);
}
th {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-muted);
}
tbody tr:hover { background: var(--c-surface-2); }

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--c-muted);
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--c-midnight);
  color: var(--c-silk);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.toast.show { opacity: 1; }

.admin-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  max-width: 360px;
  width: calc(100vw - 48px);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-left: 4px solid var(--c-almond);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  outline: none;
}
.admin-notification.show {
  opacity: 1;
  transform: translateY(0);
}
.admin-notification:hover {
  border-color: var(--c-almond);
  box-shadow: 0 12px 30px rgba(50, 10, 40, 0.20);
}
.admin-notification .notif-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.admin-notification .notif-badge {
  background: var(--c-almond);
  color: var(--c-midnight);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.admin-notification .notif-title {
  font-weight: 800;
  color: var(--c-midnight);
  font-size: 0.95rem;
}
.admin-notification .notif-msg {
  color: var(--c-text);
  font-size: 0.92rem;
  white-space: pre-line;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.admin-notification .notif-hint {
  margin-top: 8px;
  color: var(--c-muted);
  font-size: 0.78rem;
  font-style: italic;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(50, 10, 40, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.modal-backdrop.show { opacity: 1; }
.modal {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  transform: translateY(8px);
  transition: transform 0.18s ease;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-backdrop.show .modal { transform: translateY(0); }
.modal h2 { margin-top: 0; }
.modal .actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  flex-wrap: wrap;
}
.modal .actions button {
  min-width: 110px;
  justify-content: center;
}
.modal .field { margin-bottom: 14px; }
.modal .field:last-of-type { margin-bottom: 0; }

.modal-team-head {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.modal-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.modal-chip-list .player-chip {
  background: var(--c-silk);
  color: var(--c-crimson);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: default;
}
.team-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
}
.stat-tile {
  background: var(--c-silk);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  text-align: center;
}
.stat-tile-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--c-midnight);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-tile-label {
  font-size: 0.74rem;
  color: var(--c-crimson);
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.clickable-team {
  cursor: pointer;
  border-bottom: 1px dotted transparent;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.clickable-team:hover {
  border-bottom-color: var(--c-reddish);
  color: var(--c-reddish);
}
