:root {
    --success: #2ecc71;
    --warning: #ff9800;
    --error: #c0392b;
    --info: #1565c0;
    --disabled: #bdc3c7;
    --dark: #000000;
    --white: #ffffff;
    --gray-light: #f4f4f4;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: #f4f4f4;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 784px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Header */
.header-main {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--white); padding: 2px 8px; border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    min-height: 48px;
}
.main-title { font-size: 1rem; font-weight: 900; letter-spacing: 1px; }
.menu-btn, .help-btn {
    background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--dark);
    min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px; transition: background 0.15s, transform 0.1s;
}
.menu-btn:hover, .help-btn:hover { background: var(--gray-light); }
.menu-btn:active, .help-btn:active { background: #ddd; transform: scale(0.9); }

.header-stats { display: flex; gap: 5px; }
.mini-stat { background: var(--gray-light); padding: 2px 10px; border-radius: 12px; font-weight: 800; font-size: 0.75rem; }

/* Side Menu */
.side-menu { position: fixed; top: 0; left: 0; width: 100%; height: 100%; visibility: hidden; z-index: 1000; }
.side-menu.active { visibility: visible; }
.menu-overlay { position: absolute; width: 100%; height: 100%; background: rgba(0,0,0,0.5); opacity: 0; transition: opacity 0.3s; }
.side-menu.active .menu-overlay { opacity: 1; }
.menu-drawer { position: absolute; top: 0; left: -100%; width: 80%; max-width: 300px; height: 100%; background: var(--white); transition: left 0.3s; display: flex; flex-direction: column; }
.side-menu.active .menu-drawer { left: 0; }
.menu-header { padding: 10px 15px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #eee; min-height: 52px; }
.menu-title { font-weight: 900; font-size: 0.9rem; }
.close-btn {
    background: none; border: none; font-size: 1.6rem; cursor: pointer; color: var(--dark);
    min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px; transition: background 0.15s, transform 0.1s;
}
.close-btn:hover { background: var(--gray-light); }
.close-btn:active { background: #ddd; transform: scale(0.9); }

/* Accordion */
.menu-scroll-area { flex: 1; overflow-y: auto; }
.accordion-item { border-bottom: 1px solid #eee; }
.accordion-header {
    width: 100%; padding: 0 15px; background: none; border: none;
    display: flex; justify-content: space-between; align-items: center;
    font-weight: 700; font-size: 0.8rem; cursor: pointer; min-height: 48px;
    transition: background 0.15s;
}
.accordion-header:hover { background: #f0f0f0; }
.accordion-header:active { background: #e0e0e0; }
.accordion-header .arrow { display: inline-block; transition: transform 0.25s; }
.accordion-header.active .arrow { transform: rotate(180deg); }
.accordion-content { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; background: var(--gray-light); }
.accordion-content.open { max-height: 400px; padding: 10px 15px; }

.nav-categories { display: flex; flex-direction: column; gap: 6px; }
.btn-cat {
    padding: 12px; border: none; border-radius: 8px; color: var(--white);
    font-weight: 800; text-align: left; font-size: 0.75rem; cursor: pointer;
    min-height: 44px; transition: filter 0.15s, transform 0.1s;
}
.btn-cat:not(.completed):hover { filter: brightness(1.2); }
.btn-cat:not(.completed):active { transform: scale(0.96); filter: brightness(0.88); }
.btn-cat.completed { opacity: 0.5; cursor: default; }

.score-list { display: flex; flex-direction: column; gap: 4px; }
.score-entry { background: var(--white); padding: 8px 10px; border-radius: 6px; font-size: 0.72rem; font-weight: 700; display: flex; justify-content: space-between; }

.menu-footer { padding: 15px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid #eee; }
.btn-action {
    padding: 12px; border: none; border-radius: 8px; color: white;
    font-weight: 800; font-size: 0.8rem; cursor: pointer;
    min-height: 44px; transition: filter 0.15s, transform 0.1s;
}
.btn-action:hover { filter: brightness(1.2); }
.btn-action:active { transform: scale(0.96); filter: brightness(0.85); }
.btn-action.danger { background: var(--error); }
.btn-action.secondary { background: var(--info); }

/* Board */
.game-area { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; min-height: 0; }
.board-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 0;
    width: 100%; height: 100%;
    padding: 2px;
    /* Nuevas propiedades para el fondo */
    background-size: 70% auto; /* Tamaño del patrón ajustable */
    background-position: center;
    background-repeat: no-repeat;
    transition: background-image 0.5s ease-in-out;
}

/* Mapeo de categorías a archivos en img/patterns/ */
.board-grid.animales .card-back { background-image: url('./assets/img/patterns/animals.svg'); }
.board-grid.eventos .card-back { background-image: url('./assets/img/patterns/events.svg'); }
.board-grid.comida .card-back { background-image: url('./assets/img/patterns/food.svg'); }
.board-grid.colegio .card-back { background-image: url('./assets/img/patterns/school.svg'); }
.board-grid.vegetales .card-back { background-image: url('./assets/img/patterns/vegetables.svg'); }

/* Cards */
.card { perspective: 1000px; height: 100%; width: 100%; }
.card-inner { position: relative; width: 100%; height: 100%; transition: transform 0.4s; transform-style: preserve-3d; }
.card.flipped .card-inner { transform: rotateY(180deg); }
.card-face {
    position: absolute; width: 100%; height: 100%; backface-visibility: hidden;
    border-radius: 4px; display: flex; flex-direction: column;
    background: var(--white); border: 1.5px solid #ccc; overflow: hidden;
}
.card-back { background: #eee; background-repeat: repeat; background-size: 60px; }
.card-front { transform: rotateY(180deg); }
.card-front.english { border-color: royalblue; }
.card-front.spanish { border-color: crimson; }
.card.matched .card-face { border-color: var(--success); border-width: 2px; }

.image-wrapper { flex: 1; width: 100%; display: flex; justify-content: center; align-items: center; min-height: 0; padding: 1px; }
.icon-img { max-height: 85%; max-width: 85%; object-fit: contain; }
.word-text {
    font-size: calc(0.4rem + 0.4vw);
    font-weight: 900; text-align: center; width: 100%;
    padding: 1px 0; text-transform: uppercase; flex-shrink: 0;
}
.english .word-text { background: royalblue; color: white; }
.spanish .word-text { background: crimson; color: white; }

/* Shake animation */
@keyframes shake {
    0%, 100% { transform: translateX(0) rotate(0); }
    25%       { transform: translateX(-4px) rotate(-1.5deg); }
    75%       { transform: translateX(4px) rotate(1.5deg); }
}
.card.shake { animation: shake 0.3s ease; }

/* Win effects */
#global-shine { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20; display: none; }
#global-shine.active { display: block; overflow: hidden; }
#global-shine::after { content: ""; position: absolute; top: -100%; left: -100%; width: 300%; height: 300%; background: linear-gradient(135deg, transparent 45%, rgba(255,255,255,0.4) 50%, transparent 55%); animation: diagonalShine 3s infinite linear; }
@keyframes diagonalShine { 0% { transform: translate(-20%, -20%); } 100% { transform: translate(20%, 20%); } }

#sparkles-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 21; }
.sparkle { position: absolute; width: 10px; height: 10px; background: white; clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); animation: sparkleAnim 2s infinite; }
@keyframes sparkleAnim { 0%, 100% { transform: scale(0); opacity: 0; } 50% { transform: scale(1); opacity: 1; } }

/* Footer */
.footer-bar { height: 35px; display: flex; flex-direction: column; justify-content: center; padding: 0 5px; }
.progress-info { display: flex; justify-content: space-between; font-weight: 900; font-size: 0.65rem; margin-bottom: 2px; }
.progress-track { height: 4px; background: rgba(255,255,255,0.5); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--success); transition: width 0.3s; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 3000; display: none; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal-content { background: var(--white); padding: 15px; border-radius: 15px; width: 90%; max-width: 350px; text-align: center; }
.modal-flex { display: flex; gap: 10px; align-items: center; text-align: left; }
.modal-mascot-side { width: 60px; flex-shrink: 0; }
.modal-mascot-img { width: 100%; }
.modal-speech { background: #eee; border-radius: 8px; padding: 5px; font-size: 0.65rem; font-weight: 800; text-align: center; margin-bottom: 5px; }

@media (min-width: 450px) {
    .word-text { font-size: 0.6rem; }
    .header-main { padding: 6px 20px; }
    .main-title { font-size: 1.1rem; }
    .board-grid { gap: 3px; }
}
