body {
    font-family: "Press Start 2P", system-ui;
    background-color: #f8f9fa;
    /* Evitar el pull-to-refresh en móviles y scroll horizontal */
    overscroll-behavior-y: contain;
    overflow-x: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.marcador_general {
    font-family: "Press Start 2P", system-ui;
    font-weight: 400;
    font-style: normal;
    background: rgba(245, 255, 245, 0.9);
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 100, 0, 0.15);
    max-width: 600px;
    margin: 0 auto;
}

#jugador_nivel {
    font-size: 0.75rem;
    letter-spacing: 1px;
    color: #333;
}

.progress {
    background-color: #ddd;
    border-radius: 12px;
    height: 18px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.barra_progreso {
    background-color: #0d6efd;
    transition: width 0.3s ease, background-color 0.3s ease;
}

/* ═══ Name Popup ═══ */
.name-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(0, 80, 0, 0.85) 0%, rgba(0, 40, 0, 0.95) 100%);
    backdrop-filter: blur(8px);
    z-index: 9999;
}

.name-popup-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    max-width: 380px;
    width: 90%;
    animation: popupSlideIn 0.5s ease-out;
}

.name-popup-card h4 {
    font-family: "Press Start 2P", system-ui;
    font-size: 0.9rem;
    color: #198754;
}

.name-popup-card input {
    font-family: "Press Start 2P", system-ui;
    font-size: 0.7rem;
    border: 2px solid #198754;
    border-radius: 12px;
    padding: 12px;
}

.name-popup-card input:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.15);
}

@keyframes popupSlideIn {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ═══ Slider táctil ═══ */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    margin: 15px 0;
    background: transparent;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 12px;
    cursor: pointer;
    background: #ced4da;
    border-radius: 10px;
    border: 1px solid #adb5bd;
}

input[type=range]::-webkit-slider-thumb {
    height: 36px;
    width: 36px;
    border-radius: 50%;
    background: #0d6efd;
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -13px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

input[type=range]:disabled::-webkit-slider-thumb {
    background: #6c757d;
}

input[type=range]::-moz-range-track {
    width: 100%;
    height: 12px;
    cursor: pointer;
    background: #ced4da;
    border-radius: 10px;
    border: 1px solid #adb5bd;
}

input[type=range]::-moz-range-thumb {
    height: 36px;
    width: 36px;
    border-radius: 50%;
    background: #0d6efd;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* ═══ Controls bar ═══ */
.controls-ui {
    z-index: 1050;
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
    background: rgba(245, 255, 245, 0.9);
}

.controls-ui button {
    touch-action: manipulation;
}

/* ═══ Botones flechas (desktop) ═══ */
.arrow-btn {
    border-radius: 12px;
    font-size: 1.2rem;
    transition: transform 0.1s ease, background-color 0.1s ease, box-shadow 0.1s ease;
    border: 2px solid #adb5bd;
    color: #495057;
}

.arrow-btn:not(:disabled):hover {
    background-color: #e9ecef;
    border-color: #6c757d;
}

.arrow-btn:not(:disabled):active,
.arrow-btn.arrow-pressed {
    transform: scale(0.92);
    background-color: #F3E3D0;
    border-color: #F3E3D0;
    color: #fff;
    box-shadow: 0 0 10px #D2C4B4;
}

.arrow-btn:disabled {
    opacity: 0.4;
}

#game-container {
    background-color: transparent;
}

#game-container canvas {
    background: transparent !important;
}

/* ═══ Overlays ═══ */
.start-game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    z-index: 10;
}

.end-game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    color: white;
    z-index: 9998;
}

#end-game-content h5 {
    font-family: "Press Start 2P", system-ui;
    font-size: 0.85rem;
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.25);
}

#end-game-content p {
    font-family: "Roboto", sans-serif;
    font-weight: 500;
    color: #333;
    font-optical-sizing: auto;
}

#end-game-content button {
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.25);
}

#end-game-content .btn-replay:hover {
    filter: brightness(1.15);
    transform: scale(1.03);
    transition: all 0.15s ease;
}


#end-game-content {
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.nivel-materialomagico {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: contain;
    margin: 10px 0;
}

/* ═══ Stats grid (end game) ═══ */
.stats-grid {
    margin: 12px 0;
    text-align: left;
}

.stats-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.stats-label {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    color: #444;
    white-space: nowrap;
}

.stats-bar-container {
    width: 100%;
    height: 14px;
    background: #e9ecef;
    border-radius: 7px;
    overflow: hidden;
}

.stats-bar {
    height: 100%;
    border-radius: 7px;
    transition: width 0.4s ease;
    min-width: 4px;
}

.stats-count {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.5rem;
    font-weight: bold;
    color: #333;
    min-width: 32px;
    text-align: right;
}

/* ═══ Caneca activa (UX feedback) ═══ */
.caneca-btn {
    position: relative;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.caneca-activa {
    transform: scale(1.08);
    z-index: 2;
}

.caneca-organicos.caneca-activa {
    box-shadow: 0 0 0 3px #198754, 0 4px 15px rgba(25, 135, 84, 0.5) !important;
}

.caneca-reciclables.caneca-activa {
    box-shadow: 0 0 0 3px #6c757d, 0 4px 15px rgba(108, 117, 125, 0.5) !important;
}

.caneca-no-reciclables.caneca-activa {
    box-shadow: 0 0 0 3px #212529, 0 4px 15px rgba(33, 37, 41, 0.5) !important;
}

/* ═══ Tecla badge (desktop) ═══ */
.tecla-badge {
    display: inline-block;
    font-family: monospace;
    font-size: 0.55rem;
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: middle;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

#btn-blanco .tecla-badge {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

/* ═══ Micro-Tutorial ═══ */
.tutorial-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 20;
    color: white;
    transition: opacity 0.5s ease-out;
}

.tutorial-title {
    font-size: 0.75rem;
    line-height: 1.4;
    max-width: 250px;
    color: #4DFFBE;
}

.tutorial-grid {
    display: flex;
    justify-content: center;
    gap: 15px;
    width: 100%;
}

.tutorial-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.tutorial-item img {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.badge-tut {
    font-family: "Press Start 2P", system-ui;
    font-size: 0.45rem;
    padding: 4px 8px;
    border-radius: 4px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.badge-organico { background-color: #198754; color: white; }
.badge-reciclable { background-color: #6c757d; color: white; }
.badge-no-reciclable { background-color: #212529; color: white; }

.fade-out {
    opacity: 0 !important;
    pointer-events: none;
}

/* ═══ Comentario Final ═══ */
#comentario-text {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-family: inherit;
    font-size: 0.65rem;
    border-radius: 8px;
    resize: none;
    transition: all 0.2s ease;
}

#comentario-text:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: #4DFFBE;
    box-shadow: 0 0 10px rgba(77, 255, 190, 0.3);
    outline: none;
}

#comentario-text::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

#btn-toggle-comentario {
    font-size: 0.65rem;
    transition: color 0.2s;
}

#btn-toggle-comentario:hover {
    color: #4DFFBE !important;
}