:root {
    --bg-gradient: linear-gradient(135deg, #FFDEE9 0%, #B5FFFC 100%);
    --primary-color: #FF6B6B;
    /* Rojo Kawaii */
    --secondary-color: #4ECDC4;
    /* Azul Kawaii */
    --accent-color: #FFE66D;
    /* Amarillo */
    --text-color: #556270;
    --card-bg: rgba(255, 255, 255, 0.9);
    --font-main: 'Varela Round', sans-serif;
    --shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-main);
    background: var(--bg-gradient);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    /* Evitar scroll en app */
}

/* --- Controles Superiores --- */
.top-controls {
    width: 100%;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: absolute;
    top: 0;
    z-index: 10;
}

.left-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.right-controls {
    display: flex;
    align-items: center;
}

.icon-btn,
.lang-btn {
    background: var(--card-bg);
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:active,
.lang-btn:active {
    transform: scale(0.9);
}

.lang-switch {
    display: flex;
    gap: 10px;
}

.lang-btn {
    opacity: 0.5;
    filter: grayscale(1);
    padding: 0;
    overflow: hidden;
    background: transparent;
    box-shadow: none;
}

.flag-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.lang-btn.active {
    opacity: 1;
    filter: grayscale(0);
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    /* border removal if image covers it all, or style adjustment */
    border: none;
}

/* --- Contenedor Principal --- */
.main-container {
    width: 100%;
    max-width: 500px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

header {
    margin-bottom: 2rem;
    text-align: center;
}

.game-title {
    font-family: 'Fredoka One', cursive;
    font-size: 3rem;
    color: var(--text-color);
    text-shadow: 2px 2px 0px #fff;
    letter-spacing: 2px;
}

/* --- Pantallas y Transiciones --- */
.screen {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    transition: opacity 0.3s ease;
}

.hidden {
    display: none !important;
    opacity: 0;
}

.active {
    opacity: 1;
}

/* --- Botones --- */
.mascot-img {
    width: 150px;
    height: auto;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0px);
    }
}

.menu-btn {
    width: 80%;
    padding: 15px;
    border: none;
    border-radius: 25px;
    font-family: var(--font-main);
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    color: white;
    text-transform: uppercase;
}

.primary-btn {
    background: var(--primary-color);
}

.primary-btn:hover {
    background: #ff8787;
    transform: translateY(-3px);
}

.difficulty-btn {
    background: var(--secondary-color);
}

.difficulty-btn:hover {
    background: #73dcd5;
}

.secondary-btn {
    background: transparent;
    border: 2px solid var(--text-color);
    color: var(--text-color);
    padding: 10px 30px;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
}

.action-btn {
    background: var(--accent-color);
    color: #555;
    border: none;
    padding: 10px 30px;
    border-radius: 20px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* --- Marcador --- */
.scoreboard {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: var(--card-bg);
    padding: 10px 20px;
    border-radius: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0.7;
    transition: opacity 0.3s, transform 0.3s;
}

.score-box.active-turn {
    opacity: 1;
    transform: scale(1.1);
}

.score-count {
    font-family: 'Fredoka One';
    font-size: 1.5rem;
}

.player-icon {
    width: 30px;
    height: 30px;
    margin-top: 5px;
    border-radius: 50%;
}

.red-icon {
    background: var(--primary-color);
}

.blue-icon {
    background: var(--secondary-color);
}

.vs-text {
    font-family: 'Fredoka One';
    font-size: 1.5rem;
    color: #ccc;
}

/* --- Tablero --- */
.board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 10px;
    background: rgba(255, 255, 255, 0.5);
    padding: 10px;
    border-radius: 20px;
    box-shadow: var(--shadow);
    width: 300px;
    height: 300px;
    margin-bottom: 20px;
}

.cell {
    background: #fff;
    border-radius: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: background 0.2s;
}

.cell:hover {
    background: #fdfdfd;
}

/* --- SVG Personajes y Animaciones --- */
.kawaii-svg {
    width: 80%;
    height: 80%;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Animación de entrada */
@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    80% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Animación de victoria (resaltado) */
.cell.winner-cell {
    background: #FFFAE1;
    animation: pulseWinner 1s infinite;
}

.cell.winner-cell .kawaii-svg {
    animation: bounce 0.6s infinite alternate;
}

@keyframes bounce {
    0% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(-10px);
    }
}

@keyframes pulseWinner {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 230, 109, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(255, 230, 109, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 230, 109, 0);
    }
}

/* Parpadeo de ojos */
.eye {
    animation: blink 4s infinite;
}

@keyframes blink {

    0%,
    96%,
    100% {
        transform: scaleY(1);
    }

    98% {
        transform: scaleY(0.1);
        transform-origin: center;
    }
}

/* --- Modal --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 25px;
    text-align: center;
    width: 80%;
    max-width: 300px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.winner-anim {
    width: 100px;
    height: 100px;
    margin: 20px auto;
}

/* Media Queries para móviles pequeños */
@media (max-width: 350px) {
    .board {
        width: 260px;
        height: 260px;
    }

    .game-title {
        font-size: 2.5rem;
    }
}
