/*
 * OncroScore FanView - CSS
 * Matches iOS FanScoreboardView design exactly
 */

/* ============================================
   CSS VARIABLES - Match iOS Colors
   ============================================ */

:root {
    /* iOS Team Colors */
    --home-green: rgb(0, 242, 102);
    --guest-cyan: rgb(0, 188, 212);

    /* MoboScore Brand Colors */
    --electric-cyan: rgb(0, 188, 212);
    --lime-green: rgb(118, 255, 3);

    /* Possession Animation - Gold & White */
    --possession-gold: rgb(255, 215, 0);
    --possession-white: rgb(255, 255, 255);

    /* iOS Background Colors */
    --black-bg: rgb(0, 0, 0);
    --dark-gray: rgb(51, 51, 51);
    --medium-gray: rgb(85, 85, 85);
    --light-gray: rgb(170, 170, 170);

    /* Other Colors */
    --danger-red: rgb(255, 59, 48);
    --white: rgb(255, 255, 255);
}

/* ============================================
   GLOBAL STYLES
   ============================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    font-weight: 900; /* Match tvOS .black weight */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--black-bg);
    color: var(--white);
    overflow-x: hidden;
}

.screen {
    display: none;
    min-height: 100vh;
    width: 100%;
    position: relative;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* ============================================
   ENTRY SCREEN - Clean Black Background
   ============================================ */

.gradient-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--black-bg);
    z-index: -1;
}

.entry-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 32px;
    position: relative;
}

.header {
    text-align: center;
    margin-bottom: 48px;
}

.logo-entry {
    max-width: 180px;
    height: auto;
    margin-bottom: 20px;
}

.header h1 {
    font-size: 36px;
    font-weight: 900;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 16px;
    opacity: 0.9;
}

.input-section {
    width: 100%;
    max-width: 400px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid transparent;
    border-radius: 16px;
    padding: 4px 4px 4px 20px;
    transition: all 0.3s ease;
}

.input-wrapper.valid {
    border-color: rgb(76, 217, 100);
    background: rgba(76, 217, 100, 0.1);
}

.input-wrapper.invalid {
    border-color: rgb(255, 59, 48);
    background: rgba(255, 59, 48, 0.1);
}

#game-code-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 24px;
    font-weight: 900; /* Match tvOS .black weight */
    color: white;
    padding: 16px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    letter-spacing: 4px;
}

#game-code-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.qr-button {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.qr-button:hover {
    background: rgba(255, 255, 255, 0.4);
}

.qr-button svg {
    width: 28px;
    height: 28px;
}

.access-button {
    width: auto;
    min-width: 200px;
    background: var(--guest-cyan);
    border: none;
    border-radius: 12px;
    padding: 14px 32px;
    margin: 20px auto 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, opacity 0.3s ease;
}

.access-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.access-button:not(:disabled):active {
    transform: scale(0.95);
}

.access-button:not(:disabled):hover {
    opacity: 0.9;
}

.message {
    text-align: center;
    font-size: 14px;
    margin-top: 16px;
    min-height: 20px;
}

.message.validation {
    color: rgb(76, 217, 100);
}

.message.error {
    color: rgb(255, 59, 48);
}


/* ============================================
   SCOREBOARD SCREEN - iOS Design Match
   ============================================ */

#scoreboard-screen {
    background-color: var(--black-bg);
}

.scoreboard-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 8px 10px 80px 10px;
    overflow-y: auto;
    position: relative;
}

/* Fan Code Header */
.fan-code-header {
    text-align: center;
    padding: 4px 0;
    font-size: 14px;
    font-weight: 900; /* Match tvOS .black weight */
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    color: var(--white);
}

/* Clock Section - iOS Design */
.clock-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--dark-gray);
    border-radius: 10px;
    padding: 8px 10px;
    margin-top: 4px;
}

.clock-item {
    flex: 1;
    text-align: center;
}

.period-item {
    flex: 0.8;
}

.clock-label {
    font-size: 12px;
    font-weight: 900; /* Match tvOS .black weight */
    color: var(--white);
    margin-bottom: 2px;
}

.clock-value {
    font-size: 40px;
    font-weight: 900; /* Match tvOS .black weight */
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    font-variant-numeric: tabular-nums;
    color: var(--white);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    line-height: 1;
}

.period-circle {
    width: 40px;
    height: 40px;
    border: 2px solid var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.period-value {
    font-size: 24px;
    font-weight: 900; /* Match tvOS .black weight */
    color: var(--white);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

/* Ad Banner - iOS Design */
.ad-banner {
    background: var(--white);
    border-radius: 8px;
    padding: 8px 10px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.ad-label {
    font-size: 10px;
    color: rgb(0, 122, 255);
    font-weight: 400;
}

.fan-mode-badge {
    font-size: 10px;
    padding: 2px 8px;
    background: rgba(128, 128, 128, 0.8);
    color: var(--white);
    border-radius: 3px;
    font-weight: 600;
}

.oncro-label {
    font-size: 10px;
    color: rgb(128, 128, 128);
    font-weight: 400;
}

.oncro-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgb(255, 204, 0), rgb(255, 59, 48), rgb(175, 82, 222));
}

/* Main Scoreboard - iOS Design */
.main-scoreboard {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin: 20px 20px;
    flex: 1;
}

.team-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.center-spacer {
    width: 40px;
}

.team-name {
    font-size: 20px;
    font-weight: 900; /* Match tvOS .black weight */
    text-transform: uppercase;
    max-width: 180px;
    text-align: center;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.team-column.home .team-name {
    color: var(--home-green);
}

.team-column.guest .team-name {
    color: var(--guest-cyan);
}

/* Score Box - iOS Design (114x114) */
.score-box {
    position: relative;
    width: 114px;
    height: 114px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.home-score-box {
    background: var(--home-green);
}

.guest-score-box {
    background: var(--guest-cyan);
}

.score-value {
    font-size: 75px;
    font-weight: 900; /* Match tvOS .black weight */
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    font-variant-numeric: tabular-nums;
    color: var(--white);
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
    line-height: 1;
    z-index: 1;
}

/* 🔥 FIX: Responsive font size for 100+ points (3 digits) */
.score-value.large-score {
    font-size: 58px; /* Reduced from 75px to fit 3 digits */
    letter-spacing: -2px; /* Tighter spacing for 3 digits */
}

/* Possession Border - Gold & White Animated Gradient */
.possession-border {
    position: absolute;
    top: -2px;
    left: -2px;
    width: 118px;
    height: 118px;
    border-radius: 18px;
    border: 4px solid transparent;
    background: linear-gradient(45deg,
        var(--possession-gold),
        var(--possession-white),
        var(--possession-gold),
        var(--possession-white),
        var(--possession-gold)
    ) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    box-shadow:
        0 0 15px var(--possession-gold),
        0 0 25px var(--possession-white);
}

.possession-border.active {
    opacity: 1;
    animation: possessionGlow 1s ease-in-out infinite alternate,
               possessionShimmer 3s linear infinite;
}

@keyframes possessionGlow {
    from {
        box-shadow:
            0 0 15px var(--possession-gold),
            0 0 25px var(--possession-white);
    }
    to {
        box-shadow:
            0 0 25px var(--possession-gold),
            0 0 40px var(--possession-white),
            0 0 50px rgba(255, 215, 0, 0.5);
    }
}

@keyframes possessionShimmer {
    0% {
        background: linear-gradient(45deg,
            var(--possession-gold),
            var(--possession-white),
            var(--possession-gold),
            var(--possession-white),
            var(--possession-gold)
        ) border-box;
    }
    25% {
        background: linear-gradient(135deg,
            var(--possession-white),
            var(--possession-gold),
            var(--possession-white),
            var(--possession-gold),
            var(--possession-white)
        ) border-box;
    }
    50% {
        background: linear-gradient(225deg,
            var(--possession-gold),
            var(--possession-white),
            var(--possession-gold),
            var(--possession-white),
            var(--possession-gold)
        ) border-box;
    }
    75% {
        background: linear-gradient(315deg,
            var(--possession-white),
            var(--possession-gold),
            var(--possession-white),
            var(--possession-gold),
            var(--possession-white)
        ) border-box;
    }
    100% {
        background: linear-gradient(45deg,
            var(--possession-gold),
            var(--possession-white),
            var(--possession-gold),
            var(--possession-white),
            var(--possession-gold)
        ) border-box;
    }
}

/* Stat Box (Fouls/Timeouts) - iOS Design */
.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-label {
    font-size: 18px;
    font-weight: 900; /* Match tvOS .black weight */
    color: var(--white);
}

.stat-box-frame {
    width: 65px;
    height: 52px;
    border-radius: 10px;
    border: 3px solid;
    display: flex;
    align-items: center;
    justify-content: center;
}

.home-stat-frame {
    border-color: var(--home-green);
}

.guest-stat-frame {
    border-color: var(--guest-cyan);
}

.stat-box .stat-value {
    font-size: 48px;
    font-weight: 900; /* Match tvOS .black weight */
    color: var(--white);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    line-height: 1;
}

/* Bonus (red) styling for fouls >= bonus limit */
.stat-box-frame.bonus {
    border-color: var(--danger-red);
}

.stat-box .stat-value.bonus {
    color: var(--danger-red);
}

.stat-label.bonus {
    color: var(--white);
}

/* Game Leaders Section - iOS Design */
.game-leaders {
    margin-top: 4px;
}

.leaders-header {
    background: rgba(255, 255, 255, 0.1);
    padding: 6px;
    text-align: center;
    font-size: 14px;
    font-weight: 900; /* Match tvOS .black weight */
    color: var(--white);
}

.leaders-cards {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 10px;
}

.placeholder-text {
    width: 100%;
    text-align: center;
    font-size: 12px;
    color: rgb(128, 128, 128);
    padding: 20px 10px;
}

.leader-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px;
    border-radius: 8px;
}

.leader-card.home {
    background: var(--home-green);
}

.leader-card.guest {
    background: var(--guest-cyan);
}

.leader-title {
    font-size: 9px;
    font-weight: 700;
    color: var(--white);
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.leader-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.leader-circle::before {
    content: '';
    position: absolute;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--white);
    z-index: 0;
}

.leader-stat-value {
    font-size: 22px;
    font-weight: 700;
    font-family: 'SF Pro Rounded', -apple-system, sans-serif;
    position: relative;
    z-index: 1;
}

.leader-card.home .leader-stat-value {
    color: var(--home-green);
}

.leader-card.guest .leader-stat-value {
    color: var(--guest-cyan);
}

.leader-name {
    font-size: 11px;
    font-weight: 700;
    color: var(--white);
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.leader-stat {
    font-size: 10px;
    font-weight: 500;
    color: var(--white);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* Tab Bar */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: var(--black-bg);
    border-top: 1px solid rgb(128, 128, 128, 0.3);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
}

.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: rgb(128, 128, 128);
    cursor: pointer;
    padding: 8px;
    border-radius: 15px;
}

.tab svg {
    width: 24px;
    height: 24px;
}

.tab span {
    font-size: 11px;
    font-weight: 600;
}

.tab.active {
    color: var(--white);
    background: rgb(0, 188, 212);
}

/* Tab Content */
.tab-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: calc(100% - 70px); /* Account for tab bar height */
    background: var(--black-bg);
    z-index: 50;
    padding: 20px;
    padding-bottom: 90px; /* Extra padding for tab bar */
    overflow-y: auto;
}

.players-container,
.settings-container {
    color: var(--white);
}

.players-container h2,
.settings-container h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 20px;
}

/* Team Tabs */
.team-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.team-tab {
    flex: 1;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--white);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.team-tab:hover {
    background: rgba(255, 255, 255, 0.15);
}

.team-tab.active {
    background: rgba(0, 242, 102, 0.2);
    border-color: var(--home-green);
    color: var(--home-green);
}

.team-tab[data-team="guest"].active {
    background: rgba(0, 188, 212, 0.2);
    border-color: var(--guest-cyan);
    color: var(--guest-cyan);
}

/* Player Stats Table */
.stats-table {
    width: 100%;
    margin-top: 10px;
    overflow-x: auto; /* Enable horizontal scroll for wider table */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.stats-table::-webkit-scrollbar {
    height: 6px;
}

.stats-table::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.stats-header .stat-cell:first-child,
.stats-row .stat-cell:first-child {
    position: sticky;
    left: 0;
    z-index: 10;
}

.stats-header .stat-cell:first-child {
    background: rgba(255, 255, 255, 0.1);
}

.stats-row.home .stat-cell:first-child {
    background: transparent !important;
}

.stats-row.guest .stat-cell:first-child {
    background: transparent !important;
}

.stats-header {
    display: grid;
    grid-template-columns: minmax(100px, 140px) repeat(13, minmax(60px, 1fr));
    gap: 8px;
    padding: 8px 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px 8px 0 0;
    text-align: center;
    white-space: nowrap; /* Prevent header text wrapping */
}

.stats-header .stat-cell {
    font-size: 10px; /* 30% bigger than previous 8px */
    font-weight: 900; /* Extra bold to stand out */
    color: var(--white);
    letter-spacing: 0px;
}

.stats-row {
    display: grid;
    grid-template-columns: minmax(100px, 140px) repeat(13, minmax(60px, 1fr));
    gap: 8px;
    padding: 10px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 12px;
    text-align: center;
    align-items: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

/* Alternating row colors for home team */
.stats-row.home:nth-child(even) {
    background: rgba(0, 242, 102, 0.08);
    border-left: 3px solid var(--home-green);
}

.stats-row.home:nth-child(odd) {
    background: rgba(0, 242, 102, 0.15);
    border-left: 3px solid var(--home-green);
}

/* Alternating row colors for guest team */
.stats-row.guest:nth-child(even) {
    background: rgba(0, 188, 212, 0.08);
    border-left: 3px solid var(--guest-cyan);
}

.stats-row.guest:nth-child(odd) {
    background: rgba(0, 188, 212, 0.15);
    border-left: 3px solid var(--guest-cyan);
}

/* Hover animations - border glow only */
.stats-row.home:hover {
    box-shadow: 0 0 15px rgba(0, 242, 102, 0.4), inset 0 0 20px rgba(0, 242, 102, 0.1);
}

.stats-row.guest:hover {
    box-shadow: 0 0 15px rgba(0, 188, 212, 0.4), inset 0 0 20px rgba(0, 188, 212, 0.1);
}

/* Clean table background */
#home-players-list .stats-table,
#guest-players-list .stats-table {
    background: transparent;
}

.stat-cell {
    color: var(--white);
    font-weight: 600;
}

.stat-cell.player-name {
    text-align: left;
    display: flex;
    align-items: center;
    gap: 4px;
    padding-left: 4px;
    overflow: visible; /* Allow name to be fully visible */
}

.player-number {
    font-size: 10px;
    font-weight: 700;
    color: var(--light-gray);
    min-width: 22px;
    flex-shrink: 0; /* Don't shrink the number */
}

.stat-cell .name {
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap; /* Keep name on one line */
    overflow: visible; /* Don't truncate */
    flex: 1; /* Take remaining space */
}

/* Plus/Minus styling */
.stat-cell.plus-minus {
    font-weight: 700;
}

.stat-cell.plus-minus.positive {
    color: #00ff00; /* Green for positive */
}

.stat-cell.plus-minus.negative {
    color: #ff4444; /* Red for negative */
}

.players-container .placeholder {
    text-align: center;
    color: rgb(128, 128, 128);
    padding: 40px 20px;
    font-size: 14px;
}

.settings-section {
    margin-bottom: 30px;
}

.settings-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--light-gray);
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.setting-label {
    font-size: 16px;
    color: var(--white);
}

.status-indicator {
    font-size: 14px;
    color: rgb(76, 217, 100);
    font-weight: 600;
}

.disconnect-button {
    width: 100%;
    padding: 16px;
    background: var(--danger-red);
    color: var(--white);
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.app-version,
.copyright {
    font-size: 12px;
    color: rgb(128, 128, 128);
    text-align: center;
    margin: 8px 0;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    font-size: 16px;
    color: var(--white);
}

/* ============================================
   AD OVERLAY (Timeout/Warmup/Break)
   ============================================ */

.ad-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0; /* Full screen overlay - covers navigation tabs */
    background: #000000;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.overlay-top {
    padding: 40px 20px 20px;
    text-align: center;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0) 100%);
}

.overlay-label {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 3px;
    margin-bottom: 8px;
    opacity: 0.6;
}

.overlay-label.timeout-home {
    color: var(--home-green);
}

.overlay-label.timeout-guest {
    color: var(--guest-cyan);
}

.overlay-label.warmup {
    color: var(--lime-green);
}

.overlay-label.break {
    color: rgb(128, 0, 204); /* Purple */
}

.overlay-timer {
    font-size: 64px;
    font-weight: 700;
    font-family: 'SF Pro Display', -apple-system, sans-serif;
    color: var(--white);
    opacity: 0.6;
    letter-spacing: 2px;
}

.overlay-bottom {
    padding: 16px 12px 40px; /* Increased bottom padding to prevent cutoff */
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0) 100%);
    flex-shrink: 0; /* Prevent shrinking when content overflows */
    min-height: 140px; /* Increased minimum height for visibility */
    margin-bottom: 20px; /* Add margin to move entire section up from bottom edge */
}

.sponsor-text {
    text-align: center;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.lower-thirds {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(0, 0, 0, 0.7); /* Darker background for better visibility */
    border: 2px solid rgba(255, 255, 255, 0.3); /* Brighter border */
    border-radius: 12px;
    padding: 12px 12px; /* Increased padding */
    min-height: 80px; /* Ensure minimum height */
}

.team-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.team-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
}

.team-label.home {
    color: var(--home-green);
}

.team-label.guest {
    color: var(--guest-cyan);
}

.score-display {
    font-size: 56px;
    font-weight: 700;
    font-family: 'SF Pro Display', -apple-system, sans-serif;
    color: var(--white);
    padding: 4px 12px;
    border-radius: 6px;
    line-height: 1;
}

/* 🔥 FIX: Responsive font size for 100+ points in overlay (3 digits) */
.score-display.large-score {
    font-size: 44px; /* Reduced from 56px to fit 3 digits */
    letter-spacing: -1px; /* Tighter spacing for 3 digits */
}

.home-side .score-display {
    border: 2px solid var(--home-green);
}

.guest-side .score-display {
    border: 2px solid var(--guest-cyan);
}

.team-stats {
    display: flex;
    gap: 6px;
    font-size: 10px;
    color: #999999;
}

.center-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.game-clock-overlay,
.shot-clock-overlay {
    font-size: 28px;
    font-weight: 700;
    font-family: 'SF Pro Display', -apple-system, sans-serif;
    color: var(--white);
}

.clock-label-small {
    font-size: 9px;
    font-weight: 500;
    color: #999999;
    letter-spacing: 0.5px;
}

.period-circle-overlay {
    width: 36px;
    height: 36px;
    border: 2px solid var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--white);
}

.possession-arrow {
    font-size: 14px;
    margin-top: 4px;
}

/* Overlay Middle Section - Ad Content or Stats */
.overlay-middle {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    margin-bottom: 50px; /* Move ad content up 50px to ensure lower thirds visibility */
}

/* Stats Carousel Content */
.stats-content {
    width: 100%;
    max-width: 600px;
    text-align: center;
}

.stats-header {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--electric-cyan);
    margin-bottom: 30px;
    text-transform: uppercase;
}

.stats-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.stats-item {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px 20px;
    font-size: 18px;
    font-weight: 600;
    color: var(--white);
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stats-item-rank {
    color: var(--lime-green);
    font-size: 20px;
    font-weight: 700;
    min-width: 30px;
}

.stats-item-name {
    flex: 1;
    padding: 0 15px;
}

.stats-item-value {
    color: var(--electric-cyan);
    font-size: 22px;
    font-weight: 700;
}

/* ELITE: Video/Image Ad Content - Marcus Johnson (Ex-Apple) */
.video-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.overlay-ad-image {
    max-width: 70%;
    max-height: 70%;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    margin-bottom: 50px;
    /* Smooth crossfade transition - slower for better blending */
    opacity: 0;
    transform: scale(0.98);
    animation: adFadeIn 0.8s cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
}

/* Mobile Portrait: Full-screen ads with overlaid UI */
@media (max-width: 768px) and (orientation: portrait) {
    /* Make overlay container fill screen */
    .full-screen-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        z-index: 9999;
    }

    /* Make ad full-screen background */
    .overlay-middle {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        padding: 0;
        margin: 0;
        z-index: 1;
    }

    .video-content {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }

    .overlay-ad-image {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        object-fit: cover;
        margin: 0;
        border-radius: 0;
    }

    /* Overlay timer and label on top */
    .overlay-top {
        position: relative;
        z-index: 10;
        background: linear-gradient(180deg, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0) 100%);
        padding: 60px 20px 40px;
    }

    .overlay-label {
        font-size: 20px;
        text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    }

    .overlay-timer {
        font-size: 72px;
        text-shadow: 0 2px 12px rgba(0, 0, 0, 0.9);
    }

    /* Overlay scoreboard on bottom */
    .overlay-bottom {
        position: relative;
        z-index: 10;
        background: linear-gradient(0deg, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0) 100%);
        padding: 40px 16px 60px;
        margin-bottom: 0;
    }

    .lower-thirds {
        background: rgba(0, 0, 0, 0.85);
        border: 2px solid rgba(255, 255, 255, 0.4);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    }
}

/* Video Loading Indicator */
.video-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    z-index: 100;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--electric-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ELITE: Video Unmute Button - Icon Only, Top Right Above Scoreboard */
.video-unmute-button {
    position: fixed; /* Fixed to always be on top, regardless of overlay stacking */
    top: 80px;
    right: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    padding: 0;
    background: rgba(0, 0, 0, 0.9);
    border: 3px solid var(--electric-cyan);
    border-radius: 50%;
    cursor: pointer;
    z-index: 10000 !important; /* Must be above overlay (z-index: 2000) and all other elements */
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 24px rgba(0, 188, 212, 0.6);
    pointer-events: auto !important; /* Ensure button is always clickable */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.video-unmute-button svg {
    pointer-events: none !important; /* SVG should never block button clicks */
}

.video-unmute-button:hover {
    background: rgba(0, 188, 212, 0.4);
    border-color: var(--lime-green);
    border-width: 4px;
    transform: scale(1.15);
    box-shadow: 0 12px 40px rgba(118, 255, 3, 0.6),
                0 0 20px rgba(0, 188, 212, 0.8);
    animation: none; /* Stop pulse on hover */
}

.video-unmute-button:active {
    transform: scale(0.9);
    background: rgba(118, 255, 3, 0.3);
    border-color: var(--lime-green);
    box-shadow: 0 4px 16px rgba(118, 255, 3, 0.8);
    transition: all 0.1s ease;
}

.video-unmute-button svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.video-unmute-button span {
    display: none; /* Hide text, icon only */
}

/* Pulse animation for unmute button */
@keyframes pulse-unmute {
    0%, 100% {
        box-shadow: 0 8px 24px rgba(0, 188, 212, 0.6);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 12px 32px rgba(0, 188, 212, 1);
        transform: scale(1.05);
    }
}

.video-unmute-button {
    animation: pulse-unmute 2s ease-in-out infinite;
}

/* Mobile portrait adjustments */
@media (max-width: 768px) and (orientation: portrait) {
    .video-unmute-button {
        top: 60px;
        right: 20px;
        width: 48px;
        height: 48px;
        z-index: 10001 !important; /* Must be above overlay-top (z-index: 10) in portrait */
        position: fixed !important; /* Fixed positioning to ensure it's above all overlay elements */
        pointer-events: auto !important; /* Force clickability */
    }

    .video-unmute-button svg {
        width: 24px;
        height: 24px;
        pointer-events: none; /* SVG shouldn't intercept clicks */
    }
}

/* Narrow screens (any orientation) - ensure button works */
@media (max-width: 768px) {
    .video-unmute-button {
        z-index: 10001 !important; /* Always on top in narrow screens */
        position: fixed !important; /* Always fixed in narrow screens */
        pointer-events: auto !important; /* Always clickable */
    }

    .video-unmute-button svg {
        pointer-events: none !important; /* SVG never blocks clicks */
    }
}

/* ELITE: Mobile Sponsor Border Shimmer - Yuki Tanaka (Ex-Nintendo) */
.mobile-sponsor-border {
    position: fixed;
    bottom: 230px;
    left: 50%;
    transform: translateX(-50%);
    padding: 3px;
    border-radius: 18px;
    pointer-events: none;
    background: linear-gradient(90deg,
        rgba(255, 255, 255, 0.8),
        rgba(211, 211, 211, 0.5),
        rgba(255, 255, 255, 0.8),
        rgba(211, 211, 211, 0.5));
    background-size: 200% 100%;
    animation: shimmer 3s linear infinite;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
    z-index: 10001;
    opacity: 0.6;
}

/* ELITE: Visit Sponsor Button - White border with shimmer glow - Marcus Johnson (Ex-Apple), Lisa Park (Ex-Coinbase), Yuki Tanaka (Ex-Nintendo) */
.visit-sponsor-button {
    position: fixed;
    bottom: 230px; /* Positioned well above "Please Support Our Sponsors" text (moved up 20px more) */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    background: rgba(0, 188, 212, 0.9); /* Cyan background */
    border: 3px solid white; /* White border */
    border-radius: 18px;
    cursor: pointer;
    z-index: 10002 !important; /* Above video overlay and unmute button */
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5), 0 0 30px rgba(255, 255, 255, 0.3); /* White glow effect */
    pointer-events: auto !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    font-size: 12px;
    font-weight: 800;
    color: #FFF;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.visit-sponsor-button svg {
    width: 14px;
    height: 14px;
    fill: #FFF;
    flex-shrink: 0;
    pointer-events: none;
}

.visit-sponsor-button span {
    color: #FFF;
    font-weight: 700;
    white-space: nowrap;
}

.visit-sponsor-button:hover {
    transform: translateX(-50%) scale(1.08);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.7), 0 0 40px rgba(255, 255, 255, 0.5), 0 4px 12px rgba(0, 188, 212, 0.5); /* Enhanced glow on hover */
    background: rgba(0, 188, 212, 1); /* Brighter cyan on hover */
}

.visit-sponsor-button:active {
    transform: translateX(-50%) scale(0.95);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 0 0 20px rgba(255, 255, 255, 0.3); /* Reduced glow on click */
    transition: all 0.1s ease;
    background: rgba(0, 150, 170, 1); /* Darker cyan on click */
}

/* Mobile portrait adjustments */
@media (max-width: 768px) and (orientation: portrait) {
    .visit-sponsor-button {
        padding: 8px 15px;
        font-size: 10px;
        border-radius: 15px;
        bottom: 230px;
        z-index: 10002 !important;
        position: fixed !important;
        pointer-events: auto !important;
    }

    .visit-sponsor-button svg {
        width: 12px;
        height: 12px;
    }
}

/* Narrow screens (any orientation) */
@media (max-width: 768px) {
    .visit-sponsor-button {
        z-index: 10002 !important;
        position: fixed !important;
        pointer-events: auto !important;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: var(--white);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 1px;
    opacity: 0.8;
}

/* Ad fade-in animation - subtle scale and smooth ease */
@keyframes adFadeIn {
    0% {
        opacity: 0;
        transform: scale(0.98);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Ad fade-out animation - crossfade with subtle scale */
@keyframes adFadeOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(1.02);
    }
}

.overlay-ad-image.fade-out {
    animation: adFadeOut 0.7s cubic-bezier(0.4, 0.0, 0.6, 1) forwards;
}

/* Ad Placeholder Content */
.placeholder-content {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-box {
    background: linear-gradient(135deg, rgba(0, 188, 212, 0.1) 0%, rgba(118, 255, 3, 0.1) 100%);
    border: 3px dashed rgba(255, 255, 255, 0.3);
    border-radius: 24px;
    padding: 60px 40px;
    text-align: center;
    max-width: 500px;
}

.placeholder-icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.placeholder-title {
    font-size: 48px;
    font-weight: 700;
    color: var(--white);
    letter-spacing: 3px;
    margin-bottom: 15px;
}

.placeholder-subtitle {
    font-size: 20px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 25px;
}

.placeholder-email {
    font-size: 24px;
    font-weight: 600;
    color: var(--electric-cyan);
    letter-spacing: 1px;
}


/* ============================================
   SPLIT SCREEN LAYOUT - Desktop Wide Screens
   ONLY ACTIVE DURING TIMEOUT/WARMUP/BREAK
   ============================================ */

/* Default: Full width scoreboard, ads hidden */
.scoreboard-container {
    width: 100%;
    flex: 1;
}

.ads-section {
    display: none;
}

/* Desktop Wide Screen: Split layout ONLY when overlay is active (1600px and wider) */
@media (min-width: 1600px) {
    /* Add .split-screen class to #scoreboard-screen when timeout/warmup/break is active */
    #scoreboard-screen.split-screen {
        display: flex;
        flex-direction: row;
        height: 100vh;
        overflow: hidden;
    }

    #scoreboard-screen.split-screen .scoreboard-container {
        width: 50%;
        flex: 0 0 50%;
        overflow-y: auto;
        border-right: 2px solid var(--dark-gray);
    }

    #scoreboard-screen.split-screen .ads-section {
        display: flex;
        width: 50%;
        flex: 0 0 50%;
        background: var(--black-bg);
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

    .ad-container {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px;
    }

    .ad-display {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--dark-gray);
        border-radius: 12px;
        overflow: hidden;
    }

    .ad-display img,
    .ad-display video {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
    }

    .ad-placeholder {
        text-align: center;
        color: rgba(255, 255, 255, 0.5);
    }

    .ad-placeholder p {
        font-size: 32px;
        font-weight: 600;
        letter-spacing: 2px;
    }
}

/* Extra Wide Desktop: Even larger split (1920px and wider) */
@media (min-width: 1920px) {
    .ad-placeholder p {
        font-size: 48px;
    }
}

/* ============================================
   HIDE OLD FULL-SCREEN OVERLAY ON WIDE DESKTOP
   ============================================ */

/* On wide desktop (1600px+), hide the old full-screen ad-overlay when split-screen is active */
@media (min-width: 1600px) {
    #scoreboard-screen.split-screen #ad-overlay {
        display: none !important;
    }
}

/* ============================================
   ANIMATED GRADIENT BORDER - Match tvOS
   ============================================ */

/* Rotating border animation for Visit Sponsor button */
@keyframes rotateBorder {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Shimmer animation for border glow */
@keyframes shimmer {
    0% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 200% 50%;
    }
}

/* Visit Sponsor Button Hover & Active States */
#split-visit-sponsor-btn {
    transition: all 0.2s ease;
}

#split-visit-sponsor-btn:hover {
    background: rgba(0, 188, 212, 1) !important;
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.7), 0 0 40px rgba(255, 255, 255, 0.5), 0 4px 12px rgba(0, 188, 212, 0.5);
}

#split-visit-sponsor-btn:active {
    transform: translateX(-50%) scale(0.95);
    background: rgba(0, 150, 170, 1) !important;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 0 0 20px rgba(255, 255, 255, 0.3);
}

/* Unmute Button Hover & Active States */
#split-unmute-btn {
    transition: all 0.2s ease;
}

#split-unmute-btn:hover {
    background: rgba(0, 0, 0, 0.9) !important;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
}

#split-unmute-btn:active {
    transform: scale(0.9);
    background: rgba(0, 0, 0, 1) !important;
}

/* FREE TIER: AdSense & Upsell Content */
.adsense-content,
.upsell-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.9) 0%, rgba(20, 20, 20, 0.95) 100%);
}

.upsell-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 800px;
    padding: 40px;
}

.upsell-message {
    width: 100%;
    animation: fadeIn 0.5s ease-in;
}

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

/* AdSense Container */
.adsense-content ins {
    background: transparent;
}

/* YouTube Link Button Hover Effect */
#youtube-link-button:hover {
    background: #CC0000 !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255,0,0,0.4) !important;
}

#youtube-link-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(255,0,0,0.3) !important;
}

/* Unlock Livestream Button Hover Effect */
#unlock-livestream-btn:hover {
    background: #0097A7 !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,188,212,0.4) !important;
}

#unlock-livestream-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0,188,212,0.3) !important;
}
