/* Reset e Variáveis de Estilo */
:root {
    --primary: #ff477e;
    --primary-hover: #ff7096;
    --secondary: #7209b7;
    --bg-gradient: linear-gradient(135deg, #0f0c20 0%, #1f1035 50%, #2e0854 100%);
    --card-bg: rgba(255, 255, 255, 0.08);
    --card-border: rgba(255, 255, 255, 0.15);
    --font-retro: 'Press Start 2P', monospace;
    --font-modern: 'Outfit', sans-serif;
    --glow-shadow: 0 0 20px rgba(255, 71, 126, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background: var(--bg-gradient);
    font-family: var(--font-modern);
    color: #ffffff;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Container Geral do Aplicativo */
.app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

/* Glassmorphism Cards & Overlays */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 5, 24, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
    z-index: 10;
    transition: all 0.5s ease;
    overflow-y: auto;
    padding: 15px;
}

.overlay-screen.active {
    display: flex;
}

.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 30px 20px;
    max-width: 500px;
    width: 92%;
    margin: auto;
    text-align: center;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: cardEntrance 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes cardEntrance {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(30px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Estilo do Título e Textos */
.pixel-heart-header-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 10px auto 15px auto;
    width: fit-content;
    height: 72px; /* Espaço para a flutuação vertical */
}

#start-char-canvas {
    image-rendering: pixelated;
    pointer-events: none;
    animation: startCharFloatOnly 1.2s infinite ease-in-out;
}

@keyframes startCharFloatOnly {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-4px) scale(1.06); }
}

.game-title {
    font-family: var(--font-retro);
    font-size: 1.6rem;
    line-height: 2.2rem;
    color: #ffffff;
    text-shadow: 3px 3px 0px var(--primary), 6px 6px 0px var(--secondary);
    margin-bottom: 15px;
    letter-spacing: 1px;
}

.subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 30px;
}

.instructions {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 30px;
    text-align: left;
}

.instructions h3 {
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 12px;
    font-weight: 600;
}

.instructions ul {
    list-style: none;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.85);
}

.instructions li {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.key {
    background: #e0e0e0;
    color: #121212;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: monospace;
    font-weight: bold;
    font-size: 0.9rem;
    margin-right: 10px;
    border-bottom: 3px solid #b0b0b0;
    display: inline-block;
}

.mobile-tip {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 10px;
    text-align: center;
}

/* Botões Estilo Retro/Moderno */
.retro-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 15px 35px;
    font-family: var(--font-retro);
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: var(--glow-shadow);
    transition: all 0.2s ease;
    border: 3px solid transparent;
}

.retro-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 71, 126, 0.7);
}

.retro-btn:active {
    transform: scale(0.98);
}

.retro-btn.secondary {
    background: var(--secondary);
    box-shadow: 0 0 20px rgba(114, 9, 183, 0.4);
    margin-top: 25px;
}

.retro-btn.secondary:hover {
    background: #9d4edd;
    box-shadow: 0 0 30px rgba(114, 9, 183, 0.7);
}

/* Canvas e Container do Jogo */
.game-wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    overflow: hidden;
    background: #000;
}

#gameCanvas {
    flex: 1;
    width: 100%;
    min-height: 0;
    object-fit: fill;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Controles Virtuais para Celular (Barra Dedicada no Rodapé) */
.mobile-controls-container {
    display: none !important;
}

.mobile-controls-container.active {
    position: relative;
    flex-shrink: 0;
    width: 100%;
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px max(45px, calc(env(safe-area-inset-bottom) + 35px)) 16px;
    background: #0b0717;
    border-top: 2px solid rgba(255, 71, 126, 0.4);
    box-sizing: border-box;
    z-index: 100;
}

.d-pad, .action-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
}

.control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.35);
    color: white;
    font-size: 1.4rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    transition: background 0.1s, transform 0.1s;
    touch-action: manipulation;
}

.control-btn:active {
    background: rgba(255, 71, 126, 0.7);
    border-color: #ff477e;
    transform: scale(0.92);
}

.jump-btn {
    width: 85px;
    height: 50px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-family: var(--font-retro);
    background: rgba(255, 71, 126, 0.3);
    border-color: rgba(255, 71, 126, 0.8);
    box-shadow: 0 0 10px rgba(255, 71, 126, 0.3);
}

.fire-btn {
    width: 72px;
    height: 50px;
    border-radius: 25px;
    font-size: 0.8rem;
    font-family: var(--font-retro);
    background: rgba(255, 85, 0, 0.3);
    border-color: rgba(255, 85, 0, 0.8);
    box-shadow: 0 0 10px rgba(255, 85, 0, 0.3);
}

/* Tela de Vitória e Moldura da Foto */
.victory-card {
    max-width: 600px;
}

.congrats-title {
    font-family: var(--font-retro);
    font-size: clamp(0.9rem, 4.5vw, 1.6rem);
    color: #fee440;
    text-shadow: 0 0 15px rgba(254, 228, 64, 0.7);
    margin-bottom: 8px;
    letter-spacing: 1px;
    white-space: nowrap;
    word-break: keep-all;
    animation: congratsPulse 1.5s infinite;
}

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

.victory-title {
    font-family: var(--font-retro);
    font-size: 1.1rem;
    color: #ff477e;
    text-shadow: 0 0 10px rgba(255, 71, 126, 0.5);
    margin-bottom: 25px;
    animation: colorShift 3s infinite alternate;
}

@keyframes colorShift {
    0% { color: #ff477e; }
    100% { color: #f72585; }
}

.photo-frame-container {
    display: flex;
    justify-content: center;
    margin-bottom: 25px;
}

.pixel-frame {
    background: #120a21;
    border: 8px double var(--primary);
    border-radius: 12px;
    padding: 10px;
    position: relative;
    box-shadow: 0 0 25px rgba(255, 71, 126, 0.3);
    overflow: hidden;
    width: 320px;
    height: 320px;
}

#photoCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background: #000;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border-radius: 4px;
}

.photo-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(18, 10, 33, 0.95);
    font-family: var(--font-retro);
    font-size: 0.7rem;
    color: var(--primary);
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
    transition: opacity 0.5s ease;
}

.love-letter-container {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 16px;
    padding: 20px;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.love-letter-text {
    font-size: 1.1rem;
    line-height: 1.6rem;
    color: #ffe5ec;
    font-weight: 400;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    white-space: pre-wrap;
    text-align: center;
}

/* Responsividade Geral */
@media (max-width: 768px) {
    .app-container {
        padding: 10px;
    }
    
    .glass-card {
        padding: 25px 15px;
    }
    
    .game-title {
        font-size: 1.2rem;
        line-height: 1.8rem;
    }

    .congrats-title {
        font-size: clamp(0.85rem, 5.5vw, 1.2rem);
        letter-spacing: 0px;
    }

    .victory-title {
        font-size: 0.85rem;
    }
    
    .pixel-frame {
        width: 250px;
        height: 250px;
    }
    
    .love-letter-text {
        font-size: 0.95rem;
        line-height: 1.4rem;
    }
    
    .retro-btn {
        padding: 12px 25px;
        font-size: 0.8rem;
    }
}

/* Responsividade para Modo Paisagem em Celulares (pouca altura vertical) */
@media (max-height: 600px) {
    .glass-card {
        padding: 12px 18px;
        max-width: 520px;
        border-radius: 16px;
    }
    
    .pixel-heart-header-container {
        height: 35px;
        margin: 0 auto 2px auto;
    }
    
    #start-char-canvas {
        transform: scale(0.6);
    }
    
    .game-title {
        font-size: 1rem;
        line-height: 1.3rem;
        margin-bottom: 4px;
    }
    
    .subtitle {
        font-size: 0.8rem;
        margin-bottom: 6px;
    }
    
    /* No celular na horizontal, esconde os botões de teclado para o botão COMEÇAR JOGO aparecer inteiro */
    .instructions h3, .instructions ul {
        display: none;
    }
    
    .instructions {
        padding: 6px 12px;
        margin-bottom: 8px;
        background: rgba(0, 0, 0, 0.2);
    }

    .mobile-tip {
        margin: 0;
        font-size: 0.8rem;
        color: var(--primary);
        font-weight: 600;
    }
    
    .retro-btn {
        padding: 10px 30px;
        font-size: 0.8rem;
    }
    
    .victory-card {
        max-width: 620px;
        padding: 10px 16px;
    }

    .congrats-title {
        font-size: 1.3rem;
        margin-bottom: 4px;
    }

    .victory-title {
        font-size: 0.9rem;
        margin-bottom: 8px;
    }

    .victory-body {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 15px;
        width: 100%;
        margin-bottom: 6px;
    }

    .photo-frame-container {
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .pixel-frame {
        width: 130px;
        height: 130px;
        padding: 4px;
        border-width: 4px;
    }

    .love-letter-container {
        flex: 1;
        max-height: 145px;
        overflow-y: auto;
        padding: 8px 12px;
    }

    .love-letter-text {
        font-size: 0.85rem;
        line-height: 1.25rem;
    }
}
