:root {
    --bg-dark: #141414;
    --bg-light: #f0f0f0;
    --gradient-dark: linear-gradient(0deg, rgba(32, 32, 38, 1) 0%, rgba(12, 16, 33, 1) 100%);
    --gradient-light: linear-gradient(0deg, rgba(216, 255, 253, 1) 0%, rgba(34, 156, 195, 1) 100%);
    --transition-time: 500ms;
    --floor: url("background/Grass floor.png");
    --backgroundtree: url("background/Background tree.png");
    --cloudsmall: url("assets/CloudSmall.png");
    --cloudmedium: url("assets/CloudMedium.png");
    --cloudlarge: url("assets/CloudLarge.png");
    --moon: url("background/Moon.png");
    --sun: url("background/Sun.png");
    --mountainsmall: url("background/Small mountain.png");
    --mountainlarge: url("background/Tall mountain.png");
    --mountainmedium: url("background/Medium mountain.png");

    --save: url("assets/save.svg");
    --save-active: url("assets/save-active.svg");
    --load: url("assets/load.svg");
    --load-active: url("assets/load-active.svg");

    --gradient-dark-start: rgba(32,32,38,1);
    --gradient-dark-end: rgba(12,16,33,1);
    --gradient-light-start: rgba(216,255,253,1);
    --gradient-light-end: rgba(34,156,195,1);
}

* {
    font-family: Arial, Helvetica, sans-serif;
}

canvas {
    background: rgba(103, 103, 103, 0.313) !important;
    cursor: pointer;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    position: relative;
    background: var(--gradient-dark);
    overflow: hidden;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 1;
    transition: opacity 1s ease;
    background: var(--gradient-light);
    z-index: -1;
}

body[data-theme="light"]::before {
    opacity: 1;
}

body[data-theme="dark"]::before {
    opacity: 0;
}

#gameWrap {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1200px; /* Increased from 800px */
    overflow: hidden;
}

/* Toolbar styling */
.toolbar {
    flex-wrap: wrap;
    display: flex;
    align-items: center;
    gap: 10px; /* Reduced gap */
    padding: 15px 15px; /* Added horizontal padding */
    background: var(--gradient-dark);
    justify-content: space-evenly;
    border-radius: 10px;
    margin-bottom: 10px;
    z-index: 1001; /* Added z-index to ensure it's above other elements */
    width: calc(100% - 50px); /* Account for padding */
}

/* Element selector styling */
#elementSelector {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #666;
    background: #333;
    color: white;
    cursor: pointer;
    min-width: 120px; /* Reduced min-width */
    flex-shrink: 1; /* Allow these elements to shrink if needed */
}

#elementSelector:hover {
    border-color: #888;
}

/* Label styling */
.toolbar label {
    color: white;
    font-size: 14px;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Input styling */
#saveName {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #666;
    background: #333;
    color: white;
    min-width: 120px; /* Reduced min-width */
    flex-shrink: 1; /* Allow these elements to shrink if needed */
}

#saveName:focus {
    border-color: #888;
    outline: none;
}

/* Button styling */
.toolbar button {
    padding: 8px 12px; /* Reduced padding */
    border-radius: 4px;
    border: none;
    background: #444;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s ease;
    white-space: nowrap; /* Prevent button text from wrapping */
    flex-shrink: 0; /* Prevent buttons from shrinking */
    min-width: fit-content; /* Allow buttons to size to their content */
}

/* Save selector styling */
#saveSelector {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #666;
    background: #333;
    color: white;
    cursor: pointer;
    min-width: 120px; /* Reduced min-width */
    flex-shrink: 1; /* Allow these elements to shrink if needed */
}

#saveSelector:hover {
    border-color: #888;
}

/* Specific button styling */
#saveButton, #loadButton {
    background-color: #2c5282;
}

#saveButton:hover, #loadButton:hover {
    background-color: #2b6cb0;
}

#updateButton {
    background-color: #2f855a;
}

#updateButton:hover {
    background-color: #38a169;
}

#resetButton {
    background-color: #9b2c2c;
}

#resetButton:hover {
    background-color: #c53030;
}

/* Add new save/load button and dialog styles here */
.icon-button {
    width: 32px; /* Reduced from 40px */
    height: 32px; /* Reduced from 40px */
    border: none;
    background-color: transparent;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
    transition: transform 0.2s ease;
    padding: 0;
    flex-shrink: 0;
}

.icon-button:hover {
    transform: scale(1.1);
}

.save-button {
    background-image: var(--save);
}

.save-button:hover {
    background-image: var(--save-active);
}

.load-button {
    background-image: var(--load);
}

.load-button:hover {
    background-image: var(--load-active);
}

.game-dialog {
    padding: 20px;
    border-radius: 8px;
    border: none;
    background: var(--gradient-dark);
    color: white;
}

.game-dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

.game-dialog h2 {
    margin-top: 0;
    margin-bottom: 20px;
}

.game-dialog form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.game-dialog input,
.game-dialog select {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #666;
    background: #333;
    color: white;
}

.dialog-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.dialog-buttons button {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    background: #444;
    color: white;
    cursor: pointer;
}

.dialog-buttons button:hover {
    background: #555;
}

canvas#game {
    width: 100%;
    background: #000;
    border-radius: 10px;
    z-index: 1;
}

/* Floor and background tree containers */
.floor-container,
.backgroundtree-container {
    position: absolute;
    bottom: 0;
    left: 0;
    display: flex;
}

.floor-container {
    width: 100vw;
    height: 97px; /* Height of the floor */
    animation: none;
}

.backgroundtree-container {
    bottom: 97px; /* Positioned above the floor */
    width: 200vw; /* Double the viewport width */
    height: 134px; /* Height of the trees */
    animation: none;
}

.floor,
.backgroundtree {
    width: 100vw;
    height: 100%;
    background-repeat: repeat-x;
    transform: translateY(10px);
}

.floor {
    background-image: var(--floor);
    transform: translateY(-55px);
}

.backgroundtree {
    background-image: var(--backgroundtree);
}

/* Cloud container styling */
.cloud-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    overflow: hidden;
    z-index: 0; /* Adjust z-index as needed so clouds appear in the sky */
}

/* Cloud element styling */
.cloud {
    position: absolute;
    background-repeat: no-repeat;
    background-size: contain;
    /* Default width (will be randomized via JS) */
    width: 200px;
    height: auto;
    /* Apply cloud movement animation */
    animation: cloudMove linear infinite;
}

/* Updated cloud movement keyframes: 
   The clouds start at -150vw (off-screen left) and move to 150vw (off-screen right) */
@keyframes cloudMove {
    0% {
        transform: translateX(-150vw);
    }
    100% {
        transform: translateX(150vw);
    }
}

/* Base styles for the celestial element */
.celestial {
    cursor: pointer;
    position: fixed;
    top: 80px;  /* Changed from 120px to 80px */
    left: 20px;
    width: 120px;  /* Changed from 100px to 120px */
    height: 120px;  /* Changed from 100px to 120px */
    offset-distance: 0%;
}

.moon-image,
.sun-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    transition: opacity var(--transition-time) ease;
}

.moon-image {
    background-image: var(--moon);
    opacity: 0;
}

.sun-image {
    background-image: var(--sun);
    opacity: 1;
}

body[data-theme="dark"] .moon-image {
    opacity: 1;
}

body[data-theme="dark"] .sun-image {
    opacity: 0;
}


body[data-theme="light"] .moon-image {
    opacity: 0;
}

body[data-theme="light"] .sun-image {
    opacity: 1;
}

@keyframes moveArc {
    0% {
        offset-distance: 0%;
    }
    100% {
        offset-distance: 100%;
    }
}

@keyframes moveArcReverse {
    0% {
        offset-distance: 100%;
    }
    100% {
        offset-distance: 0%;
    }
}

/* Mountain Container */
.mountain-container {
    height: 100%;
    position: absolute;
    bottom: 120px; /* Position slightly above the background trees */
    width: 100%;
    overflow: hidden;
    background: transparent;
    z-index: -1; /* Place behind the background trees */
}

/* Kleine Berge */
.mountainsmall {
    position: absolute;
    bottom: 50px;
    width: 150px;
    height: 100px;
    background: var(--mountainsmall) no-repeat bottom center;
    background-size: contain;
}

/* Mittlere Berge */
.mountainmedium {
    position: absolute;
    bottom: 40px; /* Changed from 0 to 40px */
    width: 250px;
    height: 150px;
    background: var(--mountainmedium) no-repeat bottom center;
    background-size: contain;
}

/* Große Berge */
.mountainlarge {
    position: absolute;
    bottom: 0;
    width: 350px;
    height: 200px;
    background: var(--mountainlarge) no-repeat bottom center;
    background-size: contain;
}

/* Mountain base classes */
.mountainsmall, .mountainmedium, .mountainlarge {
    position: absolute;
    transform-origin: bottom center;
}

/* Remove the static positioning rules */
.mountain-container .mountainsmall:nth-of-type(1),
.mountain-container .mountainsmall:nth-of-type(2),
.mountain-container .mountainmedium:nth-of-type(1),
.mountain-container .mountainmedium:nth-of-type(2),
.mountain-container .mountainlarge:nth-of-type(1),
.mountain-container .mountainlarge:nth-of-type(2) {
    display: none;
}