/* ============================================
   MM3 - Match 3 Puzzle - Estilos Específicos
   (Imports global.css for shared styles)
   ============================================ */

/* --- Variables del juego --- */
:root {
    --board-size: 8;
    --cell-size: 56px;
    --gap: 4px;
    --board-padding: 12px;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- App Container --- */
#app {
    width: 100%;
    max-width: 520px;
    padding: 16px;
    position: relative;
    z-index: 1;
}

#game-screen {
    position: relative;
}

/* --- Pantalla de Inicio --- */
#start-screen {
    min-height: 80vh;
    justify-content: center;
}

.start-content {
    text-align: center;
    width: 100%;
    padding: 40px 20px;
}

.game-title {
    font-size: 6rem;
    font-weight: 900;
    letter-spacing: -6px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--gem-yellow) 50%, var(--gem-purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0;
    line-height: 1;
    filter: drop-shadow(0 4px 20px rgba(255, 107, 53, 0.3));
}

.game-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    letter-spacing: 6px;
    text-transform: uppercase;
    margin-bottom: 48px;
    margin-top: 8px;
}

.start-decorations {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 36px;
}

.start-decorations .deco-gem {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    opacity: 0.5;
    animation: decoFloat 3s ease-in-out infinite;
}
.start-decorations .deco-gem:nth-child(1) { background: var(--gem-red); animation-delay: 0s; }
.start-decorations .deco-gem:nth-child(2) { background: var(--gem-blue); animation-delay: 0.3s; border-radius: 3px; }
.start-decorations .deco-gem:nth-child(3) { background: var(--gem-green); animation-delay: 0.6s; clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); }
.start-decorations .deco-gem:nth-child(4) { background: var(--gem-yellow); animation-delay: 0.9s; clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.start-decorations .deco-gem:nth-child(5) { background: var(--gem-purple); animation-delay: 1.2s; clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%); }

@keyframes decoFloat {
    0%, 100% { transform: translateY(0); opacity: 0.4; }
    50% { transform: translateY(-6px); opacity: 0.8; }
}

.start-menu {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    margin-bottom: 36px;
}

/* --- High Score --- */
.high-score-display {
    display: flex;
    justify-content: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

#high-score-value {
    color: var(--gem-yellow);
    font-weight: 700;
}

/* --- Game Title Bar --- */
.game-title-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 12px;
    padding: 0 4px;
}

.game-title-bar .logo {
    font-size: 1.6rem;
    font-weight: 900;
    letter-spacing: -2px;
    background: linear-gradient(135deg, var(--accent), var(--gem-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1.4rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 8px;
    transition: all var(--transition-speed) ease;
}
.back-link:hover {
    color: var(--accent);
    background: rgba(255, 107, 53, 0.1);
}

.game-title-bar .level-badge {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.06);
    padding: 4px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* --- Header del Juego --- */
.game-header {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    width: 100%;
    margin-bottom: 10px;
    padding: 10px 8px;
}

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

.header-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.header-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
    transition: color 0.3s ease, transform 0.2s ease;
}

.header-value.bump {
    transform: scale(1.2);
}

/* --- Barra de Progreso --- */
.progress-container {
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    margin-bottom: 14px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--gem-purple), var(--gem-blue));
    background-size: 200% 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
    animation: progressShine 3s linear infinite;
}

@keyframes progressShine {
    0% { background-position: 0% 0%; }
    100% { background-position: 200% 0%; }
}

/* --- Tablero de Juego --- */
.game-board {
    display: grid;
    grid-template-columns: repeat(8, var(--cell-size));
    grid-template-rows: repeat(8, var(--cell-size));
    gap: var(--gap);
    padding: var(--board-padding);
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

/* --- Celdas de fondo del tablero --- */
.game-board::before {
    content: '';
    position: absolute;
    inset: var(--board-padding);
    border-radius: 8px;
    background-image:
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: calc(var(--cell-size) + var(--gap)) calc(var(--cell-size) + var(--gap));
    pointer-events: none;
}

/* --- Gems --- */
.gem {
    width: var(--cell-size);
    height: var(--cell-size);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform var(--transition-speed) ease, opacity var(--transition-speed) ease;
    position: relative;
}

.gem:hover {
    transform: scale(1.08);
    z-index: 2;
}

.gem.selected {
    transform: scale(1.12);
    z-index: 3;
    animation: pulse 0.8s ease-in-out infinite;
}

.gem.hint {
    animation: hintPulse 1s ease-in-out infinite;
}

/* --- Gem Drag & Drop --- */
.gem.dragging {
    z-index: 10;
    transform: scale(1.15);
    cursor: grabbing;
    transition: none;
    filter: brightness(1.2);
}

.gem.drag-target {
    transform: scale(0.9);
    opacity: 0.6;
}

/* --- Gem Shapes (CSS) --- */
.gem-inner {
    width: 38px;
    height: 38px;
    transition: all var(--transition-speed) ease;
}

/* Circulo (Rojo) */
.gem.type-0 { background: radial-gradient(circle at 35% 35%, var(--gem-red-light), var(--gem-red)); box-shadow: 0 3px 12px rgba(255, 71, 87, 0.4), inset 0 1px 1px rgba(255,255,255,0.2); }
.gem.type-0 .gem-inner {
    background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.35), transparent);
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

/* Diamante (Azul) */
.gem.type-1 { background: radial-gradient(circle at 35% 35%, var(--gem-blue-light), var(--gem-blue)); box-shadow: 0 3px 12px rgba(55, 66, 250, 0.4), inset 0 1px 1px rgba(255,255,255,0.2); }
.gem.type-1 .gem-inner {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, rgba(255,255,255,0.45), transparent 60%);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

/* Cuadrado rotado (Verde) */
.gem.type-2 { background: radial-gradient(circle at 35% 35%, var(--gem-green-light), var(--gem-green)); box-shadow: 0 3px 12px rgba(46, 213, 115, 0.4), inset 0 1px 1px rgba(255,255,255,0.2); }
.gem.type-2 .gem-inner {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, rgba(255,255,255,0.4), transparent 60%);
    transform: rotate(45deg);
    border-radius: 4px;
}

/* Estrella (Amarillo) */
.gem.type-3 { background: radial-gradient(circle at 35% 35%, var(--gem-yellow-light), var(--gem-yellow)); box-shadow: 0 3px 12px rgba(255, 165, 2, 0.4), inset 0 1px 1px rgba(255,255,255,0.2); }
.gem.type-3 .gem-inner {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, rgba(255,255,255,0.55), rgba(255,255,255,0.1));
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

/* Triangulo (Violeta) */
.gem.type-4 { background: radial-gradient(circle at 35% 35%, var(--gem-purple-light), var(--gem-purple)); box-shadow: 0 3px 12px rgba(165, 94, 234, 0.4), inset 0 1px 1px rgba(255,255,255,0.2); }
.gem.type-4 .gem-inner {
    width: 28px;
    height: 28px;
    background: linear-gradient(180deg, rgba(255,255,255,0.45), transparent 60%);
    clip-path: polygon(50% 10%, 90% 90%, 10% 90%);
}

/* Hexagono (Cyan) */
.gem.type-5 { background: radial-gradient(circle at 35% 35%, var(--gem-cyan-light), var(--gem-cyan)); box-shadow: 0 3px 12px rgba(0, 210, 211, 0.4), inset 0 1px 1px rgba(255,255,255,0.2); }
.gem.type-5 .gem-inner {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, rgba(255,255,255,0.45), transparent 60%);
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}

/* --- Animaciones de Gem --- */
.gem.matched {
    animation: matchPop 0.4s ease forwards;
}

.gem.falling {
    transition: transform var(--transition-speed) ease-in;
}

.gem.swapping {
    transition: transform 0.2s ease-in-out;
    z-index: 5;
}

.gem.invalid-swap {
    animation: invalidShake 0.4s ease;
}

@keyframes pulse {
    0%, 100% { transform: scale(1.12); box-shadow: 0 0 0 0 var(--accent-glow), 0 3px 12px rgba(255, 71, 87, 0.4); }
    50% { transform: scale(1.06); box-shadow: 0 0 20px 8px var(--accent-glow), 0 3px 12px rgba(255, 71, 87, 0.4); }
}

@keyframes hintPulse {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.1); filter: brightness(1.3); }
}

@keyframes matchPop {
    0% { transform: scale(1); opacity: 1; filter: brightness(1); }
    30% { transform: scale(1.25); opacity: 1; filter: brightness(1.5); }
    100% { transform: scale(0); opacity: 0; filter: brightness(2); }
}

@keyframes invalidShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

@keyframes scoreFloat {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-60px) scale(1.3); }
}

/* --- Combo Message --- */
.combo-message {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--gem-yellow);
    text-shadow:
        0 0 20px rgba(255, 165, 2, 0.6),
        0 0 40px rgba(255, 165, 2, 0.3);
    pointer-events: none;
    opacity: 0;
    z-index: 100;
    white-space: nowrap;
    letter-spacing: 1px;
}

.combo-message.big-combo {
    font-size: 2.6rem;
    color: var(--gem-red-light);
    text-shadow:
        0 0 30px rgba(255, 71, 87, 0.7),
        0 0 60px rgba(255, 71, 87, 0.4),
        0 0 90px rgba(255, 71, 87, 0.2);
}

.combo-message.show {
    animation: comboShow 0.9s ease-out forwards;
}

.combo-message.big-combo.show {
    animation: bigComboShow 1.1s ease-out forwards;
}

@keyframes comboShow {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    25% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    60% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -65%) scale(0.9); }
}

@keyframes bigComboShow {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
    15% { opacity: 1; transform: translate(-50%, -50%) scale(1.4); }
    30% { transform: translate(-50%, -50%) scale(1); }
    60% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -70%) scale(1.1); }
}

/* --- Overlays --- */
.overlay {
    position: fixed;
    inset: 0;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.overlay.active {
    display: flex;
    animation: slideInUp 0.3s ease;
}

.overlay-content {
    padding: 44px 40px;
    text-align: center;
    max-width: 360px;
    width: 90%;
}

.overlay-content h2 {
    font-size: 1.7rem;
    margin-bottom: 24px;
    background: linear-gradient(135deg, var(--accent), var(--gem-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.level-stats {
    margin-bottom: 28px;
}

.level-stats p {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.level-stats span {
    color: var(--text-primary);
    font-weight: 700;
}

.overlay-content .btn {
    margin: 6px auto;
    display: block;
}

/* --- Footer --- */
.game-footer {
    margin-top: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.7rem;
    letter-spacing: 2px;
    opacity: 0.5;
}

.site-footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted);
    font-size: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.site-footer .footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-speed);
}

.site-footer .footer-links a:hover {
    color: var(--accent);
}

/* --- Particulas de puntuacion --- */
.score-particle {
    position: absolute;
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--gem-yellow);
    text-shadow: 0 0 8px rgba(255, 165, 2, 0.5);
    pointer-events: none;
    z-index: 50;
    animation: scoreFloat 0.8s ease-out forwards;
}

/* --- Responsive --- */
@media (max-width: 520px) {
    :root {
        --cell-size: 42px;
        --gap: 3px;
        --board-padding: 8px;
    }

    #app {
        padding: 8px;
    }

    .game-title {
        font-size: 4.5rem;
    }

    .start-content {
        padding: 30px 16px;
    }

    .game-title-bar .logo {
        font-size: 1.3rem;
    }

    .game-header {
        padding: 8px 4px;
    }

    .header-value {
        font-size: 1.1rem;
    }

    .gem-inner {
        width: 28px !important;
        height: 28px !important;
    }

    .gem.type-0 .gem-inner { width: 18px !important; height: 18px !important; }
    .gem.type-1 .gem-inner { width: 22px !important; height: 22px !important; }
    .gem.type-2 .gem-inner { width: 18px !important; height: 18px !important; }
    .gem.type-3 .gem-inner { width: 24px !important; height: 24px !important; }
    .gem.type-4 .gem-inner { width: 22px !important; height: 22px !important; }
    .gem.type-5 .gem-inner { width: 24px !important; height: 24px !important; }

    .combo-message { font-size: 1.4rem; }
    .combo-message.big-combo { font-size: 2rem; }
}

@media (max-width: 380px) {
    :root {
        --cell-size: 36px;
        --gap: 2px;
    }

    .game-title { font-size: 3.5rem; letter-spacing: -4px; }
    .header-value { font-size: 1rem; }
    .header-label { font-size: 0.55rem; }
    .combo-message { font-size: 1.2rem; }
    .combo-message.big-combo { font-size: 1.6rem; }
}
