body {
    margin: 0;
    padding: 0;
    display: flex;
    height: 100vh;
    overflow: hidden;
    font-family: Arial, sans-serif;
}

.quiz-section {
    width: 50%;
    height: 100%;
    overflow-y: auto;
    background-color: #f0f0f0;
    padding: 20px;
    box-sizing: border-box;
}

.surface-section {
    width: 50%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #333;
    position: relative;
}

.quiz-container {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 100%;
    margin-bottom: 20px;
}

.question-container {
    margin-bottom: 20px;
}

.question-text {
    font-size: 1.5em;
    margin-bottom: 15px;
    text-align: center;
    word-break: break-word;
}

.question-image {
    max-width: 100%;
    max-height: 300px;
    margin: 15px auto;
    display: block;
    cursor: pointer;
    transition: transform 0.3s;
    border-radius: 4px;
}

.answers-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}

.answer-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    font-size: 1em;
    padding: 15px;
    margin: 0;
    background-color: #007BFF;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    box-sizing: border-box;
    transition: background-color 0.3s;
}

.answer-button.text-only {
    height: auto;
    min-height: 60px;
    justify-content: center;
}

.answer-button:hover {
    background-color: #0056b3;
}

.answer-image-container {
    width: 100%;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    overflow: hidden;
}

.answer-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: pointer;
    transition: transform 0.3s;
    border-radius: 4px;
}

.answer-text {
    width: 100%;
    text-align: center;
    word-break: break-word;
}

.correct {
    background-color: #28a745 !important;
}

.incorrect {
    background-color: #dc3545 !important;
}

#next-question {
    display: none;
    margin-top: 20px;
    width: 100%;
    padding: 12px;
    font-size: 1.2em;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

#next-question:hover {
    background-color: #5a6268;
}

#explanation-button {
    display: none;
    margin-top: 20px;
    width: 100%;
    padding: 12px;
    font-size: 1.2em;
    background-color: #17a2b8;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

#explanation-button:hover {
    background-color: #138496;
}

.score {
    margin-top: 20px;
    font-size: 1.2em;
    text-align: center;
}

.consecutive-failures {
    margin-top: 10px;
    color: #dc3545;
    font-weight: bold;
    text-align: center;
}

.drag-drop-wrapper {
    margin-bottom: 20px;
}

.drag-drop-container {
    display: flex;
    gap: 20px;
    width: 100%;
    margin: 20px 0;
}

.drag-column {
    flex: 1;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 8px;
    min-height: 200px;
}

.drag-column h3 {
    margin-top: 0;
    color: #333;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
    text-align: center;
}

.drag-item {
    padding: 12px;
    margin: 10px 0;
    background: #fff;
    border: 2px dashed #007BFF;
    cursor: move;
    border-radius: 5px;
    transition: all 0.3s;
    text-align: center;
}

.drag-item img {
    max-width: 100%;
    max-height: 150px;
    display: block;
    margin: 0 auto 10px;
}

.drop-target {
    padding: 12px;
    margin: 10px 0;
    min-height: 50px;
    background: #f9f9f9;
    border: 2px dashed #007BFF;
    border-radius: 5px;
    transition: all 0.3s;
}

.drag-item.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

.drop-target.highlight {
    background: #e1f5fe;
    border-color: #4CAF50;
}

.paired-item {
    min-height: 20px;
    margin-top: 8px;
    padding: 8px;
    background: #e8f5e9;
    border-radius: 4px;
    border: 1px solid #a5d6a7;
    text-align: center;
}

.target-label {
    text-align: center;
    font-weight: bold;
    margin-bottom: 5px;
}

#validate-pairs {
    display: block;
    margin: 20px auto 0;
    padding: 10px 20px;
    background: #007BFF;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.3s;
}

#validate-pairs:hover {
    background: #0056b3;
}

#validate-pairs:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

.image-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.enlarged-image {
    max-width: 90%;
    max-height: 90%;
    cursor: zoom-out;
}

.image-caption {
    position: absolute;
    bottom: 30px;
    left: 0;
    width: 100%;
    text-align: center;
    color: white;
    font-size: 1.2em;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.7);
}

.explanation-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1001;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.explanation-content {
    background-color: white;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    position: relative;
    transform: scale(0.8);
    transition: transform 0.3s ease-out;
}

.explanation-overlay.active {
    opacity: 1;
}

.explanation-overlay.active .explanation-content {
    transform: scale(1);
}

.close-explanation {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #777;
    transition: color 0.2s;
}

.close-explanation:hover {
    color: #333;
}

.explanation-title {
    font-size: 1.5em;
    margin-bottom: 20px;
    color: #007BFF;
    text-align: center;
}

.explanation-text {
    font-size: 1.1em;
    line-height: 1.6;
    color: #333;
}

.animation-mode-selector {
    position: fixed;
    bottom: 10px;
    left: 10px;
    z-index: 100;
    background-color: rgba(240, 240, 240, 0.7);
    border-radius: 4px;
    padding: 5px;
    font-size: 12px;
    border: 1px solid #ccc;
}

.animation-mode-selector select {
    font-size: 12px;
    padding: 3px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background-color: white;
}

.animation-mode-selector label {
    margin-right: 5px;
    color: #555;
}

.animation-full {
    width: 50%;
    height: 100%;
}

.animation-none {
    display: none;
}

.animation-small {
    position: fixed;
    bottom: 40px;
    right: 20px;
    width: 300px;
    height: 300px;
    z-index: 99;
    border: 2px solid #555;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
}

.animation-small canvas {
    width: 100%;
    height: 100%;
}

.iframe-container {
    width: 100%;
    height: 500px;
    border: none;
    margin-top: 20px;
}

.chessboard {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 400px;
    height: 400px;
    margin: 20px auto;
    border: 2px solid #333;
}

.chess-square {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
}

.chess-square.white {
    background-color: #f0d9b5;
}

.chess-square.black {
    background-color: #b58863;
}

.chess-square.highlight {
    background-color: rgba(255, 255, 0, 0.5);
}

.chess-piece {
    font-size: 35px;
}

.rat-dance-gif {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

@media (max-width: 768px) {
    body {
        flex-direction: column;
        height: auto;
        overflow-y: auto;
    }

    .quiz-section {
        width: 100%;
        height: auto;
        overflow-y: visible;
        padding: 15px;
    }

    .surface-section {
        width: 100%;
        height: 300px;
        order: -1;
    }

    .animation-small ~ .quiz-section {
        width: 100%;
    }

    .quiz-container {
        padding: 15px;
        margin-bottom: 15px;
    }

    .question-text {
        font-size: 1.2em;
    }

    .answers-container {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .drag-drop-container {
        flex-direction: column;
    }

    .answer-image-container {
        height: 120px;
    }

    .explanation-content {
        width: 95%;
        padding: 15px;
    }

    .animation-mode-selector {
        bottom: 5px;
        left: 5px;
        font-size: 10px;
        background-color: rgba(240, 240, 240, 0.9);
    }

    .animation-mode-selector select {
        font-size: 10px;
        padding: 2px;
    }

    .animation-small {
        width: 200px;
        height: 200px;
        bottom: 20px;
        right: 10px;
        position: fixed;
    }

    .animation-small ~ .quiz-section {
        padding-right: 220px;
    }

    .iframe-container {
        height: 400px;
    }
    
    .chessboard {
        width: 300px;
        height: 300px;
    }
    
    .chess-square {
        width: 37.5px;
        height: 37.5px;
    }
    
    .chess-piece {
        font-size: 25px;
    }
}