* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0;
    padding: 20px;
    font-family: Arial, sans-serif;
    min-height: 100vh;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

body.fullscreen-active {
    padding: 0;
    justify-content: center;
    height: 100vh;
    background: black;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.visible {
    display: flex !important;
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    height: 100%;
}

h1 {
    font-family: 'Luckiest Guy', cursive;
    color: #FFD700;
    text-shadow: 3px 3px 0 #000, 
                -1px -1px 0 #000, 
                1px -1px 0 #000, 
                -1px 1px 0 #000, 
                1px 1px 0 #000;
    font-size: 3.5rem; 
    letter-spacing: 2px;
    text-align: center;
    text-transform: uppercase;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 12px 25px;
    border-radius: 10px;
    margin-bottom: 20px; 
    width: fit-content;
}

canvas {
    background-color: black;
    border: 4px solid #333;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
    width: 720px;
    height: 480px;
    max-width: 100%;
    filter: blur(3px);
    image-rendering: -webkit-optimize-contrast;
    image-rendering: -moz-crisp-edges;
    image-rendering: pixelated;
}

#gameContainer {
    position: relative;
    display: inline-block;
    overflow: hidden;
    border-radius: 4px;
}

#startScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 10;
}

#gameOverScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    gap: 20px;
}

#youWonScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    gap: 20px;
}

#gameOverScreen,
#youWonScreen {
    background-color: rgba(0, 0, 0, 0.8);
}

.game-over-container,
.you-won-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-over-title,
.you-won-title {
    font-family: 'Luckiest Guy', cursive;
    font-size: 5rem;
    color: #FFD700;
    text-shadow: 4px 4px 0 #FF6B6B,
                -2px -2px 0 #000,
                2px -2px 0 #000,
                -2px 2px 0 #000,
                2px 2px 0 #000;
    text-transform: uppercase;
    letter-spacing: 4px;
    margin: 0;
}

.you-won-title {
    color: #4CAF50;
    text-shadow: 4px 4px 0 #FFD700,
                -2px -2px 0 #000,
                2px -2px 0 #000,
                -2px 2px 0 #000,
                2px 2px 0 #000;
}

.menu-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    margin: 0 auto;
}

.close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: all 0.2s ease;
}

.close-button:hover {
    background: rgba(255, 0, 0, 0.7);
    transform: scale(1.1);
}

.mobile-close {
    display: none;
}

@media (max-width: 768px) {
    .mobile-close {
        display: flex;
    }

    .game-instructions > div {
        max-height: 90vh;
        overflow-y: auto;
        padding: 50px 20px 20px 20px;
    }
    
    .ingame-controls {
        top: 5px;
        right: 5px;
        gap: 5px;
    }
    
    .control-button {
        font-size: 0.9rem;
        padding: 6px 8px;
        min-width: 35px;
    }
}

#startButton {
    font-family: 'Luckiest Guy', cursive;
    font-size: 1.4rem;
    padding: 10px 24px;
    background-color: #FFD700;
    color: #000;
    border: 3px solid #333;
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
}

#startButton:hover {
    background-color: #FFC107;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
}

#startButton:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

#restartButton {
    font-family: 'Luckiest Guy', cursive;
    font-size: 1rem;
    padding: 9px 18px;
    background-color: #FF6B6B;
    color: #FFF;
    border: 2px solid #333;
    border-radius: 6px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
    min-width: 132px;
}

#restartButton:hover {
    background-color: #FF5252;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
}

#restartButton:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

#youWonRestartButton {
    font-family: 'Luckiest Guy', cursive;
    font-size: 1rem;
    padding: 9px 18px;
    background-color: #4CAF50;
    color: #FFF;
    border: 2px solid #333;
    border-radius: 6px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
    min-width: 132px;
}

#youWonRestartButton:hover {
    background-color: #45A049;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
}

#youWonRestartButton:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Responsive Anpassungen */
@media (max-width: 768px) {
    h1 {
        font-size: 2.5rem;
        padding: 10px 20px;
    }
    .game-container {
        gap: 15px;
    }
    #startButton, .menu-button {
        font-size: 1rem;
        padding: 8px 16px;
        min-width: 100px;
    }
    #restartButton, #youWonRestartButton {
        font-size: 0.9rem;
        padding: 7px 15px;
        min-width: 110px;
    }
}

.menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 40px;
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 15px;
    margin-top: 50px;
}

.menu-button {
    font-family: 'Luckiest Guy', cursive;
    font-size: 0.9rem;
    padding: 8px 16px;
    background-color: #4CAF50;
    color: #FFF;
    border: 2px solid #333333;
    border-radius: 6px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
    min-width: 120px;
}

.menu-button:hover {
    background-color: #45A049;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
}

.menu-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.menu-button.muted {
    background-color: #FF6B6B;
}

.menu-button.muted:hover {
    background-color: #FF5252;
}

.volume-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
}

.volume-label {
    color: #FFD700;
    font-family: 'Luckiest Guy', cursive;
    font-size: 1.1rem;
    text-shadow: 2px 2px 0 #0000003b;
}

.volume-slider {
    width: 200px;
    height: 8px;
    background: #333;
    border-radius: 4px;
    outline: none;
    -webkit-appearance: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #FFD700;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #333333;
}

.volume-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #FFD700;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #333333;
}

.game-instructions {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    color: #FFD700;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2500;
    cursor: pointer;
}

.game-instructions > div {
    background-color: rgba(0, 0, 0, 0.95);
    padding: 20px;
    border-radius: 15px;
    margin: 20px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    font-family: Arial, sans-serif;
    line-height: 1.4;
    font-size: 14px;
    cursor: default;
}

.game-instructions h3 {
    font-family: 'Luckiest Guy', cursive;
    color: #FFD700;
    text-shadow: 2px 2px 0 #000000;
    margin-bottom: 10px;
    text-align: center;
    font-size: 1.5rem;
}

.guide-intro {
    text-align: center;
    margin-bottom: 15px;
    font-size: 14px;
    color: #FFF;
}

.guide-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin: 15px 0;
}

.guide-column h4 {
    color: #4CAF50;
    font-weight: bold;
    margin-bottom: 6px;
    font-size: 1rem;
}

.guide-list {
    list-style: disc;
    padding-left: 20px;
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.4;
    color: #FFF;
}

.guide-list li {
    margin: 3px 0;
}

.controls-section {
    margin: 15px 0;
}

.controls-section h4 {
    color: #4CAF50;
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 1rem;
}

.controls-list {
    list-style: none;
    padding: 0;
}

.controls-list li {
    margin: 8px 0;
    padding: 5px 10px;
    background-color: rgba(255, 215, 0, 0.1);
    border-radius: 5px;
}

.key {
    background-color: #333333;
    color: #FFD700;
    padding: 3px 8px;
    border-radius: 3px;
    font-weight: bold;
    margin-right: 10px;
}

.ingame-controls {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 8px;
    z-index: 1000;
}

.control-button {
    background-color: rgba(0, 0, 0, 0.7);
    color: #FFD700;
    border: 2px solid #FFD700;
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-button:hover {
    background-color: #FFD700;
    color: #000;
    transform: translateY(-1px);
}

body.fullscreen-active canvas.fullscreen-active {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    object-fit: contain;
    z-index: 1;
}

body.fullscreen-active #gameContainer.fullscreen-active {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

h1.fullscreen-hidden {
    display: none;
}

body.fullscreen-active #startScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

body.fullscreen-active h1 {
    display: block;
    font-size: 3rem;
}

body.fullscreen-active .menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

body.fullscreen-active .menu-button {
    font-size: 1.2rem;
    padding: 12px 24px;
}

body.fullscreen-active .game-instructions > div {
    max-width: 700px;
    max-height: 80vh;
}

body.fullscreen-active #gameOverScreen,
body.fullscreen-active #youWonScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 11;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 30px;
}

body.fullscreen-active .game-over-title,
body.fullscreen-active .you-won-title {
    font-size: 6rem;
}

body.fullscreen-active #gameOverScreen .menu-buttons,
body.fullscreen-active #youWonScreen .menu-buttons {
    gap: 20px;
}

body.fullscreen-active #gameOverScreen .menu-button,
body.fullscreen-active #youWonScreen .menu-button {
    font-size: 1.3rem;
    padding: 14px 28px;
    min-width: 150px;
}

.mobile-controls {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1002;
    gap: 20px;
    width: 90%;
    justify-content: space-between;
    align-items: flex-end;
}

.mobile-control-group {
    display: flex;
    gap: 15px;
    align-items: center;
}

.mobile-control-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid #FFD700;
    background-color: rgba(0, 0, 0, 0.1);
    color: #FFD700;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    transition: all 0.2s ease;
    will-change: transform, background-color;
}

.mobile-control-button:active {
    background-color: #FFD700;
    color: #000;
    transform: scale(0.95);
}

.mobile-control-button {
    font-size: 1.8rem;
    font-weight: bold;
}

/* Landscape Mode Warning */
.landscape-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #FFD700;
    font-family: 'Luckiest Guy', cursive;
    text-align: center;
    padding: 20px;
}

.landscape-warning h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    color: #FFD700;
    text-shadow: 2px 2px 0 #000000;
}

.landscape-warning p {
    font-size: 1.2rem;
    margin-bottom: 30px;
    line-height: 1.5;
}

.rotate-icon {
    width: 80px;
    height: 80px;
    background-color: #FFD700;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: #000;
    animation: rotate 2s infinite ease-in-out;
}

@keyframes rotate {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}


@media (hover: none) and (orientation: portrait) {
    .landscape-warning {
        display: flex;
    }
    
    #gameContainer {
        display: none;
    }
    
    h1 {
        display: none;
    }
}

@media (hover: none) and (orientation: landscape) {
    .mobile-controls.mobile-controls-active {
        display: flex !important;
    }

    .ingame-controls {
        top: 10px;
        right: 10px;
        gap: 8px;
        z-index: 1003;
    }

    /* Hide fullscreen button on mobile devices */
    #fullscreenButton {
        display: none !important;
    }

    h1 {
        display: none;
    }

    body {
        padding: 0;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        justify-content: center;
    }
    
    canvas {
        width: 100vw;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        object-fit: contain;
    }
    
    #gameContainer {
        width: 100vw;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
    }
    
    .fullscreen-button {
        display: none;
    }
}


@media (max-width: 768px) and (orientation: landscape) {
    h1 {
        font-size: 2rem;
        margin-bottom: 10px;
    }

    .menu-button {
        font-size: 0.8rem;
        padding: 6px 12px;
        min-width: 90px;
    }

    .menu-buttons {
        gap: 8px;
        max-width: 95%;
    }
}

/* Impressum Link */
.impressum-link {
    position: fixed;
    bottom: 10px;
    right: 10px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    font-family: Arial, sans-serif;
    transition: color 0.2s ease;
    z-index: 100;
    user-select: text;
    -webkit-user-select: text;
}

.impressum-link:hover {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: underline;
}

/* Hide impressum on mobile landscape mode to avoid conflicts with mobile controls */
@media (hover: none) and (orientation: landscape) {
    .impressum-link {
        display: none;
    }
}

/* Hide impressum in fullscreen mode */
body.fullscreen-active .impressum-link {
    display: none;
}

/* Info Buttons (Impressum + Privacy Policy) */
.info-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    margin-bottom: 20px;
    padding: 10px;
    position: relative;
    z-index: 15;
}

.impressum-button {
    background-color: #ffd111;
    border: none;
    padding: 12px 28px;
    font-weight: 600;
    font-size: 18px;
    cursor: pointer;
    border-radius: 10px;
    color: #2c2c2c;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25);
    transition: all 0.2s ease;
}

.impressum-button:hover {
    background-color: #ffcc00;
    transform: scale(1.05);
}

/* Impressum Popup */
#impressumPopup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    max-width: 700px;
    background-color: #fff;
    border: 3px solid #444;
    border-radius: 16px;
    padding: 30px 40px;
    padding-right: 30px;
    text-align: left;
    z-index: 2000;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    font-family: "Segoe UI", Arial, sans-serif;
    line-height: 1.6;
    color: #222;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 80vh;
    box-sizing: border-box;
}

/* Scrollbar styling for Impressum Popup */
#impressumPopup::-webkit-scrollbar {
    width: 10px;
}

#impressumPopup::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 13px 13px 0;
    margin: 8px 0;
}

#impressumPopup::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
    border: 2px solid #ffffff;
}

#impressumPopup::-webkit-scrollbar-thumb:hover {
    background: #555;
}

#impressumPopup h3 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 26px;
    font-weight: 700;
    color: #b30000;
}

#impressumPopup h4 {
    color: #ff8800;
    font-size: 20px;
    margin-top: 15px;
    margin-bottom: 10px;
    font-weight: 600;
}

#impressumPopup p {
    margin: 8px 0;
    font-size: 16px;
}

#impressumPopup a {
    color: #b30000;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease, text-shadow 0.2s ease;
}

#impressumPopup a:hover {
    color: #ff8800;
    text-shadow: 0 0 5px rgba(255, 136, 0, 0.6);
}

#impressumPopup button {
    display: block;
    margin: 25px auto 0 auto;
    background-color: #ffd111;
    border: none;
    padding: 12px 28px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    color: #2c2c2c;
    transition: all 0.2s ease;
}

#impressumPopup button:hover {
    background-color: #ffcc00;
    transform: scale(1.05);
}

/* Privacy Policy Popup */
#privacyPopup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    max-width: 700px;
    background-color: #ffffff;
    color: #222;
    border: 3px solid #ff8800;
    border-radius: 16px;
    padding: 30px 40px;
    padding-right: 30px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    font-family: "Segoe UI", Arial, sans-serif;
    line-height: 1.6;
    text-align: left;
    z-index: 3000;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 80vh;
    box-sizing: border-box;
}

/* Scrollbar styling for Privacy Policy Popup */
#privacyPopup::-webkit-scrollbar {
    width: 10px;
}

#privacyPopup::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 13px 13px 0;
    margin: 8px 0;
}

#privacyPopup::-webkit-scrollbar-thumb {
    background: #ff8800;
    border-radius: 10px;
    border: 2px solid #ffffff;
}

#privacyPopup::-webkit-scrollbar-thumb:hover {
    background: #ff6600;
}

#privacyPopup h3 {
    text-align: center;
    color: #b30000;
    font-size: 26px;
    margin-bottom: 20px;
    font-weight: 700;
}

#privacyPopup h4 {
    color: #ff8800;
    font-size: 20px;
    margin-top: 15px;
    margin-bottom: 10px;
    font-weight: 600;
}

#privacyPopup p {
    margin: 8px 0 15px 0;
    font-size: 16px;
}

#privacyPopup a {
    color: #b30000;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease, text-shadow 0.2s ease;
}

#privacyPopup a:hover {
    color: #ff8800;
    text-shadow: 0 0 5px rgba(255, 136, 0, 0.6);
}

#privacyPopup button {
    display: block;
    margin: 25px auto 0 auto;
    background-color: #ffd111;
    border: none;
    padding: 12px 28px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    color: #2c2c2c;
    transition: all 0.2s ease;
}

#privacyPopup button:hover {
    background-color: #ffcc00;
    transform: scale(1.05);
}

/* Hide info buttons on mobile landscape and fullscreen */
@media (hover: none) and (orientation: landscape) {
    .info-buttons {
        display: flex;
        position: fixed;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 1001;
        gap: 10px;
        margin: 0;
        padding: 0;
    }

    .impressum-button {
        background-color: rgba(255, 209, 17, 0.9);
        padding: 8px 16px;
        font-size: 0.75rem;
        font-weight: 600;
        border-radius: 6px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }

    .impressum-button:hover {
        background-color: rgba(255, 204, 0, 0.9);
        transform: scale(1.05);
    }
}

/* Info buttons visibility is managed programmatically via GameManager */