@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

/* Reset & Base */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    overflow: hidden;
    font-family: 'VT323', monospace;
    background-color: #2e2e2e;
    color: #fff;
}

/* Layout Containers */
#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    z-index: 10;
    pointer-events: none;
}

header > * {
    pointer-events: auto;
}

/* Header Elements */
.title-group {
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    padding: 10px 30px;
    border-radius: 4px;
    border: 2px solid #1a1a1a;
}

#main-title {
    margin: 0;
    font-size: 2.5rem;
    text-shadow: 2px 2px 0 #000;
    color: #fff;
}

#sub-title {
    margin: 5px 0 0;
    font-size: 1.2rem;
    color: #ccc;
    text-shadow: 1px 1px 0 #000;
}

/* Navigation Buttons */
.back-home-btn {
    position: absolute;
    left: 20px;
    top: 20px;
    text-decoration: none;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 15px;
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    font-size: 1.2rem;
    box-shadow: 4px 4px 0 #000;
}

.back-home-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 #000;
    background: rgba(0, 0, 0, 0.7);
}

.lang-switcher {
    position: absolute;
    right: 20px;
    top: 20px;
    display: flex;
    gap: 10px;
}

/* Minecraft Button Style */
.btn, .lang-btn, .option-chip, .tab-btn {
    border: 2px solid #000;
    border-top-color: #fff;
    border-left-color: #fff;
    border-right-color: #555;
    border-bottom-color: #555;
    background-color: #8b8b8b;
    color: #fff;
    padding: 8px 16px;
    font-size: 1.2rem;
    cursor: pointer;
    font-family: 'VT323', monospace;
    text-shadow: 1px 1px 0 #000;
    box-shadow: 2px 2px 0 #000;
    transition: transform 0.1s;
}

.btn:hover, .lang-btn:hover, .option-chip:hover, .tab-btn:hover {
    background-color: #9b9b9b;
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 #000;
}

.btn:active, .lang-btn.active, .option-chip.selected, .tab-btn.active, .btn:active {
    background-color: #6b6b6b;
    border-top-color: #555;
    border-left-color: #555;
    border-right-color: #fff;
    border-bottom-color: #fff;
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 #000;
}

.lang-btn.active {
    background-color: #5b8c28;
}

/* Game Panel */
#game-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 800px;
    background-color: #c6c6c6;
    border: 2px solid #000;
    box-shadow: 
        inset 2px 2px 0 #fff,
        inset -2px -2px 0 #555,
        4px 4px 0 #000;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 5;
}

/* Score Board */
#score-board {
    display: flex;
    justify-content: space-between;
    background: #8b8b8b;
    border: 2px solid #555;
    border-bottom-color: #fff;
    border-right-color: #fff;
    padding: 8px 15px;
    margin-bottom: 15px;
    min-height: 30px;
}

.score-item {
    font-size: 1.2rem;
    display: flex;
    gap: 10px;
    align-items: center;
    color: #000;
    text-shadow: none;
}

.progress-container {
    width: 100px;
    height: 16px;
    background: #000;
    border: 1px solid #fff;
    position: relative;
}

#mastery-bar {
    height: 100%;
    background: #5b8c28;
    width: 0%;
    color: #fff;
    font-size: 0.8rem;
    line-height: 14px;
    text-align: center;
    overflow: hidden;
}

/* Question Area */
#question-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

#question-tags {
    display: flex;
    gap: 10px;
}

.tag-pill {
    background: #000;
    color: #ffaa00;
    padding: 2px 8px;
    font-size: 1rem;
    border: 1px solid #ffaa00;
}

/* Math Question Display */
#question-prompt {
    font-size: 2.5rem;
    text-align: center;
    color: #000;
    text-shadow: none;
    font-weight: bold;
    padding: 10px 20px;
    background: rgba(255,255,255,0.3);
    border-radius: 4px;
    min-width: 200px;
}

#question-equals {
    font-size: 2rem;
    color: #333;
    margin: 5px 0;
}

#question-blank {
    font-size: 2.5rem;
    color: #5b8c28;
    font-weight: bold;
    min-width: 100px;
    text-align: center;
    border-bottom: 4px solid #5b8c28;
    padding: 5px 20px;
    transition: all 0.3s;
}

#question-blank.correct {
    color: #5b8c28;
    border-color: #5b8c28;
    background: rgba(91, 140, 40, 0.2);
}

#question-blank.wrong {
    color: #db382c;
    border-color: #db382c;
    background: rgba(219, 56, 44, 0.2);
}

/* Options Grid */
#options-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 15px 0;
}

.option-chip {
    min-width: 80px;
    font-size: 1.4rem;
    padding: 10px 20px;
}

.option-chip.correct {
    background-color: #5b8c28 !important;
    animation: pulse 0.3s ease;
}

.option-chip.wrong {
    background-color: #db382c !important;
    opacity: 0.6;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
}

.btn.primary {
    background-color: #5b8c28;
    width: 120px;
}

.btn.primary:hover {
    background-color: #6aa830;
}

.btn.primary:disabled {
    background-color: #555;
    color: #888;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Explanation Area */
#explanation-area {
    display: none;
    background: #fff3cd;
    border: 2px solid #e0a800;
    color: #856404;
    padding: 10px;
    margin-top: 10px;
    font-size: 1.1rem;
    text-align: left;
    box-shadow: 4px 4px 0 rgba(0,0,0,0.2);
    width: 100%;
}

#explanation-area.visible {
    display: block;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Settings Panel */
#settings-panel {
    display: none;
    position: absolute;
    top: 70px;
    right: 20px;
    width: 250px;
    background-color: #c6c6c6;
    border: 2px solid #000;
    box-shadow: 
        inset 2px 2px 0 #fff,
        inset -2px -2px 0 #555,
        4px 4px 0 #000;
    padding: 15px;
    z-index: 20;
    font-size: 1.1rem;
    color: #000;
}

#settings-panel.active {
    display: block;
}

#settings-panel h3 {
    margin-top: 0;
    text-align: center;
    border-bottom: 2px solid #888;
    padding-bottom: 5px;
}

.setting-group {
    margin-bottom: 15px;
}

.setting-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.setting-options {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.checkbox-wrapper, .radio-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* Reward Layer */
#reward-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
}

#reward-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: pixelated;
    transition: filter 0.5s ease;
}

#reward-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
}

/* Reward Controls */
.reward-controls {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    border-top: 2px solid #888;
    padding-top: 10px;
}

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

.modal-content {
    background: #c6c6c6;
    border: 2px solid #000;
    box-shadow: 
        inset 2px 2px 0 #fff,
        inset -2px -2px 0 #555,
        6px 6px 0 #000;
    padding: 20px;
    max-width: 800px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    color: #000;
    position: relative;
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2rem;
    cursor: pointer;
    color: #333;
    line-height: 1;
}

.close-modal:hover {
    color: #db382c;
}

/* Formula Section */
.formula-section {
    margin-bottom: 20px;
}

.formula-section h4 {
    margin: 0 0 10px 0;
    color: #333;
    border-bottom: 2px solid #5b8c28;
    padding-bottom: 5px;
}

.formula-section table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 2px solid #000;
}

.formula-section th, .formula-section td {
    border: 1px solid #888;
    padding: 8px 12px;
    text-align: left;
    font-size: 1.1rem;
}

.formula-section em {
    color: #5b8c28;
    font-style: italic;
}

/* Utility */
.hidden {
    display: none !important;
}

/* FX */
#flash-overlay {
    pointer-events: none;
}

/* Mobile Adaptation */
.close-panel-btn {
    display: none;
    position: absolute;
    top: 5px;
    right: 5px;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #333;
}

@media (max-width: 600px) {
    header {
        padding: 5px;
    }
    
    #main-title {
        font-size: 1.8rem;
    }
    
    #sub-title {
        font-size: 0.9rem;
    }
    
    .back-home-btn .text {
        display: none;
    }
    
    #settings-panel {
        top: 50%;
        left: 50%;
        right: auto;
        bottom: auto;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: 320px;
    }

    #settings-panel.active {
        box-shadow: 
            inset 2px 2px 0 #fff,
            inset -2px -2px 0 #555,
            4px 4px 0 #000,
            0 0 0 100vw rgba(0,0,0,0.6);
    }
    
    #settings-panel .close-panel-btn {
        display: block;
    }
    
    #game-panel {
        width: 95%;
        padding: 10px;
    }
    
    #question-prompt {
        font-size: 1.8rem;
    }
    
    #question-blank {
        font-size: 1.8rem;
    }
    
    .option-chip {
        font-size: 1.2rem;
        padding: 8px 15px;
    }
}

/* Loading Screen */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    transition: opacity 0.5s ease-out;
    padding: 40px 0;
    box-sizing: border-box;
    font-family: 'VT323', monospace;
}

#loading-overlay::before {
    display: none;
}

#loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.mc-header {
    text-align: center;
    z-index: 1;
    margin-top: 40px;
}

.mc-logo {
    font-size: 4rem;
    margin: 0;
    color: #fff;
    text-shadow: 4px 4px 0 #3f3f3f;
    letter-spacing: 2px;
    line-height: 1;
}

.mc-subtitle {
    font-size: 1.5rem;
    color: #ddd;
    text-shadow: 2px 2px 0 #3f3f3f;
    margin-top: 5px;
    letter-spacing: 1px;
}

.loading-container {
    width: 60%;
    max-width: 600px;
    text-align: center;
    z-index: 1;
    margin-bottom: 40px;
}

.loading-text {
    font-size: 1.8rem;
    margin-bottom: 5px;
    text-shadow: 2px 2px 0 #000;
}

.loading-subtext {
    font-size: 1.2rem;
    color: #ccc;
    text-align: left;
    margin-bottom: 5px;
    text-shadow: 1px 1px 0 #000;
}

.loading-bar-bg {
    width: 100%;
    height: 20px;
    background: #555;
    border: 2px solid #888;
    box-shadow: inset 2px 2px 0 #333;
    position: relative;
}

#loading-bar {
    width: 0%;
    height: 100%;
    background: #5b8c28;
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.3), inset 0 -2px 0 rgba(0,0,0,0.3);
    transition: width 0.2s linear;
}

.mc-tip-box {
    width: 70%;
    max-width: 800px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #fff;
    padding: 15px 20px;
    text-align: center;
    z-index: 1;
    margin-bottom: 20px;
}

#mc-tip-text {
    margin: 0;
    font-size: 1.2rem;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
}

