/* ============================================
   SPRACH-ÜBUNGS-ENGINE — Gemeinsames Styling
   ============================================ */

:root {
    --primary: #2c3e50;
    --secondary: #e67e22;
    --bg: #f4f6f8;
    --white: #ffffff;

    /* Feedback */
    --correct-bg: #d4edda;
    --correct-text: #155724;
    --wrong-bg: #f8d7da;
    --wrong-text: #721c24;

    /* Satztyp-Farben (Tags) */
    --c-hs: #2980b9;
    --c-lok: #16a085;
    --c-temp: #f39c12;
    --c-kaus: #c0392b;
    --c-mod: #27ae60;
    --c-fin: #8e44ad;
    --c-kond: #d35400;
    --c-kons: #e84393;
    --c-konz: #7f8c8d;
}

/* ---- BODY ---- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    color: var(--primary);
    margin: 0;
    padding: 20px;
    padding-bottom: 100px;
    line-height: 1.6;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: var(--white);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
    min-height: 600px;
}

h1 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 20px;
}

/* ---- START SCREEN ---- */
#start-screen {
    text-align: center;
    padding: 40px;
}

.intro-text {
    color: #666;
    margin-bottom: 40px;
    font-size: 1.1em;
    max-width: 700px;
    margin: 0 auto 30px auto;
}

.mode-selector {
    margin-bottom: 40px;
}

.mode-selector h3 {
    color: #555;
    margin-bottom: 15px;
    font-size: 1em;
    font-weight: 600;
}

.mode-btns {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.mode-btn {
    padding: 12px 24px;
    font-size: 1em;
    border: 2px solid #ddd;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    background: white;
    color: var(--primary);
    transition: all 0.2s;
}

.mode-btn:hover {
    border-color: var(--secondary);
    background: #fff8f0;
}

.mode-btn.active {
    border-color: var(--secondary);
    background: var(--secondary);
    color: white;
}

.level-btn {
    display: block;
    width: 100%;
    max-width: 400px;
    margin: 15px auto;
    padding: 20px;
    font-size: 1.1em;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-weight: bold;
    color: white;
    text-align: center;
}

.btn-level-0 {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
}

.btn-level-1 {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.btn-level-2 {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.btn-level-3 {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

.level-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.level-desc {
    display: block;
    font-size: 0.8em;
    font-weight: normal;
    opacity: 0.9;
    margin-top: 5px;
}

/* ---- GAME SCREEN ---- */
#game-screen {
    display: none;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 30px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

.back-btn {
    background: none;
    border: 1px solid #ccc;
    padding: 5px 15px;
    border-radius: 4px;
    cursor: pointer;
    color: #555;
}

.back-btn:hover {
    background: #eee;
}

.progress-indicator {
    font-weight: bold;
    color: #aaa;
}

/* ---- SENTENCE AREA ---- */
.sentence-area {
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 50px 20px;
    text-align: center;
    margin: 20px 0;
    min-height: 150px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    font-size: 1.6em;
    line-height: 2.2;
}

/* ---- KOMMA MODE: Wörter & Slots ---- */
.word {
    display: inline-block;
    user-select: none;
}

.comma-slot {
    display: inline-block;
    width: 22px;
    height: 40px;
    margin: 0 1px;
    position: relative;
    cursor: pointer;
    vertical-align: middle;
    border-radius: 4px;
    transition: background 0.2s;
}

.comma-slot::after {
    content: '';
    position: absolute;
    top: -15px;
    bottom: -15px;
    left: -10px;
    right: -10px;
    z-index: 10;
}

.comma-slot:hover {
    background-color: #f0f0f0;
}

.comma-slot.active {
    color: var(--secondary);
    font-weight: bold;
    font-family: "Georgia", serif;
}

.comma-slot.active::before {
    content: ',';
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.3em;
    line-height: 1;
}

/* ---- BESTIMMEN MODE: Clause Blocks ---- */
.clause-block {
    display: inline;
    margin-right: 5px;
}

.clause-text {
    color: #333;
}

.sentence-area-bestimmen {
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 40px 20px;
    margin: 20px 0;
    line-height: 2.5;
    font-size: 1.15em;
}

select.type-select {
    margin-left: 8px;
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
    background-color: #f8f9fa;
    font-size: 0.85em;
    cursor: pointer;
    color: var(--primary);
    max-width: 180px;
}

select.type-select:focus {
    border-color: var(--secondary);
    outline: none;
}

select.correct {
    background-color: var(--correct-bg);
    color: var(--correct-text);
    border-color: var(--correct-text);
    font-weight: bold;
}

select.wrong {
    background-color: var(--wrong-bg);
    color: var(--wrong-text);
    border-color: var(--wrong-text);
}

/* ---- ACTION AREA ---- */
.action-area {
    text-align: center;
    margin-top: 30px;
}

.check-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 12px 40px;
    font-size: 1.2em;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.1s;
}

.check-btn:hover {
    background-color: #1a252f;
    transform: scale(1.02);
}

.next-btn {
    background-color: var(--secondary);
    color: white;
    border: none;
    padding: 12px 40px;
    font-size: 1.2em;
    border-radius: 8px;
    cursor: pointer;
    display: none;
}

/* ---- FEEDBACK AREA ---- */
.feedback-area {
    margin-top: 30px;
    display: none;
    animation: fadeIn 0.5s;
}

.feedback-msg {
    padding: 15px;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 20px;
    text-align: center;
}

.msg-success {
    background: var(--correct-bg);
    color: var(--correct-text);
}

.msg-error {
    background: var(--wrong-bg);
    color: var(--wrong-text);
}

.solution-box {
    background: #fafafa;
    padding: 20px;
    border: 1px solid #eee;
    border-radius: 8px;
    line-height: 1.8;
    font-size: 1.1em;
}

/* ---- ANALYSE TAGS ---- */
.analysis-part {
    padding: 2px 0;
}

.tag {
    font-size: 0.65em;
    font-weight: bold;
    color: white;
    padding: 3px 6px;
    border-radius: 4px;
    margin-left: 5px;
    vertical-align: 2px;
    text-transform: uppercase;
    white-space: nowrap;
}

.tag-hs {
    background-color: var(--c-hs);
}

.tag-lokal {
    background-color: var(--c-lok);
}

.tag-temp {
    background-color: var(--c-temp);
}

.tag-kaus {
    background-color: var(--c-kaus);
}

.tag-mod {
    background-color: var(--c-mod);
}

.tag-fin {
    background-color: var(--c-fin);
}

.tag-kond {
    background-color: var(--c-kond);
}

.tag-kons {
    background-color: var(--c-kons);
}

.tag-konz {
    background-color: var(--c-konz);
}

/* ---- MERKBOX & MODAL ---- */
.float-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background-color: var(--secondary);
    color: white;
    padding: 15px 25px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    font-weight: bold;
    z-index: 1000;
    border: none;
    font-size: 1.1em;
}

.float-btn:hover {
    transform: scale(1.05);
}

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
}

.modal-content {
    background: white;
    width: 95%;
    max-width: 1100px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.modal-header {
    background: var(--primary);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
}

.close-modal {
    background: none;
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
}

.modal-body {
    padding: 25px;
}

/* ---- RULES TABLE ---- */
.rules-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.95em;
}

.rules-table th {
    background-color: #f8f9fa;
    text-align: left;
    padding: 12px;
    border-bottom: 2px solid #ddd;
    color: var(--primary);
}

.rules-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

.rules-table tr:hover {
    background-color: #fdfdfd;
}

/* ---- LEVEL LABEL ---- */
.level-label {
    font-size: 0.85em;
    color: #888;
    font-weight: 600;
    background: #f0f2f5;
    padding: 4px 12px;
    border-radius: 6px;
}

/* ---- COUNT SELECT (shared dropdown) ---- */
.count-select-wrapper {
    max-width: 400px;
    margin: 0 auto 25px auto;
    text-align: center;
}

.count-label {
    display: block;
    font-size: 0.95em;
    color: #666;
    font-weight: 600;
    margin-bottom: 8px;
}

.count-select {
    display: block;
    width: 100%;
    max-width: 400px;
    margin: 0 auto 20px auto;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.95em;
    color: #555;
    background: #f8f9fa;
    cursor: pointer;
    text-align: center;
    appearance: auto;
}

.count-select:focus {
    border-color: var(--secondary);
    outline: none;
}

/* ---- RESULT SCREEN ---- */
#result-screen {
    text-align: center;
    padding: 60px 20px;
    animation: fadeIn 0.5s;
}

.result-card h2 {
    font-size: 1.5em;
    color: var(--primary);
    margin-bottom: 20px;
}

.result-score {
    font-size: 4em;
    font-weight: 800;
    color: var(--secondary);
    margin-bottom: 15px;
}

.result-details {
    font-size: 1.1em;
    color: #666;
    margin-bottom: 35px;
}

.result-card .level-btn {
    max-width: 300px;
}

/* ---- CLAUSE PUNCTUATION ---- */
.clause-punct {
    margin-left: 2px;
    margin-right: 4px;
    font-weight: bold;
}

/* ---- MARKIEREN MODE: Toolbar & Wörter ---- */
#markieren-toolbar {
    margin-bottom: 15px;
    text-align: center;
}

.toolbar-group {
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
}

.toolbar-label {
    width: 100%;
    text-align: center;
    font-size: 0.85em;
    color: #7f8c8d;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tool-btn {
    padding: 8px 12px;
    border: 2px solid transparent;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    color: white;
    font-size: 0.9em;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    opacity: 0.8;
    transition: all 0.2s;
}

.tool-btn:hover {
    opacity: 1;
    transform: translateY(-1px);
}

.tool-btn.active {
    opacity: 1;
    transform: scale(1.05);
    border-color: #333;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.b-eraser {
    background-color: #95a5a6;
    color: white;
    width: 100%;
    max-width: 200px;
    margin: 10px auto;
    display: block;
}

.markieren-word {
    font-size: 1.5em;
    padding: 6px 10px;
    margin: 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s;
    user-select: none;
    border: 1px solid transparent;
    display: inline-block;
}

.markieren-word:hover {
    border-color: #ccc;
}

.markieren-area {
    font-size: 1em;
    line-height: 2.2;
}

/* Solution List (Satzglieder-Stil) */
.solution-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.solution-item {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    font-size: 1.05em;
}

.solution-item:last-child {
    border-bottom: none;
}

.sol-arrow {
    color: #999;
    margin: 0 10px;
}

.sol-term {
    font-weight: bold;
}

.msg-warning {
    background: #fff3cd;
    color: #856404;
}

/* ---- LOADING STATE ---- */
.loading {
    text-align: center;
    padding: 60px;
    color: #999;
    font-size: 1.2em;
}

.loading::after {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    margin: 20px auto;
    border: 3px solid #eee;
    border-top-color: var(--secondary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- MOBILE ---- */
@media (max-width: 768px) {

    .rules-table,
    .rules-table tbody,
    .rules-table tr,
    .rules-table td {
        display: block;
        width: 100%;
    }

    .rules-table thead {
        display: none;
    }

    .rules-table tr {
        margin-bottom: 20px;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 10px;
        background: #fff;
    }

    .rules-table td {
        border: none;
        padding: 5px 0;
    }

    .rules-table td::before {
        content: attr(data-label);
        font-weight: bold;
        display: block;
        color: #888;
        font-size: 0.8em;
        margin-bottom: 2px;
    }

    .clause-block {
        display: block;
        margin-bottom: 15px;
        border-bottom: 1px dashed #eee;
        padding-bottom: 10px;
    }

    select.type-select {
        display: block;
        margin-top: 5px;
        width: 100%;
        max-width: none;
        margin-left: 0;
    }

    .sentence-area {
        font-size: 1.2em;
        padding: 30px 15px;
    }
}