:root {
    --bg: #0f1419;
    --bg-card: #1a2332;
    --bg-hover: #243044;
    --text: #e8edf4;
    --text-muted: #8b9cb3;
    --primary: #00a651;
    --primary-dark: #008542;
    --accent: #ffd700;
    --border: #2d3a4f;
    --success: #22c55e;
    --error: #ef4444;
    --info: #3b82f6;
    --radius: 10px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* Header */
.site-header {
    background: linear-gradient(135deg, #1a2332 0%, #0d2818 100%);
    border-bottom: 2px solid var(--primary);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.2rem;
}

.logo-icon {
    font-size: 1.5rem;
}

.main-nav {
    display: flex;
    gap: 0.5rem;
}

.main-nav a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.main-nav a:hover,
.main-nav a.active {
    color: var(--text);
    background: var(--bg-hover);
}

.main-nav a.active {
    color: var(--primary);
    font-weight: 600;
}

.main-content {
    padding: 2rem 1.25rem 4rem;
}

/* Hero */
.hero {
    text-align: center;
    padding: 2.5rem 1rem;
    margin-bottom: 2rem;
    background: linear-gradient(180deg, rgba(0, 166, 81, 0.15) 0%, transparent 100%);
    border-radius: var(--radius);
}

.hero h1 {
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-sub {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.hero-small {
    padding: 1.5rem 1rem;
}

.hero-small h1 {
    font-size: 1.8rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.card h2 {
    margin-bottom: 1rem;
    font-size: 1.3rem;
    color: var(--accent);
}

.card h3,
.phase-title {
    margin: 1.5rem 0 0.75rem;
    font-size: 1.1rem;
    color: var(--primary);
}

/* Rules */
.rules-grid {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.rule-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-radius: var(--radius);
    border-left: 4px solid var(--border);
}

.rule-item.rule-10 { border-left-color: var(--accent); }
.rule-item.rule-5 { border-left-color: var(--primary); }
.rule-item.rule-3 { border-left-color: var(--info); }
.rule-item.rule-0 { border-left-color: var(--text-muted); }

.rule-points {
    font-weight: 800;
    font-size: 1.1rem;
    min-width: 60px;
    color: var(--accent);
}

.rules-extra {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.rules-extra p {
    margin-bottom: 0.5rem;
}

/* Alerts */
.alert {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-weight: 500;
}

.alert-success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid var(--success);
    color: #86efac;
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--error);
    color: #fca5a5;
}

.alert-info {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid var(--info);
    color: #93c5fd;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 0.65rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.data-table .has-result {
    background: rgba(0, 166, 81, 0.05);
}

.col-id {
    color: var(--text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
}

.col-date {
    white-space: nowrap;
    font-size: 0.85rem;
}

.col-teams {
    min-width: 200px;
}

.col-teams .vs {
    color: var(--text-muted);
    margin: 0 0.35rem;
    font-size: 0.85rem;
}

.col-teams small {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.pending-text {
    color: var(--text-muted);
    font-style: italic;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

.group-badge {
    background: rgba(0, 166, 81, 0.2);
    color: var(--primary);
}

.phase-badge {
    background: rgba(255, 215, 0, 0.15);
    color: var(--accent);
}

/* Score inputs */
.score-input {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.score-field {
    width: 52px;
    padding: 0.4rem;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
}

.score-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 166, 81, 0.25);
}

.score-sep {
    color: var(--text-muted);
    font-weight: 700;
}

.result-score,
.pred-score {
    font-weight: 700;
    font-family: 'Courier New', monospace;
}

/* Points */
.pts {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-weight: 800;
    font-size: 0.85rem;
}

.pts-10 { background: rgba(255, 215, 0, 0.25); color: var(--accent); }
.pts-5 { background: rgba(0, 166, 81, 0.25); color: #86efac; }
.pts-3 { background: rgba(59, 130, 246, 0.25); color: #93c5fd; }
.pts-0 { background: rgba(139, 156, 179, 0.15); color: var(--text-muted); }

.pts-total {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--accent);
}

/* Ranking highlights */
.ranking-table .top-1 td {
    background: rgba(255, 215, 0, 0.08);
}

.ranking-table .top-2 td {
    background: rgba(192, 192, 192, 0.06);
}

.ranking-table .top-3 td {
    background: rgba(205, 127, 50, 0.06);
}

/* Groups grid */
.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.group-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.group-card h3 {
    margin-bottom: 0.75rem;
    color: var(--primary);
    font-size: 1rem;
}

.mini-table {
    width: 100%;
    font-size: 0.8rem;
    border-collapse: collapse;
}

.mini-table th,
.mini-table td {
    padding: 0.35rem 0.4rem;
    border-bottom: 1px solid var(--border);
}

.mini-table .pos-1 td:first-child {
    color: var(--accent);
    font-weight: 700;
}

.mini-table .pos-2 td:first-child {
    color: #86efac;
}

.mini-table .pos-3 td:first-child {
    color: var(--info);
}

/* Forms */
.form-row {
    margin-bottom: 1.5rem;
}

.participant-select {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.participant-select select,
.login-form input[type="password"],
.filter-bar select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
}

.form-actions {
    margin-top: 1.5rem;
    text-align: center;
}

.sticky-actions {
    position: sticky;
    bottom: 1rem;
    background: var(--bg-card);
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    z-index: 50;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.65rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 0.85rem 2rem;
    font-size: 1.1rem;
}

/* Login */
.login-card {
    max-width: 400px;
    margin: 2rem auto;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.admin-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 166, 81, 0.15);
    border: 1px solid var(--primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.filter-bar {
    margin-bottom: 1rem;
}

.filter-bar label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
}

.status-badge {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.status-scheduled { background: rgba(139, 156, 179, 0.2); color: var(--text-muted); }
.status-live { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.status-finished { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.status-awaiting { background: rgba(139, 156, 179, 0.2); color: var(--text-muted); }
.status-locked { background: rgba(255, 215, 0, 0.15); color: var(--accent); }

.status-live.live-link {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    border: 1px solid rgba(239, 68, 68, 0.55);
    padding: 0.2rem 0.55rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    animation: live-badge-glow 2s ease-in-out infinite;
}

.status-live.live-link:hover {
    background: rgba(239, 68, 68, 0.4);
    color: #fff;
    transform: scale(1.05);
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.45);
}

.live-dot {
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    flex-shrink: 0;
    animation: live-dot-pulse 1.2s ease-in-out infinite;
}

.live-arrow {
    font-size: 0.6rem;
    opacity: 0.85;
}

.match-row.is-live {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.1) 0%, transparent 55%);
    border-left: 3px solid #ef4444;
    animation: live-row-glow 2.5s ease-in-out infinite;
}

.match-row.is-live:hover {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.16) 0%, var(--bg-hover) 55%);
}

.col-teams .live-link {
    margin-right: 0.5rem;
    vertical-align: middle;
}

@keyframes live-dot-pulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.65);
    }
    50% {
        opacity: 0.85;
        box-shadow: 0 0 0 5px rgba(239, 68, 68, 0);
    }
}

@keyframes live-badge-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.25); }
    50% { box-shadow: 0 0 10px 2px rgba(239, 68, 68, 0.35); }
}

@keyframes live-row-glow {
    0%, 100% { border-left-color: #ef4444; }
    50% { border-left-color: #f87171; }
}

.result-score.official {
    color: #86efac;
}

.locked-pred {
    opacity: 0.85;
}

.score-input-locked .score-field {
    opacity: 0.5;
    cursor: not-allowed;
}

.sync-info {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.sync-info.sync-error {
    color: #fca5a5;
}

.is-locked {
    opacity: 0.92;
}

.col-save {
    white-space: nowrap;
    min-width: 90px;
}

.btn-save-palpite {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-save-palpite.btn-saved {
    background: var(--primary-dark);
}

.save-feedback {
    display: inline-block;
    margin-left: 0.35rem;
    font-size: 0.85rem;
    font-weight: 700;
}

.save-feedback.save-ok {
    color: #86efac;
}

.save-feedback.save-error {
    color: #fca5a5;
}

.palpite-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 600;
    z-index: 200;
    box-shadow: var(--shadow);
}

.palpite-toast.toast-success {
    background: rgba(34, 197, 94, 0.95);
    color: #fff;
}

.palpite-toast.toast-error {
    background: rgba(239, 68, 68, 0.95);
    color: #fff;
}


code {
    background: var(--bg);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
}

/* Footer */
.site-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 1.6rem;
    }

    .header-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .main-nav {
        width: 100%;
        justify-content: space-around;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .score-field {
        width: 44px;
    }

    .participant-select {
        flex-direction: column;
        align-items: flex-start;
    }
}
