:root {
    --neon-green: #39ff14;
    --dark-bg: #111;
    --panel-bg: rgba(0, 0, 0, 0.85);
    --border-color: #2a2a2a;
}

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

body {
    font-family: 'Rajdhani', sans-serif;
    color: white;
    background-color: #000;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

/* Background Texture Layer */
.page-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #111;
    background-image:
        /* Vertical dashed lines on sides */
        linear-gradient(90deg,
            transparent 5%,
            rgba(57, 255, 20, 0.4) 5.5%,
            rgba(57, 255, 20, 0.4) 6.5%,
            transparent 7%,
            transparent 93%,
            rgba(57, 255, 20, 0.4) 93.5%,
            rgba(57, 255, 20, 0.4) 94.5%,
            transparent 95%),
        /* Asphalt texture */
        url('02 IMAGES/asphalt.png');
    background-repeat: repeat-y, repeat;
    background-size: 100% 100px, 512px;
    z-index: -1;
    filter: brightness(0.7);
}

/* Main Content Column */
.main-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    background: #000;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    min-height: 100vh;
    border-left: 3px dashed rgba(57, 255, 20, 0.3);
    border-right: 3px dashed rgba(57, 255, 20, 0.3);
}

/* Header & Logo */
header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin-bottom: 1rem;
    width: 100%;
}

/* Fila con Zerf + logo + Zerf espejado */
.header-logo-row {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 1.2rem;
    width: 100%;
    margin-bottom: 0.4rem;
}

.zerf-deco {
    height: 160px;
    width: auto;
    flex-shrink: 0;
    image-rendering: pixelated; /* Pixel art nítido */
    filter: drop-shadow(0 0 8px rgba(57, 255, 20, 0.35));
}

.zerf-deco-right {
    transform: scaleX(-1); /* Espejo horizontal */
}

.logo {
    display: block;
    margin: 0 auto 0.2rem auto;
    max-width: 350px;
    width: 100%;
    height: auto;
}

/* Creator credit styling below */

.start-instruction {
    background: rgba(57, 255, 20, 0.1);
    border: 1px solid var(--neon-green);
    color: var(--neon-green);
    padding: 0.8rem;
    border-radius: 4px;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
    text-align: center;
    display: inline-block;
    margin: 0 auto;
    /* Force centering */
}

.blink {
    animation: blinker 1.5s linear infinite;
}

@keyframes blinker {
    50% {
        opacity: 0;
    }
}

/* Game Iframe */
.game-wrapper {
    width: 100%;
    /* Godot con HiDPI activo gestiona la escala interna — el CSS sólo mantiene la proporción */
    aspect-ratio: 1280 / 720;
    height: auto;
    border: 4px solid #444;
    background: #000;
    margin-bottom: 2rem;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#game-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Controls Section */
.controls-section {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0;
    padding: 1.5rem;
    margin-bottom: 2rem;
    /* Increased to 2rem to match */
    border: 4px solid #444;
}

.controls-section h2 {
    font-family: 'Press Start 2P', cursive;
    font-size: 1.2rem;
    color: var(--neon-green);
    text-align: center;
    margin-bottom: 1.5rem;
    text-shadow: 2px 2px 0px #000;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    justify-items: center;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    /* Ensure full width for justification */
}

.key-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: bold;
    font-size: 1.2rem;
}

.key {
    background: #e0e0e0;
    color: #000;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    box-shadow: 0 3px 0 #999;
    font-family: sans-serif;
    min-width: 40px;
    text-align: center;
}

.key.wide {
    padding: 0.4rem 2rem;
}

.or {
    color: #888;
    font-size: 0.9rem;
}

.action {
    color: #ccc;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 100%;
    text-align: center;
}

.story-section {
    max-width: 800px;
    margin: 0 auto 2rem auto;
    /* Reset top margin to 0 or 2rem, spacing is handled by controls-section bottom margin */
    text-align: center;
    color: #ccc;
    font-size: 0.95rem;
    line-height: 1.6;
    background: rgba(0, 0, 0, 0.4);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    border: 3px dashed rgba(57, 255, 20, 0.3);
}

.story-section p {
    margin-bottom: 1rem;
}

.story-section p:last-child {
    margin-bottom: 0;
}

.story-section a {
    color: var(--neon-green);
    text-decoration: none;
    border-bottom: none;
    transition: all 0.2s;
    font-weight: bold;
}

.story-section a:hover {
    color: #fff;
    border-bottom: none;
    text-shadow: 0 0 5px var(--neon-green);
}

/* Footer */
footer {
    margin-top: auto;
    padding-top: 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    position: relative;
    /* Ensure it doesn't overlap absolutely positioned elements */
}

.footer-buttons {
    display: flex;
    flex-wrap: wrap;
    /* Changed from nowrap for better wrapping */
    gap: 0.8rem;
    justify-content: center;
    align-items: center;
}

.pdf-btn {
    display: inline-block;
    background: #222;
    color: #fff;
    text-decoration: none;
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    border: 1px solid #444;
    transition: all 0.2s;
    font-weight: bold;
    white-space: nowrap;
}

.pdf-btn:hover {
    background: var(--neon-green) !important;
    color: #000 !important;
    transform: translateY(-2px);
    box-shadow: 0 0 15px var(--neon-green);
}

.creator-credit {
    position: absolute;
    bottom: 1rem;
    right: 2rem;
    font-size: 0.85rem;
    color: #555;
    text-align: right;
    z-index: 10;
}

.creator-credit a {
    color: #777;
    text-decoration: none;
    transition: color 0.2s;
}

.creator-credit a:hover {
    color: var(--neon-green);
}

/* Ocultar Zerf en móvil Y en tablets/iPad (puntero táctil o pantalla <= 1024px) */
@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
    .zerf-deco {
        display: none !important;
    }
}

/* En cualquier dispositivo táctil (móvil, tablet, iPad de cualquier tamaño):
   - Mostrar el aviso rojo de "solo teclado"
   - Ocultar el aviso verde de escritorio */
@media (hover: none) and (pointer: coarse) {
    .mobile-only {
        display: block !important;
        color: #ff3e3e !important;
        font-weight: bold;
        padding: 1rem;
        border: 2px solid #ff3e3e;
        margin: 0.5rem 0;
        text-align: center;
    }
    .desktop-only {
        display: none !important;
    }
    /* Ocultar el juego y los controles en táctil — no son jugables */
    .game-wrapper {
        display: none !important;
    }
    .controls-section {
        display: none !important;
    }
}

.mobile-only {
    display: none;
}

/* Responsive */
@media (max-width: 800px) {
    .main-container {
        padding: 1rem;
        border-left: 3px dashed rgba(57, 255, 20, 0.3);
        border-right: 3px dashed rgba(57, 255, 20, 0.3);
    }

    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block !important;
        color: #ff3e3e !important;
        /* Red for warning */
        font-weight: bold;
        padding: 1rem;
        border: 2px solid #ff3e3e;
        margin: 0.5rem 0;
        text-align: center;
    }

    .logo {
        max-width: 85%;
        margin-top: 0.5rem;
    }

    .game-wrapper {
        display: none;
    }

    .controls-section {
        display: none;
    }

    .footer-buttons {
        flex-direction: column !important;
        width: 100%;
        gap: 1.2rem;
        display: flex !important;
    }

    .pdf-btn {
        width: 100% !important;
        max-width: 300px;
        text-align: center;
        padding: 1.2rem;
        font-size: 1.1rem;
        display: block !important;
    }

    .story-section {
        margin: 0 0 2rem 0;
        /* Match spacing */
        padding: 1.2rem;
        font-size: 0.9rem;
    }

    .creator-credit {
        position: static !important;
        margin: 4rem auto 1rem auto;
        /* Even more space from 3rem to 4rem */
        text-align: center;
        width: 100%;
        color: #555;
    }
}

/* Accessibility */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}