:root {
    --primary: #1e3a5f;
    --primary-light: #2d4a6f;
    --primary-dark: #0f2847;
    --secondary: #c9a227;
    --secondary-light: #dbb84a;
    --bg-dark: #0a1628;
    --bg-card: #12233d;
    --bg-card-hover: #1a2f4f;
    --text-primary: #ffffff;
    --text-secondary: #a8b9cf;
    --text-muted: #6b7c93;
    --border: #2d4a6f;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #3498db;
    --gradient-gold: linear-gradient(135deg, #c9a227 0%, #dbb84a 100%);
    --gradient-card: linear-gradient(145deg, #14253f 0%, #0f1e32 100%);
    --shadow-glow: 0 0 20px rgba(201,162,39,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Playfair Display', Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-main);
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at top left, rgba(30,58,95,0.4) 0%, transparent 50%),
                radial-gradient(ellipse at bottom right, rgba(201,162,39,0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

a { color: var(--secondary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--secondary-light); }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.3; margin-bottom: 0.5em; }
h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

@media (max-width: 768px) {
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
}

.container { width: 100%; max-width: 1400px; margin: 0 auto; padding: 0 1rem; }
.main-content { padding: 2rem 0; min-height: calc(100vh - 80px); }

.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) { .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

.header {
    background: var(--gradient-card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

.logo { display: flex; align-items: center; gap: 0.75rem; font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; color: var(--text-primary); }
.logo-icon { font-size: 2rem; }

.nav { display: flex; align-items: center; gap: 0.5rem; }
.nav-link { padding: 0.5rem 1rem; border-radius: var(--radius-sm); color: var(--text-secondary); font-weight: 500; transition: all var(--transition-fast); }
.nav-link:hover, .nav-link.active { background: var(--primary); color: var(--text-primary); }
.nav-link.active { background: var(--gradient-gold); color: var(--primary-dark); }

.mobile-menu-btn { display: none; background: none; border: none; color: var(--text-primary); font-size: 1.5rem; cursor: pointer; padding: 0.5rem; }

@media (max-width: 768px) {
    .mobile-menu-btn { display: block; }
    .nav { position: fixed; top: 70px; left: 0; right: 0; background: var(--bg-card); flex-direction: column; padding: 1rem; border-bottom: 1px solid var(--border); transform: translateY(-100%); opacity: 0; visibility: hidden; transition: all var(--transition-normal); }
    .nav.active { transform: translateY(0); opacity: 1; visibility: visible; }
    .nav-link { width: 100%; text-align: center; padding: 0.75rem 1rem; }
}

.user-menu { display: flex; align-items: center; gap: 1rem; }
.user-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--gradient-gold); display: flex; align-items: center; justify-content: center; font-weight: 600; color: var(--primary-dark); }

.card { background: var(--gradient-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem; transition: all var(--transition-normal); }
.card:hover { border-color: var(--secondary); box-shadow: var(--shadow-glow); transform: translateY(-2px); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.card-title { font-size: 1.25rem; margin: 0; }
.card-footer { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }

.stat-card { text-align: center; padding: 1.5rem; }
.stat-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--secondary); font-family: var(--font-display); }
.stat-label { color: var(--text-secondary); font-size: 0.875rem; margin-top: 0.25rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.75rem 1.5rem; border: none; border-radius: var(--radius-md); font-family: inherit; font-size: 1rem; font-weight: 600; cursor: pointer; transition: all var(--transition-fast); text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--gradient-gold); color: var(--primary-dark); }
.btn-primary:hover:not(:disabled) { box-shadow: var(--shadow-glow); transform: translateY(-1px); }
.btn-secondary { background: var(--primary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--primary-light); border-color: var(--secondary); }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-card-hover); color: var(--text-primary); }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.875rem; }
.btn-lg { padding: 1rem 2rem; font-size: 1.125rem; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; }

.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: var(--text-secondary); }
.form-control { width: 100%; padding: 0.75rem 1rem; background: var(--bg-dark); border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--text-primary); font-family: inherit; font-size: 1rem; transition: all var(--transition-fast); }
.form-control:focus { outline: none; border-color: var(--secondary); box-shadow: 0 0 0 3px rgba(201,162,39,0.2); }
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { opacity: 0.6; cursor: not-allowed; }
.form-control.is-invalid { border-color: var(--danger); }
.form-error { color: var(--danger); font-size: 0.875rem; margin-top: 0.25rem; }

.form-check { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.form-check input[type="checkbox"], .form-check input[type="radio"] { width: 1.25rem; height: 1.25rem; accent-color: var(--secondary); cursor: pointer; }

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23a8b9cf'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 1rem center; padding-right: 2.5rem; }

.score-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.score-table th, .score-table td { padding: 0.75rem; text-align: center; border-bottom: 1px solid var(--border); }
.score-table th { background: var(--primary-dark); color: var(--text-secondary); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; position: sticky; top: 0; }
.score-table th:first-child { text-align: left; }
.score-table tbody tr { transition: background var(--transition-fast); }
.score-table tbody tr:hover { background: var(--bg-card-hover); }
.score-table td:first-child { text-align: left; }

.player-cell { display: flex; align-items: center; gap: 0.75rem; }
.player-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; flex-shrink: 0; }
.player-name { font-weight: 600; }
.player-alias { font-size: 0.8rem; color: var(--text-muted); }

.score-cell { font-weight: 600; font-size: 1rem; }
.score-cell.winner { color: var(--secondary); }
.score-cell.closed { background: rgba(39,174,96,0.2); border-radius: var(--radius-sm); }

.score-input { width: 70px; padding: 0.5rem; text-align: center; background: var(--bg-dark); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-weight: 600; font-size: 1rem; }
.score-input:focus { outline: none; border-color: var(--secondary); }
.total-cell { font-weight: 700; font-size: 1.1rem; color: var(--secondary); background: rgba(201,162,39,0.1); }

@media (max-width: 768px) {
    .score-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .score-table { min-width: 600px; }
}

.player-card { display: flex; align-items: center; gap: 1rem; padding: 1rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); transition: all var(--transition-fast); cursor: pointer; }
.player-card:hover { border-color: var(--secondary); background: var(--bg-card-hover); }
.player-card.selected { border-color: var(--secondary); box-shadow: 0 0 0 2px rgba(201,162,39,0.3); }
.player-card .avatar { width: 50px; height: 50px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.player-card .info { flex: 1; }
.player-card .name { font-weight: 600; font-size: 1.1rem; }
.player-card .stats { font-size: 0.85rem; color: var(--text-muted); }

.player-list { display: flex; flex-direction: column; gap: 0.5rem; }
.player-item { display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); cursor: grab; transition: all var(--transition-fast); }
.player-item:active { cursor: grabbing; }
.player-item.dragging { opacity: 0.5; background: var(--primary); }
.player-item .drag-handle { color: var(--text-muted); font-size: 1.25rem; }
.player-item .order { width: 28px; height: 28px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.875rem; }

.round-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.round-info { display: flex; align-items: center; gap: 1rem; }
.round-number { width: 48px; height: 48px; background: var(--gradient-gold); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 700; color: var(--primary-dark); }
.round-title h3 { margin: 0; font-size: 1.25rem; }
.round-title p { margin: 0; color: var(--text-muted); font-size: 0.9rem; }

.round-tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; padding: 0.25rem; background: var(--bg-dark); border-radius: var(--radius-md); }
.round-tab { padding: 0.5rem 1rem; border-radius: var(--radius-sm); font-weight: 500; color: var(--text-secondary); background: transparent; border: none; cursor: pointer; transition: all var(--transition-fast); }
.round-tab:hover { background: var(--bg-card); color: var(--text-primary); }
.round-tab.active { background: var(--gradient-gold); color: var(--primary-dark); }
.round-tab.completed { color: var(--success); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 1000; opacity: 0; visibility: hidden; transition: all var(--transition-normal); }
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; transform: scale(0.9); transition: transform var(--transition-normal); }
.modal-overlay.active .modal { transform: scale(1); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 1.25rem; margin: 0; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; transition: color var(--transition-fast); }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 1.5rem; }
.modal-footer { display: flex; gap: 1rem; justify-content: flex-end; padding: 1.25rem 1.5rem; border-top: 1px solid var(--border); }

.alert { display: flex; align-items: flex-start; gap: 0.75rem; padding: 1rem 1.25rem; border-radius: var(--radius-md); margin-bottom: 1rem; }
.alert-icon { font-size: 1.25rem; flex-shrink: 0; }
.alert-content { flex: 1; }
.alert-success { background: rgba(39,174,96,0.15); border: 1px solid var(--success); color: #7dcea0; }
.alert-error { background: rgba(231,76,60,0.15); border: 1px solid var(--danger); color: #f1948a; }
.alert-warning { background: rgba(243,156,18,0.15); border: 1px solid var(--warning); color: #f9e79f; }
.alert-info { background: rgba(52,152,219,0.15); border: 1px solid var(--info); color: #85c1e9; }

.toast-container { position: fixed; bottom: 2rem; right: 2rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 1001; }
.toast { padding: 1rem 1.5rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); animation: slideIn 0.3s ease; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.game-summary { text-align: center; padding: 2rem; }
.winner-announcement { margin-bottom: 2rem; }
.winner-crown { font-size: 4rem; margin-bottom: 1rem; }
.winner-name { font-size: 2rem; font-family: var(--font-display); color: var(--secondary); margin-bottom: 0.5rem; }
.winner-score { font-size: 1.25rem; color: var(--text-secondary); }

.podium { display: flex; justify-content: center; align-items: flex-end; gap: 1rem; margin: 2rem 0; }
.podium-place { display: flex; flex-direction: column; align-items: center; padding: 1rem; }
.podium-place .avatar { width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 2rem; margin-bottom: 0.5rem; }
.podium-place .name { font-weight: 600; margin-bottom: 0.25rem; }
.podium-place .score { color: var(--text-muted); }
.podium-place .pedestal { width: 100%; display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 700; margin-top: 0.5rem; padding: 1rem; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.podium-place:nth-child(1) .pedestal { background: linear-gradient(to bottom, #c0c0c0, #808080); height: 70px; }
.podium-place:nth-child(2) .pedestal { background: linear-gradient(to bottom, #ffd700, #b8860b); height: 100px; }
.podium-place:nth-child(3) .pedestal { background: linear-gradient(to bottom, #cd7f32, #8b4513); height: 50px; }

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { width: 100%; max-width: 420px; background: var(--gradient-card); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 2.5rem; box-shadow: var(--shadow-lg); }
.login-header { text-align: center; margin-bottom: 2rem; }
.login-logo { font-size: 4rem; margin-bottom: 1rem; }
.login-title { font-family: var(--font-display); font-size: 2rem; margin-bottom: 0.5rem; }
.login-subtitle { color: var(--text-muted); }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-gold { color: var(--secondary); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.hidden { display: none !important; }

.divider { display: flex; align-items: center; text-align: center; margin: 1.5rem 0; color: var(--text-muted); }
.divider::before, .divider::after { content: ''; flex: 1; border-bottom: 1px solid var(--border); }
.divider span { padding: 0 1rem; }

.badge { display: inline-flex; align-items: center; padding: 0.25rem 0.75rem; font-size: 0.75rem; font-weight: 600; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.05em; }
.badge-success { background: rgba(39,174,96,0.2); color: var(--success); }
.badge-warning { background: rgba(243,156,18,0.2); color: var(--warning); }
.badge-danger { background: rgba(231,76,60,0.2); color: var(--danger); }
.badge-info { background: rgba(52,152,219,0.2); color: var(--info); }

.empty-state { text-align: center; padding: 3rem 2rem; color: var(--text-muted); }
.empty-state-icon { font-size: 4rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state-title { font-size: 1.25rem; color: var(--text-secondary); margin-bottom: 0.5rem; }

.loader { display: inline-block; width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--secondary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.fade-in { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.slide-up { animation: slideUp 0.3s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.confetti { position: fixed; width: 10px; height: 10px; pointer-events: none; animation: confetti-fall 3s linear forwards; }
@keyframes confetti-fall { 0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; } 100% { transform: translateY(100vh) rotate(720deg); opacity: 0; } }

@media print {
    .header, .nav, .btn, .modal-overlay { display: none !important; }
    body { background: white; color: black; }
    .card { border: 1px solid #ddd; box-shadow: none; }
}
