:root {
    --pink: #FFB7C5;
    --blue: #A2D2FF;
    --yellow: #FFFFE0;
    --green: #D4F1BE;
    --lavender: #E0BBE4;
    --dark-text: #5D5D5D;
    --white: #FFFFFF;
    --shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --font-main: 'Fredoka', sans-serif;
    --font-body: 'Quicksand', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-main);
    background: linear-gradient(135deg, #a2d2ff 0%, #ffafbd 50%, #ffc3a0 100%);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    color: var(--dark-text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    position: relative;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Bubbles Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.2) 0%, transparent 20%),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.2) 0%, transparent 20%);
    pointer-events: none;
    z-index: -1;
}

#app {
    flex-direction: column;
    width: 100%;
    max-width: 500px;
    padding: 15px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Header Pill Moderno - Alineado 3 Columnas */
.kawaii-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-radius: 50px;
    border: 3px solid var(--white);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    /* Tres columnas perfectas */
    align-items: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
    position: relative;
    z-index: 100;
    margin-bottom: 20px;
    width: 100%;
}



.header-left {
    display: flex;
    justify-content: flex-start;
}

.header-center {
    display: flex;
    justify-content: center;
}

.header-right {
    display: flex;
    justify-content: flex-end;
}

.game-title-header {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--dark-text);
    white-space: nowrap;
}

.home-logo {
    height: 32px;
    filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, 0.05));
    transition: var(--transition);
}

.top-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-btn {
    background: var(--white);
    border: 2px solid var(--blue);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.home-logo:hover {
    transform: scale(1.1) rotate(-5deg);
}

.control-btn:hover {
    transform: scale(1.1);
    border-color: var(--pink);
}

.language-selector {
    display: flex;
    gap: 5px;
    background: rgba(255, 255, 255, 0.5);
    padding: 3px;
    border-radius: 20px;
    border: 1px solid var(--blue);
}

.lang-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    filter: grayscale(1);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.lang-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.lang-btn.active {
    filter: grayscale(0);
    transform: scale(1.1);
    box-shadow: 0 0 5px var(--blue);
}

/* Screens */
.menu-screen,
#game-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    padding-top: 10px;
}

.hidden {
    display: none !important;
}

/* Main Menu & Character */
.menu-screen {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-container {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    position: relative;
}

.menu-content {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(15px);
    border-radius: 40px;
    padding: 20px;
    border: 4px solid var(--white);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    margin-top: 5px;
    animation: bounceIn 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

@keyframes bounceIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.menu-hero-img {
    width: 90px;
    /* Redimensionada para compactar */
    height: auto;
    border-radius: 20px;
    border: 4px solid var(--white);
    box-shadow: 0 6px 0 var(--lavender);
    margin-bottom: 12px;
    animation: floating 3s ease-in-out infinite;
}

.menu-title {
    font-size: 1.5rem;
    /* Más compacto */
    color: var(--dark-text);
    margin-bottom: 15px;
    text-align: center;
    font-weight: 800;
    line-height: 1.2;
}

.difficulty-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.difficulty-btn {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 12px 18px;
    border-radius: 25px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.difficulty-btn::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 10%;
    width: 80%;
    height: 20%;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 20px;
}

.difficulty-btn .icon {
    font-size: 1.8rem;
    margin-right: 12px;
    background: white;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 15px;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.05);
}

.difficulty-btn .btn-text {
    display: flex;
    flex-direction: column;
}

.difficulty-btn .title {
    font-size: 1.1rem;
    font-weight: 900;
    text-transform: uppercase;
}

.difficulty-btn .desc {
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0.9;
}

.difficulty-btn.easy {
    background: #D4F1BE;
    color: #437d1d;
    box-shadow: 0 6px 0 #aedf8e;
}

.difficulty-btn.medium {
    background: #A2D2FF;
    color: #1e4d7d;
    box-shadow: 0 6px 0 #7ab8f0;
}

.difficulty-btn.hard {
    background: #FFB7C5;
    color: #7d1e3a;
    box-shadow: 0 6px 0 #f08e9f;
}

.difficulty-btn:hover {
    transform: translateY(-5px);
}

.difficulty-btn:active {
    transform: translateY(5px);
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.1);
}

/* Game Area */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.stats {
    display: flex;
    gap: 15px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--white);
    padding: 5px 15px;
    border-radius: 15px;
    border: 3px solid var(--blue);
}

.stat-box .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
}

.stat-box span:not(.label) {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--pink);
}

main {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    border-radius: 30px;
    padding: 15px;
    border: 4px solid var(--white);
    box-shadow: var(--shadow);

    margin-bottom: 20px;
}

main::-webkit-scrollbar {
    width: 10px;
    display: block !important;
}

main::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

main::-webkit-scrollbar-thumb {
    background-color: var(--pink);
    border-radius: 10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 8px;
    width: 100%;
}

.cell {
    aspect-ratio: 1;
    background: var(--white);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition);
    border: 3px solid transparent;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.05);
    position: relative;
}

.cell:hover:not(.cleared) {
    transform: translateY(-3px);
    background: var(--yellow);
    box-shadow: 0 7px 0 rgba(0, 0, 0, 0.1);
}

.cell.selected {
    background: var(--blue) !important;
    color: white;
    border-color: var(--white);
    transform: scale(1.15);
    z-index: 10;
    box-shadow: 0 0 20px rgba(162, 210, 255, 0.8);
}

.cell.match-pop {
    transform: scale(1.2) !important;
    filter: brightness(1.2);
    z-index: 15;
}

.cell.cleared {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5);
}

/* Reflection Animation */
.cell.match-flash::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.8) 50%,
            rgba(255, 255, 255, 0) 100%);
    transform: skewX(-25deg);
    animation: reflection 0.6s ease-out forwards;
}

@keyframes reflection {
    0% {
        left: -100%;
    }

    100% {
        left: 150%;
    }
}

.cell.invalid {
    background: var(--pink) !important;
    color: white;
    animation: shake 0.5s;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}

/* Controls Narrow */
.main-controls {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    /* 4 columnas compactas */
    gap: 10px;
}

.btn.narrow {
    padding: 10px 5px;
    font-size: 0.9rem;
    border-radius: 15px;
}

.btn.hint-btn {
    background: var(--yellow);
    color: var(--dark-text);
    border: 2px solid #ecd872;
}

.badge {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 800;
    margin-left: 5px;
}

.btn.hint-btn .icon {
    font-size: 1.2rem;
}

#hint-count {
    background: var(--white);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.8rem;
    margin-left: 2px;
}

/* Hint Pulse Animation */
.cell.hint-pulse {
    border-color: #ecd872 !important;
    animation: hint-pulse 1s infinite;
    z-index: 10;
}

@keyframes hint-pulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(236, 216, 114, 0);
    }

    50% {
        transform: scale(1.1);
        box-shadow: 0 0 20px rgba(236, 216, 114, 0.8);
    }
}

.btn:active {
    transform: translateY(3px);
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.1);
}

.btn.primary {
    background: var(--pink);
    color: white;
}

.btn.secondary {
    background: var(--lavender);
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.1) !important;
}

/* Overlay & Modals */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    transition: var(--transition);
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 40px;
    padding: 45px 35px;
    text-align: center;
    border: 10px solid var(--blue);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 25px;
    width: 100%;
    /* Ahora ocupa todo el ancho disponible */
}

.message-content h2 {
    font-size: 2.8rem;
    color: var(--blue);
    margin-bottom: 5px;
    font-weight: 800;
}

.message-content p {
    font-size: 1.3rem;
    color: #666;
    margin-bottom: 20px;
    font-weight: 600;
}

.message-content .btn {
    width: 100%;
    font-size: 1.2rem;
    padding: 18px;
    border-radius: 25px;
    text-transform: none;
}

/* Effects */
.explosion {
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--blue);
    border-radius: 50%;
    pointer-events: none;
    z-index: 50;
    animation: explode 0.6s ease-out forwards;
    box-shadow: 0 0 15px var(--blue);
}

@keyframes explode {
    0% {
        transform: scale(0);
        opacity: 1;
    }

    100% {
        transform: scale(5);
        opacity: 0;
    }
}

/* Floating Points Effect */
.floating-points {
    position: absolute;
    color: var(--pink);
    font-weight: 800;
    font-size: 1.2rem;
    pointer-events: none;
    z-index: 100;
    animation: float-up 0.8s ease-out forwards;
    text-shadow: 2px 2px 0 var(--white);
}

/* Row Collapse Animation */
.cell.collapsing-cell {
    transform: scale(0.5);
    opacity: 0;
    filter: blur(5px);
    transition: all 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: -1;
}

@keyframes float-up {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateY(-50px);
        opacity: 0;
    }
}

@media (max-width: 500px) {
    .difficulty-btn {
        padding: 12px 15px;
    }

    .game-board {
        gap: 5px;
    }

    .cell {
        font-size: 1.1rem;
        border-radius: 10px;
    }

    #app {
        padding: 10px;
    }
}
#app {
    width: 100%;
    height: 90vh; /* Constrain game area */
    position: relative;
    overflow: hidden; /* Keep game clipped */
    border-bottom: 5px solid white;
}

#app {
    width: 100%;
    height: 90vh;
    position: relative;
    overflow: hidden;
    border-bottom: 5px solid white;
}
