/* --- MODALES --- */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.92);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 400;
    font-family: 'Courier New', monospace;
    animation: modalFadeIn 0.15s ease;
}
@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: scale(1); }
}

.modal-content {
    background: #000;
    border: 3px solid #fff;
    width: 85%;
    max-width: 560px;
    max-height: 82vh;
    overflow: hidden;
    color: #fff;
    text-align: center;
    position: relative;
}

/* Barra de título estilo NES */
.modal-titlebar {
    background: #fff;
    color: #000;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-titlebar .modal-close-x {
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    background: #000;
    color: #fff;
    border: none;
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    font-family: monospace;
    flex-shrink: 0;
}
.modal-titlebar .modal-close-x:hover { background: #e00; }

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(82vh - 44px);
}

/* ── OPCIONES ─────────────────────────────────────────────────── */
.option-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #222;
    font-size: 13px;
    letter-spacing: 2px;
}
.option-row:last-of-type { border-bottom: none; }
.option-row span { color: #aaa; }

/* Toggle switch estilo pixel */
.pixel-toggle {
    position: relative;
    width: 48px; height: 24px;
    cursor: pointer;
}
.pixel-toggle input { display: none; }
.pixel-toggle-track {
    width: 100%; height: 100%;
    background: #333;
    border: 2px solid #555;
    display: flex;
    align-items: center;
    padding: 2px;
    transition: background 0.1s;
}
.pixel-toggle input:checked + .pixel-toggle-track { background: #00aa00; border-color: #0f0; }
.pixel-toggle-thumb {
    width: 16px; height: 16px;
    background: #fff;
    transition: transform 0.1s;
}
.pixel-toggle input:checked + .pixel-toggle-track .pixel-toggle-thumb {
    transform: translateX(24px);
}

.pixel-select {
    background: #111;
    color: #fff;
    border: 2px solid #555;
    padding: 4px 8px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    letter-spacing: 1px;
    cursor: pointer;
}
.pixel-select:focus { outline: none; border-color: #fff; }

.option-save-btn {
    display: block;
    width: calc(100% - 32px);
    margin: 16px auto 0;
    background: #000;
    color: #0f0;
    border: 2px solid #0f0;
    padding: 10px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    letter-spacing: 3px;
    cursor: pointer;
    transition: all 0.1s;
}
.option-save-btn:hover { background: #0f0; color: #000; }

/* ── GALERÍA ──────────────────────────────────────────────────── */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
    margin: 4px 0 16px;
}
.gallery-item {
    background: #0a0a0a;
    border: 2px solid #333;
    padding: 10px 6px;
    text-align: center;
    filter: grayscale(1);
    opacity: 0.4;
    transition: 0.2s;
    cursor: default;
}
.gallery-item p     { color: #fff; font-size: 11px; margin: 6px 0 2px; letter-spacing: 1px; }
.gallery-item small { color: #555; font-size: 9px; }
.gallery-item.unlocked {
    filter: none;
    opacity: 1;
    border-color: #ffcc00;
    box-shadow: 0 0 8px rgba(255,200,0,0.3);
}
.gallery-item.unlocked small { color: #ffcc00; }
.gallery-item img { width: 72px; height: 72px; image-rendering: pixelated; }

/* ── CRÉDITOS — patos volando detrás del texto ───────────────── */
.credits-scene {
    position: relative;
    width: 100%;
    height: 360px;
    background: #000;
    overflow: hidden;
}

#credits-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    image-rendering: pixelated;
}

.credits-text-overlay {
    position: relative;
    z-index: 2;
    padding: 20px 32px 32px;
    /* Sin overflow — el scroll lo hace la animación translateY */
    overflow: visible;
    height: auto;
    text-align: center;
    /* Empieza desde abajo del contenedor y sube */
    animation: creditsScroll 22s linear forwards;
    animation-delay: 0.5s;
    transform: translateY(100%);
}
@keyframes creditsScroll {
    0%   { transform: translateY(100%); }
    100% { transform: translateY(-100%); }
}

/* Bloque del título */
.c-title-wrap { margin-bottom: 20px; }

.c-title-divider {
    width: 60%;
    height: 2px;
    background: linear-gradient(to right, transparent, #e07000, transparent);
    margin: 6px auto 8px;
}

/* Título principal animado */
.c-title {
    font-size: 20px;
    font-weight: bold;
    color: #ffcc00;
    letter-spacing: 5px;
    margin-bottom: 4px;
    text-shadow: 0 0 10px #ff8800, 2px 2px 0 #000;
    transition: opacity 0.3s;
}
.c-title-anim { display: inline-block; }
.c-title-fade { opacity: 0; }

.c-end { margin-top: 28px; font-size: 16px; }

.c-sub {
    font-size: 10px;
    color: #888;
    letter-spacing: 3px;
    margin-bottom: 4px;
}

.c-section {
    font-size: 11px;
    color: #00e5cc;
    letter-spacing: 3px;
    margin: 20px 0 6px;
    text-shadow: 0 0 6px #00e5cc;
}

.c-line {
    font-size: 12px;
    color: #ccc;
    letter-spacing: 2px;
    margin: 3px 0;
    text-shadow: 1px 1px 0 #000;
}

/* Nombre del dev destacado */
.c-highlight {
    color: #ffcc00;
    font-size: 13px;
    letter-spacing: 3px;
    text-shadow: 0 0 8px #ff8800, 1px 1px 0 #000;
}

.c-special {
    font-size: 14px;
    color: #ff6688;
    letter-spacing: 3px;
    margin: 6px 0;
    text-shadow: 0 0 8px #ff3366, 1px 1px 0 #000;
}

/* Repositorio */
.c-repo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 6px 0;
}
.c-repo-icon { color: #888; font-size: 14px; }
.c-repo-link {
    color: #7ec8ff;
    font-size: 11px;
    letter-spacing: 1px;
    text-decoration: none;
    border-bottom: 1px solid rgba(126,200,255,0.4);
    transition: color 0.2s;
}
.c-repo-link:hover { color: #fff; border-color: #fff; }

.c-version {
    font-size: 9px;
    color: #444;
    letter-spacing: 3px;
    margin: 16px 0 4px;
}

/* ── PAUSA ────────────────────────────────────────────────────── */
.pause-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 0 4px;
}
.pause-opt {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 14px;
    color: #e07000;
    letter-spacing: 3px;
    border-bottom: 1px solid #1a1a1a;
    transition: color 0.1s;
    outline: none;
}
.pause-opt:last-child { border-bottom: none; }
.pause-opt .p-arrow { color: #fff; visibility: hidden; }
.pause-opt:hover,
.pause-opt.selected { color: #fff; }
.pause-opt:hover .p-arrow,
.pause-opt.selected .p-arrow { visibility: visible; }
.pause-stat {
    display: flex;
    justify-content: space-around;
    padding: 14px 20px;
    border-bottom: 2px solid #222;
    margin-bottom: 4px;
}
.pause-stat-item { text-align: center; }
.pause-stat-item .ps-label { font-size: 9px; color: #555; letter-spacing: 2px; }
.pause-stat-item .ps-val   { font-size: 20px; color: #fff; }

/* Botón PAUSA — dentro del HUD como último elemento */
#pause-btn {
    background: transparent;
    border: 2px solid rgba(255,255,255,0.6);
    color: #fff;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 1px;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.1s;
    flex-shrink: 0;
    /* Área táctil generosa para móvil */
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#pause-btn:hover  { background: #fff; color: #000; border-color: #fff; }
#pause-btn:active { transform: scale(0.94); }

@media (max-width: 768px) {
    #pause-btn {
        font-size: 14px;
        min-width: 48px;
        min-height: 48px;
        border-color: rgba(255,255,255,0.8);
    }
}

/* ── MODO HISTORIA ────────────────────────────────────────────── */
.story-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.97);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 500;
    font-family: 'Courier New', monospace;
    animation: modalFadeIn 0.3s ease;
}
.story-overlay.story-fade-out {
    animation: storyFadeOut 0.35s ease forwards;
}
@keyframes storyFadeOut {
    to { opacity: 0; transform: scale(1.03); }
}

.story-box {
    background: #000;
    border: 3px solid #00e5cc;
    width: 90%;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0, 229, 204, 0.25);
}

/* Barra de progreso */
.story-progress-bar {
    height: 4px;
    background: #111;
    width: 100%;
}
.story-progress-fill {
    height: 100%;
    background: #00e5cc;
    transition: width 0.35s ease;
}

/* Slide de historia */
.story-slide {
    padding: 36px 32px 28px;
    text-align: center;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    animation: storySlideIn 0.25s ease;
}
@keyframes storySlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.story-slide-icon {
    font-size: 52px;
    line-height: 1;
    filter: drop-shadow(0 0 12px rgba(255,200,0,0.5));
}

.story-slide-text {
    color: #ddd;
    font-size: 14px;
    line-height: 1.8;
    letter-spacing: 1px;
    white-space: pre-line;
    max-width: 400px;
}

.story-slide-title {
    color: #ffcc00;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 4px;
    text-shadow: 0 0 8px #ff8800;
    margin-bottom: 4px;
}

/* Slide de controles */
.story-slide-controls {
    gap: 12px;
}

.story-controls-block {
    width: 100%;
}

.story-ctrl-title {
    color: #00e5cc;
    font-size: 11px;
    letter-spacing: 4px;
    margin-bottom: 12px;
    text-shadow: 0 0 6px #00e5cc;
}

.story-ctrl-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
}

.story-ctrl-item {
    background: #0a0a0a;
    border: 1px solid #222;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #aaa;
    letter-spacing: 1px;
    text-align: center;
}

.story-ctrl-key {
    background: #1a1a1a;
    border: 2px solid #555;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 2px;
    padding: 4px 8px;
    font-family: 'Courier New', monospace;
}

.story-ctrl-icon {
    font-size: 22px;
}

/* Navegación */
.story-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-top: 2px solid #111;
    background: #050505;
}

.story-dots {
    display: flex;
    gap: 6px;
}
.story-dot {
    width: 8px;
    height: 8px;
    background: #333;
    border: 1px solid #555;
    transition: background 0.2s;
}
.story-dot.active {
    background: #00e5cc;
    border-color: #00e5cc;
    box-shadow: 0 0 6px #00e5cc;
}

.story-btn {
    background: transparent;
    border: 2px solid #444;
    color: #888;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 2px;
    padding: 8px 14px;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 80px;
    min-height: 40px;
}
.story-btn:hover { border-color: #fff; color: #fff; }

.story-btn-next,
.story-btn-play {
    border-color: #00e5cc;
    color: #00e5cc;
}
.story-btn-next:hover,
.story-btn-play:hover {
    background: #00e5cc;
    color: #000;
}

.story-btn-play {
    border-color: #ffcc00;
    color: #ffcc00;
    font-size: 13px;
    letter-spacing: 3px;
}
.story-btn-play:hover {
    background: #ffcc00;
    color: #000;
    box-shadow: 0 0 12px rgba(255,200,0,0.4);
}

.story-btn-skip {
    border-color: #333;
    color: #555;
    font-size: 11px;
}
.story-btn-skip:hover { border-color: #888; color: #888; }

@media (max-width: 480px) {
    .story-slide { padding: 24px 20px 20px; min-height: 180px; }
    .story-slide-icon { font-size: 40px; }
    .story-slide-text { font-size: 12px; }
    .story-ctrl-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .story-btn { font-size: 11px; padding: 7px 10px; min-width: 64px; }
}
