/**
 * Addition Adventure Game Styles
 * Follows multiplication game structure + number line visuals
 */

/* ============================================
   Game Container
   ============================================ */

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* ============================================
   Screen Visibility
   ============================================ */

.screen {
    display: none;
    max-width: 800px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Level Selection Screen
   ============================================ */

.game-title {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 6vw, 3.5rem);
    text-align: center;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.game-subtitle {
    text-align: center;
    font-size: 1.25rem;
    color: var(--primary-dark);
    margin-bottom: 2rem;
    font-weight: 700;
}

.levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 1.5rem;
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.level-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    width: 100%;
    aspect-ratio: 1;
    background: var(--white);
    border: 4px solid var(--primary-light);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.level-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
}

.level-card:hover::before {
    opacity: 0.1;
}

.level-card:hover {
    transform: translateY(-8px) scale(1.05);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.level-card:active {
    transform: translateY(-2px) scale(0.98);
}

.level-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    z-index: 1;
    animation: wiggle 3s ease-in-out infinite;
}

@keyframes wiggle {

    0%,
    100% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(-5deg);
    }

    75% {
        transform: rotate(5deg);
    }
}

.level-name {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    color: var(--primary-dark);
    z-index: 1;
}

.level-range {
    font-size: 0.95rem;
    color: var(--gray-200);
    font-weight: 600;
    z-index: 1;
}

/* ============================================
   Question Screen
   ============================================ */

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 700;
}

.current-level {
    background: var(--gradient-primary);
    color: var(--white);
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-full);
    font-size: 1.1rem;
}

.question-counter {
    color: var(--primary);
}

/* Progress */
.progress-container {
    margin-bottom: 2rem;
}

/* Question Area */
.question-area {
    text-align: center;
    padding: 2rem;
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
}

.question-text {
    font-family: var(--font-heading);
    font-size: clamp(2.5rem, 10vw, 4rem);
    color: var(--gray-800);
    margin-bottom: 1.5rem;
}

/* ============================================
   Number Line
   ============================================ */

.number-line-container {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f5f3ff 0%, #fdf2f8 50%, #fffbeb 100%);
    border-radius: var(--radius-lg);
    border: 2px solid rgba(139, 92, 246, 0.15);
}

.number-line-label {
    font-family: var(--font-heading);
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 0.75rem;
    text-align: center;
}

.number-line-svg-wrapper {
    width: 100%;
    overflow: hidden;
    margin-bottom: 1rem;
}

#numberLine {
    width: 100%;
    height: auto;
    display: block;
}

/* SVG animation for jump arcs */
.jump-arc-path {
    animation: arcDraw 0.4s ease-out forwards;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
}

@keyframes arcDraw {
    to {
        stroke-dashoffset: 0;
    }
}

.jump-label {
    animation: labelPop 0.3s ease-out 0.2s forwards;
    opacity: 0;
}

@keyframes labelPop {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Pulsing current position indicator */
.current-pulse {
    animation: pulseGlow 1.2s ease-in-out infinite;
}

@keyframes pulseGlow {

    0%,
    100% {
        r: 10;
        opacity: 0.3;
    }

    50% {
        r: 16;
        opacity: 0.15;
    }
}

/* Target hit glow */
.target-hit-glow {
    animation: targetHit 0.6s ease-out;
}

@keyframes targetHit {
    0% {
        r: 8;
        opacity: 0.8;
    }

    100% {
        r: 24;
        opacity: 0;
    }
}

/* ============================================
   Jump Controls
   ============================================ */

.jump-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.jump-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.jump-btn {
    background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0.6rem 1.2rem;
    font-family: var(--font-heading);
    font-size: 1.15rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 3px 10px rgba(139, 92, 246, 0.3);
}

.jump-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 5px 15px rgba(139, 92, 246, 0.4);
}

.jump-btn:active {
    transform: translateY(0) scale(0.98);
}

.jump-actions {
    display: flex;
    gap: 0.5rem;
}

.jump-action-btn {
    background: var(--white);
    color: var(--primary);
    border: 2px solid var(--primary-light);
    border-radius: 10px;
    padding: 0.5rem 1rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.jump-action-btn:hover {
    background: var(--primary-light);
    color: white;
    transform: translateY(-1px);
}

.position-display {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    padding: 0.4rem 1rem;
    border-radius: var(--radius-full);
    font-weight: 800;
    font-size: 1rem;
    color: var(--primary-dark);
    border: 2px solid var(--primary-light);
}

.position-value {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: var(--primary);
}

/* ============================================
   Answer Section
   ============================================ */

.answer-section {
    margin-top: 1.5rem;
}

.answer-label {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    color: var(--primary-dark);
    margin-bottom: 0.75rem;
}

.answer-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.submit-btn {
    font-size: 1.5rem;
    padding: 1rem 3rem;
}

/* Feedback */
.feedback {
    min-height: 3rem;
    font-size: 1.5rem;
    font-weight: 800;
    margin-top: 1.5rem;
    transition: all 0.3s ease;
}

.feedback.correct {
    color: var(--success);
}

.feedback.incorrect {
    color: var(--error);
}

/* ============================================
   Mascot
   ============================================ */

.mascot {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    font-size: 4rem;
    animation: bounce 2s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
    transition: transform 0.3s ease;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.mascot.happy {
    animation: celebrate 0.5s ease-in-out;
}

.mascot.sad {
    animation: shake 0.5s ease-in-out;
}

/* ============================================
   Results Screen
   ============================================ */

.results-header {
    text-align: center;
    margin-bottom: 2rem;
}

.results-title {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 6vw, 3rem);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
}

.score-display {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.score-number {
    font-family: var(--font-heading);
    font-size: 5rem;
    color: var(--success);
}

.score-divider {
    font-family: var(--font-heading);
    font-size: 3rem;
    color: var(--gray-200);
}

.score-total {
    font-family: var(--font-heading);
    font-size: 3rem;
    color: var(--gray-800);
}

.score-message {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

/* Star Rating */
.star-rating {
    font-size: 3rem;
    margin: 1rem 0;
}

/* Results List */
.results-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.result-item.correct {
    border-left: 4px solid var(--success);
}

.result-item.incorrect {
    border-left: 4px solid var(--error);
}

.result-icon {
    font-size: 1.25rem;
}

.result-question {
    flex: 1;
    font-weight: 700;
}

.result-answer {
    font-weight: 800;
}

.result-answer.wrong {
    color: var(--error);
    text-decoration: line-through;
}

.result-correct {
    color: var(--success);
    font-weight: 800;
}

/* Results Actions */
.results-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 600px) {
    .game-container {
        padding: 1rem;
    }

    .levels-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.75rem;
    }

    .level-card {
        padding: 0.75rem;
    }

    .level-icon {
        font-size: 2.25rem;
    }

    .level-name {
        font-size: 1.25rem;
    }

    .question-area {
        padding: 1rem;
    }

    .question-text {
        font-size: clamp(2rem, 8vw, 3rem);
    }

    .number-line-container {
        padding: 0.75rem;
    }

    .jump-btn {
        padding: 0.5rem 0.9rem;
        font-size: 1rem;
    }

    .mascot {
        font-size: 3rem;
        bottom: 1rem;
        right: 1rem;
    }

    .results-actions {
        flex-direction: column;
    }

    .results-actions .btn {
        width: 100%;
    }
}