@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700;900&display=swap');

:root {
    --bg-dark: #121212;
    --accent: #E91E63;
    --accent-glow: rgba(233, 30, 99, 0.5);
    --mex-green: #006847;
    --mex-red: #CE1126;
    --mex-gold: #FFD700;

    /* Board Colors (Dark Mode) */
    --board-bg: #1e1e1e;
    --cell-bg: #2d2d2d;
    --tile-radius: 8px;

    --transition-speed: 150ms;
}

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

body {
    background-color: var(--bg-dark);
    font-family: 'Montserrat', sans-serif;
    color: #fff;
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url('images/background.png') center/cover no-repeat;
    z-index: -1;
    filter: blur(2px);
}

.screen {
    width: 100%;
    max-width: 440px;
    height: 100%;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top));
    position: absolute;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.screen.hidden,
.modal.hidden,
.overlay-container.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

/* --- SPLASH SCREEN --- */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s ease-out;
}

.splash-logo {
    width: 60%;
    max-width: 300px;
    opacity: 0;
    animation: splashEntrance 1.5s ease-in forwards;
}

@keyframes splashEntrance {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

/* --- MENU SCREEN --- */
.main-menu-screen {
    justify-content: center;
    align-items: center;
}

.menu-container {
    width: 100%;
    text-align: center;
}

.main-logo {
    width: 85%;
    max-width: 320px;
    margin-bottom: 40px;
    filter: drop-shadow(0 0 20px var(--accent-glow));
}

.anim-float {
    animation: float 4s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px);
    }
}

.main-nav {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 80%;
    margin: 0 auto;
}

.menu-btn {
    padding: 16px;
    border-radius: 8px;
    border: 4px solid #000;
    font-size: 16px;
    font-weight: 900;
    cursor: pointer;
    background: #444;
    color: #fff;
    text-decoration: none;
    transition: all 0.1s;
    box-shadow: 4px 4px 0 #000;
    text-transform: uppercase;
}

.menu-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #000;
}

.disabled-btn {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(100%);
    box-shadow: none !important;
    transform: translate(2px, 2px) !important;
}

.menu-btn.primary {
    background: var(--mex-green);
    border-color: #000;
    box-shadow: 4px 4px 0 #000;
}

.menu-btn.donor,
.nav-btn.donor {
    background: #ff8a00;
    /* Vibrant orange for support */
    color: #000;
    border-color: #000;
    box-shadow: 4px 4px 0 #000;
}

.menu-btn.donor:active,
.nav-btn.donor:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #000;
}

/* --- GAME SCREEN --- */
.game-wrapper {
    width: 100%;
    margin: auto 0;
    display: flex;
    flex-direction: column;
}

/* --- GAME HEADER V8 --- */
.header-content-v8 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header-logo-v8 {
    height: 77px;
    max-height: 12vh;
    object-fit: contain;
    filter: drop-shadow(2px 2px 0 #000);
    margin-top: 0;
}

.level-indicator-v8 {
    text-align: left;
}

.level-indicator-v8 small {
    font-size: 10px;
    font-weight: 700;
    color: #aaa;
    letter-spacing: 1px;
}

#current-level {
    display: block;
    font-size: 22px;
    font-weight: 900;
    color: var(--mex-gold);
    text-transform: uppercase;
    text-shadow: 2px 2px 0 #000;
}

/* --- STATS V8 (Above Grid) --- */
.stats-row-v8 {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.stat-box-v8 {
    flex: 1;
    background: #000;
    border: 3px solid #333;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.5);
}

.stat-box-v8 small {
    display: block;
    font-size: 10px;
    font-weight: 900;
    color: var(--mex-red);
    margin-bottom: 4px;
}

.stat-box-v8 span {
    font-size: 24px;
    font-weight: 900;
    color: #fff;
}

/* Reducción del marcador en Game Over */
.final-score-v12 span {
    font-size: 32px;
    /* Smaller than previous 48px or default large */
    font-weight: 900;
    color: var(--mex-gold);
}

.board-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-container {
    width: 100%;
    aspect-ratio: 1/1;
    background: var(--board-bg);
    border-radius: 12px;
    padding: 12px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    touch-action: none;
    box-sizing: border-box;
    /* Force padding to be inside the width */
}

.grid-background {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
    width: 100%;
    height: 100%;
}

.grid-cell {
    background: var(--cell-bg);
    border-radius: 6px;
}

.tile-container {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    bottom: 12px;
    pointer-events: none;
}

.tile {
    position: absolute;
    transition: transform var(--transition-speed) ease-in-out;
    z-index: 10;
    background: transparent;
    border-radius: 4px;
    border: none;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.tile-no-transition {
    transition: none !important;
}

.tile-inner {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 4px;
}

/* Tile Backgrounds by Level (Colores Removidos para que la imagen cubra todo) */
.tile-2,
.tile-4,
.tile-8,
.tile-16,
.tile-32,
.tile-64,
.tile-128,
.tile-256,
.tile-512,
.tile-1024,
.tile-2048,
.tile-4096 {
    border-color: transparent;
    color: transparent;
}

/* Animations */
.tile-new .tile-inner {
    animation: scaleIn 200ms ease-out forwards;
}

.tile-merged {
    z-index: 20;
}

.tile-merged .tile-inner {
    animation: explode 250ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid white;
}

@keyframes scaleIn {
    from {
        transform: scale(0.1);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes explode {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
        filter: brightness(1.5);
    }

    100% {
        transform: scale(1);
    }
}

/* Power Animations */
.tile-shuffling {
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease !important;
    animation: shuffleSpin 0.6s ease-in-out;
}

@keyframes shuffleSpin {
    0% {
        filter: blur(0);
    }

    50% {
        filter: blur(3px);
        opacity: 0.7;
    }

    100% {
        filter: blur(0);
    }
}

.tile-undoing .tile-inner {
    animation: undoSlideBack 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Rewind Undo Animations (Mochada V10) */
.tile-undo-out {
    z-index: 5;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Si el movimiento fue UP, el UNDO desliza hacia abajo (BACK) desde su var(--tx), var(--ty) */
.tile-undo-out-up {
    transform: translate(var(--tx, 0), calc(var(--ty, 0) + 40px)) !important;
    opacity: 0;
    filter: blur(2px) sepia(0.5);
}

.tile-undo-out-down {
    transform: translate(var(--tx, 0), calc(var(--ty, 0) - 40px)) !important;
    opacity: 0;
    filter: blur(2px) sepia(0.5);
}

.tile-undo-out-left {
    transform: translate(calc(var(--tx, 0) + 40px), var(--ty, 0)) !important;
    opacity: 0;
    filter: blur(2px) sepia(0.5);
}

.tile-undo-out-right {
    transform: translate(calc(var(--tx, 0) - 40px), var(--ty, 0)) !important;
    opacity: 0;
    filter: blur(2px) sepia(0.5);
}

.tile-undo-in {
    z-index: 20;
    transition: none !important;
}

.tile-undo-in-up {
    animation: undoInUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.tile-undo-in-down {
    animation: undoInDown 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.tile-undo-in-left {
    animation: undoInLeft 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.tile-undo-in-right {
    animation: undoInRight 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes undoInUp {
    0% {
        transform: translate(var(--tx, 0), calc(var(--ty, 0) - 40px));
        opacity: 0;
        filter: blur(4px) sepia(1);
    }

    100% {
        transform: translate(var(--tx, 0), var(--ty, 0));
        opacity: 1;
        filter: blur(0) sepia(0);
    }
}

@keyframes undoInDown {
    0% {
        transform: translate(var(--tx, 0), calc(var(--ty, 0) + 40px));
        opacity: 0;
        filter: blur(4px) sepia(1);
    }

    100% {
        transform: translate(var(--tx, 0), var(--ty, 0));
        opacity: 1;
        filter: blur(0) sepia(0);
    }
}

@keyframes undoInLeft {
    0% {
        transform: translate(calc(var(--tx, 0) - 40px), var(--ty, 0));
        opacity: 0;
        filter: blur(4px) sepia(1);
    }

    100% {
        transform: translate(var(--tx, 0), var(--ty, 0));
        opacity: 1;
        filter: blur(0) sepia(0);
    }
}

@keyframes undoInRight {
    0% {
        transform: translate(calc(var(--tx, 0) + 40px), var(--ty, 0));
        opacity: 0;
        filter: blur(4px) sepia(1);
    }

    100% {
        transform: translate(var(--tx, 0), var(--ty, 0));
        opacity: 1;
        filter: blur(0) sepia(0);
    }
}

.tile-slide-back {
    animation: slideBack 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 15;
}

@keyframes slideBack {
    0% {
        transform: scale(1.2) translateY(20px);
        opacity: 0;
        filter: contrast(1.5) brightness(1.5);
    }

    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
        filter: contrast(1) brightness(1);
    }
}


/* Controls */
.tile-no-transition {
    transition: none !important;
}

.game-controls {
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.top-controls {
    padding-top: 0;
    margin-bottom: 10px;
}

.stats-row {
    display: flex;
    gap: 10px;
}

.stat-box {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px;
    border-radius: 12px;
    text-align: center;
}

.stat-box small {
    display: block;
    font-size: 9px;
    font-weight: 700;
    color: #888;
    margin-bottom: 2px;
}

.stat-box span {
    font-size: 18px;
    font-weight: 900;
}

.button-row {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.control-btn {
    padding: 10px 15px;
    border-radius: 6px;
    border: 3px solid #000;
    font-size: 11px;
    font-weight: 900;
    cursor: pointer;
    background: #333;
    color: white;
    box-shadow: 3px 3px 0 #000;
    text-transform: uppercase;
}

.control-btn:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 #000;
}

.undo-btn {
    background: var(--mex-gold);
    color: #000;
}

/* --- POWERS ROW (Bottom) --- */
.powers-row {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
    margin-bottom: 5px;
    width: 100%;
}

.power-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border-radius: 8px;
    border: 3px solid #000;
    font-size: 11px;
    font-weight: 900;
    cursor: pointer;
    color: white;
    box-shadow: 4px 4px 0 #000;
    text-transform: uppercase;
    transition: transform 0.1s, box-shadow 0.1s;
}

.power-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #000;
}

.power-btn.disabled-btn {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(100%);
    box-shadow: none !important;
    transform: translate(4px, 4px) !important;
}

.shuffle-btn {
    background: #00BCD4;
    /* Color cyan distintivo */
    color: #000;
}

.power-icon {
    font-size: 16px;
}

.secondary-row {
    margin-top: 5px;
}

.audio-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    min-width: 120px;
    justify-content: center;
}

.audio-btn.muted {
    background: #222;
    border-color: #444;
    color: #666;
    box-shadow: 2px 2px 0 #000;
}

/* Ad Spaces & Touch Instruction */
.ad-space {
    width: 100%;
    height: 50px;
    background: #000;
    border: 1px dashed #444;
    color: #444;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    margin: 5px 0 15px 0;
    /* Subido (reduciendo margin-top y aumentando bottom) */
    text-transform: uppercase;
}

.move-instruction {
    text-align: center;
    font-size: 10px;
    color: #666;
    margin-top: 5px;
    margin-bottom: 25px;
    font-weight: 700;
}

/* --- CLOUDS PIXEL ART --- */
.cloud-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.pixel-cloud {
    position: absolute;
    width: 60px;
    height: 40px;
    background: url('images/cloud_v6.png') center/contain no-repeat;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: flow-up 2s ease-out forwards;
}

.pixel-coin {
    width: 25px;
    height: 25px;
    background: url('images/coin_v6.png') center/contain no-repeat;
    margin-bottom: -5px;
}

.cloud-text {
    font-size: 8px;
    font-weight: 900;
    color: #333;
    text-transform: uppercase;
}

@keyframes flow-up {
    0% {
        transform: translate(-50%, 0);
        opacity: 0;
    }

    20% {
        transform: translate(-50%, -20px);
        opacity: 1;
    }

    80% {
        transform: translate(-50%, -50px);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -80px);
        opacity: 0;
    }
}

/* --- OVERLAYS & MODALS --- */
.overlay-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.overlay-container.hidden {
    display: none;
}

.modal {
    width: 90%;
    max-width: 360px;
    border-radius: 20px;
    padding: 30px;
    text-align: center;
}

.modal.hidden {
    display: none;
}

.modal.glass {
    background: rgba(20, 20, 20, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal.glass-credits {
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    width: 90%;
    max-width: 400px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.credits-content-v8 {
    width: 100%;
    text-align: center;
}

.credits-logo {
    display: block;
    margin: 0 auto 20px auto;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.3));
}

.author-info p {
    margin-bottom: 5px;
    color: #eee;
}

.credits-author {
    font-size: 20px;
    letter-spacing: 2px;
    margin-bottom: 10px;
    text-transform: uppercase;
    font-weight: 900;
}

.credits-heart {
    font-size: 14px;
    margin-bottom: 20px;
}

.credits-divider {
    border: none;
    height: 2px;
    background: var(--mex-gold);
    width: 50px;
    margin: 20px auto;
}

.disclaimer-v8 {
    font-size: 12px;
    font-style: italic;
    color: #888;
    line-height: 1.8;
    letter-spacing: 0.5px;
}

.satirical-title {
    font-size: 24px;
    font-weight: 900;
    color: var(--mex-gold);
    margin-bottom: 20px;
    text-transform: uppercase;
}

.modal-btn,
.nav-btn,
.action-btn {
    padding: 15px;
    border-radius: 12px;
    border: none;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
    background: #444;
    color: white;
    margin-top: 15px;
    width: 100%;
}

.modal-btn.action,
.nav-btn.primary,
.action-btn {
    background: var(--mex-red);
    box-shadow: 0 4px 0 #900;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* Visual Instructions */
.visual-example {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 20px 0;
}

.example-tile {
    width: 50px;
    height: 50px;
    background-size: cover;
    background-position: center bottom;
    background-color: #fff;
    border-radius: 4px;
    border: 3px solid #333;
    /* Borde base para que las clases tile-X lo coloreen */
    display: flex;
    align-items: center;
    justify-content: center;
}

.example-tile.level-up {
    transform: scale(1.1);
    border: 3px solid var(--mex-gold);
}

.example-tile.tile-2 {
    border-color: #FF5722;
}

.example-tile.tile-4 {
    border-color: #2196F3;
}

.plus,
.equals {
    font-weight: 900;
    font-size: 20px;
    color: #fff;
}

/* Tutorial Animation */
.tutorial-body {
    text-align: center;
}

.tutorial-body p {
    font-size: 13px;
    margin-bottom: 10px;
    line-height: 1.4;
}

.tutorial-animation .slide-in-left {
    animation: slideInLeftAnim 1.2s ease-out forwards;
}

.tutorial-animation .slide-in-right {
    animation: slideInRightAnim 1.2s ease-out forwards;
}

.tutorial-animation .pop-in {
    animation: popInAnim 1.2s ease-out forwards;
}

/* Modificamos los porcentajes para que la animación fluya mucho más rápido y clara */
@keyframes slideInLeftAnim {
    0% {
        transform: translateX(-30px);
        opacity: 0;
    }

    20%,
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInRightAnim {
    0% {
        transform: translateX(30px);
        opacity: 0;
    }

    20%,
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes popInAnim {

    0%,
    30% {
        transform: scale(0);
        opacity: 0;
    }

    40% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Settings Modal */
.settings-content-v8 {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 20px 0;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.setting-icon {
    font-size: 20px;
}

.setting-label {
    flex: 1;
    text-align: left;
    margin-left: 10px;
    font-weight: 700;
    font-size: 14px;
}

.toggle-btn {
    padding: 8px 15px;
    border-radius: 8px;
    border: 2px solid #000;
    font-weight: 900;
    font-size: 12px;
    cursor: pointer;
    box-shadow: 2px 2px 0 #000;
    transition: all 0.2s;
}

.toggle-btn.on {
    background: var(--mex-green);
    color: white;
}

.toggle-btn.off {
    background: #444;
    color: #999;
}

/* Game Over Styles Compact V13.1 */
#game-over-modal {
    background: rgba(18, 18, 18, 0.98);
    border: 4px solid var(--mex-green);
    border-radius: 12px;
    padding: 8px 12px;
    /* Reduced vertical padding */
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.9);
    text-align: center;
    max-height: 98vh;
    /* Allow it to take up more screen height */
    overflow-y: auto;
    width: 88%;
    max-width: 320px;
}

.game-over-img {
    width: 100%;
    /* Ajustado para mantener proporción 5:4 */
    aspect-ratio: 5/4;
    height: auto;
    max-height: 180px;
    /* Reduced to ensure it fits on small screens */
    object-fit: cover;
    border-radius: 6px;
    /* Slightly smaller radius */
    margin: 6px 0;
    /* Reduced margin */
    border: 2px solid #000;
    background: transparent;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

#game-over-modal .satirical-title {
    font-size: 16px;
    margin: 0 0 2px 0;
}

.final-score-v12 {
    margin: 2px 0;
    line-height: 1.1;
}

.final-score-v12 small {
    display: block;
    font-size: 11px;
    color: #ffd700;
    margin-bottom: 2px;
}

#game-over-score {
    font-size: 20px;
    font-weight: 900;
    color: #fff;
}

.record-section {
    background: rgba(255, 255, 255, 0.03);
    padding: 8px;
    /* Reduced */
    border-radius: 8px;
    margin-top: 4px;
    /* Reduced */
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.input-title {
    font-size: 11px;
    /* Reduced */
    margin-bottom: 4px;
    /* Reduced */
    color: #aaa;
}

#player-name {
    width: 100%;
    border-radius: 6px;
    border: 2px solid #555;
    background: #000;
    color: #fff;
    text-align: center;
    font-size: 16px;
    /* Reduced */
    font-weight: 900;
    letter-spacing: 2px;
    /* Reduced */
    text-transform: uppercase;
    padding: 6px;
    /* Reduced padding for input */
}

.nav-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 6px;
}

#game-over-modal .nav-btn {
    padding: 8px;
    /* Reduced padding inside game over modal */
    margin-top: 0;
}

/* High Scores List */
.scores-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
}

.score-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-size: 14px;
}

.score-row .name {
    color: var(--mex-gold);
    font-weight: 900;
}

.score-row .date {
    font-size: 10px;
    color: #888;
}

@media (max-width: 400px) {
    .screen {
        padding: 15px;
    }

    .game-container {
        padding: 10px;
    }

    .grid-background {
        gap: 8px;
    }
}

/* V12 UPGRADES */
.final-score-v12 {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--neon-gold);
    border-radius: 12px;
    padding: 15px;
    margin: 15px 0;
    text-align: center;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.2);
}

.final-score-v12 small {
    display: block;
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    color: var(--neon-gold);
    font-size: 0.8rem;
    letter-spacing: 2px;
    margin-bottom: 5px;
}

.final-score-v12 span {
    font-family: 'Outfit', sans-serif;
    font-size: 2.5rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 10px var(--neon-gold);
}

.copyright-v12 {
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 15px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.tile {
    /* Touch action none to prevent scrolling while dragging */
    touch-action: none;
    user-select: none;
    z-index: 10;
}

.tile.dragging {
    transition: none !important;
    z-index: 1000;
    transform: scale(1.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

/* --- PWA INSTALL MODAL --- */
.install-icon {
    width: 80px;
    height: 80px;
    border-radius: 15px;
    margin: 10px auto 20px auto;
    display: block;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
    border: 3px solid var(--mex-gold);
    background: #fff;
}

.anim-pop {
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- PWA BANNER V14 --- */
.pwa-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.95);
    border-bottom: 2px solid var(--mex-gold);
    z-index: 5000;
    padding: 10px 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pwa-banner.hidden {
    transform: translateY(-100%);
    pointer-events: none;
    opacity: 0;
}

.banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 600px;
    margin: 0 auto;
}

.install-icon-small {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid #444;
}

.banner-text {
    flex: 1;
}

.banner-title {
    font-weight: 900;
    font-size: 14px;
    color: var(--mex-gold);
}

.disclaimer-mini {
    font-size: 10px;
    color: #aaa;
    margin-top: 2px;
}

.banner-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.banner-btn-main {
    background: var(--mex-green) !important;
    color: white !important;
    border: none !important;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 900;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: none !important;
}

.banner-btn-close {
    background: transparent;
    color: #888;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
}

@media (max-width: 480px) {
    .main-logo {
        width: 70%;
    }

    .header-logo-v8 {
        height: 60px;
    }
}

/* Animación de Ascenso (Level Up Popup) */
.ascenso-anim {
    position: absolute;
    width: 60px;
    /* Tamaño pequeño para no estorbar la vista */
    height: auto;
    z-index: 200;
    pointer-events: none;
    transform: translate(-50%, -50%);
    animation: ascensoPopUp 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes ascensoPopUp {
    0% {
        transform: translate(-50%, -50%) scale(0.2);
        opacity: 0;
    }

    30% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 1;
        filter: drop-shadow(0px 0px 8px rgba(255, 215, 0, 0.9));
    }

    70% {
        transform: translate(-50%, calc(-50% - 25px)) scale(1.1);
        opacity: 1;
        filter: drop-shadow(0px 0px 5px rgba(255, 215, 0, 0.6));
    }

    100% {
        transform: translate(-50%, calc(-50% - 40px)) scale(0.8);
        opacity: 0;
    }
}