:root {
    --primary: #2c3e50;
    --primary-light: #34495e;
    --accent: #3498db;
    --success: #2ecc71;
    --warning: #f1c40f;
    --danger: #e74c3c;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --border: #dcdde1;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

/* ==========================================
   HEADER LAYOUT (Global)
   ========================================== */
header {
    background-color: var(--primary);
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    position: relative;
}

header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.header-back-btn {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    text-decoration: none;
    font-size: 14px;
    font-weight: bold;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.header-back-btn:hover {
    opacity: 1;
}

.header-divider {
    font-weight: 300;
    opacity: 0.5;
    margin: 0 10px;
}

.header-module {
    font-weight: normal;
    font-size: 0.85em;
    opacity: 0.9;
}

.header-mvp {
    color: var(--danger);
    font-size: 0.5em;
    font-weight: bold;
    margin-left: 5px;
}

.header-action-btn {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

.header-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ==========================================
   MAIN CONTENT & FORMS
   ========================================== */
main {
    max-width: 1000px;
    margin: 30px auto;
    padding: 0 20px;
}

section {
    background-color: var(--card-bg);
    padding: 25px;
    margin-bottom: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0,0,0,0.02);
}

h2 {
    margin-top: 0;
    color: var(--primary);
    font-size: 18px;
    border-left: 4px solid var(--accent);
    padding-left: 10px;
    margin-bottom: 20px;
}

form {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 120px;
}

.form-group.wide {
    flex: 2;
    min-width: 200px;
}

label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--primary-light);
}

input[type="text"], 
input[type="number"], 
select,
textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    color: var(--text);
    background-color: #fff;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

input:focus, 
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.tiebreak-group {
    background: #fff;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    width: 100%;
    margin-top: 5px;
}

.tiebreak-item {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    font-size: 13px;
}

.tiebreak-item input {
    margin-right: 8px;
    width: auto;
}

/* ==========================================
   BUTTONS
   ========================================== */
button {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

button:active {
    transform: scale(0.98);
}

button[type="submit"] {
    background-color: var(--accent);
    color: white;
}

button[type="submit"]:hover {
    background-color: #2980b9;
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-success:hover {
    background-color: #27ae60;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-warning {
    background-color: var(--warning);
    color: #2c3e50;
}

.btn-warning:hover {
    background-color: #d4ac0d;
}

.btn-secondary {
    background-color: #7f8c8d;
    color: white;
}

.btn-secondary:hover {
    background-color: #717d7e;
}

.btn-chess {
    background-color: #8e44ad; 
    color: white;
}

.btn-chess:hover {
    background-color: #7d3c98; 
}

/* ==========================================
   LISTEN & KARTEN
   ========================================== */
ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

li {
    padding: 12px 15px;
    background-color: #f8f9fa;
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-bottom: 8px;
}

#player-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; 
    gap: 15px;
}

#player-list li > span {
    flex: 1 1 250px; 
    line-height: 1.4;
}

#player-list li > div {
    display: flex;
    gap: 5px;
    flex-shrink: 0; 
    margin-left: auto; 
}

#player-list button {
    padding: 4px 8px;
    font-size: 13px;
    margin: 0;
}

#player-list button.btn-secondary {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pairing-card {
    background-color: #f8f9fa;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 12px;
    font-size: 14px;
}

/* =========================================
   EXPORT BAR LAYOUT 
   ========================================= */
.export-bar {
    margin-top: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    background-color: var(--card-bg);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
    flex-wrap: wrap; 
}

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

.export-group-right {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
}

.export-bar button {
    height: 38px;
    padding: 0 15px;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    box-sizing: border-box;
    margin: 0;
}

.export-bar .btn-secondary {
    background-color: transparent;
    color: var(--primary);
    border: 1px solid #bdc3c7;
}

.export-bar .btn-secondary:hover {
    background-color: #f8f9fa;
    border-color: var(--primary-light);
    transform: translateY(-1px);
}

#web-sync-btn {
    background-color: var(--accent); 
    color: white;
    border: none;
    min-width: 220px;
}

#web-sync-btn:hover {
    background-color: #2980b9;
}

#web-sync-btn.btn-success {
    background-color: var(--success); 
}

#web-id-badge {
    font-weight: 600;
    color: var(--text-light);
    font-size: 13px;
    background-color: #ecf0f1;
    padding: 4px 8px;
    border-radius: 4px;
}

/* =========================================
   TABELLEN STYLES
   ========================================= */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    margin-bottom: 25px;
    background-color: var(--card-bg);
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background-color: var(--primary);
    color: white;
    font-weight: 600;
    font-size: 14px;
}

tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* =========================================
   HANDBUCH & INFO-BOXEN
   ========================================= */
.alert-box {
    padding: 15px 20px;
    margin: 25px 0;
    border-left: 5px solid;
    border-radius: 4px;
    font-size: 14px;
}

.alert-box strong {
    display: block;
    margin-bottom: 5px;
    font-size: 1.05em;
}

.alert-box ul {
    margin: 8px 0 0 20px;
    list-style-type: disc;
}

.alert-box li {
    padding: 0;
    background: transparent;
    border: none;
    margin-bottom: 4px;
}

.alert-info {
    border-color: #3498db;
    background-color: #ebf5fb;
}

.alert-info strong {
    color: #2980b9;
}

.alert-warning {
    border-color: #f1c40f;
    background-color: #fef9e7;
}

.alert-warning strong {
    color: #d4ac0d;
}

/* =========================================
   LIGA MANAGER (TABS)
   ========================================= */
.tab-container {
    display: flex;
    border-bottom: 2px solid var(--primary);
    margin-bottom: 20px;
    background: var(--card-bg); 
}

.tab-button {
    background: none;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 6px 6px 0 0;
}

.tab-button:hover {
    background: rgba(0,0,0,0.05);
    color: var(--primary);
}

.tab-button.active {
    background: var(--primary);
    color: white;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s;
}

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

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

.match-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.match-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    margin-bottom: 10px;
    font-weight: bold;
    color: var(--primary);
}

.board-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
}

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

/* ==========================================
   PORTAL (Startseite)
   ========================================== */
.portal-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--bg);
    margin: 0;
    padding: 20px;
}

.portal-container {
    text-align: center;
    background: var(--card-bg);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
    max-width: 800px;
    width: 100%;
}

.logo-text {
    font-size: 3rem;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 40px;
    letter-spacing: 2px;
}

.module-grid {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.module-card {
    flex: 1;
    min-width: 250px;
    padding: 30px 20px;
    border-radius: 8px;
    text-decoration: none;
    color: white;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
    border: none;
}

.module-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.card-turnier {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
}

.card-liga {
    background: linear-gradient(135deg, #2c3e50, #34495e);
}

.module-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.module-title {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.module-desc {
    font-size: 0.9rem;
    opacity: 0.9;
    line-height: 1.4;
}

.badge {
    position: absolute;
    top: 15px;
    right: -30px;
    background: var(--danger);
    color: white;
    padding: 5px 30px;
    font-size: 0.7rem;
    font-weight: bold;
    transform: rotate(45deg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.portal-footer {
    position: absolute;
    bottom: 20px;
    text-align: center;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.portal-about-btn {
    background-color: var(--card-bg);
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 8px 24px;
    border-radius: 20px;
    font-size: 15px;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.portal-about-btn:hover {
    background-color: var(--primary);
    color: white;
    transform: translateY(-2px);
}

/* ==========================================
   MODAL (Über T.O.M. Pop-up)
   ========================================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background-color: var(--card-bg);
    color: var(--text);
    padding: 30px 40px;
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    position: relative;
    border: 1px solid var(--border);
}

.modal-content p {
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
}

.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.2s;
}

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

/* =========================================
   HANDBUCH (Manual) Container
   ========================================= */
.manual-container {
    background-color: var(--card-bg);
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border);
    font-size: 16px;
    line-height: 1.7;
}

.manual-container h1 {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 2.2em;
}

.manual-container h2 {
    color: var(--primary);
    border-left: none;
    border-bottom: 1px solid var(--border);
    padding-left: 0;
    margin-top: 40px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    font-size: 1.5em;
}

.manual-container h3 {
    color: var(--accent);
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.manual-container p {
    margin-bottom: 15px;
}

/* ==========================================
   FEATURE & MANUAL FOOTER (Zentriert)
   ========================================== */
.feature-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    border-top: 1px solid var(--border);
    background-color: var(--bg);
    border-radius: 6px;
}

.feature-footer-text {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 15px;
}

/* =========================================
   GEKAPSELTE FEATURE-LISTE 
   ========================================= */
.feature-liste {
    max-width: 900px;
    margin: 30px auto;
    padding: 30px;
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.feature-liste h1, .feature-liste h2, .feature-liste h3, .feature-liste a {
    color: var(--primary);
}

.feature-liste h1 {
    border-bottom: 2px solid var(--primary);
    padding-bottom: 10px;
    margin-top: 0;
}

.feature-liste h2 {
    border-left: none; 
    padding-left: 0;
    border-bottom: 1px solid var(--border);
}

.feature-liste ul {
    list-style-type: square;
    margin-bottom: 20px;
    padding-left: 20px;
}

.feature-liste li {
    display: list-item;
    background-color: transparent;
    border: none;
    padding: 0;
    margin-bottom: 8px;
}

/* =========================================
   FOOTER (Global unten)
   ========================================= */
#tom-footer {
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    border-top: 1px solid var(--border);
}

.footer-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: color 0.2s;
}

.footer-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

.manual-link {
    background-color: #e8f4f8;
    color: var(--primary);
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid #bce8f1;
    margin-right: 5px;
    text-decoration: none;
}

.manual-link:hover {
    background-color: #d0eaf5;
    border-color: #9acfe3;
    text-decoration: none;
}

.footer-divider {
    color: var(--border);
    margin: 0 10px;
}

/* =========================================
   PRÄSENTATIONSANSICHT (Beamer-optimiert)
   ========================================= */
body.presentation-active header,
body.presentation-active #player-section,
body.presentation-active #tournament-section,
body.presentation-active #table-view-controls,
body.presentation-active .export-bar,
body.presentation-active #tom-footer {
    display: none !important;
}

body.presentation-active {
    padding: 0;
    background-color: var(--card-bg);
}

body.presentation-active main {
    max-width: 98%; 
    margin: 0 auto;
    padding: 20px 0;
}

body.presentation-active h2 {
    text-align: center;
    font-size: clamp(24px, 3vw, 40px); 
    margin-bottom: 20px;
    border: none;
}

body.presentation-active #progress-table-container {
    overflow-x: hidden !important;
}

body.presentation-active table {
    width: 100%;
    table-layout: auto;
}

body.presentation-active table th,
body.presentation-active table td {
    padding: 8px 6px !important; 
    font-size: clamp(12px, 1.4vw, 24px) !important; 
    white-space: nowrap; 
}

body.presentation-active table td:nth-child(2) {
    white-space: normal; 
}

/* ==========================================
   NEU: PGN ZENTRALE (TAB 3)
   ========================================== */
.pgn-dashboard {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.upload-group {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-top: 15px;
    flex-wrap: wrap;
}

.upload-group input[type="file"] {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 14px;
    flex: 1;
    min-width: 250px;
}

.viewer-placeholder {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.02);
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--text-light);
    font-style: italic;
    margin-top: 15px;
}

.pgn-match-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.pgn-match-row:last-child {
    border-bottom: none;
}

/* ==========================================
   DARK MODE
   ========================================== */
body.dark-mode {
    --bg: #121212;
    --card-bg: #1e1e1e;
    --border: #333;
    --text: #e0e0e0;
    --text-light: #aaaaaa;
    --primary: #66b2ff;
    --primary-light: #99c2ff;
    --accent: #66b2ff;
    --success: #4dd28c;
    --warning: #f5d76e;
    --danger: #ff6b6b;
}

body.dark-mode header,
body.dark-mode th {
    background-color: #1a1a1a;
    border-bottom: 1px solid #333;
}

body.dark-mode input[type="text"], 
body.dark-mode input[type="number"], 
body.dark-mode input[type="file"],
body.dark-mode select,
body.dark-mode textarea,
body.dark-mode .tiebreak-group,
body.dark-mode li,
body.dark-mode .pairing-card {
    background-color: #2c2c2c;
    border-color: #444;
    color: var(--text);
}

body.dark-mode tr:hover { background-color: #2c2c2c; }
body.dark-mode table { color: var(--text) !important; background-color: var(--card-bg) !important; }
body.dark-mode table th { background-color: #1f2d3d !important; border-color: #444 !important; color: #ffffff !important; }
body.dark-mode table td { border-color: #333 !important; }
body.dark-mode table tr:nth-child(odd) td { background-color: var(--card-bg) !important; }
body.dark-mode table tr:nth-child(even) td { background-color: #2a2a2a !important; }
body.dark-mode .export-bar .btn-secondary { border-color: #555; color: #ddd; }
body.dark-mode .export-bar .btn-secondary:hover { background-color: #333; border-color: #888; }
body.dark-mode .btn-chess { background-color: #9b59b6; color: white; }
body.dark-mode .btn-chess:hover { background-color: #8e44ad; }
body.dark-mode .alert-info { background-color: #1a3040; border-color: #2980b9; }
body.dark-mode .alert-info strong { color: #5dade2; }
body.dark-mode .match-card { background-color: #2c3e50; border: 1px solid #34495e; }
body.dark-mode .match-header { background-color: #1a252f; border-bottom: 1px solid #34495e; color: #ecf0f1; }
body.dark-mode .board-row { border-bottom: 1px solid #34495e; color: #ecf0f1; }
body.dark-mode .result-select { background-color: #1a252f; color: #ecf0f1; border: 1px solid #7f8c8d; }
body.dark-mode .portal-about-btn { background-color: #1e1e1e; color: var(--primary-light); border-color: var(--primary-light); }
body.dark-mode .portal-about-btn:hover { background-color: var(--primary-light); color: #121212; }
body.dark-mode .footer-link { color: var(--primary-light); }
body.dark-mode .footer-link:hover { color: var(--accent); }
body.dark-mode .manual-link { background-color: #1a3b4c; border-color: #295b75; color: var(--primary-light); }

/* PGN Viewer Placeholder im Dark Mode etwas abdunkeln */
body.dark-mode .viewer-placeholder { background: rgba(255,255,255,0.03); }