/**
 * Fraction Builders - Construction Site Theme
 *
 * A busy construction site: caution-yellow signage, steel-gray girders,
 * hazard black-and-yellow stripes, brick-red walls, and blueprint blue.
 * Stack fraction "bricks" to add, subtract, decompose, and build mixed numbers.
 * Builds on top of kid-friendly-theme.css
 *
 * Color Palette:
 * - Caution Yellow: #F5B700 (signage, titles, accents, score)
 * - Steel Gray:     #4A4E54 (girders, borders, dark trim)
 * - Hazard Black:   #1C1C1C (hazard stripes, text on yellow)
 * - Brick Red:      #B5462E (filled fraction bricks, hard card, errors)
 * - Blueprint Blue: #1E5F8C (equation banner, secondary bricks, links)
 * - Concrete Gray:  #D8D6CF (empty bricks, card backgrounds)
 */

body {
    background:
        repeating-linear-gradient(135deg, rgba(28,28,28,0.04) 0 22px, rgba(245,183,0,0.05) 22px 44px),
        linear-gradient(135deg, #ECEAE3 0%, #D8D6CF 100%);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    font-family: 'Nunito', sans-serif;
}

.game-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.kid-game-card {
    background: linear-gradient(135deg, #FFFEFA 0%, #ECEAE3 100%);
    border: 5px solid #4A4E54;
    border-radius: 22px;
    padding: 40px;
    max-width: 820px;
    width: 100%;
    box-shadow: 0 8px 30px rgba(28, 28, 28, 0.25);
    position: relative;
    overflow: hidden;
}

/* Hazard stripe accent across the top of every card */
.kid-game-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 12px;
    background: repeating-linear-gradient(45deg, #F5B700 0 18px, #1C1C1C 18px 36px);
}

/* Mascot */
.builder-mascot {
    font-size: 5rem;
    text-align: center;
    margin: 10px 0 20px;
    animation: float 3s ease-in-out infinite;
}

.builder-mascot.excited {
    animation: bounce 0.6s ease-in-out 3;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

/* Titles */
.kid-friendly-title {
    color: #4A4E54;
    text-align: center;
    margin: 20px 0;
    text-shadow: 2px 2px 0 #F5B700;
}

.kid-friendly-body {
    color: #2C2C2C;
    text-align: center;
    font-size: 1.3rem;
    margin-bottom: 30px;
}

/* Difficulty Selection */
.difficulty-selection {
    margin: 40px 0;
}

.section-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: #4A4E54;
    text-align: center;
    margin-bottom: 25px;
}

.difficulty-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.kid-difficulty-card {
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid #4A4E54;
    border-radius: 18px;
    padding: 22px;
}

.kid-difficulty-card:hover {
    transform: translateY(-5px) scale(1.03);
    box-shadow: 0 8px 25px rgba(74, 78, 84, 0.4);
}

.kid-difficulty-card.easy {
    background: linear-gradient(135deg, #FDE08A 0%, #F5B700 100%);
    border-color: #C99400;
}

.kid-difficulty-card.medium {
    background: linear-gradient(135deg, #A8CCE6 0%, #6FA3CC 100%);
    border-color: #1E5F8C;
}

.kid-difficulty-card.hard {
    background: linear-gradient(135deg, #E08C77 0%, #B5462E 100%);
    border-color: #8A2F1C;
}

.difficulty-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: #1C1C1C;
    margin-bottom: 10px;
}

.difficulty-description {
    font-size: 1rem;
    color: #2C2C2C;
    margin-bottom: 8px;
}

.difficulty-example {
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    font-weight: 600;
    color: #1C1C1C;
    background: rgba(255, 255, 255, 0.6);
    padding: 6px 10px;
    border-radius: 8px;
    margin-top: 10px;
}

/* Practice Mode */
.practice-mode-section {
    margin: 30px 0;
}

.practice-mode-card {
    background: linear-gradient(135deg, #A8CCE6 0%, #6FA3CC 100%);
    border: 3px solid #1E5F8C;
    border-radius: 20px;
    padding: 25px;
    text-align: center;
}

.practice-mode-card h3 {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.6rem;
    color: #16456A;
    margin-bottom: 15px;
}

.practice-mode-card p {
    font-size: 1.2rem;
    color: #1C1C1C;
    margin-bottom: 20px;
}

/* Game Actions */
.game-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 30px;
}

/* Game Screen Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.question-counter {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: #4A4E54;
}

.score-display {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: #B5462E;
}

.btn-small {
    padding: 8px 16px;
    font-size: 1rem;
}

/* Progress Bar (caution-tape styling) */
.kid-progress-bar {
    background: rgba(74, 78, 84, 0.2);
    border: 2px solid #4A4E54;
    border-radius: 15px;
    height: 25px;
    margin-bottom: 30px;
    overflow: hidden;
}

.kid-progress-fill {
    background: repeating-linear-gradient(45deg, #F5B700 0 14px, #E0A400 14px 28px);
    height: 100%;
    transition: width 0.5s ease;
    border-radius: 13px;
}

/* Problem Display */
.problem-display {
    text-align: center;
    margin: 25px 0;
}

.question-text {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: #4A4E54;
    margin-bottom: 12px;
}

.question-note {
    font-family: 'Nunito', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: #16456A;
    background: rgba(30, 95, 140, 0.1);
    border-left: 5px solid #1E5F8C;
    border-radius: 8px;
    padding: 10px 16px;
    margin: 0 auto 22px;
    max-width: 560px;
}

/* Model container: equation banner + brick walls */
.model-container {
    background:
        repeating-linear-gradient(0deg, rgba(30,95,140,0.06) 0 1px, transparent 1px 28px),
        repeating-linear-gradient(90deg, rgba(30,95,140,0.06) 0 1px, transparent 1px 28px),
        linear-gradient(135deg, #F4FAFF 0%, #E4F0F8 100%);
    border: 3px dashed #1E5F8C;
    border-radius: 18px;
    padding: 24px 20px;
    margin: 0 auto;
    max-width: 620px;
}

.equation-banner {
    font-family: 'Fredoka', sans-serif;
    font-size: 2.6rem;
    font-weight: 700;
    color: #16456A;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 22px;
}

.equation-banner .op {
    color: #B5462E;
    font-size: 2.2rem;
    margin: 0 2px;
}

.equation-banner .mystery {
    color: #F5B700;
    background: #4A4E54;
    border-radius: 10px;
    padding: 0 16px;
}

/* Inline fraction display (num over den) */
.frac {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    line-height: 1;
    margin: 0 2px;
}

.frac-num,
.frac-den {
    display: block;
    padding: 0 6px;
    font-size: 0.62em;
    font-weight: 700;
}

.frac-bar {
    display: block;
    width: 100%;
    min-width: 22px;
    height: 3px;
    background: currentColor;
    margin: 1px 0;
}

/* Mixed number: whole number next to a fraction */
.mixed {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.mixed .whole {
    font-size: 1em;
    font-weight: 700;
}

.whole-only {
    font-weight: 700;
}

/* Brick walls */
.brick-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 0;
    flex-wrap: wrap;
}

.brick-label {
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: #4A4E54;
    min-width: 56px;
    text-align: right;
}

.brick-wall {
    display: flex;
    gap: 2px;
    flex: 1;
    flex-wrap: wrap;
}

.brick {
    flex: 1 1 18px;
    min-width: 14px;
    height: 30px;
    border: 2px solid #4A4E54;
    border-radius: 4px;
    box-sizing: border-box;
    position: relative;
}

.brick.empty {
    background: #D8D6CF;
    border-style: dashed;
}

.brick.filled.fill-1 {
    background: linear-gradient(135deg, #C9543B 0%, #B5462E 100%);
    border-color: #8A2F1C;
}

.brick.filled.fill-2 {
    background: linear-gradient(135deg, #3A86B8 0%, #1E5F8C 100%);
    border-color: #16456A;
}

/* Decompose: first chunk gets a yellow overlay accent */
.brick.split {
    background: linear-gradient(135deg, #F5B700 0%, #E0A400 100%);
    border-color: #C99400;
}

/* Subtraction: removed bricks crossed out */
.brick.removed {
    opacity: 0.55;
}

.brick.removed::after {
    content: "\00D7";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-weight: 700;
    font-size: 1rem;
}

/* Thicker divider where one whole ends and the next begins */
.brick.whole-edge {
    margin-right: 8px;
    box-shadow: 8px 0 0 -3px #1C1C1C;
}

/* Answer Choices */
.answer-choices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin: 30px 0;
}

.kid-answer-btn {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.7rem;
    font-weight: 600;
    color: #1C1C1C;
    background: linear-gradient(135deg, #FFFFFF 0%, #ECEAE3 100%);
    border: 3px solid #4A4E54;
    border-radius: 14px;
    padding: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 64px;
}

.kid-answer-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(245, 183, 0, 0.45);
    background: linear-gradient(135deg, #FDE08A 0%, #F5B700 100%);
}

.kid-answer-btn.correct {
    background: linear-gradient(135deg, #BFE3A8 0%, #8FCB6A 100%);
    border-color: #4F8C2F;
    color: #1C3A0E;
    animation: pulse 0.5s ease-in-out;
}

.kid-answer-btn.incorrect {
    background: linear-gradient(135deg, #E08C77 0%, #B5462E 100%);
    border-color: #8A2F1C;
    color: #FFFFFF;
    animation: shake 0.5s ease-in-out;
}

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

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

/* Feedback Area */
.feedback-area {
    margin-top: 30px;
    text-align: center;
}

.feedback-message {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.4rem;
    font-weight: 600;
    padding: 15px 25px;
    border-radius: 15px;
    display: inline-block;
}

.feedback-message.correct {
    background: linear-gradient(135deg, #BFE3A8 0%, #8FCB6A 100%);
    color: #1C3A0E;
    border: 3px solid #4F8C2F;
}

.feedback-message.incorrect {
    background: linear-gradient(135deg, #E08C77 0%, #B5462E 100%);
    color: #FFFFFF;
    border: 3px solid #8A2F1C;
}

/* Results Screen */
.kid-stars {
    font-size: 4rem;
    text-align: center;
    margin: 30px 0;
}

.results-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 25px;
    margin: 40px 0;
}

.result-stat {
    text-align: center;
    background: linear-gradient(135deg, #ECEAE3 0%, #FFFFFF 100%);
    border: 3px solid #4A4E54;
    border-radius: 20px;
    padding: 25px;
}

.stat-value {
    font-family: 'Fredoka', sans-serif;
    font-size: 3.4rem;
    font-weight: 700;
    color: #B5462E;
    margin-bottom: 10px;
}

.stat-label {
    font-family: 'Nunito', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    color: #4A4E54;
}

/* Missed Problems */
.missed-problems {
    background: linear-gradient(135deg, #FBF4DD 0%, #F6E9C0 100%);
    border: 3px solid #C99400;
    border-radius: 20px;
    padding: 30px;
    margin: 30px 0;
    box-shadow: 0 4px 15px rgba(201, 148, 0, 0.18);
}

.missed-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: #8A6400;
    text-align: center;
    margin-bottom: 25px;
}

.missed-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

.missed-item {
    background: #FFFFFF;
    border: 2px solid #1E5F8C;
    border-radius: 15px;
    padding: 20px;
    text-align: center;
}

.missed-question {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1C1C1C;
    margin-bottom: 15px;
}

.missed-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 1rem;
}

.your-answer {
    color: #B5462E;
    font-weight: 600;
}

.correct-answer {
    color: #4F8C2F;
    font-weight: 600;
}

/* Results Actions */
.results-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 30px;
}

/* Buttons */
.kid-btn {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    padding: 15px 35px;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.kid-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.kid-btn-primary {
    background: linear-gradient(135deg, #F5B700 0%, #E0A400 100%);
    color: #1C1C1C;
    border: 3px solid #C99400;
}

.kid-btn-secondary {
    background: linear-gradient(135deg, #D3D3D3 0%, #A9A9A9 100%);
    color: #2C2C2C;
    border: 3px solid #808080;
}

.kid-btn-accent {
    background: linear-gradient(135deg, #1E5F8C 0%, #2A77AD 100%);
    color: white;
    border: 3px solid #16456A;
}

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

/* Responsive */
@media (max-width: 768px) {
    .kid-game-card {
        padding: 25px;
    }

    .builder-mascot {
        font-size: 4rem;
    }

    .kid-friendly-title {
        font-size: 2rem;
    }

    .kid-friendly-body {
        font-size: 1.1rem;
    }

    .difficulty-options {
        grid-template-columns: 1fr;
    }

    .question-text {
        font-size: 1.5rem;
    }

    .equation-banner {
        font-size: 2.1rem;
    }

    .answer-choices {
        grid-template-columns: 1fr 1fr;
    }

    .results-summary {
        grid-template-columns: 1fr;
    }

    .stat-value {
        font-size: 2.5rem;
    }

    .missed-items-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .game-content {
        padding: 10px;
    }

    .kid-game-card {
        padding: 18px;
    }

    .builder-mascot {
        font-size: 3rem;
    }

    .equation-banner {
        font-size: 1.7rem;
    }

    .equation-banner .op {
        font-size: 1.5rem;
    }

    .brick {
        height: 24px;
    }

    .brick-label {
        font-size: 1rem;
        min-width: 44px;
    }

    .kid-answer-btn {
        font-size: 1.35rem;
        padding: 14px;
        min-height: 56px;
    }

    .kid-btn {
        font-size: 1rem;
        padding: 12px 22px;
    }
}
