/* =====================================================
   RESET / BASE
===================================================== */

* {
    padding: 0;
    margin: 0;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100dvh;
}

body#game-container {
    position: relative;
    margin: 0;
    overflow: hidden;
}

.d-none {
    display: none !important;
}

button:hover {
    cursor: pointer;
}

#startButton:active,
#controlsButton:active,
#impressumButton:active,
#fullscreenButton:active,
#backButton:active,
#respawnButton:active,
#backToMenuButton:active,
#restartButton:active,
#mobile-controls button:active {
    transform: scale(0.9);
    opacity: 1;
}


/* =====================================================
   CANVAS
===================================================== */

canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: black;
}


/* =====================================================
   FULLSCREEN
===================================================== */

body#game-container:fullscreen {
    width: 100vw;
    height: 100vh;

    background: black;

    display: flex;
    justify-content: center;
    align-items: center;

    overflow: hidden;
}

body#game-container:fullscreen canvas {
    width: 100vw;
    height: 100vh;

    object-fit: contain;
    background: black;
}

body#game-container:fullscreen #startscreen,
body#game-container:fullscreen #controlscreen,
body#game-container:fullscreen #victoryscreen {
    width: 100vw;
    height: 100vh;
}


/* =====================================================
   START SCREEN
===================================================== */

#startscreen {
    position: absolute;
    width: 100%;
    height: 100%;

    background-image: url("./assets/img/5_background/first_half_background.png");
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    color: white;
    z-index: 20;
    font-family: Arial, sans-serif;
    text-align: center;
}

#startscreen h1 {
    font-size: 4rem;
    margin-bottom: 2rem;
    text-shadow: 0 0 10px #ffcc00, 0 0 20px #ff9900;
}

#startscreen p {
    margin-top: 1.5rem;
    font-size: 1.2rem;
    color: #ccc;
    text-shadow: 0 0 5px #000;
}

#startButton,
#controlsButton,
#impressumButton,
#fullscreenButton {
    display: block;
    width: min(80%, 300px);
    margin: 1rem auto;
    padding: 1rem 2rem;

    font-size: 1.5rem;
    color: white;

    background: linear-gradient(45deg, #ff6600, #ffcc00);
    border: none;
    border-radius: 12px;

    cursor: pointer;
    box-shadow: 0 0 20px rgba(255, 204, 0, 0.5);
    transition: all 0.3s ease;
    animation: glow 2s infinite alternate;
}

#startButton:hover,
#controlsButton:hover,
#impressumButton:hover,
#fullscreenButton:hover {
    transform: scale(1.1);
    box-shadow: 0 0 40px rgba(255, 204, 0, 0.9);
}


/* =====================================================
   CONTROL SCREEN
===================================================== */

#controlscreen {
    position: absolute;
    inset: 0;

    background:
        radial-gradient(circle at center, rgba(255, 153, 0, 0.18), transparent 35%),
        linear-gradient(135deg, #1a1a1a, #000000);

    display: flex;
    justify-content: center;
    align-items: center;

    color: white;
    z-index: 20;
    font-family: Arial, sans-serif;
    text-align: center;
}

.controls-panel {
    width: min(90%, 480px);
    padding: 32px 36px;

    border: 2px solid rgba(255, 204, 0, 0.65);
    border-radius: 18px;
    background: rgba(0, 0, 0, 0.65);
    box-shadow: 0 0 25px rgba(255, 153, 0, 0.35);
}

#controlscreen h2 {
    font-size: 3rem;
    margin-bottom: 2rem;

    text-shadow: 0 0 10px #ffcc00, 0 0 20px #ff9900;
    animation: pulse 1.5s infinite alternate;
}

.controls-list {
    display: flex;
    flex-direction: column;
    gap: 14px;

    margin-bottom: 2rem;
}

.control-row {
    display: grid;
    grid-template-columns: 110px 1fr;
    align-items: center;
    gap: 18px;

    font-size: 1.35rem;
}

.control-key {
    display: inline-flex;
    justify-content: center;
    align-items: center;

    min-width: 54px;
    height: 46px;
    padding: 0 14px;

    border: 2px solid #ffcc00;
    border-radius: 10px;

    background: linear-gradient(180deg, #3a2a00, #111);
    color: #ffcc00;
    font-weight: bold;

    box-shadow: 0 4px 0 #7a4a00, 0 0 12px rgba(255, 204, 0, 0.35);
}

.control-key-wide {
    min-width: 86px;
}

.control-action {
    text-align: left;
    color: #ffffff;
    text-shadow: 0 0 5px #000;
}

.keyboard-controls-info {
    display: flex;
}

.touch-controls-info {
    display: none;
}

#backButton {
    padding: 1rem 2rem;
    margin-top: 2rem;

    font-size: 1.5rem;
    color: white;

    background: linear-gradient(45deg, #ff6600, #ffcc00);
    border: none;
    border-radius: 12px;

    cursor: pointer;
    box-shadow: 0 0 20px rgba(255, 204, 0, 0.5);
    transition: all 0.3s ease;
    animation: glow 2s infinite alternate;
}

#backButton:hover {
    transform: scale(1.1);
    box-shadow: 0 0 40px rgba(255, 204, 0, 0.9);
}


/* =====================================================
   GAME OVER / VICTORY
===================================================== */

.gameover-overlay {
    position: fixed;
    inset: 0;

    background: black;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    z-index: 100;
    animation: fadeInGameOver 0.8s ease forwards;
}

.gameover-panel {
    display: flex;
    flex-direction: column;
    align-items: center;

    font-family: Arial, sans-serif;
    text-align: center;
}

.gameover-title {
    margin-bottom: 16px;

    color: #ffcc00;
    font-size: 64px;
    letter-spacing: 3px;

    text-shadow: 0 0 10px #ff6600, 0 0 24px #ff0000;
}

.gameover-subtitle {
    color: #e6e6e6;
    font-size: 28px;
    letter-spacing: 2px;
}

.gameover-buttons {
    position: absolute;
    bottom: 48px;
    left: 50%;
    transform: translateX(-50%);

    display: flex;
    gap: 24px;
    justify-content: center;
    align-items: center;
}

#respawnButton,
#backToMenuButton {
    min-width: 170px;
    padding: 12px 26px;

    font-size: 18px;
    font-weight: bold;
    color: #fff7d6;

    border: 2px solid #ffcc00;
    border-radius: 12px;

    background: linear-gradient(180deg, rgba(80, 45, 0, 0.95), rgba(20, 10, 0, 0.95));

    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;

    box-shadow:
        0 4px 0 #7a4a00,
        0 0 16px rgba(255, 204, 0, 0.35);
}

#respawnButton:hover,
#backToMenuButton:hover {
    transform: translateY(-2px);
    background: linear-gradient(180deg, rgba(120, 70, 0, 0.98), rgba(35, 15, 0, 0.98));
    box-shadow:
        0 6px 0 #7a4a00,
        0 0 24px rgba(255, 204, 0, 0.6);
}

#respawnButton:active,
#backToMenuButton:active {
    transform: translateY(2px);
    box-shadow:
        0 2px 0 #7a4a00,
        0 0 10px rgba(255, 204, 0, 0.35);
}

#victoryscreen {
    position: absolute;
    width: 100%;
    height: 100%;

    background-image: url("./assets/img/You won, you lost/You won A.png");
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
}

/* #restartButton {
    padding: 10px 26px;

    font-size: 18px;
    color: #ccc;

    border: 1px solid #666;
    background: #00000087;

    cursor: pointer;
    transition: 0.2s ease;
} */

#victoryBackButton,
#restartButton {
    min-width: 170px;
    padding: 12px 26px;

    font-size: 18px;
    font-weight: bold;
    color: #fff7d6;

    border: 2px solid #ffcc00;
    border-radius: 12px;

    background: linear-gradient(180deg, rgba(80, 45, 0, 0.95), rgba(20, 10, 0, 0.95));

    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;

    box-shadow:
        0 4px 0 #7a4a00,
        0 0 16px rgba(255, 204, 0, 0.35);
}

#victoryBackButton:hover,
#restartButton:hover {
    transform: translateY(-2px);
    background: linear-gradient(180deg, rgba(120, 70, 0, 0.98), rgba(35, 15, 0, 0.98));
    box-shadow:
        0 6px 0 #7a4a00,
        0 0 24px rgba(255, 204, 0, 0.6);
}

#victoryBackButton:active,
#restartButton:active {
    transform: translateY(2px);
    box-shadow:
        0 2px 0 #7a4a00,
        0 0 10px rgba(255, 204, 0, 0.35);
}

#restartButton:hover {
    border-color: orange;
    background: #00000099;
}

.end-screen-buttons {
    position: absolute;
    bottom: 48px;
    left: 50%;
    transform: translateX(-50%);

    display: flex;
    gap: 24px;
    justify-content: center;
    align-items: center;
}


/* =====================================================
   MOBILE CONTROLS
===================================================== */

#mobile-controls {
    display: none;
    position: absolute;
    inset: 0;

    pointer-events: none;
    z-index: 15;
}

#mobile-controls button {
    pointer-events: auto;

    width: 56px;
    height: 56px;

    border: 2px solid #ffcc00;
    border-radius: 50%;

    background: rgba(0, 0, 0, 0.55);
    color: white;

    font-size: 1.5rem;
}

.left-controls,
.right-controls {
    display: flex;
    gap: 12px;
}


/* =====================================================
   ROTATE SCREEN
===================================================== */

#rotateScreen {
    position: fixed;
    inset: 0;

    background: black;
    color: white;

    display: none;
    justify-content: center;
    align-items: center;
    text-align: center;

    z-index: 200;
    font-size: 1.5rem;
    padding: 20px;
}


/* =====================================================
   IMPRESSUM
===================================================== */

.game-footer {
    position: fixed;
    bottom: 10px;
    left: 0;

    width: 100%;
    text-align: center;

    z-index: 9999;
}

.game-footer a {
    color: white;
    background: rgba(0, 0, 0, 0.6);

    padding: 8px 12px;
    border-radius: 8px;

    text-decoration: none;
}

.game-footer a:hover {
    background: rgba(0, 0, 0, 0.9);
}

#impressumOverlay {
    position: fixed;
    inset: 0;

    background: rgba(0, 0, 0, 0.75);

    display: flex;
    justify-content: center;
    align-items: center;

    z-index: 100;
}

.impressumContent {
    position: relative;

    width: 400px;
    max-width: 90%;
    padding: 30px;

    background: rgb(0, 0, 0);
    color: white;

    border-radius: 12px;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.4);

    text-align: left;
    font-family: Arial, sans-serif;
}

.impressumContent h1 {
    margin-top: 0;
}

.impressumContent h2 {
    margin-top: 20px;
    margin-bottom: 5px;
}

.impressumContent p {
    margin: 0 0 10px;
    line-height: 1.5;
}

.impressumContent a {
    color: #007bff;
    text-decoration: none;
}

.impressumContent a:hover {
    text-decoration: underline;
}

.closeBtn {
    position: absolute;
    top: 10px;
    right: 10px;

    background: none;
    color: white;

    border: none;

    font-size: 20px;
    cursor: pointer;
}


/* =====================================================
   HUD / EFFECTS
===================================================== */

#muteButton {
    position: absolute;
    top: 20px;
    right: 20px;

    padding: 10px;

    font-size: 24px;
    cursor: pointer;

    z-index: 30;
}

#screen-flash {
    position: absolute;
    inset: 0;

    background: red;
    opacity: 0;

    pointer-events: none;
    transition: opacity 0.2s ease;

    z-index: 40;
}


/* =====================================================
   ANIMATIONS
===================================================== */

@keyframes fadeButton {
    to {
        opacity: 1;
    }
}


/* =====================================================
   GENERAL RESPONSIVE
===================================================== */

@media (max-width: 768px) {
    #startscreen h1 {
        font-size: 2.5rem;
    }

    #startscreen p {
        font-size: 1rem;
        padding: 0 20px;
    }

    #startButton,
    #controlsButton,
    #impressumButton,
    #fullscreenButton {
        width: 80%;
        font-size: 1.2rem;
        padding: 0.8rem;
        margin: 0.5rem auto;
    }

    #controlscreen h2 {
        font-size: 2rem;
    }

    #backButton {
        font-size: 1.2rem;
        padding: 0.8rem;
    }

    .gameover-title {
        font-size: 44px;
        text-align: center;
        padding: 0 20px;
    }

    .gameover-subtitle {
        font-size: 22px;
        text-align: center;
        padding: 0 20px;
    }

    #respawnButton,
    #restartButton,
    #backToMenuButton {
        font-size: 16px;
        padding: 8px 20px;
    }

    .end-screen-buttons,
    .gameover-buttons {
        bottom: 32px;
        gap: 14px;
    }

    #victoryBackButton,
    #restartButton,
    #respawnButton,
    #backToMenuButton {
        min-width: 130px;
        padding: 10px 16px;
        font-size: 15px;
    }
}

/* =====================================================
   CONTROL SCREEN RESPONSIVE
===================================================== */

@media (pointer: coarse) {
    .keyboard-controls-info {
        display: none;
    }

    .touch-controls-info {
        display: flex;
    }

    .controls-panel {
        width: min(92%, 420px);
        padding: 24px 20px;
    }

    #controlscreen h2 {
        font-size: 2.2rem;
        margin-bottom: 1.5rem;
    }

    .controls-list {
        gap: 12px;
        margin-bottom: 1.5rem;
    }

    .control-row {
        grid-template-columns: 90px 1fr;
        gap: 14px;
        font-size: 1.1rem;
    }

    .control-key {
        min-width: 46px;
        height: 40px;
        padding: 0 10px;

        font-size: 1rem;
        border-radius: 8px;
    }

    .control-key-wide {
        min-width: 74px;
    }

    .control-action {
        font-size: 1.05rem;
    }
}

@media (pointer: coarse) and (max-width: 420px) {
    .controls-panel {
        width: 92%;
        padding: 20px 16px;
    }

    .control-row {
        grid-template-columns: 80px 1fr;
        gap: 12px;
        font-size: 1rem;
    }

    .control-key {
        min-width: 42px;
        height: 36px;
        padding: 0 8px;

        font-size: 0.9rem;
    }

    .control-key-wide {
        min-width: 66px;
    }
}

@media (pointer: coarse) and (max-height: 700px) {
    .controls-panel {
        width: 90%;
        padding: 14px 16px;
        border-radius: 14px;
    }

    #controlscreen h2 {
        font-size: 1.8rem;
        margin-bottom: 0.8rem;
    }

    .controls-list {
        gap: 8px;
        margin-bottom: 1rem;
    }

    .control-row {
        grid-template-columns: 72px 1fr;
        gap: 10px;
        font-size: 0.95rem;
    }

    .control-key {
        min-width: 36px;
        height: 30px;
        padding: 0 8px;

        font-size: 0.85rem;
        border-radius: 7px;

        box-shadow: 0 3px 0 #7a4a00, 0 0 8px rgba(255, 204, 0, 0.3);
    }

    .control-key-wide {
        min-width: 58px;
    }

    .control-action {
        font-size: 0.95rem;
    }
}

@media (pointer: coarse) and (min-height: 701px) {
    .touch-controls-info .control-row {
        grid-template-columns: 100px 1fr;
        gap: 16px;

        font-size: 1.2rem;
    }

    .touch-controls-info .control-key {
        min-width: 54px;
        height: 46px;
        padding: 0 14px;

        font-size: 1.15rem;
        border-radius: 10px;
    }

    .touch-controls-info .control-action {
        font-size: 1.15rem;
    }
}

@media (pointer: coarse) and (min-height: 850px) {
    .touch-controls-info .control-key {
        min-width: 64px;
        height: 54px;

        font-size: 1.35rem;
    }

    .touch-controls-info .control-action {
        font-size: 1.3rem;
    }
}


/* =====================================================
   INGAME MOBILE CONTROLS RESPONSIVE
===================================================== */

@media (pointer: coarse) {
    #mobile-controls.mobile-controls-visible {
        display: flex;
        justify-content: space-between;
        align-items: flex-end;

        padding: 0 24px 24px;
        box-sizing: border-box;
    }
}

@media (pointer: coarse) and (max-height: 700px) {
    #mobile-controls button {
        width: 48px;
        height: 48px;

        font-size: 1.25rem;
    }

    .left-controls,
    .right-controls {
        gap: 12px;
    }
}

@media (pointer: coarse) and (min-height: 701px) {
    #mobile-controls button {
        width: 68px;
        height: 68px;

        font-size: 1.8rem;
    }

    .left-controls,
    .right-controls {
        gap: 18px;
    }
}

@media (pointer: coarse) and (min-height: 850px) and (min-width: 700px) {
    #mobile-controls button {
        width: 86px;
        height: 86px;

        font-size: 2.1rem;
    }

    .left-controls,
    .right-controls {
        gap: 24px;
    }
}

@media (pointer: coarse) and (max-height: 700px) {

    .end-screen-buttons,
    .gameover-buttons {
        bottom: 20px;
        gap: 10px;
    }

    #victoryBackButton,
    #restartButton,
    #respawnButton,
    #backToMenuButton {
        min-width: 115px;
        padding: 8px 12px;
        font-size: 14px;
    }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
    #startscreen {
        padding: 12px 20px;
        box-sizing: border-box;
    }

    #startscreen h1 {
        font-size: clamp(2rem, 6vw, 3rem);
        margin-bottom: 0.75rem;
    }

    #startButton,
    #controlsButton,
    #impressumButton,
    #fullscreenButton {
        width: min(70vw, 260px);
        padding: 0.55rem 1rem;
        margin: 0.35rem auto;
        font-size: 1rem;
        border-radius: 10px;
    }

    .gameover-title {
        font-size: clamp(2rem, 8vh, 3rem);
        margin-bottom: 8px;
    }

    .gameover-subtitle {
        font-size: clamp(1rem, 4vh, 1.3rem);
    }

    .gameover-buttons,
    .end-screen-buttons {
        bottom: 12px;
        gap: 10px;
    }

    #victoryBackButton,
    #restartButton,
    #respawnButton,
    #backToMenuButton {
        min-width: 115px;
        padding: 8px 12px;
        font-size: 14px;
    }

    #victoryscreen {
        background-size: auto 72%;
        background-position: center 42%;
    }

    #muteButton {
        top: 12px;
        right: 12px;
        padding: 6px;
        font-size: 20px;
    }
}


/* =====================================================
   ORIENTATION
===================================================== */

@media (orientation: portrait) {
    #rotateScreen {
        display: flex;
    }

    canvas,
    #startscreen,
    #controlscreen,
    #victoryscreen {
        display: none !important;
    }
}