/* DunceAI - Cross The Maze Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-orange: #FF6B35;
    --primary-yellow: #FFD23F;
    --primary-blue: #3D5A80;
    --primary-teal: #35A7A7;
    --success-green: #4CAF50;
    --error-red: #E74C3C;
    --maze-green: #33CC00;
    --maze-yellow: #FFFF00;
    --bg-cream: #FFF8E7;
    --text-dark: #2C3E50;
    --shadow: 0 4px 15px rgba(0,0,0,0.1);
}

body {
    font-family: 'Segoe UI', 'Comic Sans MS', Tahoma, sans-serif;
    background: linear-gradient(135deg, var(--bg-cream) 0%, #FFE4C4 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.game-container {
    background: white;
    border-radius: 24px;
    box-shadow: var(--shadow), 0 0 0 4px var(--primary-orange);
    max-width: 800px;
    width: 100%;
    padding: 24px;
    position: relative;
    overflow: hidden;
}

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

.logo {
    font-size: 1.5rem;
    font-weight: bold;
}

.logo-dunce {
    color: var(--primary-orange);
}

.logo-ai {
    color: var(--primary-blue);
}

.game-header h1 {
    color: var(--text-dark);
    font-size: 1.4rem;
}

/* Intro Screen */
.intro-screen {
    text-align: center;
    padding: 60px 20px;
}

.intro-content {
    max-width: 400px;
    margin: 0 auto;
}

.intro-car {
    animation: driveIn 1s ease-out;
}

.intro-car svg {
    width: 80px;
    height: 100px;
}

@keyframes driveIn {
    from { transform: translateX(-100px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.intro-content h2 {
    color: var(--primary-blue);
    font-size: 1.4rem;
    margin: 20px 0 30px;
    line-height: 1.5;
}

/* Buttons */
.btn {
    padding: 14px 32px;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-start {
    background: linear-gradient(135deg, var(--success-green) 0%, #45A049 100%);
    color: white;
    box-shadow: 0 4px 0 #2E7D32;
}

.btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #2E7D32;
}

.btn-next {
    background: linear-gradient(135deg, var(--primary-blue) 0%, #2C4A6E 100%);
    color: white;
    box-shadow: 0 4px 0 #1E3A5F;
}

.btn-next:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #1E3A5F;
}

/* Game Screen */
.game-screen {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Score Panel */
.score-panel {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 12px;
    background: linear-gradient(135deg, #E8F4FD 0%, #D0E8F8 100%);
    border-radius: 12px;
    align-items: center;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.score-label {
    font-size: 1rem;
    color: var(--text-dark);
}

.score-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-blue);
    min-width: 40px;
}

.score-perfect {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--success-green);
    animation: pulse 1s infinite;
}

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

/* Game Area */
.game-area {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 16px;
    align-items: start;
}

/* Controls Panel */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
}

.control-btn {
    width: 70px;
    height: 70px;
    border: 3px solid var(--primary-blue);
    border-radius: 12px;
    background: white;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    box-shadow: 0 3px 0 var(--primary-blue);
}

.control-btn:hover {
    background: #E8F4FD;
    transform: translateY(-2px);
    box-shadow: 0 5px 0 var(--primary-blue);
}

.control-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 var(--primary-blue);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: 0 3px 0 var(--primary-blue) !important;
}

.control-btn.go-btn {
    border-color: var(--success-green);
    box-shadow: 0 3px 0 var(--success-green);
}

.control-btn.go-btn:hover {
    background: #E8F5E9;
}

.control-icon {
    font-size: 24px;
    color: var(--primary-blue);
}

.go-btn .control-icon {
    color: var(--success-green);
}

.control-label {
    font-size: 11px;
    font-weight: bold;
    color: var(--text-dark);
    margin-top: 2px;
}

/* Maze Container */
.maze-container {
    position: relative;
    background: white;
    border: 3px solid #333;
    border-radius: 8px;
    padding: 10px;
    width: 310px;
    height: 290px;
}

.maze-grid {
    position: relative;
    width: 280px;
    height: 260px;
}

/* Maze walls */
.wall {
    position: absolute;
    background: var(--maze-green);
    border: 1px solid #2a9d00;
    border-radius: 3px;
    transition: opacity 0.3s ease;
}

.wall.horizontal {
    width: 56px;
    height: 8px;
}

.wall.vertical {
    width: 8px;
    height: 56px;
}

.wall.hidden {
    opacity: 0;
}

/* Grid nodes (corners) */
.node {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--maze-yellow);
    border: 2px solid #333;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

/* Car */
.car {
    position: absolute;
    width: 32px;
    height: 40px;
    transition: none;
    transform-origin: center center;
    z-index: 10;
    filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.4));
}

.car svg {
    width: 100%;
    height: 100%;
}

.car.animating {
    transition: left 0.4s ease-in-out, top 0.4s ease-in-out;
}

.car.turning {
    transition: transform 0.3s ease-in-out;
}

.car.bouncing {
    animation: bounce 0.4s ease-in-out;
}

@keyframes bounce {
    0%, 100% { transform: var(--car-transform); }
    25% { transform: var(--car-transform) translateX(8px); }
    50% { transform: var(--car-transform) translateX(-6px); }
    75% { transform: var(--car-transform) translateX(4px); }
}

.car.celebrating {
    animation: celebrate 0.8s ease-in-out;
}

@keyframes celebrate {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(90deg); }
    50% { transform: rotate(180deg); }
    75% { transform: rotate(270deg); }
    100% { transform: rotate(360deg); }
}

/* Exhaust / smoke effect */
.exhaust {
    position: absolute;
    width: 8px;
    height: 8px;
    background: rgba(150, 150, 150, 0.6);
    border-radius: 50%;
    animation: puff 0.3s ease-out forwards;
    pointer-events: none;
}

@keyframes puff {
    0% { transform: scale(0.5); opacity: 0.8; }
    100% { transform: scale(2); opacity: 0; }
}

/* Finish Line */
.finish-line {
    position: absolute;
    right: 5px;
    font-size: 36px;
    z-index: 5;
    animation: flag 1s ease-in-out infinite;
}

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

/* Dunce Panel */
.dunce-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: 150px;
}

.dunce-character {
    width: 80px;
    transition: transform 0.3s ease;
}

.dunce-svg {
    width: 100%;
    height: auto;
}

.dunce-character.excited {
    animation: dunce-bounce 0.4s ease;
}

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

.dunce-character.smirk {
    transform: rotate(-5deg);
}

.speech-bubble {
    background: white;
    border: 2px solid var(--primary-orange);
    border-radius: 12px;
    padding: 10px 12px;
    position: relative;
    box-shadow: var(--shadow);
    font-size: 0.85rem;
    text-align: center;
}

.speech-bubble::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: var(--primary-orange);
}

.speech-bubble::after {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: white;
}

.speech-bubble p {
    color: var(--text-dark);
    line-height: 1.3;
    margin: 0;
}

/* Win Overlay */
.win-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 24px;
    z-index: 100;
}

.win-overlay.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.win-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    border: 4px solid var(--primary-yellow);
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: popIn 0.4s ease;
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    70% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.win-car {
    animation: celebrate 1s ease-in-out infinite;
}

.win-car svg {
    width: 60px;
    height: 75px;
}

.win-content h2 {
    color: var(--primary-blue);
    margin: 16px 0 8px;
    font-size: 1.6rem;
}

.win-content p {
    color: var(--text-dark);
    margin-bottom: 24px;
    font-size: 1.1rem;
}

/* Responsive */
@media (max-width: 700px) {
    .game-container {
        padding: 16px;
    }

    .game-area {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .controls-panel {
        flex-direction: row;
        order: 2;
    }

    .maze-container {
        order: 1;
    }

    .dunce-panel {
        order: 3;
        flex-direction: row;
        max-width: none;
    }

    .dunce-character {
        width: 60px;
    }

    .control-btn {
        width: 60px;
        height: 60px;
    }
}
