/* Der Weg der Kartoffel - Stil im verspielten Bilderbuch- & Karopapier-Look */
:root {
    --bg-paper: #fcf9f2;
    --grid-line: rgba(70, 130, 180, 0.14);
    --primary-blue: #1b639b;
    --dark-blue: #0d3859;
    --accent-gold: #e5b358;
    --accent-red: #d9534f;
    --earth-brown: #795548;
    --soil-dark: #4e342e;
    --leaf-green: #4caf50;
    --card-bg: #ffffff;
    --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.08);
}

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

html, body {
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
}

body {
    background-color: var(--bg-paper);
    background-image: 
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 20px 20px;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    color: #2c3e50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 6px 12px;
}

/* Header & Top Bar - Kompakt & schick */
.game-header {
    width: 100%;
    max-width: 980px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    padding: 8px 18px;
    border-radius: 12px;
    border: 2px dashed #a0aec0;
    box-shadow: var(--shadow-soft);
    margin-bottom: 6px;
    flex-shrink: 0;
}

.game-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.game-title h1 {
    font-size: 1.25rem;
    color: var(--primary-blue);
    font-weight: 800;
    letter-spacing: -0.5px;
}

.game-title span.badge {
    background: #fef3c7;
    color: #92400e;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid #f59e0b;
}

.top-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-ctrl {
    background: #f1f5f9;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    color: #334155;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-ctrl:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
    transform: translateY(-1px);
}

.btn-ctrl:active {
    transform: translateY(1px);
}

/* Hauptspiel-Rahmen - Dynamisch an Bildschirmhöhe angepasst */
.game-container {
    width: 100%;
    max-width: 980px;
    height: calc(100vh - 78px);
    max-height: 640px;
    background: #ffffff;
    border-radius: 16px;
    border: 2.5px solid #1e293b;
    position: relative;
    overflow: hidden;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.1);
    display: flex;
    flex-direction: column;
    flex-shrink: 1;
}

/* Fortschrittsbalken oben */
.progress-container {
    background: #f8fafc;
    border-bottom: 2px dashed #cbd5e1;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}

.step-tracker {
    display: flex;
    align-items: center;
    gap: 6px;
}

.step-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    transition: all 0.2s;
}

.step-dot.active {
    background: var(--primary-blue);
    color: #ffffff;
    transform: scale(1.15);
    box-shadow: 0 0 8px rgba(27, 99, 155, 0.4);
}

.step-dot.done {
    background: #10b981;
    color: #ffffff;
}

/* Aktiver Spielbereich */
.game-stage {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Postkarten- / Sammelbild-Stil (wie die Schnipsel im Bild) */
.stamp-card {
    background: #ffffff;
    border: 2px dashed #94a3b8;
    padding: 16px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    display: inline-block;
}

/* Minigame-Standardbuttons */
.btn-primary {
    background: var(--primary-blue);
    color: white;
    font-size: 1rem;
    font-weight: 700;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(27, 99, 155, 0.3);
    transition: all 0.15s ease;
}

.btn-primary:hover {
    background: #154f7d;
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(27, 99, 155, 0.4);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-accent {
    background: #f59e0b;
    color: #78350f;
    font-size: 0.95rem;
    font-weight: 700;
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-accent:hover {
    background: #d97706;
    color: #fff;
}

/* Dialogboxen (z. B. Telefonat Minigame 1 & 5) */
.phone-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fdfbf7;
    padding: 24px;
}

.dialog-box {
    background: #ffffff;
    border: 2px solid #cbd5e1;
    border-radius: 16px;
    padding: 20px 28px;
    max-width: 620px;
    width: 100%;
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
    position: relative;
    margin-top: 15px;
}

.dialog-speaker {
    font-weight: 800;
    color: var(--primary-blue);
    font-size: 1.05rem;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dialog-text {
    font-size: 1.1rem;
    line-height: 1.5;
    color: #334155;
    margin-bottom: 20px;
}

.dialog-choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dialog-choice-btn {
    background: #f8fafc;
    border: 1.5px solid #cbd5e1;
    padding: 12px 18px;
    border-radius: 12px;
    text-align: left;
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.15s;
}

.dialog-choice-btn:hover {
    background: #e0f2fe;
    border-color: var(--primary-blue);
    color: var(--primary-blue);
    padding-left: 24px;
}

/* Info-Overlay (Schulwissen nach jedem Level) */
.overlay-modal {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 20px;
    animation: fadeIn 0.25s ease;
}

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

.fact-card {
    background: #ffffff;
    max-width: 580px;
    width: 100%;
    border-radius: 20px;
    padding: 30px;
    border: 3px solid #1e293b;
    box-shadow: 0 20px 40px rgba(0,0,0,0.25);
    text-align: center;
    position: relative;
}

.fact-card .badge-fact {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.fact-title {
    font-size: 1.4rem;
    color: #0f172a;
    font-weight: 800;
    margin-bottom: 12px;
}

.fact-content {
    font-size: 1.05rem;
    color: #475569;
    line-height: 1.6;
    margin-bottom: 24px;
    text-align: left;
    background: #f8fafc;
    padding: 16px;
    border-radius: 12px;
    border-left: 4px solid var(--primary-blue);
}

/* Kapitelmenü / Level Select */
.level-select-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 20px;
    overflow-y: auto;
    max-height: 480px;
}

.level-card {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.level-card:hover {
    border-color: var(--primary-blue);
    background: #f0f7ff;
    transform: translateY(-3px);
    box-shadow: 0 6px 14px rgba(0,0,0,0.06);
}

.level-num {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--primary-blue);
}

.level-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    margin-top: 4px;
}

/* Canvas Styling für Action-Levels (Traktor, LKW, Sortieren) - Immer verzerrungsfrei! */
canvas.game-canvas, #driveCanvas, #cityCanvas, #tractorCanvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 900 / 380;
    object-fit: contain;
    margin: auto;
}

#roadStage, #cityRoadStage, #tractorStage {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1e293b;
}

/* Feedback-Hinweis (z.B. Tastaturanweisung) */
.hint-pill {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.85);
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: 25px;
    pointer-events: none;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* W-A-S-D Tastenanzeige */
.key-badge {
    display: inline-block;
    background: #ffffff;
    color: #0f172a;
    font-family: monospace;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    border-bottom: 3px solid #94a3b8;
    margin: 0 2px;
}

/* Platsch-Animation (Fluss-Crash in Level 4) */
@keyframes splashShake {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    20% { transform: translate(-10px, 8px) rotate(-4deg); }
    40% { transform: translate(12px, -8px) rotate(4deg); }
    60% { transform: translate(-8px, 6px) rotate(-2deg); }
    80% { transform: translate(8px, -4px) rotate(2deg); }
}

.splash-active {
    animation: splashShake 0.6s ease;
}

/* Diplom / Urkunde */
.diploma-box {
    background: #fffdfa;
    border: 4px double #b45309;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    max-width: 840px;
    margin: auto;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.diploma-title {
    font-family: Georgia, serif;
    font-size: 1.8rem;
    color: #78350f;
    margin-bottom: 4px;
}

.diploma-sub {
    font-size: 0.95rem;
    color: #92400e;
    margin-bottom: 12px;
}

/* Vollbild-Modus Anpassung */
:fullscreen body {
    padding: 10px 20px;
}

:fullscreen .game-container {
    height: calc(100vh - 80px);
    max-height: none;
    max-width: 1400px;
}

/* 🖨️ Druck-Optimierung: A4 Hochkant für das Kartoffel-Diplom */
@media print {
    @page {
        size: A4 portrait;
        margin: 1.5cm;
    }

    html, body {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        background: #ffffff !important;
        background-image: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Alle Spiel-Bedienelemente ausblenden */
    .game-header,
    .progress-container,
    .top-controls,
    .overlay-modal,
    .hint-pill,
    button,
    .btn-ctrl,
    .btn-primary,
    #levelSelectModal,
    #factModal {
        display: none !important;
    }

    .game-container {
        border: none !important;
        box-shadow: none !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .game-stage {
        overflow: visible !important;
        padding: 0 !important;
        height: auto !important;
        display: block !important;
    }

    /* Das Diplom füllt das A4-Blatt schön und würdevoll aus */
    .diploma-box {
        display: block !important;
        background: #ffffff !important;
        border: 4px double #b45309 !important;
        padding: 40px 30px !important;
        max-width: 100% !important;
        width: 100% !important;
        box-shadow: none !important;
        box-sizing: border-box !important;
        page-break-inside: avoid !important;
        margin: 20px auto !important;
    }

    .diploma-title {
        font-size: 2.2rem !important;
        color: #78350f !important;
    }

    .diploma-sub {
        font-size: 1.1rem !important;
        color: #92400e !important;
    }
}
