/* ========================================
   FLAPPY CEMETERY - Neon 80s Style
   ======================================== */

:root {
    /* Paleta Neon Anos 80 */
    --neon-green: #39FF14;
    --neon-pink: #FF10F0;
    --dark-bg: #000000;
    --gray-dark: #1a1a1a;
    --gray-medium: #404040;
    --gray-light: #808080;

    /* Sombras Neon */
    --glow-green: 0 0 10px #39FF14, 0 0 20px #39FF14, 0 0 30px #39FF14;
    --glow-pink: 0 0 10px #FF10F0, 0 0 20px #FF10F0, 0 0 30px #FF10F0;
}

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

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

body {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    background-color: var(--dark-bg);
    color: var(--neon-green);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    /* Mobile FIX: Considera safe areas (notch, barras de navegação) */
    height: 100dvh; /* dvh = dynamic viewport height (melhor para mobile) */
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none; /* Previne scroll no mobile */
    /* Mobile FIX: Padding para safe-areas */
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

/* ========================================
   GAME CONTAINER
   ======================================== */

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100dvh;
    background-color: var(--dark-bg);
    overflow: hidden;
}

/* Canvas */
#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background-color: var(--dark-bg);
    cursor: pointer;
}

/* ========================================
   UI OVERLAY
   ======================================== */

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Permite cliques passarem para o canvas */
}

/* ========================================
   SCOREBOARD
   ======================================== */

#scoreboard {
    position: absolute;
    top: 20px;
    right: 20px;
    text-align: right;
    pointer-events: none;
    z-index: 10;
}

.score-label {
    font-size: 14px;
    letter-spacing: 2px;
    color: var(--neon-pink);
    margin-bottom: 5px;
}

#score-value {
    font-size: 48px;
    font-weight: bold;
    color: var(--neon-green);
    line-height: 1;
    margin-bottom: 30px;
}

.top-score-label {
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--neon-pink);
    margin-bottom: 3px;
    margin-top: 10px;
    opacity: 0.8;
}

#top-score-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--neon-green);
    line-height: 1;
    opacity: 0.8;
}

/* ========================================
   SCREENS (Start & Game Over)
   ======================================== */

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    background-image: url('sprites/bg.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 100;
    pointer-events: all;
}

.screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(2px);
    z-index: -1;
}

.screen.active {
    display: flex;
}

.screen-content {
    text-align: center;
    padding: 40px;
}

/* ========================================
   TÍTULOS & TEXTOS
   ======================================== */

.game-logo {
    max-width: 400px;
    width: 80%;
    height: auto;
    margin-bottom: 20px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.game-title {
    font-size: 72px;
    font-weight: bold;
    color: var(--neon-pink);
    text-shadow: var(--glow-pink);
    margin-bottom: 20px;
    line-height: 0.9;
    letter-spacing: 4px;
}

.game-subtitle {
    font-size: 16px;
    color: var(--gray-light);
    margin-bottom: 40px;
    letter-spacing: 1px;
}

.credits {
    font-size: 10px;
    color: var(--gray-light);
    margin-top: 30px;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.credits a {
    color: var(--neon-green);
    text-decoration: none;
    transition: all 0.3s ease;
}

.credits a:hover {
    color: var(--neon-pink);
    text-shadow: 0 0 10px var(--neon-pink);
}

.gameover-title {
    font-size: 56px;
    font-weight: bold;
    color: var(--neon-pink);
    margin-bottom: 50px;
    letter-spacing: 3px;
}

.final-score {
    margin: 40px 0 50px 0;
}

.final-score .score-label {
    margin-bottom: 50px;
}

#final-score-value {
    font-size: 64px;
    font-weight: bold;
    color: var(--neon-green);
}

/* ========================================
   BOTÕES NEON
   ======================================== */

.neon-button {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 2px;
    padding: 15px 40px;
    background-color: transparent;
    color: var(--neon-green);
    border: 3px solid var(--neon-green);
    box-shadow: var(--glow-green);
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    pointer-events: all;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

#start-button {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    margin-bottom: 0;
}

#start-button.ready {
    opacity: 1;
    pointer-events: all;
}

.neon-button:hover {
    background-color: var(--neon-green);
    color: var(--dark-bg);
    transform: scale(1.05);
}

.neon-button:active {
    transform: scale(0.98);
}

.share-button {
    margin-top: 15px;
    font-size: 14px;
    padding: 12px 30px;
    opacity: 0.8;
}

.share-button:hover {
    opacity: 1;
}

.instructions-button {
    margin-top: 20px;
    font-size: 14px;
    padding: 12px 30px;
    opacity: 0.7;
}

.instructions-button:hover {
    opacity: 1;
}

.leaderboard-button {
    margin-top: 20px;
    font-size: 14px;
    padding: 12px 30px;
    opacity: 0.7;
}

.leaderboard-button:hover {
    opacity: 1;
}

/* ========================================
   MOBILE HINT
   ======================================== */

#mobile-hint {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: var(--gray-light);
    letter-spacing: 1px;
    opacity: 0.7;
    z-index: 5;
}

.mobile-only {
    display: none;
}

.desktop-only-text {
    display: block;
}

/* ========================================
   SHARE NOTIFICATION
   ======================================== */

.share-notification {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--neon-green);
    color: var(--dark-bg);
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 12px;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: var(--glow-green);
    z-index: 200;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    text-align: center;
    max-width: 80%;
    line-height: 1.5;
}

.share-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ========================================
   RESPONSIVIDADE
   ======================================== */

/* Mobile Portrait */
@media screen and (max-width: 768px) and (orientation: portrait) {
    /* Mobile FIX: Garante visibilidade do ground */
    body {
        height: 100dvh;
        padding-bottom: max(env(safe-area-inset-bottom, 0px), 20px);
    }

    #game-container {
        width: 100%;
        height: 100%;
        /* Mobile FIX: Força altura dinâmica para compensar safe-areas */
        max-height: calc(100dvh - env(safe-area-inset-bottom, 0px));
    }

    #gameCanvas {
        /* Mobile FIX: Ajusta canvas para não ser cortado */
        height: 100% !important;
    }

    .game-logo {
        max-width: 300px;
    }

    .game-title {
        font-size: 36px;
    }

    .gameover-title {
        font-size: 28px;
        margin-bottom: 30px;
    }

    .final-score {
        margin: 25px 0 35px 0;
    }

    .final-score .score-label {
        margin-bottom: 10px;
    }

    #final-score-value {
        font-size: 36px;
    }

    #score-value {
        font-size: 24px;
        margin-bottom: 30px;
    }

    .score-label {
        font-size: 10px;
    }

    .top-score-label {
        font-size: 8px;
        margin-top: 10px;
    }

    #top-score-value {
        font-size: 14px;
    }

    .neon-button {
        font-size: 12px;
        padding: 10px 25px;
    }

    .share-button {
        font-size: 11px;
        padding: 8px 20px;
        margin-top: 15px;
    }

    .instructions-button {
        font-size: 11px;
        padding: 8px 20px;
        margin-top: 15px;
    }

    .leaderboard-button {
        font-size: 11px;
        padding: 8px 20px;
        margin-top: 15px;
    }

    .share-notification {
        font-size: 10px;
        padding: 12px 20px;
        max-width: 90%;
    }

    .mobile-only {
        display: block;
    }

    .desktop-only-text {
        display: none;
    }

    #scoreboard {
        top: 50px;
        right: 10px;
    }
}

/* Mobile Landscape */
@media screen and (max-width: 768px) and (orientation: landscape) {
    /* Mobile FIX: Garante visibilidade do ground em landscape */
    body {
        height: 100dvh;
        padding-bottom: max(env(safe-area-inset-bottom, 0px), 15px);
    }

    #game-container {
        width: 100%;
        height: 100%;
        /* Mobile FIX: Força altura dinâmica para compensar safe-areas */
        max-height: calc(100dvh - env(safe-area-inset-bottom, 0px));
    }

    #gameCanvas {
        /* Mobile FIX: Ajusta canvas para não ser cortado */
        height: 100% !important;
    }

    .game-title {
        font-size: 48px;
    }

    .gameover-title {
        font-size: 36px;
        margin-bottom: 40px;
    }

    #score-value {
        font-size: 32px;
        margin-bottom: 24px;
    }

    .score-label {
        font-size: 11px;
    }

    .top-score-label {
        font-size: 9px;
        margin-top: 8px;
    }

    #top-score-value {
        font-size: 18px;
    }

    .neon-button {
        font-size: 16px;
        padding: 12px 30px;
    }

    .share-button {
        font-size: 13px;
        padding: 10px 25px;
    }

    .share-notification {
        font-size: 11px;
        padding: 12px 20px;
    }

    .mobile-only {
        display: block;
    }

    .desktop-only-text {
        display: none;
    }

    #scoreboard {
        top: 50px;
        right: 10px;
    }
}

/* Desktop */
@media screen and (min-width: 769px) {
    #game-container {
        width: 100vw;
        height: 100vh;
    }
}

/* Extra Small Devices */
@media screen and (max-height: 400px) {
    .game-title {
        font-size: 36px;
    }

    .gameover-title {
        font-size: 28px;
        margin-bottom: 20px;
    }

    .final-score {
        margin: 15px 0 20px 0;
    }

    .final-score .score-label {
        margin-bottom: 8px;
    }

    #final-score-value {
        font-size: 32px;
    }

    .screen-content {
        padding: 20px;
    }

    .neon-button {
        font-size: 14px;
        padding: 10px 25px;
    }

    .share-button {
        font-size: 12px;
        padding: 8px 20px;
    }

    .share-notification {
        font-size: 9px;
        padding: 10px 15px;
    }
}

/* ========================================
   LOADER
   ======================================== */

.loader {
    border: 4px solid var(--gray-dark);
    border-top: 4px solid var(--neon-green);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 30px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loader-text {
    font-size: 14px;
    color: var(--neon-green);
    text-shadow: var(--glow-green);
    letter-spacing: 1px;
    text-align: center;
    margin-top: 20px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

@media screen and (max-width: 768px) {
    .loader {
        width: 40px;
        height: 40px;
        margin-bottom: 20px;
    }

    .loader-text {
        font-size: 11px;
    }
}

/* ========================================
   TUTORIAL MODAL (HOW TO PLAY)
   ======================================== */

.tutorial-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('sprites/bg.webp') center center / cover no-repeat;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 20px;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.tutorial-modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: -1;
}

.tutorial-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.tutorial-content {
    position: relative;
    z-index: 1;
    background: rgba(26, 26, 26, 0.95);
    border: 3px solid var(--neon-green);
    border-radius: 16px;
    padding: 40px 30px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 0 40px rgba(57, 255, 20, 0.3);
    animation: modalFadeIn 0.4s ease;
    pointer-events: auto;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.tutorial-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    position: relative;
}

.tutorial-title {
    font-size: 24px;
    color: var(--neon-green);
    text-align: center;
    letter-spacing: 2px;
    text-shadow: 0 0 10px var(--neon-green);
}

.lang-flag {
    width: 32px;
    height: 32px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    border-radius: 4px;
}

.lang-flag:hover {
    transform: scale(1.1);
    border-color: var(--neon-pink);
    box-shadow: 0 0 10px var(--neon-pink);
}

.tutorial-section {
    margin-bottom: 30px;
}

.section-title {
    font-size: 14px;
    color: var(--neon-pink);
    margin-bottom: 15px;
    text-shadow: 0 0 8px var(--neon-pink);
}

.control-info {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    border-left: 3px solid var(--neon-blue);
}

.control-icon {
    font-size: 32px;
    min-width: 40px;
    text-align: center;
}

.control-text {
    font-size: 11px;
    line-height: 1.6;
    color: var(--gray-light);
}

.enemies-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.enemy-card {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--neon-pink);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
}

.enemy-sprite {
    width: 80px;
    height: 80px;
    margin: 0 auto 10px;
    background: rgba(255, 16, 240, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.enemy-sprite img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    image-rendering: pixelated;
}

.enemy-name {
    font-size: 10px;
    color: var(--neon-pink);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.enemy-desc {
    font-size: 8px;
    color: var(--gray-light);
    line-height: 1.5;
}

.tip-box {
    background: rgba(57, 255, 20, 0.1);
    border: 2px solid var(--neon-green);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.tip-title {
    font-size: 10px;
    color: var(--neon-green);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tip-text {
    font-size: 9px;
    color: var(--gray-light);
    line-height: 1.6;
}

.tutorial-content .close-button {
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    width: 100%;
    padding: 18px;
    background: var(--gray-dark);
    color: var(--neon-green);
    border: 2px solid var(--neon-green);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.tutorial-content .close-button:hover {
    background: var(--neon-green);
    color: var(--dark-bg);
    box-shadow: 0 0 20px var(--neon-green);
    transform: translateY(-2px);
}

/* Mobile adjustments for tutorial modal */
@media (max-width: 768px) {
    .tutorial-content {
        padding: 30px 20px;
        max-height: 85vh;
    }

    .tutorial-title {
        font-size: 18px;
    }

    .section-title {
        font-size: 12px;
    }

    .control-info {
        flex-direction: column;
        text-align: center;
    }

    .enemies-grid {
        grid-template-columns: 1fr;
    }

    .control-text, .tip-text {
        font-size: 10px;
    }

    .enemy-desc {
        font-size: 9px;
    }
}

/* Custom scrollbar for tutorial */
.tutorial-content::-webkit-scrollbar {
    width: 8px;
}

.tutorial-content::-webkit-scrollbar-track {
    background: var(--gray-dark);
}

.tutorial-content::-webkit-scrollbar-thumb {
    background: var(--neon-green);
    border-radius: 4px;
}

.tutorial-content::-webkit-scrollbar-thumb:hover {
    background: var(--neon-pink);
}

/* ========================================
   LEADERBOARD MODAL
   ======================================== */

.leaderboard-content {
    max-width: 500px;
}

.leaderboard-list {
    margin: 30px 0;
    min-height: 400px;
}

.leaderboard-loading {
    text-align: center;
    color: var(--gray-light);
    font-size: 14px;
    padding: 40px 0;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: rgba(57, 255, 20, 0.05);
    border: 2px solid var(--gray-medium);
    border-radius: 8px;
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.leaderboard-entry:hover {
    background: rgba(57, 255, 20, 0.1);
    border-color: var(--neon-green);
    transform: translateX(5px);
}

.leaderboard-rank {
    font-size: 14px;
    font-weight: bold;
    color: var(--neon-pink);
    min-width: 40px;
    text-align: center;
}

.leaderboard-name {
    flex: 1;
    font-size: 11px;
    color: var(--neon-green);
    letter-spacing: 0.5px;
    padding: 0 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-score {
    font-size: 13px;
    font-weight: bold;
    color: var(--gray-light);
    min-width: 70px;
    text-align: right;
}

/* Highlighting top 3 */
.leaderboard-entry:nth-child(1) .leaderboard-rank { color: #FFD700; } /* Gold */
.leaderboard-entry:nth-child(2) .leaderboard-rank { color: #C0C0C0; } /* Silver */
.leaderboard-entry:nth-child(3) .leaderboard-rank { color: #CD7F32; } /* Bronze */

/* ========================================
   NAME SUBMIT MODAL
   ======================================== */

.name-submit-info {
    text-align: center;
    margin: 20px 0 30px 0;
}

.name-submit-text {
    font-size: 16px;
    color: var(--gray-light);
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.name-submit-subtitle {
    font-size: 14px;
    color: var(--neon-green);
    margin-top: 20px;
    letter-spacing: 1px;
}

.rank-highlight {
    font-size: 24px;
    font-weight: bold;
    color: var(--neon-pink);
    animation: rankBlink 0.8s infinite;
    text-shadow: var(--glow-pink);
}

@keyframes rankBlink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0.6; }
}

.name-input-container {
    margin: 20px 0;
}

.name-input {
    width: 100%;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 16px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.5);
    border: 3px solid var(--neon-green);
    border-radius: 8px;
    color: var(--neon-green);
    text-align: center;
    letter-spacing: 2px;
    text-transform: uppercase;
    outline: none;
    transition: all 0.3s ease;
}

.name-input:focus {
    border-color: var(--neon-pink);
    box-shadow: 0 0 20px rgba(255, 16, 240, 0.3);
}

.name-input::placeholder {
    color: var(--gray-medium);
    opacity: 0.5;
}

.name-error {
    color: var(--neon-pink);
    font-size: 10px;
    text-align: center;
    margin-top: 10px;
    letter-spacing: 1px;
    animation: errorShake 0.3s ease;
}

.name-error.hidden {
    display: none;
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Mobile adjustments for name input */
@media (max-width: 768px) {
    .name-input {
        font-size: 14px;
        padding: 12px;
    }

    .rank-highlight {
        font-size: 20px;
    }
}

/* ========================================
   LIVES INDICATOR (in-game)
   ======================================== */

#lives-indicator {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 10px;
    z-index: 10;
    pointer-events: none;
}

.life-heart {
    font-size: 24px;
    filter: drop-shadow(0 0 5px var(--neon-pink));
    transition: opacity 0.3s ease;
}

.life-heart.lost {
    opacity: 0.3;
    filter: grayscale(100%);
}

@media (max-width: 768px) {
    #lives-indicator {
        top: 15px;
        left: 15px;
    }

    .life-heart {
        font-size: 20px;
    }

    /* Leaderboard adjustments for mobile */
    .leaderboard-entry {
        padding: 10px 12px;
    }

    .leaderboard-rank {
        font-size: 12px;
        min-width: 35px;
    }

    .leaderboard-name {
        font-size: 10px;
        letter-spacing: 0px;
        padding: 0 8px;
    }

    .leaderboard-score {
        font-size: 11px;
        min-width: 60px;
    }
}
