:root {
    --primary: #64ffda;
    --primary-dark: #1de9b6;
    --secondary: #00bcd4;
    --accent: #ffd700;
    --bg-primary: #131331;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #002b3a;
    /*--bg-primary: #0f172a;     
    --bg-secondary: #1e293b;   
    --bg-tertiary: #1a202c;*/
    --surface: rgba(30, 41, 59, 0.4);
    --surface2: rgba(127, 255, 234, 0.03);
    --surface-hover: rgba(30, 41, 59, 0.6);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(148, 163, 184, 0.1);
    --border-focus: rgba(100, 255, 218, 0.3);
    --shadow: rgba(0, 0, 0, 0.3);
    --glow: rgba(100, 255, 218, 0.3)
}

/* Custom Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(30, 41, 59, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--secondary) 100%);
    box-shadow: 0 0 6px rgba(100, 255, 218, 0.3);
}

::-webkit-scrollbar-thumb:active {
    background: var(--primary);
}

::-webkit-scrollbar-corner {
    background: rgba(30, 41, 59, 0.3);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--primary) rgba(30, 41, 59, 0.3);
}

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

/*
html {
    font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-weight: 600;*/ /* SemiBold */
/*}

body { font: inherit; }
button, input, select, textarea { font: inherit; }
h1, h2, h3, h4, h5, h6 { font: inherit; }
code, pre, kbd, samp { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", "Courier New", monospace; font-weight: 400; }



body {
   /*font-family: 'Inter', sans-serif;*/ 
    /*font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-tertiary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    position: relative;
    overflow-x: hidden;
}*/

html {
    font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-weight: 600;
}

* {
    font-family: inherit;
}

body {
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-tertiary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    position: relative;
    overflow-x: hidden;
}

code, pre, kbd, samp {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important;
    font-weight: 400;
}


body::before {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background:
        radial-gradient(circle at 20% 80%, rgba(100, 255, 218, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(29, 233, 182, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(0, 188, 212, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

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

.header {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
}

.lang-selector {
    position: absolute;
    top: 20px;
    right: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    backdrop-filter: blur(10px);
    z-index: 100;
}

.lang-selector i {
    color: var(--primary);
    font-size: 1rem;
}

.lang-select {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    font-weight: 500;
    min-width: 100px;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364ffda' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

.lang-select:focus {
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(100, 255, 218, 0.1);
}

.lang-select:hover {
    border-color: var(--border-focus);
}

.main-title-container {
    display: inline-block;
    margin-bottom: 0.5rem;
}

.logo-image {
    height: 300px;
    width: auto;
    display: block;
    filter: drop-shadow(0 0 20px rgba(100, 255, 218, 0.3));
    animation: titleGlow 3s ease-in-out infinite alternate;
    transition: transform 0.3s ease;
}

.logo-image:hover {
    transform: scale(1.05);
}

@keyframes titleGlow {
    from { filter: drop-shadow(0 0 20px rgba(100, 255, 218, 0.3)); }
    to { filter: drop-shadow(0 0 30px rgba(100, 255, 218, 0.5)); }
}

.subtitle {
    font-size: 1.5rem;
    color: var(--text-secondary);
    font-weight: 300;
    letter-spacing: 0.1em;
    opacity: 0;
    animation: fadeInUp 1s ease-out 0.5s forwards;
}

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

.section {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2.5rem;
    margin-bottom: 2rem;
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px var(--shadow);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.section::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    opacity: 0.5;
}

.section:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px var(--shadow);
    border-color: var(--border-focus);
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-title i {
    font-size: 1.25rem;
    color: var(--primary-dark);
}

.setup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#leagueFormatGroup,
#playoffEndingGroup,
#groupAdvancementGroup {
    flex-direction: column;
    gap: 0.5rem;
}

#matchupConfigGroup,
#matchupGamesToWinGroup,
#matchupTiebreakRuleGroup {
    flex-direction: column;
    gap: 1rem !important;
}

#leagueFormatGroup:not([style*="display: none"]),
#playoffEndingGroup:not([style*="display: none"]),
#groupAdvancementGroup:not([style*="display: none"]),
#matchupConfigGroup:not([style*="display: none"]),
#matchupGamesToWinGroup:not([style*="display: none"]),
#matchupTiebreakRuleGroup:not([style*="display: none"]) {
    display: flex;
}

#leagueFormatGroup .input-label,
#playoffEndingGroup .input-label,
#groupAdvancementGroup .input-label {
    display: block;
    width: 100%;
}

#matchupConfigGroup .input-label,
#matchupGamesToWinGroup .input-label {
    display: block;
    width: 100%;
    margin-bottom: 0.5rem;
}

#leagueFormatGroup #format,
#playoffEndingGroup #playoffEnding,
#groupAdvancementGroup #groupAdvancement,
#matchupConfigGroup #matchupBestOfSeries,
#matchupGamesToWinGroup #matchupGamesToWin,
#matchupTiebreakRuleGroup #matchupTiebreakRule {
    display: block;
    width: 100%;
}

.input-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-field, .score-input {
    padding: 0.875rem 1rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
    outline: none;
    font-weight: 500;
}

.input-field {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

select.input-field {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364ffda' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
    cursor: pointer;
}

.input-field:focus, .score-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(100, 255, 218, 0.1);
    background-color: var(--bg-secondary);
    filter: brightness(1.1);
}

.input-field:hover, .score-input:hover {
    border-color: var(--border-focus);
}

.team-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.team-input-wrapper {
    position: relative;
}

.seed-number {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary);
    font-weight: 600;
    font-size: 0.9rem;
    pointer-events: none;
    z-index: 1;
}

.team-input-wrapper .input-field {
    padding-left: 2.5rem;
    width: 100%;
    box-sizing: border-box;
}

.completed-score {
    background: rgba(100, 255, 218, 0.1) !important;
    border-color: rgba(100, 255, 218, 0.3) !important;
}

.completed-score:hover {
    background: rgba(100, 255, 218, 0.15) !important;
    border-color: var(--primary) !important;
    cursor: pointer;
}

.completed-score:focus {
    background: rgba(15, 23, 42, 0.95) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 4px rgba(100, 255, 218, 0.2) !important;
}

.btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--bg-primary);
    padding: 1rem 2rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px var(--glow);
    min-height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px var(--glow);
    filter: brightness(1.1);
}

.btn:active {
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--surface-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-focus);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.btn-secondary:hover {
    background: rgba(100, 255, 218, 0.1);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 8px 30px rgba(100, 255, 218, 0.2);
}

.btn:disabled {
    opacity: 0.7;
    cursor: default;
    transform: none;
}

.btn:disabled:hover {
    transform: none;
    box-shadow: 0 4px 20px var(--glow);
}

.hidden {
    display: none;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s linear infinite;
}

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

.phase-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 2.5rem 0 1.5rem 0;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, rgba(100, 255, 218, 0.1), rgba(29, 233, 182, 0.1));
    border-radius: 12px;
    border-left: 4px solid var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.matchday-header {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin: 2rem 0 1rem 0;
    padding: 0.75rem 1rem;
    border-left: 3px solid var(--primary-dark);
    background: rgba(29, 233, 182, 0.05);
    border-radius: 0 8px 8px 0;
}

.table-container {
    overflow-x: auto;
    border-radius: 16px;
    box-shadow: 0 4px 20px var(--shadow);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: rgba(15, 23, 42, 0.7);
    border-radius: 16px;
    overflow: hidden;
}

th {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: var(--primary);
    padding: 1.5rem 1rem;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border-focus);
    text-transform: uppercase;
    position: sticky;
    top: 0;
    z-index: 10;
}

td {
    padding: 1.25rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    transition: all 0.3s ease;
    font-weight: 500;
}

tbody tr:hover td {
    background: rgba(100, 255, 218, 0.05);
}

tbody tr:last-child td {
    border-bottom: none;
}

.champion {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 193, 7, 0.15) 100%) !important;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.position-cell {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.1rem;
}

.points-cell {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary-dark);
}

.export-buttons, .action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.export-btn {
    background: var(--surface-hover);
    color: var(--text-primary);
    padding: 1rem 1.75rem;
    border: 1px solid var(--border-focus);
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 48px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.export-btn:hover {
    background: rgba(100, 255, 218, 0.1);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(100, 255, 218, 0.2);
}

.legend {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.8;
    border: 1px solid var(--border);
}

.legend strong {
    color: var(--text-primary);
    font-weight: 600;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.stat-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-focus);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(148, 163, 184, 0.2);
    border-radius: 3px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    border-radius: 3px;
    transition: width 0.5s ease;
}

.notification {
    position: fixed;
    top: 20px;
    right: -25px;
    background: var(--surface);
    border: 1px solid var(--border-focus);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    color: var(--text-primary);
    box-shadow: 0 4px 20px var(--shadow);
    backdrop-filter: blur(10px);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.notification.show {
    transform: translateX(-45px);
}

.notification.success {
    border-color: var(--primary);
}

.notification.error {
    border-color: #ef4444;
}

.bracket-scroll-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    padding-bottom: 10px;
}

.bracket-scroll-wrapper::-webkit-scrollbar {
    height: 8px;
}

.bracket-scroll-wrapper::-webkit-scrollbar-track {
    background: rgba(30, 41, 59, 0.3);
    border-radius: 4px;
}

.bracket-scroll-wrapper::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 4px;
}

.bracket-scroll-wrapper::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(90deg, var(--primary-dark) 0%, var(--secondary) 100%);
}

.bracket-scroll-wrapper,
.section {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}

.swiss-standings-permanent {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border);
}

.swiss-advanced {
    background: linear-gradient(135deg, rgba(100, 255, 218, 0.15) 0%, rgba(29, 233, 182, 0.15) 100%) !important;
    border: 1px solid rgba(100, 255, 218, 0.3);
}

.swiss-eliminated {
    opacity: 0.5;
    background: rgba(239, 68, 68, 0.05) !important;
}

.swiss-status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 1rem;
}

.swiss-status-badge.advanced {
    background: rgba(100, 255, 218, 0.2);
    color: var(--primary);
    border: 1px solid var(--primary);
}

.swiss-status-badge.eliminated {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid #ef4444;
}

.bracket {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 4rem;
    min-width: max-content;
    padding: 20px;
}

.bracket-round {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    position: relative;
    min-width: 240px;
}

.bracket-round-title {
    text-align: center;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.bracket-match {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 0;
    min-width: 240px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.bracket-match:hover {
    border-color: var(--border-focus);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(100, 255, 218, 0.1);
}

/* Disable hover during transition to prevent jump */
.bracket-match.no-hover {
    pointer-events: none;
}

.bracket-match.no-hover:hover {
    transform: none;
    border-color: var(--border);
    box-shadow: none;
}

.bracket-match.completed {
    border-color: rgba(29, 233, 182, 0.4);
}

.bracket-match.live {
    animation: liveMatchPulse 3s ease-in-out infinite;
}

/* Mobile-focused state (requires focus before live mode on mobile) */
@media (max-width: 768px) {
    .bracket-match.mobile-focused,
    .series-match-container.mobile-focused {
        border-color: rgba(100, 255, 218, 0.3);
        box-shadow: 0 0 15px rgba(100, 255, 218, 0.15);
    }
}

.bracket-match .live-indicator {
    position: absolute;
    top: 50%;
    left: 66.6666666667%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.2s ease;
    z-index: 10;
    pointer-events: none;
    background: transparent;
    border: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.bracket-match:hover .live-indicator {
    opacity: 1;
    pointer-events: all;
}

.bracket-match.live .live-indicator {
    opacity: 0;
}

.bracket-match.live:hover .live-indicator {
    opacity: 1;
    pointer-events: all;
}

.live-indicator i {
    font-size: 18px;
    color: rgba(100, 255, 218, 0.9);
    filter: drop-shadow(0 0 4px rgba(100, 255, 218, 0.4));
    transition: all 0.2s ease;
}

.bracket-match.live .live-indicator i,
.series-match-container.live .live-indicator i {
    color: #ef4444;
    filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.4));
}

.live-indicator:hover i {
    transform: scale(1.2);
    filter: drop-shadow(0 0 6px rgba(100, 255, 218, 0.6));
}

.bracket-match.live .live-indicator:hover i,
.series-match-container.live .live-indicator:hover i {
    color: #ef4444;
    filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.6));
}

/*@keyframes liveDotPulse {
    0%, 100% {
        transform: scale(0.9);
        box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 12px rgba(239, 68, 68, 0.8);
    }
}

.bracket-match.live .live-dot,
.series-match-container.live .live-dot {
    animation: liveDotPulse 3s ease-in-out infinite;
    transform-origin: center;
}*/

/* Ring (outline) that grows and fades from the dot */
.bracket-match.live .live-dot::before,
.bracket-match.live .live-dot::after,
.series-match-container.live .live-dot::before,
.series-match-container.live .live-dot::after,
.matchup-container.live .live-dot::before,
.matchup-container.live .live-dot::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 10px;               
    height: 10px;            
    transform: translate(-50%, -50%) scale(1);
    border-radius: 50%;
    border: 0.8px solid rgba(239, 68, 68, 0.9); 
    background: transparent;  
    pointer-events: none;
    box-sizing: border-box;
    z-index: 5;                
    animation: liveRing 2.5s ease-out infinite;
    transform-origin: center center;
}


.bracket-match.live .live-dot::after,
.series-match-container.live .live-dot::after,
.matchup-container.live .live-dot::after {
    animation-delay: 0.8s;
}


@keyframes liveRing {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
        border-color: rgba(239, 68, 68, 0.9);
    }
    60% {
        opacity: 0.05;
        transform: translate(-50%, -50%) scale(2.6); 
        border-color: rgba(239, 68, 68, 0.5);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(3.2);
        border-color: rgba(239, 68, 68, 0);
    }
}



.bracket-match.live .live-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 10px;
    height: 10px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

.bracket-team {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    transition: all 0.3s ease;
    min-height: 60px;
    min-width: 280px;
    gap: 0.75rem;
}

.bracket-team:last-child {
    border-bottom: none;
}

.bracket-team.winner {
    background: rgba(100, 255, 218, 0.1);
    color: var(--primary);
    font-weight: 700;
}

.bracket-team.loser {
    opacity: 0.8;
    color: var(--text-primary);
}

.bracket-team-name {
    font-weight: 600;
    flex: 1;
    padding-right: 0.75rem;
    text-align: left;
    min-width: 0;
    font-size: 0.98rem;
    max-width: 155px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bracket-score-input {
    width: 50px;
    height: 38px;
    padding: 0;
    text-align: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.bracket-score-input::-webkit-outer-spin-button,
.bracket-score-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.bracket-score-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(100, 255, 218, 0.1);
    background: var(--bg-secondary);
    filter: brightness(1.1);
}

.champion-display {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 193, 7, 0.2) 100%);
    border: 2px solid var(--accent);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    margin: 2rem auto;
    max-width: 300px;
    box-shadow: 0 8px 32px rgba(255, 215, 0, 0.3);
}

.champion-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.champion-name {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--accent), #ffa000);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bracket-container {
    padding: 0;
    min-height: 400px;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.bracket-scroll-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    padding-bottom: 10px;
}

/* NEW STYLES FOR GROUPS FEATURE */

.group-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    justify-content: center;
}

.group-tab {
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.group-tab:hover {
    border-color: var(--border-focus);
    color: var(--text-primary);
}

.group-tab.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--bg-primary);
    border-color: var(--primary);
    box-shadow: 0 4px 20px var(--glow);
}

.group-content {
    display: none;
}

.group-content.active {
    display: block;
}

.group-stage-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.group-summary-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.group-summary-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-focus);
}

.group-summary-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.group-summary-team {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
}

.group-summary-team:last-child {
    border-bottom: none;
}

.group-summary-position {
    font-weight: 700;
    color: var(--primary);
    min-width: 30px;
}

.group-summary-name {
    flex: 1;
    padding: 0 1rem;
    font-weight: 600;
}

.group-summary-points {
    font-weight: 700;
    color: var(--primary-dark);
    min-width: 40px;
    text-align: right;
}

.group-summary-team.qualified {
    background: rgba(100, 255, 218, 0.1);
    border-radius: 5px;
    padding: -0.5rem 0;
	margin-bottom: 0.25rem;
}

.group-summary-team.qualified .group-summary-position,
.group-summary-team.qualified .group-summary-name {
    color: var(--primary);
}

.group-assignment-section {
    margin: 2rem 0;
}

.group-assignment-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.group-assignment-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
}

.group-assignment-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
    text-align: center;
    text-transform: uppercase;
}

.group-assignment-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

#groupTabsBottom {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

:focus-visible {
    outline: 3px solid rgba(100,255,218,0.12);
    outline-offset: 3px;
    border-radius: 8px;
}

.btn:focus-visible, .export-btn:focus-visible, .input-field:focus-visible, .score-input:focus-visible, .bracket-score-input:focus-visible {
    outline: 3px solid rgba(100,255,218,0.18);
    outline-offset: 3px;
}

#setupSection input:disabled,
#setupSection select:disabled {
    background: rgba(15, 23, 42, 0.4) !important;
    color: var(--text-muted) !important;
    border-color: var(--border) !important;
    cursor: default !important;
}

/* Match-Up Tiebreaker: Locked but more visible (V11 Addition) */
#matchupTiebreaker {
    opacity: 0.85 !important;
    pointer-events: none !important; /* Lock it - can't be changed by user */
    cursor: default !important;
    background-image: none !important; /* Hide dropdown arrow */
    padding-right: 1rem !important; /* Remove extra padding for arrow */
}


#setupSection .btn:disabled:not(.btn-secondary) {
    background: linear-gradient(135deg, rgba(100, 255, 218, 0.3), rgba(29, 233, 182, 0.3)) !important;
}

.btn-secondary {
    z-index: 2;
    position: relative;
}

select.input-field {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364ffda' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
    cursor: pointer;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
}

select.input-field:disabled {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-position: right 1rem center;
    background-size: 1rem;
}

#generateBtn:disabled {
    pointer-events: none !important;
}

#generateBtn {
    position: relative;
}

#generateBtn[disabled] {
    pointer-events: none !important;
    cursor: default !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

.btn-blocker {
    display: block !important;
    pointer-events: auto !important;
    cursor: default !important;
}

#generateBtn:disabled {
    background: linear-gradient(135deg, rgba(100, 255, 218, 0.3), rgba(29, 233, 182, 0.3)) !important;
    opacity: 0.5 !important;
}

#generateBtn:not(:disabled) {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    opacity: 1 !important;
    cursor: pointer !important;
}

.footer {
    margin-top: 4rem;
    padding: 2rem 0;
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 2.5rem;
    outline: 1px solid rgba(100,255,218,0.12);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    background: linear-gradient(180deg, transparent, rgba(15, 23, 42, 0.8));
    border-top: 2px solid var(--border);
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 2rem;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.footer-version {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: rgba(100, 255, 218, 0.1);
    border: 1px solid rgba(100, 255, 218, 0.2);
    border-radius: 4px;
    color: var(--primary);
    font-weight: 600;
}

.footer-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

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

.footer-link i {
    font-size: 1rem;
}

.footer-copyright {
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.footer-logo {
    height: 50px;
    margin-top: 1.5rem;
    margin-right: 1.5rem;
}


/* Desktop: Separated (badge left, language right) */
.top-controls {
    position: relative;
}

.master-badge {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--surface);/*linear-gradient(135deg, rgba(100, 255, 218, 0.1), rgba(29, 233, 182, 0.1));*/
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    border: 1px solid rgba(100, 255, 218, 0.3);
    backdrop-filter: blur(10px);
    z-index: 100;
    animation: badgePulse 3s ease-in-out infinite;
}

/*.master-badge i {
    color: var(--primary);
    font-size: 2rem;
    filter: drop-shadow(0 0 8px rgba(27, 173, 192, 0.4));
}*/

.badge-icon-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    position: relative;
}

.badge-star {
    font-size: 0.70rem;
    color: var(--primary);
    filter: drop-shadow var(--primary-dark);
    /*animation: starTwinkle 0s ease-in-out infinite;*/
}

.badge-trophy {
    font-size: 1.80em;
    color: var(--primary);
    filter: drop-shadow var(--primary-dark);
}

@keyframes starTwinkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.master-badge-content {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.master-badge-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.master-badge-status {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}

@keyframes badgePulse {
    0%, 100% {
        border-color: rgba(100, 255, 218, 0.2);
        box-shadow: 0 0 0 0 rgba(100, 255, 218, 0);
    }
    50% {
        border-color: rgba(100, 255, 218, 0.6);
        box-shadow: 0 0 25px rgba(100, 255, 218, 0.2);
    }
}

@keyframes liveMatchPulse {
    0%, 100% {
        border-color: rgba(239, 68, 68, 0.2);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
    50% {
        border-color: rgba(239, 68, 68, 0.6);
        box-shadow: 0 0 25px rgba(239, 68, 68, 0.2);
    }
}

.series-match-container {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 0;
    min-width: 350px;
    transition: all 0.3s ease;
    overflow: hidden;
}

.series-match-container:hover {
    border-color: var(--border-focus);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(100, 255, 218, 0.1);
}

.series-match-container.completed {
    border-color: rgba(29, 233, 182, 0.4);
}

.series-match-container.live {
    animation: liveMatchPulse 3s ease-in-out infinite;
    position: relative;
}

.series-match-container .live-indicator {
    position: absolute;
    top: 50%;
    left: 66.6666666667%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.2s ease;
    z-index: 10;
    pointer-events: none;
    background: transparent;
    border: none;
}

.series-match-container:hover .live-indicator {
    opacity: 1;
    pointer-events: all;
}

.series-match-container.live .live-indicator {
    opacity: 0;
}

.series-match-container.live:hover .live-indicator {
    opacity: 1;
    pointer-events: all;
}

.series-match-container.live .live-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 10px;
    height: 10px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

.series-header {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.25rem;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.series-team-name-header {
    flex: 1;
    max-width: 200px;
}

.series-game-header {
    width: 50px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
}

.series-total-header {
    width: 50px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
}

.series-team-row {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
    min-height: 60px;
}

.series-team-row:last-child {
    border-bottom: none;
}

.series-team-row.winner {
    background: rgba(100, 255, 218, 0.1);
}

.series-team-row.loser {
    opacity: 0.6;
}

.series-team-name {
    flex: 1;
    font-weight: 600;
    padding-right: 1rem;
    text-align: left;
    max-width: 200px;
    font-size: 1.02rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.series-team-row.winner .series-team-name {
    color: var(--primary);
    font-weight: 700;
}

.series-team-row.loser .series-team-name {
    opacity: 0.7;
    /*color: var(--text-muted);*/
}

.series-game-score {
    width: 50px;
    display: flex;
    justify-content: center;
}

.series-total-score {
    width: 50px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.series-team-row.winner .series-total-score {
    color: var(--primary);
}

.bracket-score-input:disabled {
    opacity: 0.9 !important;
    cursor: default;
    background: rgba(15, 23, 42, 0.4);
}

/*.bracket-score-input.decisive-game {
    border: 2px solid #ef4444;
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.3);
}

.bracket-score-input.decisive-game:focus {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}*/

.bracket-score-input.decisive-game {
    border-left: 3px solid #ef4444 !important;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

.bracket-score-input.decisive-game:focus {
    border-left: 3px solid #ef4444 !important;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

/* Grand Finals Visual Hierarchy */
.grand-finals-wb-team {
    border-left: 4px solid #10b981; /* Green border for Winners Bracket */
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.1), transparent);
    font-weight: 700; /* Bold text */
}

.grand-finals-lb-team {
    border-left: 4px solid #f59e0b; /* Orange border for Losers Bracket */
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.1), transparent);
    font-weight: 500; /* Medium text */
}

.third-place-match {
    /*border: 2px solid #CD7F32 !important;*/
    border: 2px solid #f59e0b !important;
}

.third-place-match.live {
    border: 2px solid #ef4444 !important;
    animation: liveMatchPulse 3s ease-in-out infinite;
}

/* Two-Legged Tie Home/Away Indicators */
.bracket-score-input.two-legged-home {
    border-left: 3px solid #10b981 !important;
}

.bracket-score-input.two-legged-away {
    border-left: 3px solid #f59e0b !important;
}

/* Keep colors when completed */
.bracket-score-input.two-legged-home.completed-score {
    border-left: 3px solid #10b981 !important;
    border-top: 2px solid rgba(100, 255, 218, 0.3);
    border-right: 2px solid rgba(100, 255, 218, 0.3);
    border-bottom: 2px solid rgba(100, 255, 218, 0.3);
}

.bracket-score-input.two-legged-away.completed-score {
    border-left: 3px solid #f59e0b !important;
    border-top: 2px solid rgba(100, 255, 218, 0.3);
    border-right: 2px solid rgba(100, 255, 218, 0.3);
    border-bottom: 2px solid rgba(100, 255, 218, 0.3);
}

/* Focus states with preserved colors */
.bracket-score-input.two-legged-home:focus {
    border-left-color: #10b981 !important;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

.bracket-score-input.two-legged-away:focus {
    border-left-color: #f59e0b !important;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.1);
}

/* Legend container styling */
#playoffLegendContainer,
#finalPlayoffLegendContainer {
    margin-bottom: 1.5rem;
}

/* Two-Legged Legend */
.two-legged-legend {
    display: flex;
    gap: 2rem;
    justify-content: center;
    align-items: center;
    padding: 1rem 1.5rem;
    margin: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.two-legged-legend-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 600;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 8px currentColor;
}

.legend-dot.home {
    background-color: #10b981;
    color: #10b981;
}

.legend-dot.away {
    background-color: #f59e0b;
    color: #f59e0b;
}

/*.series-match-container {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 0;
    min-width: 200px;
    transition: all 0.3s ease;
    overflow: hidden;
}

.series-match-container:hover {
    border-color: var(--border-focus);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(100, 255, 218, 0.1);
}

.series-match-container.completed {
    border-color: rgba(29, 233, 182, 0.4);
}

.series-header {
    display: flex;
    align-items: center;
    padding: 1rem;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.series-team-name {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 120px;
}

.series-game-header {
    width: 60px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
}

.series-total-header {
    width: 60px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
}

.series-team-row {
    display: flex;
    align-items: center;
    padding: 1rem;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.series-team-row:last-child {
    border-bottom: none;
}

.series-team-row.winner {
    background: rgba(100, 255, 218, 0.1);
}

.series-team-row.loser {
    opacity: 0.6;
}

.series-team-row .series-team-name {
    color: var(--text-primary);
}

.series-team-row.winner .series-team-name {
    color: var(--primary);
    font-weight: 700;
}

.series-game-score {
    width: 60px;
    display: flex;
    justify-content: center;
}

.series-total-score {
    width: 60px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.series-team-row.winner .series-total-score {
    color: var(--primary);
}

.bracket-score-input:disabled {
    opacity: 0.3;
    cursor: default;
    background: rgba(15, 23, 42, 0.4);
}*/

@media (max-width: 768px) {
    .container {
        padding: 0.9rem;
    }

    html {
        font-size: 18px;
    }

    .logo-image {
        height: 250px;
    }

    .bracket-round {
        min-width: 240px;
    }

    .bracket-match {
        min-width: 240px;
    }

    .bracket-team-name {
        font-size: 0.95rem;
        padding-right: 0.1rem;
        min-width: 0;
    }

    .bracket-score-input {
        width: 50px !important;
        height: 38px !important;
        font-size: 1.1rem !important;
    }

    .subtitle {
        font-size: 1.8rem !important;
    }

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

    .team-inputs {
        grid-template-columns: 1fr;
    }

    .export-buttons, .action-buttons {
        flex-direction: column;
        align-items: center;
    }

    .section {
        padding: 1.3rem;
    }

    .main-title {
        font-size: 4rem;
    }
    
    .footer-container {
        flex-direction: column;
        text-align: center;
    }
        
    .footer-links {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .footer-logo {
        height: 60px;
        margin-top: 1.5rem;
        margin-right: 1.5rem;
    }
    
    .group-tabs {
        flex-direction: column;
    }
    
    .group-tab {
        width: 100%;
        text-align: center;
    }
    
    .group-stage-summary {
        grid-template-columns: 1fr;
    }
    
    .group-assignment-container {
        grid-template-columns: 1fr;
    }

    /* Top controls: badge left, language right */
    .top-controls {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 1.2rem;
        padding: 0 0.9rem;
    }
    
    .master-badge {
        position: static;
        padding: 0.6rem 1rem;
        gap: 0.6rem;
    }
    
    .badge-star {
    font-size: 0.70rem;
    color: var(--primary);
    filter: drop-shadow var(--primary-dark);
    /*animation: starTwinkle 0s ease-in-out infinite;*/
    }

    .badge-trophy {
        font-size: 1.80em;
        color: var(--primary);
        filter: drop-shadow var(--primary-dark);
    }
    .master-badge-label {
        font-size: 0.8rem;
    }
    
    .master-badge-status {
        font-size: 0.65rem;
    }
    
    .lang-selector {
        position: static;
        padding: 0.6rem 0.85rem;
    }
    
}

@media (max-width: 480px) {
    html {
        font-size: 17px; 
    }

    .logo-image {
        height: 250px;
    }

    .bracket-round {
        min-width: 220px;
    }

    .bracket-match {
        min-width: 220px;
    }

    .container {
        padding: 0.7rem;
    }

    .main-title {
        font-size: 3rem;
    }

    .master-badge {
        padding: 0.5rem 0.85rem;
        gap: 0.5rem;
    }
    
    
    .master-badge-label {
        font-size: 0.75rem;
    }
    
    .master-badge-status {
        font-size: 0.6rem;
    }
    
    .lang-selector {
        padding: 0.5rem 0.75rem;
    }
    
}

@media print {
    body {
        background: white;
        color: black;
    }

    .section {
        box-shadow: none;
        border: 1px solid #ccc;
        background: white;
    }

    .btn, .export-buttons {
        display: none;
    }

    .main-title {
        color: black;
        background: none;
        -webkit-text-fill-color: initial;
    }
}

@supports (-webkit-touch-callout: none) {
    html, body { min-height: 100%; }

    body {
        min-height: 100dvh;
        background-attachment: scroll !important;
        background-color: var(--bg-primary);
        background-image:
        linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-tertiary) 100%);
        background-repeat: no-repeat;
        background-size: cover;
    }
}


/* Hindi/Devanagari font support */
[lang="hi"] {
    font-family: 'Noto Sans Devanagari', 'Inter', sans-serif;
}


/* ===================================
   RTL Support for Arabic
   =================================== */

[lang="ar"] {
    direction: rtl;
    text-align: right;
}

[lang="ar"] .lang-selector {
    right: auto;
    left: 0;
}

[lang="ar"] .master-badge {
    right: 20px;
    left: auto;
}

[lang="ar"] .bracket-team-name {
    text-align: right;
    padding-right: 0;
    padding-left: 0.75rem;
}

[lang="ar"] .series-team-name {
    text-align: right;
}

[lang="ar"] .phase-title {
    border-left: none;
    border-right: 4px solid var(--primary);
}

[lang="ar"] .matchday-header {
    border-left: none;
    border-right: 3px solid var(--primary-dark);
    border-radius: 8px 0 0 8px;
}

[lang="ar"] .section::before {
    background: linear-gradient(270deg, transparent, var(--primary), transparent);
}

[lang="ar"] .bracket-team {
    flex-direction: row-reverse;
}

[lang="ar"] .series-team-row {
    flex-direction: row-reverse;
}

[lang="ar"] .stat-card {
    text-align: center;
}

[lang="ar"] td {
    text-align: center;
}

[lang="ar"] td[style*="text-align: left"],
[lang="ar"] td[style*="text-align: center"] {
    text-align: center !important;
}

[lang="ar"] .group-summary-team {
    flex-direction: row-reverse;
}

[lang="ar"] .swiss-status-badge {
    margin-left: 0;
    margin-right: 1rem;
}

/* Mobile RTL adjustments */
@media (max-width: 768px) {
    [lang="ar"] .top-controls {
        flex-direction: row-reverse;
    }
    
    [lang="ar"] .master-badge {
        position: static;
        margin-right: 0;
        margin-left: auto;
    }
    
    [lang="ar"] .lang-selector {
        position: static;
    }
}
/* ==========================================
   SHARE MODAL STYLES
   ========================================== */

/* Prevent page scroll when modal is open */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.2s ease-out;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid rgba(100, 255, 218, 0.2);
    border-radius: 16px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideUp 0.3s ease-out;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(100, 255, 218, 0.1);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary);
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-body p {
    margin-bottom: 1rem;
    color: var(--text);
    line-height: 1.6;
}

.share-link-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.share-link-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(100, 255, 218, 0.2);
    border-radius: 8px;
    color: var(--primary);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    outline: none;
}

.share-link-input:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
}

.share-hint {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0;
    text-align: center;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* Mobile adjustments */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
    }
    
    .share-link-container {
        flex-direction: column;
    }
    
    .share-link-input {
        font-size: 0.8rem;
    }
}

/* ==========================================
   VIEWER MODE STYLES
   ========================================== */

/* Hide control buttons viewers don't need */
/* ===== VIEWER MODE STYLES ===== */

/* Hide control buttons in viewer mode */
/* CRITICAL: Hide scrollbar ONLY during splash screen (not after!) */
/* Applied to html (from head script) and body (from inline script) */
html.splash-active,
body.splash-active,
html:has(body.splash-active) {
    overflow: hidden !important;
}

.viewer-mode #saveBtn,
.viewer-mode #loadBtn,
.viewer-mode #shareBtn,
.viewer-mode #resetBtn,
.viewer-mode #generateBtn,
.viewer-mode .export-btn {
    display: none !important;
}

/* Hide setup section immediately in viewer mode to prevent flash */
.viewer-mode #setupSection {
    display: none !important;
}

/* Hide live mode controls completely */
.viewer-mode .match-live-controls,
.viewer-mode .live-mode-indicator,
.viewer-mode .match-live-button,
.viewer-mode .live-indicator {
    display: none !important;
    visibility: hidden !important;
}

/* Hide AD buttons for viewers (organizer-only controls) */
.viewer-mode .floating-ad-button {
    display: none !important;
}

/* CRITICAL: .live-dot is NOT hidden - viewers need to see live match indicator! */

/* Default cursor everywhere in viewer mode */
.viewer-mode,
.viewer-mode * {
    cursor: default !important;
}

/* Pointer cursor only for truly clickable elements */
.viewer-mode #faqToggleBtn,
.viewer-mode #languageSelect,
.viewer-mode .faq-content a,
.viewer-mode a[href^="mailto"],
.viewer-mode .group-tab {
    cursor: pointer !important;
}

/* CRITICAL: Don't change ANY styling for inputs or teams */
/* Let them use the exact same styles as organizer mode */
/* Winner/loser colors, input colors - everything stays IDENTICAL */

/* ============================================
   VIEWER LOADING SPLASH SCREEN
   ============================================ */

#viewerLoadingSplash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-tertiary) 100%);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

#viewerLoadingSplash.fade-out {
    opacity: 0;
    pointer-events: none;
}

.splash-content {
    text-align: center;
    animation: splashFadeIn 0.6s ease-out;
}

.splash-logo {
    width: 300px;
    max-width: 80vw;
    height: auto;
    margin-bottom: 2rem;
    filter: drop-shadow(0 0 20px rgba(100, 255, 218, 0.3));
}

.splash-spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 1.5rem;
    border: 4px solid rgba(100, 255, 218, 0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.splash-text {
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 1px;
    margin: 0;
}

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

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

/* Mobile adjustments */
@media (max-width: 768px) {
    .splash-logo {
        width: 200px;
    }
    
    .splash-spinner {
        width: 40px;
        height: 40px;
    }
    
    .splash-text {
        font-size: 1rem;
    }
}

/* ========================================
   CHUNK 5: VIEWER COUNT BADGE
   ======================================== */

/* Floating viewer count badge - bottom right corner */
#viewerCountBadge {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;
}

/* Red dot with pulsing ring (reuse from live mode) */
#viewerCountBadge .live-dot {
    position: relative;
    width: 10px;
    height: 10px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

/* Pulsing rings animation */
#viewerCountBadge .live-dot::before,
#viewerCountBadge .live-dot::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 10px;
    height: 10px;
    transform: translate(-50%, -50%) scale(1);
    border-radius: 50%;
    border: 0.8px solid rgba(239, 68, 68, 0.9);
    background: transparent;
    pointer-events: none;
    box-sizing: border-box;
    z-index: 5;
    animation: liveRing 2.5s ease-out infinite;
    transform-origin: center center;
}

#viewerCountBadge .live-dot::after {
    animation-delay: 0.8s;
}

/* Viewer count number */
#viewerCountBadge .viewer-count-number {
    font-size: 16px;
    font-weight: 600;
    color: #e2e8f0;
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}

/* Hide badge in viewer mode (only show on organizer side) */
.viewer-mode #viewerCountBadge {
    display: none !important;
}

/* ===== SCOREBOARD PREVIEW SECTION ===== */
.scoreboard-preview-section {
    grid-column: 1 / -1;
    margin: 1rem 0;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(100, 255, 218, 0.1);
    border-radius: 12px;
    display: none;
    overflow: visible; /* ✅ Allow dropdowns to overflow */
}

.scoreboard-preview-section.active {
    display: block;
}

.scoreboard-preview-classic,
.scoreboard-preview-matchup {
    display: none;
}

.scoreboard-preview-classic.active,
.scoreboard-preview-matchup.active {
    display: block;
}

.preview-title {
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 1rem;
}

.preview-note {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 1rem;
}

/* Classic preview - just center it and constrain width */
.scoreboard-preview-classic .bracket-match {
    margin: 0 auto;
    max-width: 280px;
}

/* Classic preview - center series containers (Two-Legged, Best of Series) */
.scoreboard-preview-classic .series-match-container {
    width: fit-content;
    margin: 0 auto;
    min-width: auto;
}

/* Classic preview wrapper (matches matchup-scoreboard-wrapper pattern) */
.classic-series-wrapper {
    width: fit-content;
    margin: 0 auto;
    padding: 5px 0 15px 0; /* Space for hover transform and shadow */
}

/* Classic Simple variation - padding only */
.classic-variation-simple {
    padding: 5px 0 25px 0; /* 5px top + 25px bottom = same as preview-content-scroll + classic-series-wrapper */
}

/* Parent container needs width for children percentage to work */
.classic-preview-container {
    width: 100%;
}

/* Two-Legged, BOS, and Grand Finals variations need full width for proper scroll (matches Match-Up pattern) */
.classic-variation-twoLegged,
.classic-variation-bestOfSeries,
.classic-variation-grandFinals {
    width: 100%;
}

/* Classic preview - make it a positioning context for floating legend */
.scoreboard-preview-classic {
    position: relative;
}

/* Floating legend - absolutely positioned, doesn't affect any layout */
.classic-preview-legend-float {
    position: absolute;
    top: 47.5%;
    right: 40px;
    transform: translateY(-50%);
    z-index: 100;
    pointer-events: none; /* Doesn't block clicks on preview */
}

.classic-preview-legend-float .two-legged-legend {
    pointer-events: all; /* Re-enable clicks on legend itself */
}

/* Classic preview legend - vertical compact layout */
.two-legged-legend-preview {
    padding: 0.6rem 0.8rem;
    font-size: 0.8rem;
    gap: 0.8rem;
    flex-direction: column;
    align-items: flex-start;
}

.two-legged-legend-preview .two-legged-legend-item {
    gap: 0.5rem;
}

/* Match-Up preview content scroll wrapper (works on desktop when zoomed + mobile) */
.preview-content-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    padding-bottom: 10px;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}

/* Groups Match-Up Matchday Scroll Container (V11 Addition) */
.matchday-scroll-container {
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    padding-bottom: 10px;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}

/* ============================================
   MATCH-UP SCOREBOARD STYLES
   Set-based scoring display with IsLive mode
   ============================================ */
/* ============================================
   MATCH-UP SCOREBOARD STYLES
   Set-based scoring display with IsLive mode
   ============================================ */

/* Wrapper for set numbers + container to size together */
.matchup-scoreboard-wrapper {
    width: fit-content;
    margin: 0 auto;
    padding: 5px 0 25px 0; /* Match Classic variation padding for consistent switching */
}

/* Dynamic min-width based on best-of series */
.matchup-scoreboard-wrapper[data-best-of="3"] {
    min-width: 500px;
}

.matchup-scoreboard-wrapper[data-best-of="5"] {
    min-width: 600px;
}

/* Set numbers above container */
.set-numbers {
    display: flex;
    align-items: center;
    padding: 0 1.25rem 0.5rem 1.25rem;
    gap: 0.75rem;
}

.set-numbers-spacer {
    flex: 1;
    min-width: 160px;  /* ✅ Force minimum width for consistency */
    max-width: 200px;
}

.set-numbers-current {
    width: 50px;
    flex-shrink: 0;
}

.set-numbers-separator {
    width: 2px;
    margin: 0 0.5rem;
    flex-shrink: 0;
}

.set-number {
    width: 50px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
}

.set-number.tb-label {
    color: var(--primary-dark);
}

.set-numbers-total {
    width: 50px;
    flex-shrink: 0;
}

/* EXACT copy of .series-match-container */
.matchup-container {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 0;
    min-width: 350px;
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
}

.matchup-container:hover {
    border-color: var(--border-focus);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(100, 255, 218, 0.1);
}

.matchup-container.completed {
    border-color: rgba(29, 233, 182, 0.4);
}

/* IsLive mode support */
.matchup-container.live {
    animation: liveMatchPulse 3s ease-in-out infinite;
}

.matchup-container .live-indicator {
    position: absolute;
    top: 50%;
    left: 66.6666666667%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.2s ease;
    z-index: 10;
    pointer-events: none;
    background: transparent;
    border: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.matchup-container:hover .live-indicator {
    opacity: 1;
    pointer-events: all;
}

.matchup-container.live .live-indicator {
    opacity: 0;
}

.matchup-container.live:hover .live-indicator {
    opacity: 1;
    pointer-events: all;
}

.matchup-container.live .live-indicator i {
    color: #ef4444;
    filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.4));
}

.matchup-container.live:hover .live-indicator i {
    color: #ef4444;
    filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.6));
}

.matchup-container.live .live-dot {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    z-index: 5;
}

.matchup-container.live .live-dot::before,
.matchup-container.live .live-dot::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 10px;
    height: 10px;
    transform: translate(-50%, -50%) scale(1);
    border-radius: 50%;
    border: 0.8px solid rgba(239, 68, 68, 0.9);
    background: transparent;
    pointer-events: none;
    box-sizing: border-box;
    z-index: 5;
    animation: liveRing 2.5s ease-out infinite;
    transform-origin: center center;
}

.matchup-container.live .live-dot::after {
    animation-delay: 0.8s;
}

.matchup-team-row.loser .matchup-team-name {
    opacity: 0.9!important;
}

.matchup-team-row.loser {
    opacity: 0.9!important;
}

.matchup-team-row.loser .bracket-score-input {
    opacity: 1 !important;
}

/* Mobile focus support */
@media (max-width: 768px) {
    .matchup-container.mobile-focused {
        border-color: rgba(100, 255, 218, 0.3);
        box-shadow: 0 0 15px rgba(100, 255, 218, 0.15);
    }
}

/* EXACT copy of .series-team-row */
.matchup-team-row {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
    min-height: 60px;
}

.matchup-team-row:last-child {
    border-bottom: none;
}

.matchup-team-row.winner {
    background: rgba(100, 255, 218, 0.1);
}

.matchup-team-row.loser {
    opacity: 1;
}

/* EXACT copy of .series-team-name */
.matchup-team-name {
    flex: 1;
    min-width: 160px;  /* ✅ Force minimum width for consistency */
    max-width: 200px;
    font-weight: 600;
    padding-right: 1rem;
    text-align: left;
    font-size: 1.02rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.matchup-team-row.winner .matchup-team-name {
    color: var(--primary);
    font-weight: 700;
}

.matchup-team-row.loser .matchup-team-name {
    opacity: 1;
}

/* EXACT copy of .series-game-score */
.matchup-current-score {
    width: 50px;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
}

/* Separator line - GREEN like first example */
.matchup-separator {
    width: 2px;
    height: 40px;
    background: linear-gradient(to bottom, transparent, var(--primary), transparent);
    margin: 0 0.5rem;
    flex-shrink: 0;
}

/* EXACT copy of .series-game-score */
.matchup-set-score {
    width: 50px;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
}

/* EXACT copy of .series-total-score */
.matchup-total-sets {
    width: 50px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    flex-shrink: 0;
}

.matchup-team-row.winner .matchup-total-sets {
    color: var(--primary);
}

/* TB column styling */
.matchup-set-score.tb-column {
    background: rgba(100, 255, 218, 0.1) !important;
    border-radius: 8px;
}

/* TB column input - lighter background to show green tint through */
.matchup-set-score.tb-column .bracket-score-input {
    background: rgba(100, 255, 218, 0.08) !important;
    border-color: rgba(100, 255, 218, 0.3) !important;
    color: var(--primary) !important;
}

.matchup-set-score.tb-column .bracket-score-input:focus {
    background: rgba(100, 255, 218, 0.15) !important;
    border-color: var(--primary) !important;
}

/* TB label styling */
.set-number.tb-label {
    color: var(--primary-dark);
    font-weight: 700;
}

/* Floating TB indicators - MUST be above focused inputs */
.matchup-set-score > div[id$="-tb-indicator"] {
    z-index: 10 !important;
    pointer-events: none;
}

/* Current score input - special styling for advantage */
.current-score-input {
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.current-score-input.advantage {
    color: var(--primary);
    font-weight: 700;
}

.bracket-score-input:focus-visible {
    outline: 3px solid rgba(100,255,218,0.18);
    outline-offset: 3px;
}

/* ============================================
   MOBILE RESPONSIVE FIXES FOR PREVIEWS
   ============================================ */

/* Ensure dropdowns are fully visible on mobile */
select.input-field {
    position: relative;
    z-index: 100;
}

/* Form groups need relative positioning for proper dropdown display */
.form-group {
    position: relative;
    z-index: 1;
}

/* Active/focused form groups should be above others */
.form-group:has(select:focus) {
    z-index: 101;
}

@media (max-width: 768px) {
    /* ✅ Preview section scrollable (for Classic preview) */
    .scoreboard-preview-section {
        overflow-x: auto;
        overflow-y: hidden;
        width: 100%;
        padding-bottom: 10px;
    }
    
    /* ✅ Match-Up preview: Don't scroll at preview level (title/subtitle stay visible) */
    .scoreboard-preview-matchup {
        overflow-x: visible;
    }
    
    /* ✅ Match-Up content scroll wrapper: Only the content scrolls */
    .preview-content-scroll {
        overflow-x: auto;
        overflow-y: hidden;
        width: 100%;
        padding-bottom: 10px;
    }
    
    /* ✅ Add padding-right to Match-Up wrapper to match left padding */
    .scoreboard-preview-matchup .matchup-scoreboard-wrapper {
        padding-right: 20px;
    }
    
    /* Custom scrollbar for preview section (Classic preview) */
    .scoreboard-preview-section::-webkit-scrollbar {
        height: 8px;
    }
    
    .scoreboard-preview-section::-webkit-scrollbar-track {
        background: rgba(30, 41, 59, 0.3);
        border-radius: 4px;
    }
    
    .scoreboard-preview-section::-webkit-scrollbar-thumb {
        background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
        border-radius: 4px;
    }
    
    .scoreboard-preview-section::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(90deg, var(--primary-dark) 0%, var(--secondary) 100%);
    }
    
    /* Custom scrollbar for Match-Up content scroll */
    .preview-content-scroll::-webkit-scrollbar {
        height: 8px;
    }
    
    .preview-content-scroll::-webkit-scrollbar-track {
        background: rgba(30, 41, 59, 0.3);
        border-radius: 4px;
    }
    
    .preview-content-scroll::-webkit-scrollbar-thumb {
        background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
        border-radius: 4px;
    }
    
    .preview-content-scroll::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(90deg, var(--primary-dark) 0%, var(--secondary) 100%);
    }
    
    /* Custom scrollbar for Groups Match-Up matchday scroll (V11 Addition) */
    .matchday-scroll-container::-webkit-scrollbar {
        height: 8px;
    }
    
    .matchday-scroll-container::-webkit-scrollbar-track {
        background: rgba(30, 41, 59, 0.3);
        border-radius: 4px;
    }
    
    .matchday-scroll-container::-webkit-scrollbar-thumb {
        background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
        border-radius: 4px;
    }
    
    .matchday-scroll-container::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(90deg, var(--primary-dark) 0%, var(--secondary) 100%);
    }
    
    /* ✅ Classic preview: Center properly */
    .scoreboard-preview-classic.active {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
    }
    
    /* ✅ Floating legend: Reposition to top-right on mobile */
    .classic-preview-legend-float {
        top: 35px;
        right: 5px;
        transform: none;
    }
    
    /* ✅ Make legend compact horizontal on mobile */
    .two-legged-legend-preview {
        flex-direction: row;
        padding: 0.3rem 0.5rem;
        font-size: 0.65rem;
        gap: 0.5rem;
    }
    
    .two-legged-legend-preview .two-legged-legend-item {
        gap: 0.3rem;
    }
    
    .two-legged-legend-preview .legend-dot {
        width: 8px;
        height: 8px;
    }
}

/* ===== ORGANIZER COUNT BADGE (Bottom-Left) ===== */
#organizerCountBadge {
    position: fixed;
    bottom: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;
}

/* Primary color dot with pulsing rings animation */
#organizerCountBadge .organizer-dot {
    position: relative;
    width: 10px;
    height: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(100, 255, 218, 0.6);
}

/* Pulsing rings animation with primary color */
#organizerCountBadge .organizer-dot::before,
#organizerCountBadge .organizer-dot::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 10px;
    height: 10px;
    transform: translate(-50%, -50%) scale(1);
    border-radius: 50%;
    border: 0.8px solid var(--primary);
    background: transparent;
    pointer-events: none;
    box-sizing: border-box;
    z-index: 5;
    animation: organizerRing 2.5s ease-out infinite;
    transform-origin: center center;
}

#organizerCountBadge .organizer-dot::after {
    animation-delay: 0.8s;
}

/* Organizer count number */
#organizerCountBadge .organizer-count-number {
    font-size: 16px;
    font-weight: 600;
    color: #e2e8f0;
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}

/* Hide badge in viewer mode (only show on organizer side) */
.viewer-mode #organizerCountBadge {
    display: none !important;
}

/* Organizer ring animation with primary color */
@keyframes organizerRing {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
        border-color: rgba(100, 255, 218, 0.9);
    }
    60% {
        opacity: 0.05;
        transform: translate(-50%, -50%) scale(2.6); 
        border-color: rgba(100, 255, 218, 0.5);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(3.2);
        border-color: rgba(100, 255, 218, 0);
    }
}

/* Groups Tab Content Visibility (V11 Addition) */
.group-tab-content {
    display: none;
}

.group-tab-content.active {
    display: block;
}

/* V16: Info Icon for labels */
.label-with-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#matchupTiebreakRuleGroup .label-with-info {
    margin-bottom: 0.5rem;
}

.info-icon {
    color: var(--primary);
    font-size: 0.85rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.info-icon:hover {
    opacity: 1;
}

/* V16: Info Modal wider for tables */
.info-modal-content {
    max-width: 700px;
}

/* V16: Info Table Container (scroll on overflow) */
.info-table-container {
    overflow-x: auto;
    margin-bottom: 1rem;
}

/* V16: Info Table Styling */
.info-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.info-table th,
.info-table td {
    padding: 0.5rem 0.4rem;
    text-align: left;
    border-bottom: 1px solid rgba(100, 255, 218, 0.1);
    white-space: nowrap;
}

.info-table th {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-table td {
    color: var(--text);
}

.info-table tr:last-child td {
    border-bottom: none;
}

.info-table .preset-name {
    font-weight: 600;
    color: var(--text);
}

.info-table .preset-style {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 0.3rem;
}

/* V16: Info Legend */
.info-legend {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.info-legend span {
    display: block;
}

.info-disclaimer {
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
    font-style: italic;
}

/* V16: Match-Up hero description mobile fix */
@media (max-width: 768px) {
    #heroDescriptionText.matchup-single-line {
        padding-bottom: 2rem;
    }
    
    .info-modal-content {
        max-width: 95%;
    }
    
    .info-table {
        font-size: 0.8rem;
    }
    
    .info-table th {
        font-size: 0.75rem;
    }
    
    .info-table th,
    .info-table td {
        padding: 0.4rem 0.3rem;
    }
    
    .info-table .preset-style {
        font-size: 0.7rem;
    }
    
    .info-legend {
        font-size: 0.75rem;
    }
    
    .info-disclaimer {
        font-size: 0.65rem;
    }
}
