/* Klas Persson Game Styles */
.klas-persson-game {
    max-width: 100vw;
    width: 100%;
    margin: 0 auto;
    padding: 10px;
    background: #000;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    font-family: 'Courier New', monospace;
    color: #fff;
    position: relative; /* Viktigt för overlay-positionering */
    overflow: hidden;
    box-sizing: border-box;
}

/* Säkerställ att spelcontainern har rätt position för overlay */
#klas-persson-game-container {
    position: relative !important;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    border: 3px solid #444;
    box-shadow:
        0 0 20px rgba(0, 255, 0, 0.3),
        inset 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Menu Screen */
.menu-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    border: 2px solid #fff;
}

.game-title {
    font-size: 4rem;
    color: #fff;
    font-family: 'Black Ops One', 'Orbitron', monospace;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    margin-bottom: 2rem;
    text-align: center;
}

.game-subtitle {
    font-size: 1.2rem;
    color: #ccc;
    font-family: 'Inter', sans-serif;
    text-align: center;
    margin-bottom: 3rem;
    max-width: 600px;
    line-height: 1.5;
}

/* Intro Screen */
.intro-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    border: 2px solid #fff;
    padding: 2rem;
    box-sizing: border-box;
}

.intro-content {
    max-width: 600px;
    text-align: center;
    color: #fff;
    font-family: 'Inter', sans-serif;
}

.intro-title {
    font-size: 3rem;
    color: #fff;
    font-family: 'Black Ops One', monospace;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.intro-story {
    font-size: 1.2rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    color: #ccc;
}

.intro-controls {
    background: rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.intro-controls h3 {
    color: #fff;
    font-family: 'Orbitron', monospace;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.control-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.control-key {
    font-weight: bold;
    color: #00ff00;
    font-family: 'Courier New', monospace;
}

.start-game-btn {
    font-size: 1.2rem;
    padding: 1rem 2rem;
}

.start-btn {
    background: #fff;
    color: #000;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.2rem;
    font-weight: bold;
    font-family: 'Orbitron', monospace;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.start-btn:hover {
    background: #ccc;
    transform: translateY(-2px);
}

/* Game UI */
.game-ui {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 2px solid #333;
    margin-bottom: 10px;
}

.game-info {
    display: flex;
    gap: 20px;
    font-size: 16px;
    font-weight: bold;
    color: #fff;
}

.game-info div {
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Canvas */
#game-canvas {
    display: block;
    margin: 0 auto;
    background: #000; /* Svart bakgrund för start-skärmen */
    border: 2px solid #666;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    position: relative;
    z-index: 1;
    max-width: 100%;
    max-height: 70vh; /* Begränsa höjden till 70% av viewport */
    width: auto;
    height: auto;
}

/* Mobil canvas - mycket större */
@media (max-width: 1024px) {
    #game-canvas {
        max-height: 90vh !important; /* Ännu större på mobil - 90% av skärmhöjden */
        width: 100vw !important;
        max-width: 100vw !important;
        height: auto !important;
        min-height: 500px !important; /* Minst 500px höjd */
    }
}

/* Controls */
.game-controls {
    margin-top: 15px;
    text-align: center;
}

.controls-info {
    background: #111;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 15px;
    border: 1px solid #333;
}

.controls-info h3 {
    color: #00ff00;
    margin-bottom: 10px;
    text-shadow: 0 0 5px #00ff00;
}

.controls-info p {
    margin: 5px 0;
    font-size: 14px;
}

/* Buttons */
.start-btn, .pause-btn, .restart-btn, .next-level-btn {
    background: #fff;
    color: #000;
    border: 2px solid #000;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 0;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 2px 2px 0px #000;
    transition: all 0.3s ease;
    font-family: 'Courier New', monospace;
}

.start-btn:hover, .pause-btn:hover, .restart-btn:hover, .next-level-btn:hover {
    background: #000;
    color: #fff;
    box-shadow: 2px 2px 0px #fff;
}

.pause-btn {
    background: #ccc;
    color: #000;
}

/* Game Over Screen */
.game-over-screen {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border: 2px solid #fff;
}

.game-over-content {
    text-align: center;
    animation: gameOverFadeIn 1s ease-in-out;
}

.game-over-title {
    font-size: 5rem;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    margin: 0;
    font-weight: 900;
    letter-spacing: 4px;
    font-family: 'Black Ops One', 'Orbitron', monospace;
}

.game-over-subtitle {
    font-size: 1.5rem;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    margin: 20px 0 40px 0;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
}

/* Level Complete Screen */
.level-complete-screen {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border: 2px solid #fff;
}

.level-complete-content {
    text-align: center;
    animation: levelCompleteFadeIn 1s ease-in-out;
}

.level-complete-title {
    font-size: 3rem;
    color: #00ff00;
    text-shadow: 0 0 20px #00ff00;
    margin: 0 0 20px 0;
    font-weight: bold;
    letter-spacing: 2px;
}

.level-complete-text {
    font-size: 1.5rem;
    color: #ffffff;
    margin-bottom: 30px;
}

/* Animations */
@keyframes gameOverFadeIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes gameOverPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes gameOverSubtitleFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes levelCompleteFadeIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 1300px) {
    .klas-persson-game {
        padding: 5px;
        margin: 0;
    }

    #game-canvas {
        max-width: 100vw;
        max-height: 60vh;
        width: auto;
        height: auto;
    }

    .game-over-title {
        font-size: 2.5rem;
    }

    .game-over-subtitle {
        font-size: 1.5rem;
    }

    .level-complete-title {
        font-size: 2rem;
    }
}

/* Ytterligare responsivitet för mindre skärmar */
@media (max-width: 768px) {
    .klas-persson-game {
        padding: 1px;
        border-radius: 0;
    }

    #game-canvas {
        max-width: 100vw !important;
        max-height: 85vh !important; /* Ännu större på små skärmar */
        border-radius: 0 !important;
        width: 100vw !important;
        min-height: 450px !important; /* Ökat från 400px */
    }
}

/* Specifikt för mycket små skärmar (telefoner) */
@media (max-width: 480px) {
    #game-canvas {
        max-height: 80vh !important; /* Större även på telefoner */
        min-height: 400px !important; /* Ökat från 350px */
        width: 100vw !important;
        max-width: 100vw !important;
    }
}

/* Mobil-kontroller styling - dold som standard */
#mobile-controls {
    position: fixed !important;
    bottom: 5px !important; /* ALLRA LÄNGST NER */
    left: 0 !important;
    right: 0 !important;
    display: none !important; /* Dold som standard */
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0 10px !important; /* Mindre padding för att komma närmare kanterna */
    z-index: 1000 !important;
    pointer-events: none !important;
    gap: 10px !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    margin: 0 !important;
}

/* När JavaScript aktiverar mobil-kontroller */
#mobile-controls.mobile-active {
    display: flex !important;
}

/* Justera kontroller när disclaimer är dold */
body:has(.disclaimer-hidden) #mobile-controls,
.disclaimer-hidden ~ * #mobile-controls {
    bottom: 20px !important;
}

#mobile-controls button {
    pointer-events: auto !important;
    min-height: 60px !important;
    font-size: 16px !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-touch-callout: none !important;
    background-color: rgba(55, 65, 81, 0.8) !important;
    border: 2px solid rgba(107, 114, 128, 0.8) !important;
    color: white !important;
    border-radius: 8px !important;
    padding: 16px !important;
    font-weight: bold !important;
    touch-action: manipulation !important;
    cursor: pointer !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
    transition: all 0.2s ease !important;
}

#mobile-controls button:active {
    background-color: rgba(85, 85, 85, 0.9) !important;
    transform: scale(0.95) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5) !important;
}

#mobile-controls button:hover {
    background-color: rgba(75, 85, 99, 0.8) !important;
    border-color: rgba(156, 163, 175, 0.8) !important;
}

/* Riktningsknappar */
#mobile-left, #mobile-right, #mobile-up, #mobile-down {
    font-size: 24px !important;
    padding: 16px 20px !important;
    min-width: 60px !important;
}

/* Spacer mellan vänster/höger och upp/ned knappar */
.mobile-spacer {
    flex: 1 !important;
}

/* Hoppa/kasta knappar */
#mobile-jump, #mobile-throw {
    font-size: 18px !important;
    padding: 16px !important;
    margin-left: 8px !important;
}

#mobile-jump {
    margin-right: 8px !important;
}

/* Mobile touch controls - endast layout-justeringar */
@media (max-width: 1024px) {
    .klas-persson-game {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100vw !important;
        width: 100vw !important;
    }

    #game-canvas {
        width: 100vw !important;
        max-width: 100vw !important;
        max-height: 90vh !important; /* Ännu större spelyta - 90% */
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        min-height: 500px !important; /* Ökat från 400px */
    }

    .controls-info {
        display: none; /* Dölj tangentbordsinstruktioner på mobil */
    }

    /* Ge plats för mobil-kontroller */
    body {
        padding-bottom: 150px !important; /* Ökat för att ge mer plats */
        margin: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Ta bort all padding från text-områden på mobil */
    main {
        padding: 0.25rem !important;
    }

    /* Minska horisontell padding rejält på små enheter */
    .klas-persson-game {
        padding-left: 0.25rem !important;
        padding-right: 0.25rem !important;
    }

    /* Dölj desktop-knappar på mobil */
    .mt-8.flex.flex-col.md\\:flex-row {
        display: none;
    }

    /* Dölj gråa runda knappar på mobil */
    .start-btn {
        display: none !important;
    }
}
