:root {
    --primary: #2196F3;
    --primary-dark: #1976D2;
    --success: #4CAF50;
    --danger: #f44336;
    --warning: #ff9800;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-700: #424242;
    --gray-900: #212121;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

/* Login Screen */
.login-screen {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-screen.active {
  display: flex;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    font-size: 28px;
    margin-bottom: 30px;
    text-align: center;
    color: var(--gray-900);
}

.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--gray-700);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
	width: 100%;
}

.btn-shine {
    position: relative;
    overflow: hidden;
}

.btn-shine::before {
    content: '';
    position: absolute;
    top: -120%;
    left: -120%;
    width: 240%;
    height: 260%;
    background: linear-gradient(120deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.65) 50%, rgba(255,255,255,0) 100%);
    transform: translateX(-100%) rotate(25deg);
    opacity: 0;
    transition: transform 0.7s ease, opacity 0.7s ease;
    pointer-events: none;
}

.btn-shine:hover::before {
    transform: translateX(100%) rotate(25deg);
    opacity: 1;
}

.btn-shine::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(33, 33, 33, 0.92);
    color: white;
    padding: 6px 10px;
    border-radius: 5px;
    white-space: nowrap;
    font-size: 12px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transition-delay: 0s;
}

.btn-shine:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    transition-delay: 2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-900);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #da190b;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #45a049;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.alert-error {
    background: #ffebee;
    color: var(--danger);
    border: 1px solid #ef5350;
}

.alert-success {
    background: #e8f5e9;
    color: var(--success);
    border: 1px solid #4CAF50;
}

.alert-info {
    background: #e3f2fd;
    color: var(--primary);
    border: 1px solid var(--primary);
}

/* Dashboard */
.dashboard {
    display: none;
}

.dashboard.active {
    display: block;
}

.header {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.header h1 {
    font-size: 24px;
    color: var(--gray-900);
}

.user-info {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* User Info Buttons */
.user-info .user-btn {
    padding: 0px 16px;
    font-size: 12px;
    min-height: 30px;
    width: auto !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    border: 1px solid var(--gray-300);
    transition: all 0.2s ease;
}

.user-info .user-btn:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.user-info .user-btn:active {
    transform: translateY(0);
}

.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: var(--gray-200);
    color: var(--gray-900);
}

.badge-primary {
    background: var(--primary);
    color: white;
}

.navigation {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.nav-btn {
    padding: 8px 16px;
    background: var(--gray-200);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
    color: var(--gray-700);
}

.nav-btn.active {
    background: var(--primary);
    color: white;
}

.nav-btn:hover {
    background: var(--primary);
    color: white;
}

.nav-btn i {
    font-size: 1.1em;
}

.content-section {
    display: none;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.content-section.active {
    display: block;
}

.section-title {
    font-size: 20px;
    margin-bottom: 0px;
    color: var(--gray-900);
    border-bottom: 2px solid var(--gray-200);
    padding-bottom: 10px;
}

.section-margin-top {
    margin-top: 30px;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    margin-bottom: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

thead {
    background: var(--gray-100);
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--gray-300);
}

th {
    font-weight: 600;
    color: var(--gray-900);
}

tr:hover {
    background: var(--gray-50);
}

tr.highlight {
    background: #e3f2fd;
}

.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Forms */
.form-card {
    background: var(--gray-50);
    padding: 20px;
    border-radius: 4px;
    margin-bottom: 20px;
    border: 1px solid var(--gray-200);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    font-size: 20px;
    margin-bottom: 20px;
    color: var(--gray-900);
}

.modal-footer {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: flex-end;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--gray-500);
}

.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Results Table */
.results-filters {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.results-filters select,
.results-filters input {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
}

.score-input {
    width: 80px;
    padding: 8px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    text-align: center;
}

.score-input:focus {
    border-color: var(--primary);
    outline: none;
}

/* ==================== JUDGE TRICKS ICON (Phase 1B - minimal start) ==================== */
.tricks-icon {
    transition: transform 0.1s ease, opacity 0.1s ease;
}
.tricks-icon:hover {
    transform: scale(1.2);
    opacity: 1;
}

/* ==================== TRICKS POPUP CARDS (hover + persistent) ==================== */
.tricks-popup-card {
    --tricks-card-width: 280px;
    --tricks-card-max-height: min(320px, 45dvh);
    width: var(--tricks-card-width);
    max-width: var(--tricks-card-width);
    max-height: var(--tricks-card-max-height);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.35;
    background: #fff;
    border-radius: 5px;
    padding: 8px 11px;
    pointer-events: auto;
    overflow: hidden;
}

.tricks-hover-card {
    border: 1px solid #bbb;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
    transition: opacity 0.1s ease;
}

.tricks-card {
    border: 1px solid #1976d2;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}

.tricks-popup-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 5px;
    padding-bottom: 4px;
    border-bottom: 1px solid #eee;
}

.tricks-popup-title {
    font-weight: 600;
    color: #1976d2;
    font-size: 12.5px;
    line-height: 1.3;
}

.tricks-popup-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    margin: 0 -2px;
    padding: 0 2px;
}

.tricks-popup-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
    padding: 4px 0;
    border-bottom: 1px solid #eee;
}

.tricks-popup-row:last-child {
    border-bottom: none;
}

.tricks-popup-row-name {
    flex: 1;
    min-width: 0;
    padding-right: 4px;
    white-space: normal;
    word-break: break-word;
}

.tricks-popup-row-remove {
    flex: 0 0 auto;
    cursor: pointer;
    color: #999;
    padding: 2px 4px;
    font-size: 12px;
    line-height: 1;
    min-width: 22px;
    min-height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tricks-popup-row-remove:hover {
    color: #cc3333;
}

.tricks-card-close {
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    color: #666;
    padding: 0 4px;
    flex-shrink: 0;
}

.tricks-card .tricks-card-close:hover {
    color: #d32f2f;
    font-weight: bold;
}

@media (max-width: 768px) {
    .tricks-popup-card {
        --tricks-card-width: min(280px, calc(100vw - 24px));
        --tricks-card-max-height: min(280px, 50dvh);
    }

    .tricks-popup-row-remove {
        min-width: 28px;
        min-height: 28px;
    }
}

.position {
    font-weight: 600;
    color: var(--primary);
    font-size: 18px;
}

.badge-runner {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: var(--gray-200);
}

.badge-runner.male {
    background: #e3f2fd;
    color: var(--primary);
}

.badge-runner.female {
    background: #fce4ec;
    color: #c2185b;
}

/* Helpers */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.muted {
    color: var(--gray-500);
}

/* Credential Input Group */
.credential-input-group {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 12px;
    border-radius: 4px;
}

.credential-input-group input {
    flex: 1;
    border: none;
    padding: 0;
    font-size: 14px;
    font-weight: bold;
    text-align: left;
    background: transparent;
    outline: none;
}

.credential-input-group input::placeholder {
    color: var(--gray-400);
}

.copy-icon {
    font-size: 18px;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.copy-icon:hover {
    color: var(--primary-dark);
    transform: scale(1.1);
}

/* Password Input Group */
.password-input-group {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 12px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
}

.password-input-group input {
    flex: 1;
    border: none;
    padding: 0;
    font-size: 14px;
    background: transparent;
    outline: none;
}

.password-input-group .toggle-password {
    color: var(--gray-500);
    cursor: pointer;
    transition: color 0.2s;
}

.password-input-group .toggle-password:hover {
    color: var(--primary);
}

/* Responsive */
/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 12px 15px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
    }

    .navigation {
        width: 100%;
    }

    .nav-btn {
        flex: 1;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 20px;
        margin-right: 15px;
    }

    table {
        font-size: 12px;
    }

    th, td {
        padding: 8px;
    }

    .action-buttons {
        flex-direction: column;
    }
}

/* Bulk Import Modal Styles */
#bulkImportModal .modal-content {
    max-width: 1100px;
}

#bulkImportPaste {
    font-family: 'Courier New', monospace;
    resize: vertical;
}

/* Bulk import table input styling */
#bulkImportTableBody input,
#bulkImportTableBody select {
    font-size: 13px;
    padding: 6px 4px;
}

#bulkImportTableBody input:invalid,
#bulkImportTableBody select:invalid {
    border-color: #f44336;
}

#bulkImportTableBody input:valid {
    border-color: #4CAF50;
}

/* Alert styling for bulk import */
#bulkImportAlert {
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 14px;
    line-height: 1.5;
}

#bulkImportAlert.alert-error {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ef5350;
}

/* Improving button styling in bulk modal */
#bulkImportParseBtn {
    margin-top: 8px;
}

/* View Mode Selector Styles */
.view-mode-selector {
    margin-bottom: 20px;
}

.view-mode-chip {
    padding: 8px 16px;
    border: 2px solid var(--gray-300);
    border-radius: 20px;
    background: white;
    color: var(--gray-700);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.view-mode-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(33, 150, 243, 0.05);
}

.view-mode-chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.view-mode-chip i {
    font-size: 14px;
}


/* New round management style block */
.btn-icon {
    background: none;
    border: none;
    font-size: 18px;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
}
.btn-icon:hover {
    background: #f0f0f0;
    color: #333;
}
.btn-icon.btn-danger:hover {
    background: #fee;
    color: #d32f2f;
}


/* THIS BLOCK IS USED TO SETUP THE SCROLLING OF THE JUDGE SECTION BELOW THE SCORE HEADER */
#judgeSection {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 160px); /* desktop: nav + page chrome */
    min-height: 0;
}

.judge-top-controls {
    flex: 0 0 auto;
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 2px solid #dee2e6;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.judge-top-controls-content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}
.judge-scroll-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
}
.judge-scores-table,
#judgeScoresTable {
    width: 100%;
    margin: 0;
    table-layout: fixed;
    min-width: 700px;
}

#judgeScoresTable thead {
    position: sticky;
    top: 0;
    background: #f1f3f5;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.score-input {
    width: 85px;
    padding: 8px;
    text-align: center;
    font-size: 1.05rem;
}

/* ==================== HEAD JUDGE SCORES TABLE - MOBILE RESPONSIVE ====================*/

/* Desktop: All columns visible with optimized sizing */
#headJudgeScoresTable {
    width: 100%;
}

#headJudgeScoresTable th,
#headJudgeScoresTable td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

/* Score columns take only the space needed */
#headJudgeScoresTable .col-score {
    width: auto;
    padding: 8px 4px !important;
    text-align: center;
    white-space: nowrap;
    min-width: 65px;
}

/* Overall column sticky on the right */
#headJudgeScoresTable .col-overall {
    position: sticky;
    right: 0;
    z-index: 11;
    min-width: 85px;
}

/* Mobile: Hide non-essential columns (<768px) */
@media (max-width: 768px) {
    /* Hide FIS, Gender, Age, Category on mobile - these columns add minimal value on small screens */
    #headJudgeScoresTable .col-fis,
    #headJudgeScoresTable .col-gender,
    #headJudgeScoresTable .col-age,
    #headJudgeScoresTable .col-category {
        display: none;
    }

    /* Adjust sticky positions for mobile (only Bib and Name are sticky) */
    #headJudgeScoresTable .col-bib {
        position: sticky;
        left: 0;
        z-index: 11;
        width: 50px;
        padding: 8px 4px !important;
    }

    #headJudgeScoresTable .col-name {
        position: sticky;
        left: 50px;
        z-index: 11;
        min-width: 120px;
        padding: 8px 6px !important;
    }

    /* Reduce padding on mobile for compact display */
    #headJudgeScoresTable th,
    #headJudgeScoresTable td {
        padding: 8px 4px;
        font-size: 13px;
    }

    /* Make score columns even narrower on mobile */
    #headJudgeScoresTable .col-score {
        min-width: 55px;
        padding: 6px 2px !important;
        font-size: 12px;
    }

    /* Adjust overall column for mobile */
    #headJudgeScoresTable .col-overall {
        min-width: 70px;
        padding: 8px 4px !important;
        font-size: 12px;
        font-weight: 700;
    }

    /* Score table wrapper - enable horizontal scroll on mobile */
    #head-judge-scroll-wrapper {
        overflow-x: auto;
        overflow-y: auto;
        max-height: calc(100vh - 200px);
        -webkit-overflow-scrolling: touch;
    }

    /* Make table take full width for mobile scrolling */
    #headJudgeScoresTable {
        min-width: 300px;
    }
}



/* ============================================= */
/* RESULTS TABLE - FIXED NARROW COLUMNS FOR ROUNDS & OVERALL */
/* Forces tight 98px columns (no more huge scrolling on mobile) */
/* ============================================= */
#resultsTable {
    table-layout: fixed !important;
    width: 100% !important;
}

#resultsTable th[data-sort-key^="round-"],
#resultsTable th[data-sort-key="overall"] {
    width: 98px !important;
    min-width: 98px !important;
    max-width: 110px !important;
    text-align: center !important;
    white-space: nowrap !important;
    padding: 6px 4px !important;
    vertical-align: middle !important;
    line-height: 1.25 !important;
}

#resultsTable td.round-score,
#resultsTable td.overall-score {
    width: 98px !important;
    min-width: 98px !important;
    max-width: 110px !important;
    text-align: center !important;
    white-space: nowrap !important;
    padding: 8px 4px !important;
}

#resultsTable th[data-sort-key="overall"] {
    background: #e3f2fd !important;
}



/* ============================================= */
/* NAME COLUMN - 240px DESKTOP / 150px MOBILE */
/* ============================================= */
#resultsTable {
    table-layout: fixed !important;
    width: 100% !important;
}

#resultsTable th[data-sort-key="name"],
#resultsTable td.name-cell {
    width: 280px !important;
    min-width: 280px !important;
    max-width: 280px !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
    hyphens: auto !important;
    line-height: 1.35 !important;
    vertical-align: middle !important;
    padding: 8px 6px !important;
}

/* Mobile override - exactly 150px */
@media (max-width: 768px) {
    #resultsTable th[data-sort-key="name"],
    #resultsTable td.name-cell {
        width: 150px !important;
        min-width: 150px !important;
        max-width: 150px !important;
    }
}



/* ============================================= */
/* HEAD JUDGE TABLE - 280px DESKTOP / 150px MOBILE */
/* ============================================= */
#headJudgeScoresTable {
    table-layout: fixed !important;
    width: 100% !important;
}

/* NAME COLUMN */
#headJudgeScoresTable th[data-sort-key="name"],
#headJudgeScoresTable td.name-cell {
    width: 280px !important;
    min-width: 280px !important;
    max-width: 280px !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
    hyphens: auto !important;
    line-height: 1.35 !important;
    padding: 8px 6px !important;
    vertical-align: middle !important;
}

/* CATEGORY COLUMN - fixed width to prevent overlap */
#headJudgeScoresTable th[data-sort-key="category"],
#headJudgeScoresTable td.category-cell {
    width: 140px !important;
    min-width: 140px !important;
    max-width: 140px !important;
    text-align: left !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
}

/* Round / Judge columns (98px) */
#headJudgeScoresTable th[data-sort-key^="round-"],
#headJudgeScoresTable th[data-sort-key^="judge-"],
#headJudgeScoresTable td.round-score,
#headJudgeScoresTable td.judge-score {
    width: 98px !important;
    min-width: 98px !important;
    max-width: 110px !important;
    text-align: center !important;
    white-space: nowrap !important;
    padding: 6px 4px !important;
}

/* Overall column (98px) */
#headJudgeScoresTable th[data-sort-key="overall"],
#headJudgeScoresTable td.overall-score {
    width: 98px !important;
    min-width: 98px !important;
    max-width: 110px !important;
    text-align: center !important;
    white-space: nowrap !important;
    padding: 8px 4px !important;
    font-weight: 700;
    background: #e3f2fd !important;
}

/* MOBILE OVERRIDE */
@media (max-width: 768px) {
    #headJudgeScoresTable th[data-sort-key="name"],
    #headJudgeScoresTable td.name-cell {
        width: 150px !important;
        min-width: 150px !important;
        max-width: 150px !important;
    }

    #headJudgeScoresTable th[data-sort-key="category"],
    #headJudgeScoresTable td.category-cell {
        width: 110px !important;
        min-width: 110px !important;
        max-width: 110px !important;
    }

    #headJudgeScoresTable th[data-sort-key^="round-"],
    #headJudgeScoresTable th[data-sort-key^="judge-"],
    #headJudgeScoresTable td.round-score,
    #headJudgeScoresTable td.judge-score {
        width: 88px !important;
        min-width: 88px !important;
    }
}



/* ============================================= */
/* JUDGE SECTION TOP CONTROLS (desktop row / mobile stack) */
/* ============================================= */
#judgeSection {
    text-align: left;
}

.judge-control-label {
    font-weight: 600;
    white-space: nowrap;
    margin: 0;
}

/* --- Round + Save --- */
.judge-round-save-row {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.judge-round-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 auto;
    min-width: 0;
}

.judge-round-select {
    padding: 10px 12px;
    font-size: 15px;
    border-radius: 6px;
    border: 1px solid #ccc;
    flex: 1 1 auto;
    min-width: 140px;
    max-width: 100%;
    box-sizing: border-box;
}

.judge-save-scores-btn,
#saveScoresBtn {
    padding: 10px 28px;
    font-size: 1.1em;
    white-space: nowrap;
    flex-shrink: 0;
    width: auto !important;
}

/* --- Filters + audio --- */
.judge-filters-row {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.judge-filter-gender,
.judge-filter-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.judge-filter-name {
    flex: 1 1 200px;
    min-width: 0;
}

.judge-gender-select {
    padding: 9px 12px;
    border-radius: 6px;
    border: 1px solid #ccc;
}

.judge-name-input {
    padding: 9px 12px;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    border-radius: 6px;
    border: 1px solid #ccc;
    box-sizing: border-box;
}

.judge-audio-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.judge-voice-btn,
#recordAudioBtn {
    background: #2196F3;
    color: white;
    padding: 10px 18px;
    border-radius: 50px;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.35);
    transition: all 0.2s ease;
}

.judge-voice-btn .fa-microphone,
#recordAudioBtn .fa-microphone {
    font-size: 17px;
}

.judge-recording-timer,
#recordingTimer {
    display: none;
    margin-left: 6px;
    font-family: 'Courier New', monospace;
    background: #fff3f3;
    padding: 1px 7px;
    border-radius: 3px;
    color: #c62828;
    font-weight: 700;
}

#uploadAudioBtn {
    background: #2196F3;
    color: white;
    padding: 0;
    border: none;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.35);
    cursor: pointer;
    transition: all 0.2s ease;
}

#uploadAudioBtn .fa-upload {
    font-size: 17px;
}

/* Mobile: stack round/save and filters (breakpoint matches judge table) */
@media (max-width: 768px) {
    .judge-top-controls {
        padding: 12px 14px;
    }

    .judge-top-controls-content {
        gap: 14px;
    }

    .judge-round-save-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .judge-round-row {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        width: 100%;
    }

    .judge-round-select {
        width: 100%;
        min-width: 0;
    }

    .judge-save-scores-btn,
    #saveScoresBtn {
        width: 100% !important;
        max-width: 100%;
        box-sizing: border-box;
    }

    .judge-filters-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .judge-filter-gender,
    .judge-filter-name {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        width: 100%;
        flex: none;
    }

    .judge-gender-select,
    .judge-name-input {
        width: 100%;
    }

    .judge-audio-controls {
        width: 100%;
        justify-content: flex-start;
        padding-top: 2px;
    }

    /* Table area: 1–6 rows tall (content-sized); scroll only above 6 rows (JS sets exact height) */
    #judgeSection {
        --judge-min-rows: 1;
        --judge-max-rows: 6;
        --judge-row-height: 2.75rem;
        --judge-thead-height: 2.35rem;
        height: auto !important;
        min-height: 0;
        max-height: none;
        padding: 10px 12px;
        box-sizing: border-box;
    }

    .judge-scroll-wrapper {
        flex: 0 0 auto;
        width: 100%;
        height: fit-content;
        min-height: calc(
            var(--judge-thead-height) +
            var(--judge-min-rows) * var(--judge-row-height)
        );
        max-height: calc(
            var(--judge-thead-height) +
            var(--judge-max-rows) * var(--judge-row-height)
        );
        overflow-x: auto;
        overflow-y: auto;
    }

    #judgeScoresTable th,
    #judgeScoresTable td {
        padding: 7px 8px;
        font-size: 13px;
        line-height: 1.25;
    }

    #judgeScoresTable .score-input {
        width: 64px;
        padding: 6px;
        font-size: 1em;
    }
}

#micBtn {
    width: 200px;
    min-width: 200px;
    height: 44px;
    padding: 10px 20px;
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Ensure any recorder buttons rendered dynamically keep the same size
   and their inner text doesn't push the layout when labels change. */
#recordAudioBtn,
#micBtn {
    width: 200px !important;
    min-width: 200px !important;
    height: 44px !important;
    box-sizing: border-box;
    overflow: hidden !important;
    white-space: nowrap !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* When recording, make the button visually red (stop state) */
#recordAudioBtn.recording {
    background: linear-gradient(135deg, #d32f2f 0%, #ef5350 100%) !important;
    color: white !important;
    box-shadow: 0 8px 20px rgba(211,47,47,0.24) !important;
}


/* Upload audio — circular companion to voice input (fixed size, no layout shift) */
#uploadAudioBtn {
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 44px !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
}

#uploadAudioBtn:hover:not(:disabled) {
    background: #1976D2 !important;
    box-shadow: 0 4px 12px rgba(33,150,243,0.45) !important;
}

#uploadAudioBtn:disabled,
#uploadAudioBtn.processing {
    cursor: not-allowed !important;
}

.judge-audio-controls {
    flex-shrink: 0;
}

/* Truncate the label inside the button so changing text doesn't expand it */
#recordAudioBtn span,
#micBtn span,
#recordAudioBtn #recordBtnText {
    display: inline-block;
    max-width: calc(100% - 36px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Ensure the whole judge section content is left-aligned inside the container */
#judgeSection .content-section,
#judgeSection > * {
    text-align: left;
}