/**
 * O Apalpador - Estilos principais
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-background: #2d2d2d;
    --color-panel-bg: rgba(0, 0, 0, 0.5);
    --color-text: #ffffff;
    --color-text-muted: #aaaaaa;
    --color-accent: #f4a261;
    --panel-width: 180px;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--color-background);
    font-family: monospace;
    color: var(--color-text);
}

/* Wrapper principal */
#game-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    gap: 20px;
}

/* Paneis laterais */
.panel {
    width: var(--panel-width);
    height: 540px;
    background: var(--color-panel-bg);
    border: 2px solid #444;
    border-radius: 10px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel h2 {
    font-size: 14px;
    text-align: center;
    color: var(--color-accent);
    border-bottom: 1px solid var(--color-accent);
    padding-bottom: 10px;
}

/* Estatísticas */
.stat-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding-left: 30px;
}

.stat-icon {
    width: 24px;
    height: 24px;
    image-rendering: pixelated;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 18px;
    font-weight: bold;
}

.stat-label {
    font-size: 10px;
    color: var(--color-text-muted);
}

/* Botóns de acción */
.action-btn {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 2px solid var(--color-text-muted);
    border-radius: 5px;
    color: var(--color-text);
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.action-btn:hover {
    border-color: var(--color-accent);
}

.action-btn.placeholder {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Container do xogo */
#game-container {
    width: 960px;
    height: 540px;
    border-radius: 10px;
    overflow: hidden;
}

/* Mensaxe xirar móbil */
#rotate-message {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--color-background);
    color: var(--color-text);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 40px;
    font-size: 16px;
    gap: 20px;
}

#rotate-message .icon {
    font-size: 64px;
}

#rotate-message p {
    max-width: 280px;
    line-height: 1.6;
}

/* Controis táctiles */
#touch-controls {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100px;
    padding: 10px 20px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 1000;
    box-sizing: border-box;
}

#touch-controls .touch-group {
    display: flex;
    gap: 15px;
    pointer-events: auto;
}

#touch-controls .touch-btn {
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    position: relative;
}

/* Frechas con CSS - triángulos perfectos en todos os dispositivos */
#touch-controls .touch-btn.arrow-left::before,
#touch-controls .touch-btn.arrow-right::before,
#touch-controls .touch-btn.arrow-up::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-style: solid;
}

#touch-controls .touch-btn.arrow-left::before {
    border-width: 10px 14px 10px 0;
    border-color: transparent #ffffff transparent transparent;
    transform: translate(-60%, -50%);
}

#touch-controls .touch-btn.arrow-right::before {
    border-width: 10px 0 10px 14px;
    border-color: transparent transparent transparent #ffffff;
    transform: translate(-40%, -50%);
}

#touch-controls .touch-btn.arrow-up::before {
    border-width: 0 12px 16px 12px;
    border-color: transparent transparent #ffffff transparent;
    transform: translate(-50%, -60%);
}

#touch-controls .touch-btn:active,
#touch-controls .touch-btn.pressed {
    background: rgba(244, 162, 97, 0.6);
    border-color: #f4a261;
    transform: scale(0.95);
}

#touch-controls .touch-btn.jump {
    width: 75px;
    height: 75px;
}

#touch-controls .touch-btn.jump.arrow-up::before {
    border-width: 0 14px 20px 14px;
}

/* Media queries */
@media (max-width: 1400px) {
    .panel {
        width: 150px;
    }
}

@media (max-width: 1200px) {
    .panel {
        display: none;
    }
}

@media (orientation: portrait) {
    #game-wrapper {
        display: none;
    }

    #rotate-message {
        display: flex;
    }

    #touch-controls {
        display: none !important;
    }
}

/* Móbil en landscape - mostrar controis táctiles e HUD */
@media (max-width: 1024px) and (orientation: landscape) {
    #touch-controls {
        display: flex;
    }

    #game-container {
        width: 100%;
        height: calc(100dvh - 100px);
        height: calc(100vh - 100px); /* Fallback para navegadores antigos */
        border-radius: 0;
    }

    @supports (height: 100dvh) {
        #game-container {
            height: calc(100dvh - 100px);
        }
    }

    #game-wrapper {
        flex-direction: column;
        gap: 0;
        height: 100dvh;
        height: 100vh; /* Fallback */
    }

    @supports (height: 100dvh) {
        #game-wrapper {
            height: 100dvh;
        }
    }

    .panel {
        display: none;
    }

    /* HUD móbil */
    #mobile-hud {
        display: flex !important;
    }
}

/* HUD móbil - oculto por defecto */
#mobile-hud {
    display: none;
    position: fixed;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    flex-direction: column;
    gap: 8px;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 8px;
    z-index: 1000;
    font-family: monospace;
    font-size: 12px;
    color: #ffffff;
}

#mobile-hud .hud-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

#mobile-hud .hud-item img {
    width: 18px;
    height: 18px;
    image-rendering: pixelated;
}
