@font-face {
    font-family: 'Sancreek';
    src: url('Fonts/Sancreek-Regular.ttf') format('truetype');
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    min-height: 100%;
    margin: 0;
    background-image: url('img/5_Fondo/paisaje.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

h1 {
    color: black;
    font-size: 4em;
    margin-top: 100px;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    font-family: 'Sancreek', sans-serif;
    letter-spacing: 0.1em;
}

canvas {
    background-color: black;
    border-radius: 20px;
    background-image: url('img/9_juego_modelos/iniciar/startscreen_1.png');
    background-size: cover;
    background-position: -74px center;
    display: block;
}

#gameContainer {
    position: relative;
    display: inline-block;
    width: 720px;
    height: 480px;
}

.impressum-footer-link {
    position: fixed;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    background: rgba(245, 232, 201, 0.92);
    border: 1px solid rgba(76, 43, 12, 0.35);
    color: #2f1705;
    font-size: 1.05em;
    font-family: 'Sancreek', sans-serif;
    letter-spacing: 0.08em;
    cursor: pointer;
    z-index: 40;
    padding: 8px 18px;
    border-radius: 999px;
    text-decoration: none;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(4px);
    display: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.impressum-footer-link:hover {
    color: #1c0d02;
    background: rgba(255, 240, 207, 0.98);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.34);
    text-decoration: none;
    transform: translateX(-50%) scale(1.03);
}

@media only screen and (min-width: 820px) and (min-height: 820px) {
    .impressum-footer-link {
        display: block;
    }
}

.mobile-controls {
    position: absolute;
    left: 0;
    right: 0;
    top: auto;
    bottom: 14px;
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    z-index: 220;
    pointer-events: none;
    box-sizing: border-box;
}

.touch-device .mobile-controls {
    display: flex;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
}

.mobile-controls.hidden {
    display: none !important;
}

.mobile-controls-left,
.mobile-controls-right {
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.mobile-control-btn {
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.mobile-control-btn img {
    width: 34px;
    height: 34px;
    object-fit: contain;
    pointer-events: none;
}

@media (hover: none) and (pointer: coarse) and (min-width: 820px) and (min-height: 700px) {
    .mobile-controls {
        position: fixed;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: min(720px, calc(100vw - 32px));
        bottom: calc(14px + env(safe-area-inset-bottom, 0px));
        padding: 0 20px;
    }

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

    .mobile-control-btn {
        width: 72px;
        height: 72px;
    }

    .mobile-control-btn img {
        width: 42px;
        height: 42px;
    }
}

/* Start Screen Styles */
#startScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 720px;
    height: 480px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    border-radius: 20px;
}

#startScreen.hidden {
    display: none;
}

.button-container {
    display: flex;
    gap: 30px;
    flex-direction: row;
    position: absolute;
    bottom: 5px;
}

.start-button,
.option-button {
    padding: 12px 30px;
    font-size: 1.2em;
    font-family: 'Sancreek', sans-serif;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.start-button {
    background-color: #B47807;
    color: black;
}

.start-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(180, 120, 7, 0.6);
}

.option-button {
    background-color: #B47807;
    color: black;
}

.option-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(180, 120, 7, 0.6);
}

/* Mute Button */
.mute-button {
    position: absolute;
    top: 10px;
    left: calc(50% - 25px);
    width: 50px;
    height: 50px;
    border: none;
    background-color: rgba(180, 120, 7, 0.9);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

.mute-button img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

.mute-button:hover {
    background-color: #B47807;
    transform: scale(1.1);
}

.mute-button.hidden {
    display: none;
}

/* Settings Button */
.settings-button {
    position: absolute;
    top: 10px;
    left: calc(50% - 80px);
    width: 50px;
    height: 50px;
    border: none;
    background-color: rgba(180, 120, 7, 0.9);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

.settings-button img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

.settings-button:hover {
    background-color: #B47807;
    transform: scale(1.1);
}

.settings-button.hidden {
    display: none;
}

/* Game Over Screen */
.game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('img/Pierde_o\ _gana/You\ lost.png');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 200;
    border-radius: 20px;
}

.game-over-screen.hidden {
    display: none;
}

/* Restart Button */
.restart-button {
    padding: 12px 40px;
    font-size: 1.2em;
    font-family: 'Sancreek', sans-serif;
    background-color: #B47807;
    color: black;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    margin-bottom: 20px;
}

.restart-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(180, 120, 7, 0.6);
}

/* Game Won Screen */
.game-won-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('img/Pierde_o _gana/You won A.png');
    background-size: 720px 380px;
    background-position: top center;
    background-repeat: no-repeat;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 200;
    border-radius: 20px;
}

@media only screen and (max-width: 900px), only screen and (max-height: 700px) {
    .game-won-screen {
        background-size: contain;
    }
}

.game-won-screen.hidden {
    display: none;
}

/* Options Menu */
.options-menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 150;
    border-radius: 20px;
}

.options-menu.hidden {
    display: none;
}

.options-content {
    text-align: center;
    background-color: rgba(180, 120, 7, 0.95);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
}

.options-content h2 {
    color: black;
    margin-top: 0;
    margin-bottom: 30px;
    font-family: 'Sancreek', sans-serif;
    font-size: 2em;
}

.option-menu-button {
    display: block;
    width: 200px;
    padding: 12px 20px;
    margin: 10px auto;
    font-size: 1.1em;
    font-family: 'Sancreek', sans-serif;
    background-color: #333;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}

.option-menu-button:hover {
    background-color: #555;
    transform: scale(1.05);
}

/* Controls Menu */
.controls-menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 150;
    border-radius: 20px;
}

.controls-menu.hidden {
    display: none;
}

.controls-content {
    text-align: center;
    background-color: rgba(180, 120, 7, 0.95);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
    max-width: 500px;
}

.controls-content h2 {
    color: black;
    margin-top: 0;
    margin-bottom: 30px;
    font-family: 'Sancreek', sans-serif;
    font-size: 2em;
}

.controls-content p {
    color: black;
    font-size: 1em;
    margin: 15px 0;
    text-align: left;
    font-family: Arial, sans-serif;
}

/* Game Explanation Menu */
.game-explanation-menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 150;
    border-radius: 20px;
    overflow-y: auto;
}

.game-explanation-menu.hidden {
    display: none;
}

.game-explanation-content {
    text-align: center;
    background-color: rgba(180, 120, 7, 0.95);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
    max-width: 550px;
}

.game-explanation-content h2 {
    color: black;
    margin-top: 0;
    margin-bottom: 30px;
    font-family: 'Sancreek', sans-serif;
    font-size: 2em;
}

.game-explanation-content p {
    color: black;
    font-size: 1em;
    margin: 15px 0;
    text-align: left;
    font-family: Arial, sans-serif;
}

.game-explanation-content strong {
    font-weight: bold;
    color: #333;
}

/* Impressum Menu */
.impressum-menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 150;
    border-radius: 20px;
    overflow-y: auto;
}

.impressum-menu.hidden {
    display: none;
}

.impressum-content {
    text-align: center;
    background-color: rgba(180, 120, 7, 0.95);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
    max-width: 550px;
}

.impressum-content h2 {
    color: black;
    margin-top: 0;
    margin-bottom: 30px;
    font-family: 'Sancreek', sans-serif;
    font-size: 2em;
}

.impressum-content p {
    color: black;
    font-size: 0.95em;
    margin: 12px 0;
    text-align: left;
    font-family: Arial, sans-serif;
}

.impressum-content strong {
    font-weight: bold;
    color: #333;
}

/* Rotate Overlay */
.rotate-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    background-color: #FE8905;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    margin: 0;
    padding: 0;
}

.rotate-content {
    text-align: center;
    color: white;
}

.rotate-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    animation: rotate 2s ease-in-out infinite;
}

@keyframes rotate {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

.rotate-content p {
    font-size: 1.5em;
    font-family: 'Sancreek', sans-serif;
    color: #B47807;
    margin: 0;
    padding: 10px;
}

/* Responsive Styles */
@media only screen and (max-width: 1024px) {
    h1 {
        font-size: 3em;
        margin-top: 50px;
        margin-bottom: 20px;
    }
}

/* Mobile Portrait - Show Rotate Overlay */
@media only screen and (max-width: 768px) and (orientation: portrait) {
    html, body {
        width: 100vw !important;
        height: 100vh !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .rotate-overlay {
        display: flex !important;
        position: fixed !important;
        inset: 0 !important;
    }
}

/* Mobile Landscape - Fullscreen Game (all mobile devices in landscape) */
@media only screen and (max-height: 768px) and (orientation: landscape) {
    .touch-device .impressum-footer-link {
        display: none !important;
    }

    .rotate-overlay {
        display: none !important;
    }

    body {
        background-size: cover;
        justify-content: center;
        padding: 0;
        margin: 0;
        overflow: hidden;
    }

    body > div {
        width: 100vw !important;
        height: 100vh !important;
        display: block !important;
        background-color: black !important;
    }

    h1 {
        display: none !important;
    }

    canvas {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        object-fit: fill !important;
        background-position: center center !important;
        background-size: cover !important;
    }

    #startScreen {
        width: 100vw !important;
        height: 100vh !important;
        border-radius: 0;
        top: 0 !important;
        left: 0 !important;
    }

    .game-over-screen,
    .game-won-screen {
        border-radius: 0;
    }

    .mute-button,
    .settings-button {
        width: 45px;
        height: 45px;
        top: 15px;
    }

    .mute-button {
        left: calc(50% - 22.5px);
        right: auto;
    }

    .settings-button {
        left: calc(50% - 77.5px);
        right: auto;
    }

    .mute-button img,
    .settings-button img {
        width: 26px;
        height: 26px;
    }

    .start-button,
    .option-button {
        padding: 12px 30px;
        font-size: 1.1em;
    }

    .restart-button {
        padding: 12px 35px;
        font-size: 1.1em;
    }

    .options-content,
    .controls-content,
    .game-explanation-content,
    .impressum-content {
        padding: 20px 25px;
        max-width: 85%;
        max-height: 85vh;
        overflow-y: auto;
    }

    .options-content h2,
    .controls-content h2,
    .game-explanation-content h2,
    .impressum-content h2 {
        font-size: 1.3em;
        margin-top: 0;
        margin-bottom: 15px;
    }

    .controls-content p,
    .game-explanation-content p,
    .impressum-content p {
        font-size: 0.85em;
        margin: 8px 0;
        line-height: 1.3;
    }

    .option-menu-button {
        width: 180px;
        font-size: 0.9em;
        padding: 8px 15px;
        margin: 8px auto;
    }

    .options-menu,
    .controls-menu,
    .game-explanation-menu,
    .impressum-menu {
        border-radius: 0;
    }

    .mobile-controls {
        display: flex !important;
    }
}

/* Mobile Portrait - Show Rotate Overlay */
@media only screen and (max-width: 480px) and (orientation: portrait) {
    html, body {
        width: 100vw !important;
        height: 100vh !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .rotate-overlay {
        display: flex !important;
        position: fixed !important;
        inset: 0 !important;
    }
}

/* Mobile Landscape - Fullscreen Game */
@media only screen and (max-width: 480px) and (orientation: landscape) {
    .touch-device .impressum-footer-link {
        display: none !important;
    }

    .rotate-overlay {
        display: none !important;
    }

    body {
        overflow: hidden;
    }

    body > div {
        width: 100vw !important;
        height: 100vh !important;
        display: block !important;
        background-color: black !important;
    }

    h1 {
        display: none;
    }

    canvas {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        object-fit: fill !important;
        background-position: center center !important;
        background-size: cover !important;
    }

    #startScreen {
        width: 100vw !important;
        height: 100vh !important;
        border-radius: 0;
        top: 0 !important;
        left: 0 !important;
    }

    .mute-button,
    .settings-button {
        width: 40px;
        height: 40px;
        top: 10px;
    }

    .mute-button {
        left: calc(50% - 20px);
        right: auto;
    }

    .settings-button {
        left: calc(50% - 70px);
        right: auto;
    }

    .mute-button img,
    .settings-button img {
        width: 22px;
        height: 22px;
    }

    .start-button,
    .option-button {
        padding: 10px 25px;
        font-size: 1em;
    }

    .button-container {
        gap: 20px;
    }

    .restart-button {
        padding: 10px 30px;
        font-size: 1em;
        margin-bottom: 20px;
    }

    .options-content,
    .controls-content,
    .game-explanation-content,
    .impressum-content {
        padding: 15px 20px;
        max-width: 90%;
        max-height: 85vh;
        overflow-y: auto;
    }

    .options-content h2,
    .controls-content h2,
    .game-explanation-content h2,
    .impressum-content h2 {
        font-size: 1.2em;
        margin-top: 0;
        margin-bottom: 12px;
    }

    .controls-content p,
    .game-explanation-content p,
    .impressum-content p {
        font-size: 0.8em;
        margin: 6px 0;
        line-height: 1.2;
    }

    .option-menu-button {
        width: 160px;
        font-size: 0.85em;
        padding: 8px 12px;
        margin: 6px auto;
    }

    .game-won-screen {
        background-size: contain;
    }

    .mobile-controls {
        display: flex !important;
        bottom: 10px;
        padding: 0 10px;
    }

    .mobile-control-btn {
        width: 50px;
        height: 50px;
    }

    .mobile-control-btn img {
        width: 30px;
        height: 30px;
    }
}

@media (hover: none) and (pointer: coarse) and (max-width: 819px) {
    .touch-device .impressum-footer-link {
        display: none !important;
    }

    .mobile-controls {
        display: flex;
    }
}
