:root {
    --primary: #f59e0b;
    --primary-hover: #d97706;
    --secondary: #475569;
    --success: #16a34a;
    --danger: #ef4444;
    --dark: #0f172a;
    --light: #f3f4f6;
    --white: #ffffff;
    --app-max-width: 1800px;
    --bs-primary: #f59e0b;
    --bs-primary-rgb: 245, 158, 11;
    --bs-secondary: #475569;
    --bs-secondary-rgb: 71, 85, 105;
    --bs-success: #16a34a;
    --bs-success-rgb: 22, 163, 74;
    --bs-danger: #ef4444;
    --bs-danger-rgb: 239, 68, 68;
    --bs-dark: #0f172a;
    --bs-dark-rgb: 15, 23, 42;
    --bs-light: #f3f4f6;
    --bs-light-rgb: 243, 244, 246;
    --score-digit: #d6ff00;
    --timer-digit: #ff2d2d;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--light);
    color: var(--dark);
    margin: 0;
    padding: 0;
}

.app-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
}

.app-logo {
    width: 240px;
    max-width: 80vw;
    height: auto;
    display: block;
}

.match-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    background: #fff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.has-topbar .match-topbar .container,
.has-topbar > .container {
    max-width: var(--app-max-width);
}

.has-topbar {
    padding-top: var(--match-topbar-height, 112px);
}

.match-topbar-logo {
    max-height: 76px;
    height: auto;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
}

.match-topbar-layout {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
        "logo championship ."
        "logo title ."
        "logo badge badge"
        "logo meta .";
    column-gap: 14px;
    row-gap: 2px;
    align-items: center;
    


}

.match-topbar-logo-area {
    grid-area: logo;
}

.match-topbar-championship {
    grid-area: championship;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.match-topbar-title {
    grid-area: title;
    min-width: 0;
}

.match-topbar-badge {
    grid-area: badge;
    justify-self: end;
    align-self: center;
}

.match-topbar-meta {
    grid-area: meta;
    min-width: 0;
}

.match-topbar-info-wrap,
.match-topbar-info {
    min-width: 0;
}

.match-topbar-match {
    font-weight: 900;
    font-size: 1.2rem;
    line-height: 1.15;
}

@media (max-width: 576px) {
    .has-topbar {
        padding-top: var(--match-topbar-height, 92px);
    }

    .match-topbar-logo {
        max-height: 56px;
    }

    .match-topbar-match {
        font-size: 1.05rem;
    }
}

.auth-brand {
    margin-bottom: 14px;
}

.auth-brand .app-logo {
    width: 220px;
}

.dashboard-brand {
    margin-bottom: 22px;
}

.page-brand {
    margin-bottom: 16px;
}

.card {
    border: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border-radius: 12px;
}

.btn {
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary);
    border: none;
}

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

/* Auth Styles */
.auth-container {
    max-width: 400px;
    margin: 50px auto;
    padding: 20px;
}

.auth-toggle {
    text-align: center;
    margin-top: 15px;
    cursor: pointer;
    color: var(--primary);
    font-weight: 600;
}

.home-main {
    max-width: var(--app-max-width);
}

.home-navbar {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

.home-navbar .container-fluid {
    max-width: var(--app-max-width);
    margin-left: auto;
    margin-right: auto;
    padding-left: calc(var(--bs-gutter-x, 1.5rem) * 0.5);
    padding-right: calc(var(--bs-gutter-x, 1.5rem) * 0.5);
}

.home-navbar .navbar-brand {
    padding-top: 0;
    padding-bottom: 0;
}

.home-logo {
    width: 120px;
    height: auto;
    display: block;
}

.home-navbar .nav-link {
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: rgba(15, 23, 42, 0.85);
}

.home-navbar .nav-link.active {
    color: var(--primary);
}

/* Dashboard Styles */
.dashboard-container {
    max-width: var(--app-max-width);
    margin: 50px auto;
    padding: 20px calc(var(--bs-gutter-x, 1.5rem) * 0.5);
}

@media (min-width: 992px) {
    .publico-page .col-lg-8,
    .mesario-container .col-lg-8 {
        flex: 0 0 auto;
        width: 100%;
    }
}

.nav-pills .nav-link {
    color: rgba(15, 23, 42, 0.85);
    font-weight: 700;
}

.nav-pills .nav-link.active,
.nav-pills .show > .nav-link {
    background-color: var(--primary);
    color: #111;
}

/* Control Panel Styles */
.scoreboard-control {
    text-align: center;
}

.score-display {
    font-size: 5rem;
    font-weight: 900;
    font-family: 'Courier New', Courier, monospace;
    background: #000;
    color: var(--score-digit);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    line-height: 1;
}

.timer-display {
    font-size: 4rem;
    font-weight: 700;
    font-family: 'Courier New', Courier, monospace;
    background: #000;
    color: var(--timer-digit);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.team-name {
    font-size: clamp(0.95rem, 1.4vw, 1.5rem);
    font-weight: 700;
    margin-bottom: 10px;
    text-transform: uppercase;
    line-height: 1.15;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
}

.team-name.text-truncate {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}

.score-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
    gap: 12px;
    max-width: 520px;
    margin: 0 auto;
}

.athlete-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 360px;
    margin: 0 auto;
}

.athlete-btn {
    width: 56px;
    min-height: 48px;
    padding: 0 !important;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    font-weight: 900;
    line-height: 1;
    white-space: nowrap;
}

.player-actions {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-top: 14px;
}

.player-action-btn {
    width: 78px;
    min-height: 64px;
    padding: 0 !important;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 900;
    line-height: 1;
}

.foul-dialog {
    border: 0;
    border-radius: 14px;
    padding: 0;
    max-width: min(520px, 92vw);
    width: 100%;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
}

.foul-dialog::backdrop {
    background: rgba(15, 23, 42, 0.55);
}

.btn-score {
    width: 100%;
    min-height: 64px;
    padding: 0;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

.btn-score .score-value {
    pointer-events: none;
}

.publico-events-log {
    overflow-y: auto;
    min-height: 120px;
    max-height: 220px;
}

.mesario-container {
    max-width: 100%;
    padding-top: 10px !important;
}

@media (min-width: 768px) {
    .publico-page {
        min-height: 100vh;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .publico-page .container {
        box-sizing: border-box;
    }

    .publico-card {
        display: flex;
        flex-direction: column;
    }

    .publico-page .timer-display {
        font-size: 3.2rem;
        margin-bottom: 10px;
    }

    .publico-page .score-display {
        font-size: 4rem;
        padding: 16px;
        margin-bottom: 0;
    }

    .publico-chart-card {
        flex: 0 0 auto;
    }

    .publico-events-log {
        max-height: clamp(160px, 26vh, 280px);
    }
}

@media (max-width: 576px) {
    .score-actions {
        grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
        gap: 10px;
    }

    .athlete-buttons {
        gap: 8px;
    }

    .athlete-btn {
        width: 52px;
        min-height: 44px;
        font-size: 1rem;
    }

    .player-actions {
        gap: 12px;
    }

    .player-action-btn {
        width: 72px;
        min-height: 60px;
        font-size: 1.5rem;
    }

    .btn-score {
        min-height: 58px;
        font-size: 1.1rem;
    }

    .publico-page .timer-display {
        font-size: 2.6rem;
    }

    .publico-page .score-display {
        font-size: 3.2rem;
        padding: 14px;
    }

    .publico-events-log {
        max-height: 200px;
    }
}

/* Public View Styles */
.public-container,
.public-container * {
    box-sizing: border-box;
}

.public-container {
    min-height: 100vh;
    padding: 16px;
    background-color: #f4f5f7;
    color: #111;
    overflow-x: hidden;
    overflow-y: auto;
}

.public-scoreboard {
    width: 100%;
    max-width: 1800px;
    margin: 0 auto;
    background: #fff;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.12);
}

.public-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.public-scoreline {
    text-align: center;
    font-weight: 900;
    font-family: 'Courier New', Courier, monospace;
    font-size: clamp(34px, 5vw, 60px);
    line-height: 1;
    padding: 6px 0 10px;
}

.public-sport {
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 1rem;
    line-height: 1.2;
}

.public-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.public-col {
    display: grid;
    grid-template-rows: auto auto auto 1fr;
    gap: 14px;
    min-width: 0;
}

.public-box {
    border: 2px solid #111;
    border-radius: 4px;
    background: #fff;
    padding: 12px 14px;
    min-width: 0;
}

.public-box-label {
    text-align: center;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 0.9rem;
    margin-bottom: 10px;
    line-height: 1.2;
}

.public-box-value {
    text-align: center;
    font-weight: 800;
    text-transform: uppercase;
    font-size: clamp(18px, 2.2vw, 30px);
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.public-box-score {
    text-align: center;
    font-weight: 900;
    font-family: 'Courier New', Courier, monospace;
    font-size: clamp(40px, 6vw, 78px);
    line-height: 1;
}

.public-box-meta {
    text-align: center;
    font-weight: 900;
    font-family: 'Courier New', Courier, monospace;
    font-size: clamp(22px, 3.5vw, 44px);
    line-height: 1;
}

.public-events {
    display: grid;
    gap: 10px;
}

.public-event {
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0,0,0,0.15);
}

.public-event-meta {
    font-size: 0.85rem;
    color: rgba(0,0,0,0.65);
    font-family: 'Courier New', Courier, monospace;
}

.public-event-text {
    font-size: 0.95rem;
    overflow-wrap: anywhere;
}

.public-empty {
    text-align: center;
    color: rgba(0,0,0,0.6);
    font-size: 0.95rem;
    padding: 10px 0;
}

.public-chart {
    display: grid;
    gap: 14px;
}

.public-hchart-team {
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
}

.public-hchart-title {
    text-align: center;
    font-weight: 700;
    color: rgba(0,0,0,0.7);
    margin-bottom: 10px;
}

.public-hchart-axis-row,
.public-hchart-row {
    display: grid;
    grid-template-columns: minmax(140px, 1.6fr) minmax(0, 4fr) 44px;
    gap: 10px;
    align-items: center;
}

.public-hchart-axis-row {
    margin-bottom: 8px;
}

.public-hchart-axis {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: rgba(0,0,0,0.55);
    padding: 0 2px;
}

.public-hchart-tick {
    min-width: 0;
    text-align: center;
}

.public-hchart-rows {
    display: grid;
    gap: 10px;
}

.public-hchart-label {
    text-align: right;
    font-size: 0.9rem;
    color: rgba(0,0,0,0.75);
    overflow-wrap: anywhere;
}

.public-hchart-bar-wrap {
    position: relative;
    width: 100%;
    height: 14px;
    border: 1px solid rgba(0,0,0,0.18);
    background-color: #fff;
    overflow: hidden;
    background-image: linear-gradient(to right, rgba(0,0,0,0.12) 1px, transparent 1px);
    background-size: calc(100% / var(--tick-count)) 100%;
    background-repeat: repeat;
}

.public-hchart-bar {
    height: 100%;
}

.public-hchart-bar--team1 {
    background: #f59e0b;
}

.public-hchart-bar--team2 {
    background: #ef4444;
}

.public-hchart-value {
    text-align: right;
    font-weight: 700;
    font-family: 'Courier New', Courier, monospace;
    color: rgba(0,0,0,0.7);
    font-size: 0.9rem;
}

.public-chart-team {
    display: grid;
    gap: 10px;
}

.public-chart-title {
    font-weight: 900;
    text-transform: uppercase;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
}

.public-chart-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 6fr auto;
    gap: 10px;
    align-items: center;
}

.public-chart-label {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 0.9rem;
}

.public-chart-bar-wrap {
    width: 100%;
    height: 12px;
    border: 1px solid rgba(0,0,0,0.25);
    background: rgba(0,0,0,0.06);
    overflow: hidden;
    border-radius: 6px;
}

.public-chart-bar {
    height: 100%;
    border-radius: 6px;
}

.public-chart-bar--home {
    background: #f59e0b;
}

.public-chart-bar--away {
    background: #ef4444;
}

.public-chart-value {
    font-family: 'Courier New', Courier, monospace;
    font-weight: 900;
    font-size: 0.95rem;
}

.public-footer {
    margin-top: 14px;
    text-align: center;
    color: rgba(0,0,0,0.7);
}

.status-badge {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #fff;
}

.status-live { background-color: var(--danger); animation: blink 1s infinite; }
.status-paused { background-color: var(--secondary); }
.status-finished { background-color: var(--success); }

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

@media (min-width: 768px) {
    .public-scoreboard {
        padding: 22px;
    }

    .public-grid {
        grid-template-columns: 1fr 1fr;
    }
}
