/* Reset und Basis-Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 900px;
    width: 100%;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    animation: fadeInDown 0.8s ease;
}

header h1 {
    font-size: 3.5rem;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.2rem;
    color: #f0f0f0;
    font-weight: 300;
}

/* Game Wrapper */
.game-wrapper {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: fadeInUp 0.8s ease;
}

/* Info Panel */
.info-panel {
    display: flex;
    justify-content: space-around;
    margin-bottom: 25px;
    gap: 20px;
}

.score-box {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 15px 30px;
    border-radius: 15px;
    text-align: center;
    flex: 1;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: transform 0.3s ease;
}

.score-box:hover {
    transform: translateY(-5px);
}

.score-box .label {
    display: block;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    margin-bottom: 5px;
    font-weight: 500;
}

.score-box .score {
    display: block;
    color: #fff;
    font-size: 2rem;
    font-weight: bold;
}

/* Game Container */
.game-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 25px;
}

#gameCanvas {
    border: 4px solid #667eea;
    border-radius: 10px;
    background: #f8f9fa;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: block;
}

/* Overlays */
.game-over,
.start-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.98);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    min-width: 300px;
    display: none;
}

.game-over.active,
.start-screen.active {
    display: block;
    animation: popIn 0.4s ease;
}

.game-over h2,
.start-screen h2 {
    color: #667eea;
    font-size: 2rem;
    margin-bottom: 20px;
}

.game-over p,
.start-screen p {
    color: #555;
    font-size: 1.1rem;
    margin-bottom: 15px;
}

#finalScore {
    color: #764ba2;
    font-weight: bold;
    font-size: 1.5rem;
}

/* Buttons */
.btn-restart,
.btn-start {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.1rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    margin-top: 10px;
}

.btn-restart:hover,
.btn-start:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-restart:active,
.btn-start:active {
    transform: translateY(0);
}

/* Controls Info */
.controls-info {
    text-align: center;
}

.controls-info h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-width: 500px;
    margin: 0 auto;
}

.control-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.key {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 1.5rem;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

.control-item span:last-child {
    color: #555;
    font-size: 0.9rem;
}

/* Touch-Steuerung für Handy */
.touch-controls {
    display: none;
    margin: 16px auto 0;
    width: 220px;
    grid-template-columns: repeat(3, 64px);
    grid-template-rows: repeat(2, 64px);
    gap: 8px;
    justify-content: center;
    align-content: center;
}

.touch-btn {
    border: none;
    border-radius: 14px;
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 6px 14px rgba(102, 126, 234, 0.35);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.touch-btn:active {
    transform: scale(0.96);
}

.touch-btn.up { grid-column: 2; grid-row: 1; }
.touch-btn.left { grid-column: 1; grid-row: 2; }
.touch-btn.down { grid-column: 2; grid-row: 2; }
.touch-btn.right { grid-column: 3; grid-row: 2; }

/* Footer */
footer {
    text-align: center;
    margin-top: 25px;
    animation: fadeIn 1s ease;
}

footer p {
    color: #fff;
    font-size: 1.1rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Responsive Design + Mobile Optimierung */
@media (max-width: 768px) {
    header h1 {
        font-size: 2.5rem;
    }

    .game-wrapper {
        padding: 20px;
    }

    .info-panel {
        flex-direction: column;
    }

    .controls-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    #gameCanvas {
        max-width: 100%;
        height: auto;
        touch-action: none;
        display: block;
        margin: 0 auto;
    }

    .touch-controls {
        display: grid;
    }
}