:root {
    --bg-color: #f0f9ff;
    --sidebar-bg: #ffffff;
    --text-color: #334155;
    --primary-color: #3b82f6;
    --secondary-color: #64748b;
    --accent-color: #f59e0b;
    --wall-color: #1e293b;
    --solution-color: rgba(245, 158, 11, 0.5);
    --font-heading: 'Verdana', 'Segoe UI', 'Arial', sans-serif;
    --font-body: 'Helvetica Neue', 'Arial', sans-serif;
}

/* Theme: Forest */
[data-theme="forest"] {
    --bg-color: #ecfccb;
    --sidebar-bg: #f7fee7;
    --text-color: #365314;
    --primary-color: #65a30d;
    --secondary-color: #a16207;
    --wall-color: #14532d;
    --solution-color: rgba(234, 179, 8, 0.6);
}

/* Theme: Medieval */
[data-theme="medieval"] {
    --bg-color: #f5f5f4;
    --sidebar-bg: #e7e5e4;
    --text-color: #44403c;
    --primary-color: #dc2626;
    --secondary-color: #57534e;
    --wall-color: #292524;
    --solution-color: rgba(220, 38, 38, 0.4);
}

/* Theme: Ocean */
[data-theme="ocean"] {
    --bg-color: #ecfeff;
    --sidebar-bg: #f0f9ff;
    --text-color: #0c4a6e;
    --primary-color: #0ea5e9;
    --secondary-color: #0891b2;
    --wall-color: #164e63;
    --solution-color: rgba(6, 182, 212, 0.5);
}

/* Theme: Space */
[data-theme="space"] {
    --bg-color: #0f172a;
    --sidebar-bg: #1e293b;
    --text-color: #e2e8f0;
    --primary-color: #8b5cf6;
    --secondary-color: #64748b;
    --wall-color: #f8fafc;
    --solution-color: rgba(139, 92, 246, 0.6);
}

/* Theme: Candy */
[data-theme="candy"] {
    --bg-color: #fff1f2;
    --sidebar-bg: #ffe4e6;
    --text-color: #881337;
    --primary-color: #db2777;
    --secondary-color: #be185d;
    --wall-color: #9d174d;
    --solution-color: rgba(219, 39, 119, 0.5);
}

/* Theme: Pirate */
[data-theme="pirate"] {
    --bg-color: #fffbeb;
    --sidebar-bg: #fef3c7;
    --text-color: #451a03;
    --primary-color: #b45309;
    --secondary-color: #78350f;
    --wall-color: #451a03;
    --solution-color: rgba(180, 83, 9, 0.5);
}

/* Theme: Dino */
[data-theme="dino"] {
    --bg-color: #f0fdf4;
    --sidebar-bg: #dcfce7;
    --text-color: #14532d;
    --primary-color: #16a34a;
    --secondary-color: #15803d;
    --wall-color: #14532d;
    --solution-color: rgba(22, 163, 74, 0.5);
}


/* Theme: Royal Garden */
[data-theme="royal_garden"] {
    --bg-color: #dcfce7;
    --sidebar-bg: #f0fdf4;
    --text-color: #14532d;
    --primary-color: #15803d;
    --secondary-color: #166534;
    --wall-color: #14532d;
    /* Dark green hedge */
    --solution-color: rgba(234, 179, 8, 0.7);
    /* Gold path */
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    display: flex;
    width: 100%;
    height: 100%;
}

.controls {
    width: 300px;
    background-color: var(--sidebar-bg);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    z-index: 10;
    transition: background-color 0.3s;
}

h1 {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-align: center;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-weight: 700;
    font-size: 1.1rem;
}

select {
    padding: 0.8rem;
    border-radius: 12px;
    border: 2px solid var(--secondary-color);
    font-family: var(--font-body);
    font-size: 1rem;
    background-color: white;
    cursor: pointer;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    cursor: pointer;
}

.actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.btn {
    padding: 1rem;
    border: none;
    border-radius: 12px;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.1s, filter 0.2s;
}

.btn:hover {
    transform: scale(1.02);
    filter: brightness(1.1);
}

.btn:active {
    transform: scale(0.98);
}

.primary {
    background-color: var(--primary-color);
    color: white;
}

.secondary {
    background-color: var(--secondary-color);
    color: white;
}

.maze-area {
    flex: 1;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 2rem;
    padding-left: 4rem;
    position: relative;
}

.maze-container {
    position: relative;
    background-color: white;
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

canvas {
    display: block;
}

.maze-icon {
    position: absolute;
    font-size: 2rem;
    pointer-events: none;
    z-index: 5;
    display: flex;
    justify-content: center;
    align-items: center;
}

.instructions {
    margin-top: 1rem;
    text-align: center;
    font-weight: bold;
    font-size: 1.1rem;
}

/* Print Styles */
@media print {

    .no-print,
    .controls,
    .instructions {
        display: none !important;
    }

    body,
    html {
        background-color: white;
        height: 100%;
        margin: 0;
        padding: 0;
        overflow: hidden;
        /* Prevent scrollbars from creating a second page */
    }

    .container {
        display: block;
        height: 100%;
    }

    .maze-area {
        height: 100vh;
        width: 100vw;
        padding: 0;
        margin: 0;
        position: fixed;
        top: 0;
        left: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: white;
    }

    .maze-container {
        box-shadow: none;
        border: none;
        padding: 0;
        /* Ensure it scales down if somehow still too big */
        max-width: 95vw;
        max-height: 95vh;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    canvas {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
    }

    /* Ensure icons scale or are positioned correctly relative to the scaled canvas context? */
    /* Icons are absolute positioned: if canvas scales via CSS, icons might drift if they aren't scaled. 
       Actually, since the canvas is just an element, if we scale it with CSS (max-width), 
       the coordinate system for the DOM elements (icons) won't automatically scale unless 
       we use transform: scale() on the parent.
    */
    .maze-container {
        /* Using generic scaling might be safer for print */
        transform-origin: center center;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 30px;
    border: 1px solid #888;
    width: 90%;
    max-width: 800px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    font-family: var(--font-body);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.close {
    color: #aaa;
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    transition: color 0.2s;
}

.close:hover,
.close:focus {
    color: var(--text-color);
    text-decoration: none;
    cursor: pointer;
}

.impressum-body {
    color: var(--text-color);
}

.impressum-body h2 {
    font-family: var(--font-heading);
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 0.5rem;
}

.impressum-body h2:first-of-type {
    margin-top: 0;
}

.impressum-body h3 {
    margin-top: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--secondary-color);
    font-weight: bold;
}

.impressum-body p {
    margin-bottom: 0.8rem;
    line-height: 1.6;
}

.impressum-body hr {
    margin: 2rem 0;
    border: none;
    border-top: 1px solid #ccc;
}