/* Grundlegendes Body-Styling */
html, body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100%;
    font-family: 'Arial', sans-serif;
    background-color: #000;
    /* Performance-Optimierungen */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    display: flex;
    flex-direction: column;
}

#gameContainer {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    background-color: #87CEEB;
}

#backgroundContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background-size: cover;
    background-position: center bottom;
    transition: background-image 1s ease-in-out;
}

#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    /* Performance-Optimierungen */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    will-change: transform;
}

#game-ui-top, #game-ui-bottom {
    position: absolute;
    z-index: 10;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
    display: none;
}

#game-ui-top {
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

#scoreDisplay {
    background: linear-gradient(135deg, rgba(0, 150, 255, 0.9), rgba(0, 200, 255, 0.9)) !important;
    padding: 8px 16px !important;
    border-radius: 20px !important;
    border: 2px solid #00A0FF !important;
    font-weight: bold !important;
    font-size: 1.2em !important;
    color: white !important;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.7) !important;
    box-shadow: 0 3px 10px rgba(0, 150, 255, 0.3) !important;
    white-space: nowrap;
}

#game-ui-bottom {
    bottom: 15px;
    left: 15px;
}

#livesDisplay, #sheepDisplay, #levelDisplay, #magneticTimer { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    font-size: 1.1em !important;
    font-weight: 600;
    font-family: 'Arial', sans-serif !important;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
}

#levelDisplay {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.9), rgba(255, 165, 0, 0.9));
    padding: 6px 12px;
    border-radius: 15px;
    border: 2px solid #FFD700;
    font-weight: bold;
    font-size: 1.1em !important;
    font-family: 'Arial', sans-serif !important;
    box-shadow: 0 3px 10px rgba(255, 215, 0, 0.4);
    backdrop-filter: blur(10px);
}

#magneticTimer {
    background: linear-gradient(135deg, rgba(255, 0, 0, 0.9), rgba(255, 100, 100, 0.9));
    padding: 6px 12px;
    border-radius: 15px;
    border: 2px solid #FF0000;
    font-size: 1.1em !important;
    font-family: 'Arial', sans-serif !important;
    box-shadow: 0 3px 10px rgba(255, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

/* GEÄNDERT: Arcade-Styling für alle Bildschirme */
.screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: #000; /* Schwarzer Hintergrund */
    color: white;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 25px;
    z-index: 30;
    box-sizing: border-box;
    padding: 20px;
    border: 8px solid #444;
    border-top: 8px solid #999;
    border-left: 8px solid #999;
}

#loadingScreen {
    display: flex;
}

#startScreen {
    background-image: url('./assets/images/backgrounds/start.jpg');
    background-size: contain;
    background-position: center bottom;
    background-repeat: no-repeat;
    justify-content: flex-end;
    padding-bottom: 10%;
    border: none; /* Kein extra Rahmen für den Startbildschirm */
}

.game-tips {
    margin-bottom: 30px;
    text-align: center;
}

.game-tips h2 {
    color: #FFD700;
    margin-bottom: 20px;
    font-size: 2em;
}

.tips-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 500px;
    margin: 0 auto;
}

.tip-item {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.1);
    padding: 12px 20px;
    border-radius: 10px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    font-size: 1.1em;
}

.tip-icon {
    font-size: 1.5em;
    min-width: 30px;
}

.tip-content {
    display: flex;
    align-items: center;
    gap: 20px;
    background: rgba(255, 255, 255, 0.1);
    padding: 20px 30px;
    border-radius: 15px;
    border: 2px solid rgba(255, 215, 0, 0.5);
    font-size: 1.3em;
    max-width: 600px;
    margin: 0 auto;
}

#gameTipsOverlay {
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 40;
}

.ad-banner {
    margin: 20px 0;
    text-align: center;
    display: block;
}

.ad-placeholder {
    background: rgba(255, 255, 255, 0.1);
    border: 2px dashed rgba(255, 215, 0, 0.5);
    padding: 20px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.7);
}

.ad-placeholder span {
    display: block;
    font-size: 1.2em;
    margin-bottom: 5px;
}

.ad-placeholder small {
    font-size: 0.9em;
    opacity: 0.7;
}

.start-menu-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    width: 100%;
    flex-wrap: wrap;
}

.screen button {
    padding: 10px 20px;
    font-size: 1.2em;
    cursor: pointer;
    border: 4px solid #555;
    border-radius: 0;
    background-color: #f0f0f0;
    color: #000;
    font-family: 'Arial', sans-serif;
    font-weight: bold;
    box-shadow: 4px 4px 0px #000;
    transition: all 0.1s ease-in-out;
}
.screen button:active {
    box-shadow: none;
    transform: translate(4px, 4px);
}

#levelUpScreen {
    background-color: transparent;
    border: none;
}

#levelUpScreen h2 {
    font-size: 5em;
    color: #FFD700;
    text-shadow: 3px 3px 5px rgba(0,0,0,0.5);
}

.screen h1 { font-size: 3em; margin-bottom: 0; color: #FFD700; }
.screen h2 { font-size: 2.5em; margin-bottom: 0; color: #FFD700; }

/* Start Screen Styling */
.start-menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 20px;
}

#heartsContainer { 
    display: flex; 
    gap: 8px; 
    flex-wrap: nowrap; 
}

/* Modern Score Display */
#scoreDisplay {
    background: linear-gradient(135deg, rgba(0, 150, 255, 0.9), rgba(0, 200, 255, 0.9));
    padding: 12px 20px;
    border-radius: 25px;
    border: 3px solid #00A0FF;
    font-weight: bold;
    font-size: 1.6em !important;
    font-family: 'Arial', sans-serif !important;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    box-shadow: 0 4px 15px rgba(0, 150, 255, 0.4);
    backdrop-filter: blur(10px);
    min-width: 200px;
    text-align: center;
}

#score {
    color: #39ff14;
    font-size: 1.4em !important;
    font-weight: 700;
}
.heart-icon { 
    width: 40px; 
    height: 40px; 
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.8));
    transition: transform 0.2s ease;
}

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

.info-icon {
    width: 40px;
    height: auto;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.8));
}

/* Modern Sheep Display */
#sheepDisplay {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(240, 240, 240, 0.9));
    padding: 12px 20px;
    border-radius: 25px;
    border: 3px solid #FFFFFF;
    font-weight: bold;
    font-size: 1.6em !important;
    font-family: 'Arial', sans-serif !important;
    color: #333;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    min-width: 150px;
    text-align: center;
}

#sheepCount {
    color: #00AA00;
    font-weight: 700;
}

/* FORCE UI ELEMENTS TO BE VISIBLE AND LARGE */
#scoreDisplay, #heartsContainer, #levelDisplay, #sheepDisplay, #magneticTimer, #livesDisplay {
    font-size: 1.1em !important;
    font-family: 'Arial', sans-serif !important;
    font-weight: bold !important;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9) !important;
    z-index: 1000 !important;
    position: relative !important;
}

/* FORCE SPECIFIC ELEMENTS */
#scoreDisplay {
    background: linear-gradient(135deg, #0066FF, #00AAFF) !important;
    padding: 6px 12px !important;
    border-radius: 15px !important;
    border: 2px solid #FFFFFF !important;
    font-size: 1.1em !important;
    color: #FFFFFF !important;
    box-shadow: 0 3px 10px rgba(0, 102, 255, 0.6) !important;
}

#levelDisplay {
    background: linear-gradient(135deg, #FFD700, #FFA500) !important;
    padding: 6px 12px !important;
    border-radius: 15px !important;
    border: 2px solid #FFD700 !important;
    font-size: 1.1em !important;
    color: #000000 !important;
    box-shadow: 0 3px 10px rgba(255, 215, 0, 0.6) !important;
}

#heartsContainer {
    gap: 12px !important;
}

.heart-icon {
    width: 30px !important;
    height: 30px !important;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.9)) !important;
}

#sheepDisplay {
    background: linear-gradient(135deg, #FFFFFF, #F0F0F0) !important;
    padding: 6px 12px !important;
    border-radius: 15px !important;
    border: 2px solid #FFFFFF !important;
    font-size: 1.1em !important;
    color: #000000 !important;
    box-shadow: 0 3px 10px rgba(255, 255, 255, 0.6) !important;
}

#progressBarContainer {
    width: 60%;
    max-width: 400px;
    background-color: rgba(255, 255, 255, 0.2);
    border: 2px solid #FFD700;
    border-radius: 0;
    padding: 5px;
}

.loading-content {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

.loading-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 40px;
}

.loading-dog-icon {
    width: 240px;
    height: 240px;
    object-fit: contain;
}

.loading-title {
    font-size: 4em;
    margin: 0;
    color: #FFD700;
    text-shadow: 3px 3px 5px rgba(0,0,0,0.7);
}

.loading-bar-container {
    width: 100%;
    max-width: 400px;
    margin: 20px auto;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 3px;
}

#progressBar {
    width: 0%;
    height: 25px;
    background-color: #FFD700 !important;
    background: #FFD700 !important;
    border-radius: 10px;
    transition: width 0.3s ease;
}

.loading-tips {
    margin-top: 40px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

#loadingStatus {
    margin-top: 15px;
    font-size: 1.2em;
    color: #FFD700;
}

#pauseButton, #muteButton {
    position: absolute;
    z-index: 20;
    display: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid white;
    background-color: rgba(0, 0, 0, 0.4);
    color: white;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    justify-content: center;
    align-items: center;
    line-height: 1;
    padding: 0;
    transition: background-color 0.2s;
}

#pauseButton:hover, #muteButton:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

#pauseButton { top: 20px; left: 20px; }
#muteButton { top: 20px; right: 20px; font-size: 0.8em; }

.instructions-content {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 20px;
    max-width: 90%;
    width: 600px;
    text-align: left;
    max-height: 70vh;
    overflow-y: auto;
}

.control-section {
    margin: 20px 0;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 15px 0;
}

.control-icon {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.tips-list {
    list-style: none;
    padding: 0;
}

.tips-list li {
    margin: 10px 0;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 215, 0, 0.3);
}

.back-button {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 215, 0, 0.8);
    color: #000;
    border: 2px solid #FFD700;
    padding: 12px 20px;
    font-size: 1.1em;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 50;
}

.back-button:hover {
    background: rgba(255, 215, 0, 1);
    transform: scale(1.05);
}

.instructions-content h3 {
    color: #FFD700;
    border-bottom: 1px solid #FFD700;
    padding-bottom: 5px;
    margin-top: 0;
}

.instructions-content p {
    line-height: 1.6;
}

.obstacle-gallery {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
}

.obstacle-gallery figure {
    margin: 0;
    text-align: center;
}

.obstacle-gallery img {
    height: 40px;
    width: auto;
}

.obstacle-gallery figcaption {
    font-size: 0.8em;
    margin-top: 5px;
}

/* NEU: Highscore-Tabelle Styling */
.highscore-container {
    width: 90%;
    max-width: 600px;
    max-height: 70vh;
    border: 4px solid #fff;
    padding: 10px;
    overflow-y: auto;
    overflow-x: hidden;
}

#highscoreTable {
    width: 100%;
    border-collapse: collapse;
    color: #fff;
}

#highscoreTable th, #highscoreTable td {
    padding: 10px;
    text-align: left;
}

#highscoreTable thead {
    color: #FFD700;
    border-bottom: 4px double #fff;
}

#highscoreTable td:nth-child(1),
#highscoreTable td:nth-child(4) {
    text-align: center;
}

#highscoreTable td:nth-child(3) {
    text-align: right;
    color: #39ff14; /* Grüne Score-Farbe */
}

/* Scrollbar Styling für die Highscore-Tabelle */
.highscore-container::-webkit-scrollbar {
    width: 12px;
}

.highscore-container::-webkit-scrollbar-track {
    background: #333;
    border-radius: 6px;
}

.highscore-container::-webkit-scrollbar-thumb {
    background: #FFD700;
    border-radius: 6px;
    border: 2px solid #333;
}

.highscore-container::-webkit-scrollbar-thumb:hover {
    background: #FFA500;
}

@media (max-width: 600px) {
    #startScreen {
        background-image: url('./assets/images/backgrounds/start_mobile.jpg');
        background-size: contain;
        background-position: center bottom;
        background-repeat: no-repeat;
    }

    .start-menu-buttons {
        flex-direction: column;
        gap: 20px;
        width: 80%;
        max-width: 250px;
    }

    .start-menu-buttons button {
        width: 100%;
    }
    
    .instructions-content {
        max-width: 95%;
        padding: 15px;
        font-size: 0.9em;
    }
    
    .obstacle-gallery {
        gap: 10px;
    }
    
    .obstacle-gallery figure {
        flex: 1;
        min-width: 80px;
    }
    
    .obstacle-gallery img {
        height: 30px;
    }
    
    .back-button {
        bottom: 15px;
        left: 15px;
        padding: 10px 15px;
        font-size: 1em;
    }
}
