/* =============================================================================
   TOURNAMENT MANAGER SHARED STYLES - DARK THEME WITH IMPROVED CONTRAST
   ============================================================================= */

/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    padding: 1px;
    color: #f0f0f0;
    /* Better text rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Ensure text scales with zoom */
    font-size: 100%;
}

@media (min-width: 768px) {
    body {
        padding: 20px;
    }
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Skip to main content link for keyboard users */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #22d3ee;
    color: #0a0a0a;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 100;
    border-radius: 0 0 5px 0;
    font-weight: bold;
}

.skip-link:focus {
    top: 0;
}

/* Main Container */
.tournament-container {
    max-width: calc(100% - 2px);
    margin: 0 auto;
    background: #0f1419;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    overflow: hidden;
}

@media (min-width: 768px) {
    .tournament-container {
        max-width: 90%;
        border-radius: 10px;
    }
}

@media (min-width: 1200px) {
    .tournament-container {
        max-width: 1200px;
    }
}

@media (min-width: 1600px) {
    .tournament-container {
        max-width: 1400px;
    }
}

@media (min-width: 1920px) {
    .tournament-container {
        max-width: 1600px;
    }
}

/* Header */
.tournament-header {
    background: linear-gradient(135deg, #2c5aa0 0%, #1e3a5f 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

@media (min-width: 768px) {
    .tournament-header {
        padding: 30px;
    }
}

.tournament-header h1 {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    margin-bottom: 10px;
    line-height: 1.2;
}

.tournament-header p {
    font-size: clamp(1rem, 3vw, 1.2rem);
    opacity: 0.95;
    line-height: 1.5;
}

/* Navigation Tabs */
.tournament-nav {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.tournament-nav a {
    background: rgba(255,255,255,0.05);
    border: 2px solid #22d3ee;
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 5px;
    text-decoration: none;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    transition: all 0.3s;
    font-weight: 500;
    /* Better touch target size */
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tournament-nav a:hover,
.tournament-nav a:focus {
    background: rgba(34, 211, 238, 0.2);
    color: white;
    transform: translateY(-2px);
    border-color: #22d3ee;
    outline: none;
}

.tournament-nav a.active {
    background: #22d3ee;
    color: #0a0a0a;
    border-color: #22d3ee;
    font-weight: bold;
}

/* Hamburger menu button */
.nav-toggle {
    display: none;
    background: none;
    border: 2px solid #22d3ee;
    color: #22d3ee;
    font-size: 1.5rem;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 10px;
}

.nav-toggle:hover,
.nav-toggle:focus {
    background: rgba(34, 211, 238, 0.1);
    outline: none;
}

/* Mobile navigation */
@media (max-width: 767px) {
    .nav-toggle {
        display: block;
    }
    
    .tournament-nav {
        flex-direction: column;
        align-items: stretch;
    }
    
    .tournament-nav a {
        display: none;
    }
    
    /* Show all links when menu is open */
    .tournament-nav.nav-open a {
        display: flex;
    }
}

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 3px solid #22d3ee;
    outline-offset: 2px;
}

/* Content Area */
.tournament-content {
    padding: 12px;
    background: #0f1419;
}

@media (min-width: 768px) {
    .tournament-content {
        padding: 25px;
    }
}

@media (min-width: 1200px) {
    .tournament-content {
        padding: 25px 40px;
    }
}

@media (min-width: 1600px) {
    .tournament-content {
        padding: 30px 50px;
    }
}

@media (min-width: 1920px) {
    .tournament-content {
        padding: 30px 60px;
    }
}

/* Section Titles */
.section-title {
    color: #ffffff;
    font-size: clamp(1.3rem, 4vw, 1.8rem);
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 3px solid #22d3ee;
    line-height: 1.3;
}

@media (min-width: 768px) {
    .section-title {
        margin-bottom: 20px;
        padding-bottom: 10px;
    }
}

/* Filter Controls */
.filter-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
    background: #1a1f2e;
    padding: 12px;
    border-radius: 5px;
    border: 1px solid #2a3544;
}

@media (min-width: 768px) {
    .filter-controls {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 15px;
        margin-bottom: 20px;
    }
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-group label {
    font-weight: bold;
    color: #f0f0f0;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
}

.filter-group select,
.filter-group input[type="text"] {
    padding: 8px 12px;
    border: 2px solid #3a4554;
    border-radius: 5px;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    background: #0f1419;
    color: #f0f0f0;
    /* Better touch target */
    min-height: 44px;
}

.filter-group select:focus,
.filter-group input[type="text"]:focus {
    outline: none;
    border-color: #22d3ee;
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.3);
}

/* Match Cards */
.match {
    background: #1a1f2e;
    border-left: 4px solid #22d3ee;
    padding: 10px 15px;
    margin-bottom: 8px;
    border-radius: 5px;
    /* Better for screen readers */
    position: relative;
}

.match-header {
    font-weight: bold;
    color: #22d3ee;
    margin-bottom: 8px;
    font-size: clamp(0.8rem, 2.5vw, 0.95rem);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 5px;
    line-height: 1.5;
}

@media (max-width: 767px) {
    .match-header {
        justify-content: flex-start;
    }
}

.match-teams {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

@media (min-width: 768px) {
    .match-teams {
        gap: 15px;
    }
}

.team {
    flex: 1;
    font-size: clamp(0.95rem, 2.5vw, 1.05rem);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    line-height: 1.5;
    color: #f0f0f0;
}

@media (min-width: 768px) {
    .team {
        text-align: left;
        justify-content: flex-start;
    }
    
    .team:last-child {
        justify-content: flex-end;
    }
}

.vs {
    color: #b0b0b0;
    font-weight: bold;
    text-align: center;
}

.score {
    font-size: clamp(1.2rem, 4vw, 1.5rem);
    font-weight: bold;
    color: #22d3ee;
    text-align: center;
    line-height: 1.3;
}

/* Tables */
.standings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: clamp(0.8rem, 2.5vw, 0.9rem);
    background: #1a1f2e;
    border-radius: 0;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

@media (min-width: 768px) {
    .standings-table {
        border-radius: 5px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    }
}

/* Table caption for screen readers */
.standings-table caption {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.standings-table thead tr {
    background: #2a3544;
}

.standings-table th {
    padding: 10px 6px;
    text-align: left;
    border-bottom: 2px solid #22d3ee;
    font-weight: bold;
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    line-height: 1.5;
    color: #ffffff;
}

@media (min-width: 768px) {
    .standings-table th {
        padding: 12px 10px;
    }
}

.standings-table th.center {
    text-align: center;
}

.standings-table td {
    padding: 8px 6px;
    border-bottom: 1px solid #2a3544;
    line-height: 1.5;
    color: #f0f0f0;
}

@media (min-width: 768px) {
    .standings-table td {
        padding: 10px;
    }
}

.standings-table td.center {
    text-align: center;
}

.standings-table tbody tr:hover,
.standings-table tbody tr:focus-within {
    background: #252a38;
}

.standings-table tbody tr.top-3 {
    background: #1e3a5f;
    font-weight: bold;
}

/* Group Sections */
.sarja-section {
    margin-bottom: 30px;
}

@media (max-width: 767px) {
    .sarja-section {
        margin-bottom: 20px;
    }
}

.sarja-title {
    color: white;
    font-size: clamp(1.3rem, 4vw, 1.5rem);
    margin-bottom: 15px;
    padding: 12px 15px;
    background: linear-gradient(135deg, #2c5aa0 0%, #1e3a5f 100%);
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    line-height: 1.3;
}

.group-section {
    margin-bottom: 20px;
    margin-left: 0;
}

@media (min-width: 768px) {
    .group-section {
        margin-left: 20px;
    }
}

.group-title {
    color: #22d3ee;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #22d3ee;
    font-size: clamp(1rem, 3vw, 1.1rem);
    line-height: 1.4;
}

/* Bracket Sections */
.bracket-section {
    margin-bottom: 20px;
    margin-left: 0;
}

@media (min-width: 768px) {
    .bracket-section {
        margin-left: 20px;
        margin-bottom: 25px;
    }
}

.bracket-title {
    color: #fbbf24;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #fbbf24;
    font-size: clamp(1rem, 3vw, 1.1rem);
    line-height: 1.4;
}

.bracket-slot {
    background: #1a1f2e;
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 5px;
    border: 2px dashed #3a4554;
}

.bracket-container {
    background: #1a1f2e;
    padding: 15px;
    border-radius: 5px;
    border-left: 4px solid #fbbf24;
}

/* Admin Styles */
.admin-controls {
    background: #2a3544;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
    border: 2px solid #22d3ee;
}

@media (min-width: 768px) {
    .admin-controls {
        padding: 20px;
    }
}

/* Two-column layout for match forms */
.match-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

@media (min-width: 768px) {
    .match-form-grid {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }
}

.match-form-column {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Admin Groups - Mobile Card Layout */
.admin-group-card {
    background: #1a1f2e;
    border: 1px solid #3a4554;
    border-left: 4px solid #22d3ee;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.admin-group-info {
    flex: 1;
    min-width: 0;
}

.admin-group-name {
    font-weight: bold;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    color: #ffffff;
    margin-bottom: 4px;
    word-wrap: break-word;
    line-height: 1.4;
}

.admin-group-details {
    font-size: clamp(0.8rem, 2vw, 0.85rem);
    color: #c0c0c0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    line-height: 1.5;
}

.admin-group-detail {
    white-space: nowrap;
}

.admin-group-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.admin-group-actions button {
    white-space: nowrap;
    font-size: clamp(0.8rem, 2vw, 0.85rem);
    padding: 6px 12px;
    min-height: 44px;
}

/* Hide table on mobile, show cards */
@media (max-width: 767px) {
    .admin-groups-table-container {
        display: none;
    }
    
    .admin-groups-cards-container {
        display: block;
    }
}

/* Hide cards on desktop, show table */
@media (min-width: 768px) {
    .admin-groups-table-container {
        display: block;
    }
    
    .admin-groups-cards-container {
        display: none;
    }
}

/* Admin Groups Table Wrapper */
.admin-groups-section-wrapper {
    margin-bottom: 25px;
}

.admin-groups-section-wrapper h3 {
    color: #22d3ee;
    margin-bottom: 12px;
    padding: 10px;
    background: #1a1f2e;
    border-left: 4px solid #22d3ee;
    border-radius: 4px;
    font-size: clamp(1rem, 3vw, 1.1rem);
    line-height: 1.4;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #f0f0f0;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    line-height: 1.5;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 2px solid #3a4554;
    border-radius: 5px;
    font-size: max(16px, 1rem); /* Prevents zoom on iOS */
    min-height: 44px;
    background: #0f1419;
    color: #f0f0f0;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #22d3ee;
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.3);
}

/* Buttons */
button.primary {
    background: #22d3ee;
    color: #0a0a0a;
    border: none;
    padding: 12px 24px;
    border-radius: 5px;
    cursor: pointer;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    transition: all 0.3s;
    width: 100%;
    min-height: 44px;
    font-weight: bold;
}

@media (min-width: 768px) {
    button.primary {
        width: auto;
    }
}

button.primary:hover,
button.primary:focus {
    background: #06b6d4;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(34, 211, 238, 0.4);
}

button.secondary {
    background: #4a5568;
    color: #f0f0f0;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: clamp(0.85rem, 2vw, 0.9rem);
    transition: background 0.3s;
    min-height: 44px;
}

button.secondary:hover,
button.secondary:focus {
    background: #5a6678;
}

button.danger {
    background: #ef4444;
}

button.danger:hover,
button.danger:focus {
    background: #dc2626;
}

button.success {
    background: #10b981;
}

button.success:hover,
button.success:focus {
    background: #059669;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: clamp(0.8rem, 2vw, 0.85rem);
    font-weight: bold;
    margin-left: 10px;
    line-height: 1.5;
}

.status-finished {
    background: #10b981;
    color: white;
}

.status-pending {
    background: #fbbf24;
    color: #0a0a0a;
    font-weight: bold;
}

/* Collapsible Sections */
.collapsible-section {
    margin-bottom: 20px;
}

.collapsible-header {
    cursor: pointer;
    padding: 15px;
    background: #2c5aa0;
    color: white;
    border-radius: 5px;
    margin-bottom: 10px;
    user-select: none;
    transition: background 0.3s;
    border: none;
    width: 100%;
    text-align: left;
    font-size: clamp(0.95rem, 2.5vw, 1rem);
    font-weight: bold;
    min-height: 44px;
    display: flex;
    align-items: center;
    line-height: 1.5;
}

.collapsible-header:hover,
.collapsible-header:focus {
    background: #1e3a5f;
}

.collapsible-header span {
    display: inline-block;
    width: 20px;
    font-weight: bold;
}

.collapsible-content {
    padding: 0 10px;
    display: none;
}

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

/* Match Card (Admin) */
.match-card {
    background: #1a1f2e;
    border-left: 4px solid #22d3ee;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.editing-card {
    background: #2a3544;
    border-left: 4px solid #fbbf24;
}

.editing-header {
    background: #fbbf24;
    padding: 8px;
    margin: -15px -15px 15px -15px;
    border-radius: 5px 5px 0 0;
    font-weight: bold;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    line-height: 1.5;
    color: #0a0a0a;
}

/* Button Group */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

@media (min-width: 768px) {
    .button-group {
        flex-direction: row;
        gap: 10px;
    }
}

/* Set Scores Grid */
.set-scores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 8px;
    background: #1a1f2e;
    padding: 12px;
    border-radius: 5px;
    margin-top: 10px;
    max-width: 100%;
    overflow-x: auto;
}

@media (min-width: 768px) {
    .set-scores-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
    }
}

@media (min-width: 1200px) {
    .set-scores-grid {
        gap: 10px;
    }
}

.set-scores-grid > div {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.set-scores-grid label {
    font-size: clamp(0.8rem, 2vw, 0.85rem);
    font-weight: bold;
    color: #f0f0f0;
    margin-bottom: 2px;
    line-height: 1.5;
}

.set-scores-grid .score-inputs {
    display: flex;
    gap: 4px;
    align-items: center;
    min-width: 0;
}

.set-scores-grid input[type="number"] {
    flex: 1;
    min-width: 0;
    max-width: 60px;
    padding: 6px 4px;
    border: 2px solid #3a4554;
    border-radius: 4px;
    font-size: max(14px, 0.9rem);
    text-align: center;
    min-height: 40px;
    background: #0f1419;
    color: #f0f0f0;
}

.set-scores-grid input[type="number"]:focus {
    outline: none;
    border-color: #22d3ee;
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.3);
}

.set-scores-grid .score-separator {
    color: #b0b0b0;
    font-weight: bold;
    flex-shrink: 0;
    font-size: 0.9rem;
}

/* Login Box */
.login-box {
    max-width: 400px;
    margin: 20px auto;
    padding: 20px;
    background: #1a1f2e;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    border: 1px solid #3a4554;
}

@media (min-width: 768px) {
    .login-box {
        margin: 50px auto;
        padding: 30px;
    }
}

.error {
    color: #fca5a5;
    margin-top: 10px;
    font-weight: bold;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    line-height: 1.5;
}

.info-text {
    color: #c0c0c0;
    font-size: clamp(0.85rem, 2vw, 0.9rem);
    margin-top: 5px;
    line-height: 1.5;
}

/* Utility Classes */
.loading {
    text-align: center;
    padding: 40px;
    font-size: clamp(1rem, 3vw, 1.2rem);
    color: #c0c0c0;
    line-height: 1.5;
}

.no-data {
    text-align: center;
    padding: 40px;
    color: #c0c0c0;
    font-style: italic;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    line-height: 1.5;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .tournament-nav a {
        border-width: 3px;
    }
    
    button.primary,
    button.secondary {
        border: 2px solid currentColor;
    }
    
    .standings-table th {
        border-bottom-width: 3px;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .tournament-nav a:hover,
    button.primary:hover {
        transform: none;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
        color: black;
    }
    
    .tournament-nav,
    .filter-controls,
    button {
        display: none;
    }
    
    .tournament-container {
        box-shadow: none;
        background: white;
    }
}

/* Phase Section Styling */
.phase-section {
    margin-bottom: 30px;
}

.phase-header {
    background: linear-gradient(135deg, #2c5aa0 0%, #1e3a5f 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: all 0.3s ease;
}

.phase-header:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(34, 211, 238, 0.4);
}

.phase-header h3 {
    margin: 0;
    font-size: 1.3rem;
}

.phase-toggle {
    font-size: 1.5em;
    transition: transform 0.3s ease;
}

.phase-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.phase-content.active {
    max-height: 10000px;
    padding-top: 20px;
}

/* Standings Table Wrapper */
.standings-table-wrapper {
    overflow-x: auto;
    margin-bottom: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* =============================================================================
   JAVASCRIPT-GENERATED CONTENT STYLES
   Add these classes for content generated by JavaScript
   ============================================================================= */

/* Match header bold text */
.match-header-bold {
    font-weight: bold;
}

/* Match card pipe separators */
.match-header-separator {
    margin: 0 10px;
    color: #d0d0d0;
}

/* Match vs separator */
.match-vs-separator {
    text-align: center;
    color: #d0d0d0;
    font-weight: bold;
    padding: 0 10px;
}

/* Match status text (Tulossa/Päättynyt) */
.match-status-text {
    margin-top: 10px;
    text-align: center;
    color: #d0d0d0;
    font-style: italic;
}

/* Set scores display */
.match-set-scores {
    margin-top: 8px;
    text-align: center;
    color: #c0c0c0;
    font-size: 0.95em;
}

/* Player score display */
.player-score {
    margin-left: 10px;
    font-size: 1.2em;
    color: #22d3ee;
}

/* Search highlight */
.search-highlight {
    background: #fff3cd;
    padding: 2px 4px;
    border-radius: 2px;
}

/* Compact match header layout */
.match-header-info {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.match-header-status {
    color: #d0d0d0;
    font-style: italic;
    font-weight: normal;
    font-size: 1em;
}

/* Compact match teams layout - single row */
.match-teams-compact {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: clamp(0.9rem, 2.5vw, 1.05rem);
    flex-wrap: wrap;
    line-height: 1.4;
}

@media (min-width: 768px) {
    .match-teams-compact {
        gap: 12px;
        flex-wrap: nowrap;
    }
}

.team-name {
    color: #f0f0f0;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

@media (min-width: 400px) {
    .team-name {
        max-width: 180px;
    }
}

@media (min-width: 768px) {
    .team-name {
        max-width: none;
        overflow: visible;
        text-overflow: unset;
    }
}

.team-score-inline {
    color: #22d3ee;
    font-size: 1.1em;
    font-weight: bold;
    margin-left: 6px;
    flex-shrink: 0;
}

.match-vs-inline {
    color: #d0d0d0;
    font-weight: bold;
    padding: 0 4px;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .team-score-inline {
        margin-left: 8px;
    }
    
    .match-vs-inline {
        padding: 0 6px;
    }
}

.match-set-scores-inline {
    color: #c0c0c0;
    font-size: 1em;
    margin-left: 6px;
    flex-basis: 100%;
    text-align: center;
}

@media (min-width: 768px) {
    .match-set-scores-inline {
        margin-left: 8px;
        flex-basis: auto;
    }
}

/* Mobile optimization for very narrow screens */
@media (max-width: 380px) {
    .match-teams-compact {
        font-size: 0.85rem;
        gap: 5px;
    }
    
    .team-name {
        max-width: 120px;
    }
    
    .team-score-inline {
        font-size: 1em;
        margin-left: 4px;
    }
    
    .match-vs-inline {
        padding: 0 3px;
    }
    
    .match-set-scores-inline {
        font-size: 1em;
        margin-top: 2px;
    }
}

/* Better spacing for medium mobile screens */
@media (min-width: 381px) and (max-width: 767px) {
    .team-name {
        max-width: 160px;
    }
}

/* Mobile vs Desktop labels */
.label-full {
    display: none;
}

.label-mobile {
    display: inline;
}

@media (min-width: 768px) {
    .label-full {
        display: inline;
    }
    
    .label-mobile {
        display: none;
    }
}

/* Make mobile header info flow as single line */
@media (max-width: 767px) {
    .match-header-info {
        display: flex;
        flex-wrap: nowrap;
        gap: 4px;
        width: 100%;
    }
}

/* =============================================================================
   FRONT PAGE SPECIFIC STYLES
   ============================================================================= */

/* Info Grid - Tournament Information Cards */
.info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 30px;
}

@media (min-width: 640px) {
    .info-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .info-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
}

.info-card {
    background: #1a1f2e;
    border-left: 4px solid #22d3ee;
    padding: 15px;
    border-radius: 5px;
}

.info-label {
    color: #c0c0c0;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.info-value {
    color: #f0f0f0;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
}

/* Level Sections */
.level-section {
    margin-bottom: 30px;
}

.level-title {
    color: #22d3ee;
    font-size: clamp(1.1rem, 3vw, 1.3rem);
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #22d3ee;
}

/* Participants Table */
.participants-table-container {
    overflow-x: auto;
    background: #1a1f2e;
    border-radius: 5px;
    border: 1px solid #2a3544;
}

.participants-table {
    width: 100%;
    border-collapse: collapse;
    font-size: clamp(0.85rem, 2.5vw, 0.95rem);
}

.participants-table thead {
    background: #2a3544;
}

.participants-table th {
    color: #22d3ee;
    font-weight: 600;
    padding: 12px 10px;
    text-align: left;
    border-bottom: 2px solid #22d3ee;
}

.participants-table tbody tr {
    border-bottom: 1px solid #2a3544;
}

.participants-table tbody tr:last-child {
    border-bottom: none;
}

.participants-table tbody tr:hover {
    background: rgba(34, 211, 238, 0.05);
}

.participants-table td {
    color: #f0f0f0;
    padding: 12px 10px;
}

.participants-table td strong {
    color: #f0f0f0;
}

/* Mobile: hide club and grouping columns */
@media (max-width: 767px) {
    .participants-table th.desktop-only,
    .participants-table td.desktop-only {
        display: none;
    }
    
    .participants-table {
        font-size: 0.9rem;
    }
    
    .participants-table th,
    .participants-table td {
        padding: 10px 8px;
    }
}

/* Desktop: hide mobile-only columns */
@media (min-width: 768px) {
    .participants-table th.mobile-only,
    .participants-table td.mobile-only {
        display: none;
    }
}

/* Club in brackets styling */
.player-club-inline {
    color: #f0f0f0;
    font-size: 0.9em;
    margin-left: 4px;
}

@media (min-width: 768px) {
    .player-club-inline {
        display: none;
    }
}

/* Responsive table on very small screens */
@media (max-width: 480px) {
    .participants-table {
        font-size: 0.85rem;
    }
    
    .participants-table th,
    .participants-table td {
        padding: 8px 6px;
    }
}

/* =============================================================================
   GROUPS AND BRACKETS PAGE STYLES
   ============================================================================= */

/* Collapsible group sections */
.group-details {
    margin-bottom: 15px;
}

.group-summary {
    background: #1a1f2e;
    color: #22d3ee;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    font-size: clamp(0.95rem, 2.5vw, 1.05rem);
    border-left: 4px solid #22d3ee;
    list-style: none;
    user-select: none;
    transition: background 0.2s;
}

.group-summary:hover {
    background: rgba(34, 211, 238, 0.1);
}

.group-summary::-webkit-details-marker {
    display: none;
}

.group-summary::after {
    content: '▼';
    float: right;
    transition: transform 0.2s;
    font-size: 0.8em;
}

.group-details[open] .group-summary::after {
    transform: rotate(180deg);
}

/* Compact standings table */
.standings-table-container {
    overflow-x: auto;
    background: #1a1f2e;
    border-radius: 5px;
    margin-top: 10px;
}

.standings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: clamp(0.85rem, 2.5vw, 0.95rem);
}

.standings-table.compact-table {
    font-size: clamp(0.8rem, 2.5vw, 0.9rem);
}

.standings-table thead {
    background: #2a3544;
}

.standings-table th {
    color: #22d3ee;
    font-weight: 600;
    padding: 8px 10px;
    text-align: left;
    border-bottom: 2px solid #22d3ee;
    white-space: nowrap;
}

.standings-table.compact-table th {
    padding: 6px 8px;
    font-size: 0.85em;
}

.standings-table tbody tr {
    border-bottom: 1px solid #2a3544;
}

.standings-table tbody tr:last-child {
    border-bottom: none;
}

.standings-table tbody tr:hover {
    background: rgba(34, 211, 238, 0.05);
}

.standings-table td {
    color: #c0c0c0;
    padding: 8px 10px;
}

.standings-table.compact-table td {
    padding: 6px 8px;
}

.standings-table td strong {
    color: #f0f0f0;
}

/* Hide Pisteet (Points/Wins) column - it's redundant with Voitot */
.standings-table th:nth-child(3),
.standings-table td:nth-child(3) {
    display: none;
}

/* Mobile: hide Tappiot (Losses) column - column 5 after hiding column 3 becomes column 4 */
@media (max-width: 767px) {
    .standings-table th:nth-child(5),
    .standings-table td:nth-child(5) {
        display: none;
    }
    
    .group-summary {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    .standings-table th,
    .standings-table td {
        padding: 6px 5px;
        font-size: 0.8rem;
    }
    
    .standings-table.compact-table th,
    .standings-table.compact-table td {
        padding: 5px 4px;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .standings-table th,
    .standings-table td {
        padding: 5px 3px;
    }
}

/* Phase section collapsible headers (Lohkovaihe/Pudotuspelivaihe) */
.phase-section {
    margin-bottom: 25px;
}

.phase-header {
    background: #1a1f2e;
    border-left: 4px solid #22d3ee;
    color: #22d3ee;
    padding: 12px 15px;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: all 0.3s ease;
}

.phase-header:hover {
    background: rgba(34, 211, 238, 0.1);
}

.phase-header h3 {
    margin: 0;
    font-size: clamp(1.1rem, 3vw, 1.3rem);
    font-weight: 600;
}

.phase-toggle {
    font-size: 1.2em;
    transition: transform 0.3s ease;
}

.phase-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.phase-content.active {
    max-height: 10000px;
    padding-top: 15px;
}

/* Bracket sections */
.bracket-container {
    background: #1a1f2e;
    padding: 15px;
    border-radius: 5px;
    border-left: 4px solid #22d3ee;
    margin-bottom: 15px;
}

.bracket-slot {
    background: #2a3544;
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 5px;
    border: 2px dashed #3a4554;
    color: #f0f0f0;
}

.tie-warning {
    background: rgba(255, 193, 7, 0.15);
    border: 2px solid #ffc107;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 5px;
}

.tie-warning strong,
.tie-warning span {
    color: #ffc107;
}

/* Compact table wrapper */
.standings-table-wrapper {
    overflow-x: auto;
    margin-bottom: 15px;
}

@media (max-width: 767px) {
    .phase-header {
        padding: 10px 12px;
    }
    
    .phase-header h3 {
        font-size: 1rem;
    }
    
    .bracket-container {
        padding: 12px;
    }
}
