@font-face {
    font-family: 'dchbasisschriftregular';
    src: url('dch-basisschrift-webfont.woff2') format('woff2'),
         url('dch-basisschrift-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;

}

/* Reset and base styles */
* {
    font-family: 'dchbasisschriftregular', 'Arial', sans-serif;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
}

/* Screen management */
.screen {
    display: none;
    width: 100%;
    max-width: 1200px;
    padding: 20px;
}

.screen.active {
    display: block;
}

/* Exercise selection screen */
#exercise-selection {
    text-align: center;
}

#exercise-selection h1 {
    color: white;
    font-size: 2.5em;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.exercise-container {
    display: flex;
    gap: 40px;
    justify-content: center;
    align-items: flex-start;
}

.exercise-column {
    flex: 1;
    max-width: 400px;
}

.exercise-column h2 {
    color: white;
    font-size: 1.8em;
    margin-bottom: 20px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.exercise-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Exercise buttons */
.exercise-btn {
    background: white;
    border: 3px solid #ddd;
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    min-height: 80px;
}

.exercise-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
    border-color: #667eea;
}

.exercise-btn span {
    font-size: 1.5em;
    font-weight: bold;
    color: #333;
    min-width: 30px;
}

.exercise-preview {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
}

/* Preview styles for different exercise types */
.grid-preview {
    width: 60px;
    height: 40px;
    background: #f0f0f0;
    border: 2px solid #ccc;
    position: relative;
}

.grid-preview::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    background: 
        linear-gradient(90deg, #ccc 1px, transparent 1px),
        linear-gradient(180deg, #ccc 1px, transparent 1px);
    background-size: 10px 10px;
}

.number-preview {
    background: #ffb3ba;
    padding: 10px 15px;
    border-radius: 8px;
    font-weight: bold;
    color: #333;
}

.question-preview {
    background: #ffb3ba;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 1.8em;
    font-weight: bold;
    color: #333;
}

.word-preview {
    background: #bae1ff;
    padding: 10px 15px;
    border-radius: 8px;
    font-weight: bold;
    color: #333;
}

.question-grid {
    background: #ffb3ba;
    padding: 10px 15px;
    border-radius: 8px;
    font-weight: bold;
    color: #333;
}

.equation-preview {
    background: #baffc9;
    padding: 10px 15px;
    border-radius: 8px;
    font-weight: bold;
    color: #333;
    font-size: 0.9em;
}

.number-highlight {
    background: #87ceeb;
    padding: 10px 15px;
    border-radius: 8px;
    font-weight: bold;
    color: #333;
    font-size: 1.3em;
}

.speech-bubble {
    background: #98fb98;
    padding: 10px 15px;
    border-radius: 12px;
    font-weight: bold;
    color: #333;
    position: relative;
    font-size: 0.9em;
    line-height: 1.3;
}

.speech-bubble::before {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid #98fb98;
}

.ear-preview {
    background: #ff9800;
    padding: 10px 15px;
    border-radius: 50%;
    font-size: 1.8em;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    box-shadow: 0 4px 8px rgba(255, 152, 0, 0.3);
}

/* Exercise screens */
.exercise-screen {
    background: transparent;
    border-radius: 0;
    padding: 30px;
    box-shadow: none;
    min-height: 80vh;
}

.exercise-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid rgba(255,255,255,0.3);
    justify-content: space-between;
}

.exercise-counter {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 1.1em;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-left: auto;
}

.counter-first {
    color: #4caf50;
}

.counter-total {
    color: #666;
}

.back-btn {
    background: #465eca;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 2em;
    font-weight: bold;
    transition: background 0.3s ease;
}

.back-btn:hover {
    background: #5a6fd8;
}

.exercise-header h2 {
    color: white;
    font-size: 1.8em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.exercise-content {
    font-size: 1.2em;
    line-height: 1.6;
    color: #666;
}

/* Responsive design */
@media (max-width: 768px) {
    .exercise-container {
        flex-direction: column;
        gap: 30px;
    }
    
    .exercise-column {
        max-width: 100%;
    }
    
    #exercise-selection h1 {
        font-size: 2em;
    }
    
    .exercise-btn {
        padding: 15px;
        min-height: 70px;
    }
    
    .screen {
        padding: 15px;
    }
    
    .exercise-screen {
        padding: 20px;
        min-height: 70vh;
    }
}

/* Exercise 1 specific styles */
.exercise-instruction {
    text-align: center;
    margin-bottom: 30px;
}

.exercise-instruction h3 {
    color: white;
    font-size: 1.4em;
    margin-bottom: 10px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.exercise-layout {
    display: flex;
    gap: 40px;
    align-items: flex-start;
    justify-content: center;
    margin-bottom: 30px;
}

.right-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 350px;
    min-width: 300px;
}

.dot-grid-container {
    text-align: center;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.dot-grid-container h4 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.dot-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr) 6px repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr) 6px repeat(5, 1fr);
    gap: 2px;
    width: 206px;
    height: 206px;
    background: #f0f0f0;
    border: 2px solid #ccc;
    padding: 5px;
    border-radius: 8px;
    margin: 0 auto;
}

.dot {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #ddd;
    transition: background 0.3s ease;
}

.dot.filled {
    background: #333;
}

/* Separator elements for cross pattern */
.dot.separator {
    background: transparent;
    border-radius: 0;
}

/* Unified grid styles for all exercises */
.number-grid-container {
    background: white;
    padding: clamp(10px, 3vw, 20px);
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    position: relative;
    width: 100%;
    max-width: 550px;
    margin: 0 auto;
}

.tens-toggle-btn {
    position: absolute;
    bottom: -45px;
    right: 0px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.9em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.tens-toggle-btn:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

.tens-toggle-btn.active {
    background: #4caf50;
}

.tens-toggle-btn.active:hover {
    background: #45a049;
}

.number-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 2px;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.number-cell {
    aspect-ratio: 1;
    border: 1px solid #666;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    font-weight: bold;
    color: transparent; /* Hide all numbers by default */
    width: 100%;
    height: auto;
    min-width: 0;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
}

.number-cell:hover {
    background: #f0f0f0;
}

.number-cell.correct {
    background: #4caf50;
    color: white;
    border-color: #2e7d32;
    animation: correctPulse 0.6s ease;
}

.number-cell.incorrect {
    background: #f44336;
    color: white;
    border-color: #c62828;
    animation: shake 0.5s ease;
}

.number-cell.editable {
    background: #e3f2fd;
    border-color: #007bff;
    color: #007bff;
}

.number-cell input {
    border: none;
    background: transparent;
    width: 100%;
    height: 100%;
    text-align: center;
    font-size: 0.9em;
    font-weight: bold;
    color: #007bff;
    outline: none;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    position: absolute;
    top: 0;
    left: 0;
}

/* Exercise 1 specific modifications */
.number-cell.exercise-1 {
    color: #333; /* Show numbers for exercise 1 */
}

.number-cell.exercise-1:hover {
    background: #bbdefb;
}

/* Exercise 2 specific modifications */
.number-cell.highlighted {
    background: #ffeb3b;
    border-color: #fbc02d;
    box-shadow: 0 0 10px rgba(255, 235, 59, 0.5);
    color: #333; /* Make highlighted number visible */
}

.number-cell.question {
    background: #ff9800;
    color: white; /* Make question mark visible */
    font-size: 1.4em;
    border-color: #f57c00;
    box-shadow: 0 0 10px rgba(255, 152, 0, 0.5);
}

.number-cell:not(.highlighted):not(.question):hover {
    background: #f0f0f0;
}

/* Exercise 5 specific modifications */
.number-cell.exercise-5 {
    font-size: 1em;
}

/* Show tens numbers when toggle is active */
.number-cell.show-tens {
    color: #888 !important;
    font-size: 0.8em;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.exercise-controls {
    text-align: center;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.next-btn {
    background: #4caf50;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2em;
    font-weight: bold;
    transition: background 0.3s ease;
}

.next-btn:hover {
    background: #45a049;
}

.feedback {
    font-size: 1.1em;
    font-weight: bold;
    min-height: 30px;
}

.feedback.correct {
    color: #4caf50;
}

.feedback.incorrect {
    color: #f44336;
}

/* Target display container - reusable for exercises that show a target */
.target-display-container,
.text-display-container {
    text-align: center;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.target-display-container h4,
.text-display-container h4 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.target-number {
    font-size: 3em;
    font-weight: bold;
    color: #667eea;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    padding: 20px;
    border-radius: 10px;
    border: 3px solid #667eea;
    margin: 10px 0;
}

.text-number {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    padding: 25px;
    border-radius: 15px;
    font-size: 2em;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 6px 15px rgba(0, 123, 255, 0.3);
    margin: 15px 0;
    text-transform: lowercase;
    border: 3px solid #0056b3;
    /* Dynamic font sizing for long words */
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

/* Responsive font sizes based on content length */
.text-number[data-length="short"] {
    font-size: 2em;
}

.text-number[data-length="medium"] {
    font-size: 1.6em;
}

.text-number[data-length="long"] {
    font-size: 1.3em;
}

.text-number[data-length="extra-long"] {
    font-size: 1.2em;
}

/* Remove old exercise-specific styles that are no longer needed */
.target-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 350px;
    min-width: 300px;
}

.target-number-container {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    text-align: center;
}

.target-number-container h4 {
    margin-bottom: 20px;
    font-size: 1.3em;
    color: #333;
}



@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Responsive adjustments for exercise layout */
@media (max-width: 768px) {
    .exercise-layout {
        flex-direction: column;
        gap: 20px;
        align-items: center;
    }
    
    .right-section {
        max-width: 100%;
        min-width: auto;
        width: 100%;
    }
    
    .dot-grid {
        width: 200px;
        height: 200px;
    }
    
    .ear-container {
        padding: 15px;
    }
    
    .ear-icon {
        font-size: 4em;
        padding: 15px;
    }
    
    .number-grid {
        max-width: 90vw;
        gap: 1px;
    }
    
    .number-grid-container {
        padding: clamp(8px, 2vw, 15px);
        max-width: 95vw;
    }
    
    .number-cell {
        font-size: clamp(0.6rem, 1.8vw, 0.8rem);
        border-width: 0.5px;
    }
    
    .target-section {
        max-width: 100%;
        min-width: auto;
        width: 100%;
    }
}

/* Ear exercise styles */

.ok-btn {
    padding: 15px 30px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.ok-btn:hover:not(:disabled) {
    background: #5a6fd8;
    transform: translateY(-2px);
}

.ok-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.play-btn {
    background: transparent;
    color: white;
    border: none;
    font-size: 3em;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.play-btn:hover {
    transform: scale(1.1);
}

/* Ear Exercise 1 Styles */
.ear-container {
    text-align: center;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.ear-container h4 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.ear-icon {
    font-size: 4em;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: inline-block;
    background: linear-gradient(135deg, #ff9800, #f57c00);
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    box-shadow: 0 8px 20px rgba(255, 152, 0, 0.4);
    border: 4px solid #fff;
    margin: 10px 0;
}

.ear-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 30px rgba(255, 152, 0, 0.6);
    background: linear-gradient(135deg, #ffb74d, #ff9800);
}

.ear-icon:active {
    transform: scale(0.95);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.8);
}

.ear-icon.played {
    background: linear-gradient(135deg, #4caf50, #388e3c);
    box-shadow: 0 8px 20px rgba(76, 175, 80, 0.4);
}

.ear-icon.played:hover {
    background: linear-gradient(135deg, #66bb6a, #4caf50);
    box-shadow: 0 12px 30px rgba(76, 175, 80, 0.6);
}

.ear-hint {
    color: #666;
    font-size: 0.9em;
    margin-top: 10px;
    font-style: italic;
}

.ear-hint.hidden {
    opacity: 0;
}

/* Exercise ear-1 specific modifications */
.number-cell.exercise-ear-1 {
    color: #333; /* Show numbers for ear exercise 1 */
}

.number-cell.exercise-ear-1:hover {
    background: #bbdefb;
}

.number-cell.exercise-ear-1.correct {
    background: #4caf50;
    color: white;
    border-color: #2e7d32;
    animation: correctPulse 0.6s ease;
}

.number-cell.exercise-ear-1.incorrect {
    background: #f44336;
    color: white;
    border-color: #c62828;
    animation: shake 0.5s ease;
}

/* Exercise ear-2 specific modifications */
.number-cell.exercise-ear-2 {
    color: transparent; /* Hide numbers for ear exercise 2 */
}

.number-cell.exercise-ear-2:hover {
    background: #bbdefb;
}

.number-cell.exercise-ear-2.correct {
    background: #4caf50;
    color: white;
    border-color: #2e7d32;
    animation: correctPulse 0.6s ease;
}

.number-cell.exercise-ear-2.incorrect {
    background: #f44336;
    color: white;
    border-color: #c62828;
    animation: shake 0.5s ease;
}

/* Exercise ear-3 specific modifications */
.number-cell.exercise-ear-3 {
    color: transparent; /* Hide numbers for ear exercise 3 */
}

.number-cell.exercise-ear-3:hover {
    background: #bbdefb;
}

.number-cell.exercise-ear-3.correct {
    background: #4caf50;
    color: white;
    border-color: #2e7d32;
    animation: correctPulse 0.6s ease;
}

.number-cell.exercise-ear-3.incorrect {
    background: #f44336;
    color: white;
    border-color: #c62828;
    animation: shake 0.5s ease;
}

/* Exercise ear-4 specific modifications */
.number-cell.exercise-ear-4 {
    color: transparent; /* Hide numbers for ear exercise 4 */
}

.number-cell.exercise-ear-4:hover {
    background: #bbdefb;
}

.number-cell.exercise-ear-4.correct {
    background: #4caf50;
    color: white;
    border-color: #2e7d32;
    animation: correctPulse 0.6s ease;
}

.number-cell.exercise-ear-4.incorrect {
    background: #f44336;
    color: white;
    border-color: #c62828;
    animation: shake 0.5s ease;
}

/* Ear Exercise 2 layout and input styles */
.exercise-layout-ear-2 {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 40px;
    margin: 20px 0;
    justify-content: center;
}

.ear-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 350px;
    min-width: 300px;
}

.answer-section-ear-2 {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    text-align: center;
    max-width: 350px;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.answer-section-ear-2 h4 {
    margin-bottom: 0;
    font-size: 1.3em;
    color: #333;
}

.answer-input-ear-2 {
    width: 120px;
    padding: 12px 15px;
    font-size: 1.2em;
    border: 2px solid #ddd;
    border-radius: 8px;
    text-align: center;
    margin: 0 auto 15px auto;
    font-weight: bold;
    display: block;
}

.answer-input-ear-2:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 5px rgba(102, 126, 234, 0.3);
}

.answer-input-ear-2.correct {
    border-color: #4caf50;
    background: #e8f5e8;
}

.answer-input-ear-2.incorrect {
    border-color: #f44336;
    background: #ffebee;
    animation: shake 0.5s ease-in-out;
}

.check-btn-ear-2 {
    padding: 12px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s ease;
}

.check-btn-ear-2:hover {
    background: #5a6fd8;
}

/* Extra small devices (phones, less than 480px) */
@media (max-width: 480px) {
    .screen {
        padding: 10px;
    }
    
    .number-grid {
        max-width: 95vw;
        gap: 1px;
    }
    
    .number-grid-container {
        padding: 8px;
        max-width: 98vw;
    }
    
    .number-cell {
        font-size: clamp(0.5rem, 1.5vw, 0.7rem);
        border-width: 0.5px;
    }
    
    .exercise-instruction h3 {
        font-size: 1.1em;
        margin-bottom: 15px;
    }
    
    .exercise-header h2 {
        font-size: 1.3em;
    }
    
    .exercise-counter {
        font-size: 0.9em;
        padding: 6px 12px;
        margin-left: 10px;
    }
    
    .tens-toggle-btn {
        font-size: 0.8em;
        padding: 6px 10px;
        bottom: -40px;
    }
    
    .right-section {
        min-width: auto;
        width: 100%;
    }
}

.check-btn-ear-2:disabled {
    background: #ccc;
    cursor: not-allowed;
}
