/* ============================================================
   BRAILLE LERN-APP – Stylesheet
   ============================================================ */

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

body {
    font-family: 'Comic Sans MS', 'Arial Rounded MT Bold', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Scrollen überall erlauben */
.screen {
    touch-action: pan-y;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.container {
    touch-action: pan-y;
}

.main-container {
    touch-action: pan-y;
}

/* touch-action: none NUR auf dem interaktiven Dot-Grid */
.dot-grid.interactive {
    touch-action: none;
}

/* ===== SCREENS ===== */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* Übungsscreen scrollt als ganzes */
#exerciseScreen.active {
    min-height: 100vh;
    height: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ===== STARTBILDSCHIRM ===== */
.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding-bottom: 40px;
}

h1 {
    font-size: 3em;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    margin: 30px 0 10px;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 1.3em;
    color: #f0e6ff;
    margin-bottom: 30px;
}

h2 { font-size: 1.7em; color: #5a67d8; margin-bottom: 20px; }
h3 { font-size: 1.3em; color: #4a5568; margin-bottom: 12px; text-align: center; }

/* ===== EINSTELLUNGSBOX ===== */
.settings-box {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 540px;
    margin-bottom: 30px;
    text-align: center;
}

.setting-group { margin-bottom: 22px; }
.setting-group label { display: block; margin-bottom: 7px; font-weight: bold; color: #4a5568; }
.setting-group input[type="number"] {
    width: 100%;
    padding: 11px;
    font-size: 1.1em;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 10px;
    font-family: inherit;
}
.setting-group input[type="number"]:focus { outline: none; border-color: #667eea; }

.hint-text { font-size: 0.85em; color: #888; margin-top: 5px; }

.radio-group { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; text-align: left; }
.radio-label { display: flex; align-items: center; cursor: pointer; font-weight: normal; }
.radio-label input[type="radio"] { margin-right: 8px; width: 20px; height: 20px; cursor: pointer; }

/* ===== BUTTONS ===== */
.btn {
    padding: 14px 36px;
    font-size: 1.15em;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: inline-block;
}
.btn:active { transform: scale(0.95); }

.btn-primary { background: linear-gradient(135deg, #667eea, #764ba2); color: white; }
.btn-primary:hover { box-shadow: 0 6px 14px rgba(102,126,234,0.45); }

.btn-secondary { background: #e2e8f0; color: #4a5568; }
.btn-secondary:hover { background: #cbd5e0; }

.btn-success { background: linear-gradient(135deg, #48bb78, #38a169); color: white; }
.btn-success:hover { box-shadow: 0 6px 14px rgba(72,187,120,0.45); }

.btn-info { background: linear-gradient(135deg, #4299e1, #3182ce); color: white; }
.btn-info:hover { box-shadow: 0 6px 14px rgba(66,153,225,0.45); }

.btn-small { padding: 9px 18px; font-size: 0.9em; }
.btn-large { width: 100%; font-size: 1.25em; padding: 17px 20px; }

/* ===== REFERENZ-MODAL ===== */
.ref-modal {
    max-width: 720px;
    width: 95%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 30px 25px;
}
.ref-modal h2 { margin-bottom: 18px; }

.ref-modal-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

.ref-cell-lg {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 10px 6px;
    background: #f7fafc;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    transition: background 0.2s, border-color 0.2s;
}
.ref-cell-lg:hover { background: #ebf4ff; border-color: #667eea; }
.ref-cell-active {
    background: #ebf4ff !important;
    border-color: #667eea !important;
    box-shadow: 0 0 0 3px #667eea44;
}

.ref-braille-lg { display: flex; flex-direction: column; gap: 4px; }
.ref-dot-lg { width: 13px; height: 13px; border-radius: 50%; border: 2px solid #aaa; }
.ref-dot-lg.filled { background: #1a1a2e; border-color: #1a1a2e; }
.ref-dot-lg.empty  { background: white; }

.ref-letter-lg { font-size: 1em; font-weight: bold; color: #667eea; }

@media (max-width: 600px) {
    .ref-modal-grid { grid-template-columns: repeat(5, 1fr); gap: 7px; }
    .ref-dot-lg { width: 11px; height: 11px; }
}
@media (max-width: 420px) {
    .ref-modal-grid { grid-template-columns: repeat(4, 1fr); }
}
.reference-box {
    background: rgba(255,255,255,0.95);
    border-radius: 20px;
    padding: 25px;
    width: 100%;
    max-width: 760px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    text-align: center;
    margin-bottom: 30px;
}

.reference-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 8px;
    margin-top: 15px;
}

.ref-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 6px 4px;
    background: #f7fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    cursor: default;
    transition: background 0.2s;
}
.ref-cell:hover { background: #ebf4ff; border-color: #667eea; }

.ref-braille { display: flex; flex-direction: column; gap: 2px; }
.ref-braille-row { display: flex; gap: 2px; }
.ref-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1.5px solid #aaa;
}
.ref-dot.filled { background: #1a1a2e; border-color: #1a1a2e; }
.ref-dot.empty { background: white; }

.ref-letter { font-size: 0.85em; font-weight: bold; color: #667eea; }

@media (max-width: 600px) {
    .reference-grid { grid-template-columns: repeat(5, 1fr); }
    .ref-dot { width: 7px; height: 7px; }
}

/* ===== ÜBUNGSBILDSCHIRM ===== */
.header {
    background: white;
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    gap: 10px;
    flex-wrap: wrap;
}

.progress-info { font-size: 1.3em; font-weight: bold; color: #667eea; }

.task-type-label {
    font-size: 0.9em;
    font-weight: bold;
    padding: 6px 14px;
    border-radius: 20px;
    color: white;
}
.type-ltb { background: linear-gradient(135deg, #4299e1, #3182ce); }
.type-btl { background: linear-gradient(135deg, #ed8936, #dd6b20); }

/* ===== MAIN CONTAINER ===== */
.main-container {
    display: flex;
    gap: 16px;
    padding: 16px;
    height: auto;
    align-items: stretch;
}

.section {
    flex: 1;
    background: white;
    border-radius: 15px;
    padding: 18px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ===== VORLAGE ===== */
.template-section { min-width: 200px; max-width: 380px; justify-content: space-between; }

.template-area {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    border: 3px dashed #cbd5e0;
    border-radius: 12px;
    background: #f7fafc;
    margin-bottom: 12px;
}

/* Buchstabe groß anzeigen */
.template-letter {
    font-size: 7em;
    font-weight: bold;
    color: #2d3748;
    line-height: 1;
    text-shadow: 1px 1px 0 #667eea33;
}

.template-buttons {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 8px;
    flex-wrap: nowrap;
    width: 100%;
}

/* ===== BRAILLE DISPLAY (READ-ONLY) ===== */
.braille-display-large {
    display: flex;
    align-items: center;
    justify-content: center;
}

.braille-cell {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.braille-cell.braille-large .braille-dot { width: 60px; height: 60px; }
.braille-cell.braille-medium .braille-dot { width: 38px; height: 38px; }
.braille-cell.braille-small  .braille-dot { width: 22px; height: 22px; }

.braille-row { display: flex; gap: 8px; }

.braille-dot {
    border-radius: 50%;
    border: 3px solid #b0b8c1;
    transition: background 0.2s, transform 0.1s;
}
.braille-dot.filled {
    background: #1a1a2e;
    border-color: #1a1a2e;
    box-shadow: 0 3px 8px rgba(0,0,0,0.35);
}
.braille-dot.empty { background: #f0f4f8; }

/* ===== ANTWORTBEREICH ===== */
.answer-section { min-width: 240px; max-width: 420px; }

.answer-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px;
}

/* ===== INTERAKTIVES DOT-GRID ===== */
.dot-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(3, 1fr);
    gap: 16px;
    padding: 20px;
}

.dot-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid #b0c4de;
    background: #f0f4f8;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
    box-shadow: 0 3px 8px rgba(0,0,0,0.12);
}
.dot-circle:hover { border-color: #667eea; transform: scale(1.05); }
.dot-circle.active {
    background: #1a1a2e;
    border-color: #1a1a2e;
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
    transform: scale(1.02);
}
.dot-circle.hint-dot {
    background: #38a169;
    border-color: #276749;
    box-shadow: 0 4px 14px rgba(56,161,105,0.5);
}

.canvas-controls {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    justify-content: center;
}

/* ===== MULTIPLE-CHOICE ===== */
.choice-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
    padding: 10px;
}

.choice-btn {
    padding: 22px 10px;
    font-size: 2em;
    font-weight: bold;
    border: 3px solid #e2e8f0;
    border-radius: 16px;
    background: #f7fafc;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    color: #2d3748;
    box-shadow: 0 3px 8px rgba(0,0,0,0.08);
}
.choice-btn:hover { border-color: #667eea; background: #ebf4ff; transform: scale(1.04); }
.choice-btn.selected { border-color: #667eea; background: #ebf4ff; box-shadow: 0 0 0 3px #667eea55; }
.choice-btn.correct-choice { border-color: #38a169; background: #c6f6d5; color: #276749; }
.choice-btn.wrong-choice { border-color: #e53e3e; background: #fed7d7; color: #742a2a; }
.choice-btn:disabled { cursor: default; transform: none; }

/* ===== INFO-BEREICH ===== */
.info-section { min-width: 240px; max-width: 340px; justify-content: center; }

.info-box {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 18px;
    text-align: center;
    border-radius: 15px;
    transition: background 0.3s;
}
.info-box.success { background: linear-gradient(135deg, #c6f6d5, #9ae6b4); }
.info-box.warning { background: linear-gradient(135deg, #fef5e7, #fbd38d); }
.info-box.error   { background: linear-gradient(135deg, #fed7d7, #fc8181); }

.feedback-icon { font-size: 4em; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{transform:scale(1);} 50%{transform:scale(1.1);} }

.feedback-text { font-size: 1.15em; font-weight: bold; color: #2d3748; line-height: 1.5; }

/* Progress Bar */
.progress-container { width: 100%; }
.progress-label { font-size: 0.95em; font-weight: bold; color: #4a5568; margin-bottom: 6px; }
.progress-bar-wrapper { position: relative; width: 100%; margin-bottom: 6px; }
.progress-bar-bg {
    width: 100%;
    height: 36px;
    background: #e2e8f0;
    border-radius: 18px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #48bb78, #38a169);
    border-radius: 18px;
    transition: width 0.8s ease;
}
.progress-bar.low    { background: linear-gradient(90deg, #fc8181, #f56565); }
.progress-bar.medium { background: linear-gradient(90deg, #f6ad55, #ed8936); }
.progress-bar.high   { background: linear-gradient(90deg, #48bb78, #38a169); }

.progress-target {
    position: absolute; left: 70%; top: 0; width: 3px; height: 100%;
    background: #2d3748; z-index: 2;
}
.progress-target::before {
    content: '70%'; position: absolute; top: -22px; left: 50%;
    transform: translateX(-50%); font-size: 0.8em; font-weight: bold;
    color: #2d3748; white-space: nowrap;
}
.progress-target::after {
    content: '▼'; position: absolute; top: -7px; left: 50%;
    transform: translateX(-50%); font-size: 0.65em; color: #2d3748;
}
.progress-text { font-size: 1em; font-weight: bold; color: #4a5568; }

.button-area { width: 100%; display: flex; flex-direction: column; gap: 10px; }

/* ===== MODALS ===== */
.modal {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.55); align-items: center; justify-content: center; z-index: 1000;
}
.modal.active { display: flex; }

.modal-content {
    background: white; border-radius: 20px; padding: 40px;
    max-width: 480px; width: 90%; text-align: center;
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
.modal-content h2 { margin-bottom: 20px; color: #5a67d8; }
#resultText { font-size: 1.25em; margin: 15px 0; color: #4a5568; }
.modal-buttons { display: flex; gap: 15px; justify-content: center; margin-top: 25px; flex-wrap: wrap; }

/* Name-Modal */
.name-modal { position: relative; min-width: 280px; }
.close-modal {
    position: absolute; top: 10px; right: 10px;
    background: none; border: none; font-size: 1.8em; cursor: pointer;
    color: #666; width: 36px; height: 36px; padding: 0; line-height: 1;
}
.close-modal:hover { color: #333; }

.letter-name-display { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.letter-name-icon { font-size: 2.5em; }
.letter-name-text { font-size: 5em; font-weight: bold; color: #667eea; }
.letter-name-sub { font-size: 1em; color: #888; }
.braille-in-modal { margin: 8px 0; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
    .main-container { flex-direction: column; height: auto; }
    .section { max-width: 100% !important; }
    .dot-circle { width: 70px; height: 70px; }
    .template-letter { font-size: 5em; }
    .braille-cell.braille-large .braille-dot { width: 50px; height: 50px; }
}

@media (max-width: 768px) {
    h1 { font-size: 1.8em; margin: 16px 0 6px; }
    .subtitle { font-size: 1.1em; margin-bottom: 16px; }

    /* Startscreen kompakter */
    .container { padding: 12px; min-height: unset; padding-bottom: 24px; justify-content: flex-start; }
    .settings-box { padding: 18px 16px; border-radius: 14px; margin-bottom: 16px; margin-top: 12px; max-width: 100%; }
    .settings-box h2 { font-size: 1.3em; margin-bottom: 14px; }
    .setting-group { margin-bottom: 14px; }
    .setting-group label { font-size: 0.95em; margin-bottom: 5px; }
    .setting-group input[type="number"] { padding: 9px; font-size: 1em; margin-bottom: 6px; }
    .radio-group { gap: 7px; }
    .radio-label { font-size: 0.95em; }
    .hint-text { font-size: 0.8em; }
    .btn { padding: 11px 24px; font-size: 1.05em; }

    /* Referenztabelle auf Handy ausblenden */
    .reference-box { display: none; }

    /* Übungsscreen */
    .main-container { padding: 8px; gap: 8px; }
    .section { padding: 12px; }
    .section h3 { font-size: 1.1em; margin-bottom: 8px; }
    .dot-circle { width: 60px; height: 60px; }
    .dot-grid { gap: 10px; padding: 12px; }
    .template-letter { font-size: 4em; }
    .template-area { min-height: 140px; }
    .braille-cell.braille-large .braille-dot { width: 44px; height: 44px; }
    .braille-cell.braille-large .braille-row { gap: 6px; }
    .braille-cell.braille-large { gap: 6px; }
    .choice-btn { font-size: 1.5em; padding: 16px 8px; }
    .feedback-icon { font-size: 2.5em; }
    .btn-large { font-size: 1.05em; padding: 13px; }
    .canvas-controls { margin-top: 8px; gap: 8px; }
    .template-buttons { gap: 5px; }
    .template-buttons .btn { padding: 8px 10px; font-size: 0.82em; }
    .modal-buttons { flex-direction: column; }
    .modal-buttons .btn { width: 100%; }

    /* Info-Box minimaler */
    .info-box { gap: 12px; padding: 14px; }
}

@media (max-width: 480px) {
    .dot-circle { width: 52px; height: 52px; }
    .dot-grid { gap: 8px; padding: 10px; }
    .choice-btn { font-size: 1.25em; padding: 13px 5px; }
    .template-letter { font-size: 3em; }
    .template-area { min-height: 110px; }
    .braille-cell.braille-large .braille-dot { width: 38px; height: 38px; }
}

/* ===== FEEDBACK POPUP ===== */
.feedback-popup {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) scale(0.7);
    z-index: 2000;
    background: white;
    border-radius: 24px;
    padding: 18px 40px;
    text-align: center;
    box-shadow: 0 16px 50px rgba(0,0,0,0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    min-width: 120px;
}

.feedback-popup.feedback-popup-visible {
    opacity: 1;
    transform: translateX(-50%) scale(1);
    pointer-events: none;
}

.feedback-popup-icon {
    font-size: 4em;
    line-height: 1;
    margin-bottom: 8px;
}

.feedback-popup-text {
    font-size: 1.15em;
    font-weight: bold;
    color: #2d3748;
    font-family: 'Comic Sans MS', 'Arial Rounded MT Bold', sans-serif;
}

.feedback-popup-success { border: 4px solid #48bb78; background: #f0fff4; }
.feedback-popup-error   { border: 4px solid #fc8181; background: #fff5f5; }
.feedback-popup-warning { border: 4px solid #f6ad55; background: #fffaf0; }

/* ===== START BUTTONS ===== */
.start-buttons {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
}
