:root {
    --color-primary: #667eea;
    --color-secondary: #764ba2;
    --color-success: #27ae60;
    --color-dark: #2c3e50;
    --color-rank-gold:   #fff3cd;
    --color-rank-silver: #e8eaed;
    --color-rank-bronze: #fde8d8;

    --color-text: #2c3e50;
    --color-text-muted: #555e6b;
}

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

/* Touch-Optimierungen für alle Geräte */
button, .btn, a, input[type="submit"] {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
}

/* Verhindert Zoom bei Tap auf Inputs auf iOS */
input, select, textarea {
    font-size: 16px;
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    color: var(--color-text);
    background: linear-gradient(135deg, #111111 0%, #b91c1c 50%, #1a1a1a 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.banner {
    background: #333;
    padding: 12px 24px;
    display: flex;
    flex-direction: row;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.banner > * + * { margin-left: 16px; }

.banner-logo {
    height: 72px;
    width: auto;
    border-radius: 50%;
    flex-shrink: 0;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
}

.banner-logo:hover {
    opacity: 0.85;
    transform: scale(1.05);
}

.banner-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.banner-content > * + * { margin-top: 10px; }

.banner-title {
    color: white;
    font-size: 1.3em;
    text-align: center;
    margin: 0;
}

.banner-buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    margin: -7px;
}
.banner-buttons > * { margin: 7px; }

.banner.hidden {
    display: none;
}

.banner-btn {
    padding: 10px 25px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: white;
}

#homeBtn      { background: #34495e; }
#apparatusBtn { background: #16a085; }
#backBtn      { background: #3498db; }
#finishBtn    { background: var(--color-success); }
#evaluationBtn { background: #e67e22; }
#helpBtn      { background: #718096; }

#homeBtn:hover      { background: var(--color-dark); }
#apparatusBtn:hover { background: #138d75; }
#backBtn:hover      { background: #2980b9; }
#finishBtn:hover    { background: #229954; }
#evaluationBtn:hover { background: #d35400; }
#helpBtn:hover      { background: #4a5568; }

#homeBtn:hover, #apparatusBtn:hover, #backBtn:hover,
#finishBtn:hover, #evaluationBtn:hover {
    transform: translateY(-2px);
}

.btn-upload {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%) !important;
    font-size: 1.1em !important;
    padding: 25px 50px !important;
}

.page {
    display: none;
    padding: 40px;
    min-height: 400px;
}

.page.active {
    display: block;
}

.site-logo {
    display: block;
    margin: 0 auto 20px;
    width: 120px;
    height: auto;
}

h1 {
    color: var(--color-dark);
    text-align: center;
    margin-bottom: 12px;
    font-size: 2em;
    letter-spacing: -0.3px;
}

h2 {
    color: var(--color-text-muted);
    text-align: center;
    margin-bottom: 28px;
    font-size: 1.2em;
    font-weight: 500;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin: 30px -10px -10px;
}
.button-group > * { margin: 0 10px 10px; }

/* Geräteauswahl: 2-spaltiges Grid, zentriert */
#boysApparatus .button-group,
#girlsApparatus .button-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    max-width: 560px;
    margin: 30px auto;
}
#boysApparatus .button-group > *,
#girlsApparatus .button-group > * { margin: 0; }

#boysApparatus .button-group .btn,
#girlsApparatus .button-group .btn {
    min-width: unset;
    width: 100%;
    padding: 20px 16px 18px;
    font-size: 17px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 155px;
}
#boysApparatus .button-group .btn > * + *,
#girlsApparatus .button-group .btn > * + * { margin-top: 14px; }

.apparatus-icon {
    width: 68px;
    height: 56px;
    flex-shrink: 0;
}

[data-theme="dark"] .apparatus-icon {
    opacity: 0.9;
}

.btn {
    padding: 20px 40px;
    font-size: 18px;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    background: linear-gradient(135deg, #c92a2a 0%, #991b1b 100%);
    color: white;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    min-width: 200px;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(185, 28, 28, 0.45);
}

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

.btn-back {
    background: linear-gradient(135deg, #7f1d1d 0%, #5a1212 100%);
    margin-top: 20px;
}

.btn-evaluation {
    background: linear-gradient(135deg, #c92a2a 0%, #991b1b 100%);
    margin-top: 20px;
}

.table-wrapper {
    overflow-x: auto;
    margin-top: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

thead {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    color: white;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e0e5ea;
}

th {
    font-weight: 700;
    font-size: 0.82em;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

tbody tr:nth-child(even):not([class]) {
    background: #f7f9fc;
}

tbody tr:hover {
    background: #eef2f9;
}

input[type="number"], input[type="text"] {
    width: 100%;
    padding: 8px;
    border: 2px solid #bdc3c7;
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

input[type="number"]:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--color-primary);
}

.readonly-cell {
    background: #f0f4f8 !important;
    color: var(--color-dark);
    font-weight: 600;
    user-select: none;
    border-right: 2px solid #dde3ea;
    white-space: nowrap;
}

.result-cell {
    font-weight: 700;
    color: var(--color-success);
    font-size: 1.05em;
    background: #f0faf5 !important;
    border-left: 3px solid var(--color-success);
}

.evaluation-section {
    margin-bottom: 48px;
}

.evaluation-section h3 {
    color: var(--color-dark);
    font-size: 1.15em;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #f0f4f8;
    border-left: 5px solid var(--color-primary);
    border-radius: 0 6px 6px 0;
}

.evaluation-section table {
    font-size: 15px;
}

.evaluation-section th:last-child {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    font-weight: bold;
}

.evaluation-section td:last-child {
    font-weight: 700;
}

/* Upload-Bereich */
.upload-section {
    text-align: center;
    margin: 30px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.upload-section-hint {
    color: #7f8c8d;
    margin-top: 15px;
    font-size: 0.9em;
}

/* Riegen-Auswahl */
.scoring-riege-selector {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #b91c1c;
    border-radius: 10px;
}

.riege-section {
    text-align: center;
    margin: 20px 0;
    padding: 20px;
    background: #b91c1c;
    border-radius: 10px;
}

.riege-section-inner h3 {
    margin-bottom: 12px;
    color: rgba(255,255,255,0.85);
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.riege-btn-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    max-width: 800px;
    margin: 0 auto;
}
.riege-btn-group > * { margin: 0; }

.riege-btn {
    min-width: 0;
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    background: #95a5a6;
}

.riege-btn:hover {
    background: #7f8c8d;
}

.riege-btn.active {
    background: var(--color-dark) !important;
    color: white;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(44,62,80,0.4);
}

.riege-btn.locked {
    background: #27ae60 !important;
    color: white !important;
    border-color: #1e8449 !important;
}

.riege-btn.locked.active {
    background: #1e8449 !important;
    box-shadow: 0 2px 8px rgba(30,132,73,0.5);
}

.lock-notice {
    display: flex;
    align-items: center;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    padding: 10px 18px;
    margin-bottom: 14px;
    font-weight: bold;
    color: #155724;
}

.lock-icon {
    font-size: 1.2em;
    margin-right: 12px;
}

.btn-korrektur {
    margin-left: auto;
    padding: 6px 16px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: bold;
    cursor: pointer;
}

.btn-korrektur:hover {
    background: #c0392b;
}

.scoring-locked-row input:disabled {
    background: #f0f4f0;
    color: #777;
    cursor: not-allowed;
    border-color: #c8d8c8;
}

.riege-header {
    background: linear-gradient(135deg, var(--color-primary) 0%, #764ba2 100%);
    color: white;
    font-weight: bold;
    font-size: 1.05em;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    box-shadow: 0 3px 8px rgba(0,0,0,0.25);
}

.riege-header td {
    padding: 12px 16px;
    border-top: 6px solid white;
}

.top-score {
    background: #fff3cd !important;
    font-weight: bold;
    border-left: 4px solid #f39c12;
}

.top-score td { color: #1a1a1a; }
.top-score td:last-child { background: #fff3cd !important; }

/* Gerätewertungen Toggle */
.geraet-toggle-row {
    display: flex;
    align-items: center;
    margin: 10px 0 14px;
}
.geraet-toggle-row > * + * { margin-left: 10px; }

.toggle-label {
    font-size: 0.95em;
    font-weight: 600;
    color: var(--color-dark);
    user-select: none;
    cursor: pointer;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 26px;
    cursor: pointer;
    transition: background 0.25s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.25s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--color-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* Auswertung Download */
.eval-download-row {
    display: flex;
    justify-content: flex-end;
    padding: 8px 0 4px;
}

.eval-download-btn {
    background: linear-gradient(135deg, #27ae60, #2ecc71) !important;
    color: white !important;
    padding: 10px 26px !important;
    font-size: 0.95em !important;
    border-radius: 8px !important;
    font-weight: 700 !important;
    box-shadow: 0 3px 10px rgba(39, 174, 96, 0.35) !important;
    transition: transform 0.15s, box-shadow 0.15s !important;
}

.eval-download-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 5px 15px rgba(39, 174, 96, 0.5) !important;
}

/* Auswertung Modus-Switch */
.eval-mode-switch {
    display: flex;
    justify-content: center;
    padding: 15px 0 5px;
    margin-bottom: 10px;
}
.eval-mode-switch > * + * { margin-left: 12px; }

.eval-mode-btn {
    min-width: 180px;
    padding: 12px 24px;
    font-size: 15px;
    opacity: 0.55;
}

.eval-mode-btn.active-mode {
    opacity: 1;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.5);
    transform: translateY(-2px);
}

/* Pro-Gerät-Ansicht */
.apparatus-block { margin-top: 16px; }

.wknr-subheader {
    margin: 18px 0 6px;
    font-size: 0.95em;
    font-weight: bold;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 4px;
}

[data-theme="dark"] .wknr-subheader {
    color: #a0aec0;
    border-bottom-color: #4a5568;
}

.apparatus-btn-bar {
    display: flex;
    flex-wrap: wrap;
    margin: 14px -5px -5px;
}
.apparatus-btn-bar > * { margin: 0 5px 5px; }

.apparatus-select-btn {
    padding: 10px 22px;
    font-size: 0.95em;
    background: #e8ecf0;
    color: var(--color-dark);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    opacity: 0.7;
}

.apparatus-select-btn:hover {
    background: #d0d7e0;
    opacity: 1;
}

.apparatus-select-btn.active {
    background: linear-gradient(135deg, var(--color-primary) 0%, #764ba2 100%);
    color: white;
    opacity: 1;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.45);
    transform: translateY(-2px);
}

/* Platzierungsfarben */
.rank-1 { background: var(--color-rank-gold)   !important; font-weight: bold; }
.rank-2 { background: var(--color-rank-silver) !important; font-weight: bold; }
.rank-3 { background: var(--color-rank-bronze) !important; font-weight: bold; }

.rank-1 td, .rank-2 td, .rank-3 td { color: #1a1a1a; }

.rank-1 td:last-child { background: var(--color-rank-gold)   !important; }
.rank-2 td:last-child { background: var(--color-rank-silver) !important; }
.rank-3 td:last-child { background: var(--color-rank-bronze) !important; }

/* Passwort-Modal */
.password-modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.password-modal.active {
    display: flex;
}

.password-modal-content {
    background: white;
    border-radius: 15px;
    padding: 40px;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.password-modal-content h2 {
    margin-bottom: 10px;
    color: #333;
}

.password-modal-content p {
    color: #666;
    margin-bottom: 25px;
}

.password-modal-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    margin-bottom: 15px;
    outline: none;
}

.password-modal-error {
    color: #e74c3c;
    margin-bottom: 15px;
    display: none;
}

.password-modal-actions {
    display: flex;
    justify-content: center;
}
.password-modal-actions > * + * { margin-left: 10px; }

.password-modal-btn-primary {
    padding: 12px 30px;
    background: linear-gradient(135deg, #c92a2a, #991b1b);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
}

.password-modal-btn-cancel {
    padding: 12px 30px;
    background: #ccc;
    color: #333;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
}

/* ── PDF-Anzeige-Modal (Bedienungsanleitung) ─────────────────────────────── */
.pdf-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1100;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.pdf-modal.active { display: flex; }
.pdf-modal-inner {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 1000px;
    height: 92%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
}
.pdf-modal-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: #2c3e50;
    color: #fff;
}
.pdf-modal-bar .pdf-title { font-weight: 600; font-size: 0.95em; }
.pdf-modal-bar .pdf-actions { display: flex; gap: 8px; }
.pdf-bar-btn {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: none;
    border-radius: 7px;
    padding: 7px 12px;
    font-size: 0.85em;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.pdf-bar-btn:hover { background: rgba(255, 255, 255, 0.28); }
.pdf-modal-frame { flex: 1; width: 100%; border: none; background: #fff; }

/* ══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE DESIGN FÜR MOBILE GERÄTE
   ══════════════════════════════════════════════════════════════════════════════ */

/* ─── Tablets & kleinere Desktops (≤ 1024px) ───────────────────────────────── */
@media (max-width: 1024px) {
    body {
        font-size: 15px;
        padding: 15px;
    }

    .container {
        margin: 0 auto;
        border-radius: 12px;
    }

    h1 {
        font-size: 1.9em;
    }

    h2 {
        font-size: 1.15em;
    }

    /* Geräte-Grid: bleibt 2-spaltig */
    #boysApparatus .button-group,
    #girlsApparatus .button-group {
        gap: 16px;
        max-width: 100%;
    }

    /* Riegen-Auswahl: mehr Buttons pro Zeile auf Tablets */
    .riege-btn-group {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 8px;
    }
}

/* ─── Mobile Geräte (≤ 768px) ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    body {
        font-size: 14px;
        padding: 10px;
    }

    .container {
        margin: 0;
        border-radius: 10px;
    }

    .page {
        padding: 20px 16px;
        min-height: 300px;
    }

    /* ─── Überschriften ─────────────────────────────────────────────────── */
    h1 {
        font-size: 1.6em;
        margin-bottom: 10px;
    }

    h2 {
        font-size: 1.05em;
        margin-bottom: 20px;
    }

    .site-logo {
        width: 90px;
        margin-bottom: 16px;
    }

    /* ─── Banner ────────────────────────────────────────────────────────── */
    .banner {
        padding: 10px 12px;
        flex-direction: column;
        align-items: flex-start;
    }
    .banner > * + * { margin-left: 0; margin-top: 10px; }

    .banner-logo {
        height: 48px;
        align-self: center;
    }

    .banner-content {
        width: 100%;
        align-items: stretch;
    }

    .banner-title {
        font-size: 1.1em;
        text-align: center;
    }

    .banner-buttons {
        width: 100%;
        flex-direction: column;
        margin: 0;
    }
    .banner-buttons > * {
        margin: 0 0 8px 0;
        width: 100%;
    }
    .banner-buttons > *:last-child { margin-bottom: 0; }

    .banner-btn {
        padding: 10px 16px;
        font-size: 14px;
        width: 100%;
    }

    .banner-admin-btn {
        position: fixed;
        top: 12px;
        right: 12px;
        z-index: 110;
        width: 40px;
        height: 40px;
    }

    .banner-admin-btn svg {
        width: 20px;
        height: 20px;
    }

    /* ─── Buttons ───────────────────────────────────────────────────────── */
    .button-group {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin: 20px 0;
    }
    .button-group > * { margin: 0; }

    .btn {
        min-width: 0;
        width: 100%;
        padding: 16px 12px;
        font-size: 14px;
        line-height: 1.3;
    }

    .btn-back,
    .btn-evaluation {
        width: 100%;
        margin-top: 16px;
        grid-column: 1 / -1;
    }

    /* ─── Geräteauswahl ─────────────────────────────────────────────────── */
    #boysApparatus .button-group,
    #girlsApparatus .button-group {
        display: flex;
        flex-direction: column;
        gap: 12px;
        max-width: 100%;
        margin: 20px 0;
    }

    #boysApparatus .button-group .btn,
    #girlsApparatus .button-group .btn {
        width: 100%;
        min-height: 0;
        padding: 16px;
        flex-direction: row;
        justify-content: flex-start;
        gap: 16px;
    }

    #boysApparatus .button-group .btn > * + *,
    #girlsApparatus .button-group .btn > * + * {
        margin-top: 0;
    }

    .apparatus-icon {
        width: 56px;
        height: 46px;
    }

    /* ─── Tabellen ──────────────────────────────────────────────────────── */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        padding: 0 16px;
    }

    table {
        font-size: 12px;
        min-width: 600px;
    }

    th, td {
        padding: 8px 6px;
        font-size: 0.9em;
    }

    th {
        font-size: 0.7em;
        letter-spacing: 0.05em;
    }

    input[type="number"],
    input[type="text"] {
        padding: 6px;
        font-size: 14px;
    }

    /* ─── Riegen-Auswahl ────────────────────────────────────────────────── */
    .riege-section {
        padding: 14px;
        border-radius: 8px;
    }

    .riege-section-inner h3 {
        font-size: 0.85em;
        margin-bottom: 10px;
    }

    .riege-btn-group {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
        margin: 0;
    }
    .riege-btn-group > * { margin: 0; }

    .riege-btn {
        min-width: 0;
        width: 100%;
        padding: 10px 8px;
        font-size: 13px;
    }

    /* ─── Auswertung ────────────────────────────────────────────────────── */
    .eval-mode-switch {
        flex-direction: column;
        padding: 12px 0;
    }
    .eval-mode-switch > * + * { margin-left: 0; margin-top: 8px; }

    .eval-mode-btn {
        min-width: 0;
        width: 100%;
        padding: 10px 20px;
        font-size: 14px;
    }

    .apparatus-btn-bar {
        flex-wrap: wrap;
        margin: 10px -4px -4px;
    }
    .apparatus-btn-bar > * { margin: 0 4px 4px; }

    .apparatus-select-btn {
        padding: 8px 16px;
        font-size: 0.9em;
    }

    .evaluation-section h3 {
        font-size: 1em;
        padding: 10px 12px;
    }

    /* ─── Modals ────────────────────────────────────────────────────────── */
    .password-modal-content {
        padding: 30px 24px;
        max-width: 90%;
    }

    .password-modal-input {
        font-size: 16px;
    }

    .password-modal-actions {
        flex-direction: column;
    }
    .password-modal-actions > * + * {
        margin-left: 0;
        margin-top: 8px;
    }

    .password-modal-btn-primary,
    .password-modal-btn-cancel {
        width: 100%;
        padding: 12px 24px;
    }

    .help-modal {
        padding: 16px;
    }

    .help-modal-inner {
        padding: 24px 20px;
        max-width: 100%;
    }

    .help-modal-title {
        font-size: 1.1em;
        padding-bottom: 10px;
    }

    .help-section-heading {
        font-size: 0.9em;
    }

    .help-section-body {
        font-size: 0.85em;
    }

    /* ─── Admin & Dark Mode Toggle ──────────────────────────────────────── */
    .selection-admin-btn {
        top: 12px;
        right: 12px;
        width: 44px;
        height: 44px;
    }

    .selection-admin-btn svg {
        width: 20px;
        height: 20px;
    }

    .dark-mode-toggle {
        top: 12px;
        right: 66px;       /* links neben dem Zahnrad (right:12 + 44 Breite + 10 Abstand) */
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    /* ─── Lock Notice ───────────────────────────────────────────────────── */
    .lock-notice {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px 14px;
    }

    .btn-korrektur {
        margin-left: 0;
        margin-top: 8px;
        width: 100%;
    }

    /* ─── Download Button ───────────────────────────────────────────────── */
    .eval-download-row {
        justify-content: center;
    }

    .eval-download-btn {
        width: 100% !important;
        padding: 12px 20px !important;
        font-size: 0.9em !important;
    }
}

/* ─── Kleine Smartphones (≤ 480px) ─────────────────────────────────────────── */
@media (max-width: 480px) {
    body {
        font-size: 13px;
        padding: 8px;
    }

    .page {
        padding: 16px 12px;
    }

    h1 {
        font-size: 1.4em;
        line-height: 1.3;
    }

    h2 {
        font-size: 1em;
        margin-bottom: 16px;
    }

    .site-logo {
        width: 80px;
        margin-bottom: 14px;
    }

    .btn {
        padding: 14px 10px;
        font-size: 13px;
        line-height: 1.2;
    }

    .button-group {
        gap: 10px;
    }

    .banner-logo {
        height: 42px;
    }

    .banner-title {
        font-size: 1em;
    }

    .banner-btn {
        padding: 9px 14px;
        font-size: 13px;
    }

    table {
        font-size: 11px;
    }

    th, td {
        padding: 6px 4px;
    }

    input[type="number"],
    input[type="text"] {
        padding: 5px;
        font-size: 13px;
    }

    .riege-btn-group {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 6px;
    }

    .riege-btn {
        min-width: 0;
        padding: 9px 6px;
        font-size: 12px;
    }

    .apparatus-icon {
        width: 48px;
        height: 40px;
    }

    #boysApparatus .button-group .btn,
    #girlsApparatus .button-group .btn {
        padding: 14px;
        gap: 12px;
    }

    .password-modal-content {
        padding: 24px 18px;
    }

    .help-modal-inner {
        padding: 20px 16px;
    }

    .selection-admin-btn,
    .dark-mode-toggle {
        width: 40px;
        height: 40px;
    }

    .selection-admin-btn svg,
    .dark-mode-toggle {
        font-size: 18px;
    }
}

/* ─── Landscape-Modus auf kleinen Geräten ──────────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        padding: 5px;
    }

    .page {
        padding: 12px 10px;
    }

    h1 {
        font-size: 1.3em;
        margin-bottom: 8px;
    }

    h2 {
        font-size: 0.95em;
        margin-bottom: 12px;
    }

    .site-logo {
        width: 60px;
        margin-bottom: 10px;
    }

    .banner {
        padding: 8px 10px;
    }

    .banner-logo {
        height: 38px;
    }

    .btn {
        padding: 10px 18px;
        font-size: 13px;
    }

    .button-group {
        margin: 12px -6px -6px;
    }

    .banner-buttons > * {
        margin-bottom: 6px;
    }
}

/* ─── Touch-Feedback und Aktive Zustände ───────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
    /* Nur auf Touch-Geräten */
    .btn:active,
    .banner-btn:active,
    .riege-btn:active {
        transform: scale(0.97);
        opacity: 0.9;
    }

    .selection-admin-btn:active,
    .dark-mode-toggle:active {
        transform: scale(0.92);
    }

    /* Tabellen-Rows auf Touch-Geräten */
    tbody tr {
        cursor: default;
    }

    /* Größere Touch-Targets für kleine Elemente */
    .btn-unlock,
    .btn-delete,
    .btn-korrektur {
        min-height: 44px;
        padding: 10px 14px;
    }

    .lock-dot,
    .status-online-dot {
        width: 10px;
        height: 10px;
    }
}

/* ─── Vermeidung von Layout-Shift bei virtueller Tastatur ──────────────────── */
@media (max-width: 768px) {
    #scoringView input:focus {
        scroll-margin-top: 60px;
    }

    .table-wrapper {
        scroll-snap-type: x mandatory;
    }
}

/* ─── Hochformat-spezifische Anpassungen ────────────────────────────────────── */
@media (max-width: 768px) and (orientation: portrait) {
    /* Tabellen: Horizontal scrollbar prominenter */
    .table-wrapper {
        border: 2px solid var(--color-primary);
        border-radius: 8px;
        padding: 8px;
    }

    .table-wrapper::after {
        content: "→ Schieben für mehr";
        display: block;
        text-align: center;
        font-size: 0.75em;
        color: var(--color-text-muted);
        margin-top: 8px;
        font-style: italic;
    }
}

/* ─── Sehr schmale Bildschirme (≤ 360px) ───────────────────────────────────── */
@media (max-width: 360px) {
    h1 {
        font-size: 1.3em;
    }

    .btn {
        padding: 12px 8px;
        font-size: 12px;
    }

    .button-group {
        gap: 8px;
    }
}

/* ─── Sehr große Geräte (Tablets im Querformat) ────────────────────────────── */
@media (min-width: 769px) and (max-width: 1200px) {
    .container {
        max-width: 95%;
    }

    #boysApparatus .button-group,
    #girlsApparatus .button-group {
        grid-template-columns: repeat(3, 1fr);
        max-width: 800px;
    }
}

/* ===== Admin Link Button (top-right) ===== */
.banner-admin-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.25);
    color: white;
    text-decoration: none;
    transition: background 0.2s, transform 0.2s;
}

.banner-admin-btn svg {
    width: 22px;
    height: 22px;
}

.banner-admin-btn:hover {
    background: rgba(0, 0, 0, 0.45);
    transform: rotate(30deg);
}

/* ===== Admin Link Button (fixed, Auswahlseiten) ===== */
.selection-admin-btn {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c92a2a, #991b1b);
    color: white;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
    transition: transform 0.2s, box-shadow 0.2s;
}

.selection-admin-btn svg {
    width: 22px;
    height: 22px;
}

.selection-admin-btn:hover {
    transform: rotate(30deg) scale(1.1);
    box-shadow: 0 6px 20px rgba(185, 28, 28, 0.45);
}

/* ===== Dark Mode Toggle Button ===== */
.dark-mode-toggle {
    position: fixed;
    top: 16px;
    right: 76px;          /* links neben dem Zahnrad-Symbol (right:16 + 48 Breite + 12 Abstand) */
    z-index: 9999;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #c92a2a, #991b1b);
    color: white;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}
.dark-mode-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(185, 28, 28, 0.45);
}

/* ===== Dark Mode Overrides ===== */
[data-theme="dark"] {
    --color-text: #e2e8f0;
    --color-text-muted: #94a3b8;
    --color-rank-gold:   #a08820;
    --color-rank-silver: #4e7098;
    --color-rank-bronze: #a05040;

}

[data-theme="dark"] body {
    background: linear-gradient(135deg, #111111 0%, #b91c1c 50%, #1a1a1a 100%);
    color: var(--color-text);
}

[data-theme="dark"] .container {
    background: #1e2535;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

[data-theme="dark"] .page {
    background: #1e2535;
}

[data-theme="dark"] .banner {
    background: #111827;
}

[data-theme="dark"] h1,
[data-theme="dark"] h2 {
    color: #e2e8f0;
}

[data-theme="dark"] h2 {
    color: #94a3b8;
}

[data-theme="dark"] h3 {
    color: #e2e8f0;
}

[data-theme="dark"] table {
    background: #1e2535;
    color: #e2e8f0;
}

[data-theme="dark"] th {
    background: #2d3748;
    color: #cbd5e0;
    border-color: #4a5568;
}

[data-theme="dark"] td {
    border-color: #2d3748;
    color: #e2e8f0;
}

[data-theme="dark"] tbody tr:nth-child(even):not([class]) {
    background: #252f3f;
}

[data-theme="dark"] tbody tr:hover {
    background: #2d3a52 !important;
}

[data-theme="dark"] .readonly-cell {
    background: #252f3f !important;
    color: #e2e8f0 !important;
    border-right-color: #4a5568;
}

[data-theme="dark"] .result-cell.readonly-cell {
    background: #1a3a2a !important;
    color: #6ee7b7 !important;
}

[data-theme="dark"] .result-cell {
    background: #1a3a2a;
    color: #6ee7b7;
}

[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] select {
    background: #2d3748;
    color: #e2e8f0;
    border-color: #4a5568;
}

[data-theme="dark"] .btn {
    background: linear-gradient(135deg, #c92a2a, #7f1d1d);
    color: #ffffff;
}

[data-theme="dark"] .btn:hover {
    background: linear-gradient(135deg, #e53e3e, #991b1b);
}

[data-theme="dark"] .riege-btn {
    background: #4a5568;
    color: #e2e8f0;
}

[data-theme="dark"] .riege-btn:hover {
    background: #5a6a7e;
}

[data-theme="dark"] #homeBtn      { background: #34495e; }
[data-theme="dark"] #apparatusBtn { background: #16a085; }
[data-theme="dark"] #backBtn      { background: #3498db; }
[data-theme="dark"] #finishBtn    { background: var(--color-success); }
[data-theme="dark"] #evaluationBtn { background: #e67e22; }

[data-theme="dark"] #homeBtn:hover      { background: var(--color-dark); }
[data-theme="dark"] #apparatusBtn:hover { background: #138d75; }
[data-theme="dark"] #backBtn:hover      { background: #2980b9; }
[data-theme="dark"] #finishBtn:hover    { background: #229954; }
[data-theme="dark"] #evaluationBtn:hover { background: #d35400; }

/* ── Hilfe-Modal ──────────────────────────────────────────────────────── */
.help-modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
}
.help-modal.active { display: flex; }

.help-modal-inner {
    background: white;
    border-radius: 16px;
    padding: 30px 32px 28px;
    max-width: 520px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    margin: auto;
}

.help-modal-title {
    font-size: 1.2em;
    font-weight: 700;
    color: #1a202c;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 12px;
    margin-bottom: 20px;
}

.help-section { margin-bottom: 16px; }
.help-section:last-of-type { margin-bottom: 0; }

.help-section-heading {
    font-size: 0.95em;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 5px;
}

.help-section-body {
    font-size: 0.875em;
    color: #4a5568;
    line-height: 1.65;
}
.help-section-body strong { color: #2d3748; }

.help-divider {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 18px 0;
}

.help-close-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #c92a2a, #991b1b);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 700;
    cursor: pointer;
    margin-top: 22px;
}
.help-close-btn:hover { opacity: 0.9; }

[data-theme="dark"] .help-modal-inner {
    background: #1e2535;
    color: #e2e8f0;
}
[data-theme="dark"] .help-modal-title {
    color: #e2e8f0;
    border-bottom-color: #4a5568;
}
[data-theme="dark"] .help-section-heading { color: #e2e8f0; }
[data-theme="dark"] .help-section-body    { color: #a0aec0; }
[data-theme="dark"] .help-section-body strong { color: #e2e8f0; }
[data-theme="dark"] .help-divider         { border-top-color: #4a5568; }

[data-theme="dark"] .password-modal-content {
    background: #1e2535;
    color: #e2e8f0;
}

[data-theme="dark"] .password-modal-input {
    background: #2d3748;
    color: #e2e8f0;
    border-color: #4a5568;
}

[data-theme="dark"] .riege-header td {
    color: #fff;
}

[data-theme="dark"] .top-score {
    background: #3a3010 !important;
}
[data-theme="dark"] .top-score td { color: #fde68a; }
[data-theme="dark"] .top-score td:last-child { background: #3a3010 !important; }

[data-theme="dark"] .rank-1 { background: var(--color-rank-gold) !important; }
[data-theme="dark"] .rank-1 td { color: #ffffff; }
[data-theme="dark"] .rank-1 td:last-child { background: var(--color-rank-gold) !important; color: #ffffff; }
[data-theme="dark"] .rank-2 { background: var(--color-rank-silver) !important; }
[data-theme="dark"] .rank-2 td { color: #ffffff; }
[data-theme="dark"] .rank-2 td:last-child { background: var(--color-rank-silver) !important; color: #ffffff; }
[data-theme="dark"] .rank-3 { background: var(--color-rank-bronze) !important; }
[data-theme="dark"] .rank-3 td { color: #ffffff; }
[data-theme="dark"] .rank-3 td:last-child { background: var(--color-rank-bronze) !important; color: #ffffff; }

[data-theme="dark"] .evaluation-section h3 {
    background: #2d3748;
    color: #e2e8f0;
}


[data-theme="dark"] .eval-section {
    background: #252f3f;
    border-color: #4a5568;
}

[data-theme="dark"] .upload-section,
[data-theme="dark"] .scoring-riege-selector,
[data-theme="dark"] .riege-section {
    background: #b91c1c;
    color: #ffffff;
}

[data-theme="dark"] .eval-download-btn {
    background: linear-gradient(135deg, #27ae60, #1e8449);
}

[data-theme="dark"] .apparatus-select-btn {
    background: #2d3748;
    color: #e2e8f0;
    border-color: #4a5568;
}

[data-theme="dark"] .apparatus-select-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

[data-theme="dark"] .lock-notice {
    background: #1a3a2a;
    border-color: #2d6a4f;
    color: #6ee7b7;
}

[data-theme="dark"] .scoring-locked-row input:disabled {
    background: #1e2a1e;
    color: #6b8c6b;
    border-color: #2d4a2d;
}

[data-theme="dark"] .toggle-slider {
    background: #4a5568;
}

[data-theme="dark"] .dark-mode-toggle {
    background: linear-gradient(135deg, #f6c90e, #e67e22);
}
