/* -------------------- Variables base -------------------- */
:root {
    --bg-soft: #eef5ff;
    --bg-card: #fff7fb;
    --accent: #ff8fab;
    --accent-alt: #fdba74;
    --accent-danger: #ff4b6b;
    --accent-success: #22c55e;
    --accent-text: #1f2933;
    --chip-bg: rgba(255, 255, 255, 0.92);
    --tile-bg: #ffffff;
    --tile-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    --radius-xl: 26px;
    --transition-fast: 0.18s ease-out;
    --transition-med: 0.28s cubic-bezier(.25,.8,.25,1);
    --font-main: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
                 -system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
                 sans-serif;
}

/* -------------------- Temas + fondo animado -------------------- */

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    overflow: hidden;
    background: linear-gradient(120deg, #fdf2ff, #e5f0ff, #dde7ff);
    background-size: 220% 220%;
    animation: gradientMove 20s ease infinite;
}

/* blobs decorativos de fondo */
body::before,
body::after {
    content: "";
    position: fixed;
    inset: -40%;
    background:
        radial-gradient(circle at 10% 20%, rgba(244, 114, 182, 0.22), transparent 55%),
        radial-gradient(circle at 80% 10%, rgba(59, 130, 246, 0.2), transparent 60%),
        radial-gradient(circle at 20% 80%, rgba(45, 212, 191, 0.22), transparent 55%),
        radial-gradient(circle at 90% 75%, rgba(251, 191, 36, 0.2), transparent 60%);
    z-index: -2;
    opacity: 0.85;
    pointer-events: none;
    filter: blur(1px);
    animation: blobsMove 40s linear infinite alternate;
}

/* tema suave por defecto */
body.theme-soft {
    background: linear-gradient(120deg, #fdf2ff, #e5f0ff, #dde7ff);
    background-size: 220% 220%;
    animation: gradientMove 20s ease infinite;
}

/* menta */
body.theme-mint {
    background: linear-gradient(120deg, #ecfdf5, #d1fae5, #bfdbfe);
    background-size: 220% 220%;
    animation: gradientMove 22s ease-in-out infinite;
}

/* lavanda */
body.theme-lilac {
    background: linear-gradient(120deg, #faf5ff, #e9d5ff, #dbeafe);
    background-size: 240% 240%;
    animation: gradientMove 24s ease-in-out infinite;
}

/* neón suave */
body.theme-neon {
    background: radial-gradient(circle at top, #020617, #0f172a, #111827);
    background-size: 200% 200%;
    animation: gradientMove 26s ease-in-out infinite;
}

/* animación gradiente */
@keyframes gradientMove {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position:   0% 50%; }
}

/* animación blobs */
@keyframes blobsMove {
    0% {
        transform: translate3d(0, 0, 0) scale(1);
    }
    50% {
        transform: translate3d(-4%, 3%, 0) scale(1.04);
    }
    100% {
        transform: translate3d(3%, -3%, 0) scale(1.02);
    }
}

/* -------------------- Layout principal -------------------- */

#app-container {
    width: 100%;
    max-width: 1200px;
    padding: 24px;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
}

#game-card {
    position: relative;
    margin: 0 auto;
    max-width: 980px;
    padding: 32px 40px 40px;
    background: radial-gradient(circle at top left, rgba(255,255,255,0.96), rgba(255,247,251,0.98));
    border-radius: 32px;
    box-shadow:
        0 20px 60px rgba(15, 23, 42, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(18px);
    overflow: hidden;
}

/* halo animado dentro del card */
#game-card::before {
    content: "";
    position: absolute;
    inset: -30%;
    background:
        radial-gradient(circle at 10% 0%, rgba(248, 250, 252, 0.5), transparent 60%),
        radial-gradient(circle at 80% 100%, rgba(251, 207, 232, 0.35), transparent 65%),
        radial-gradient(circle at 100% 40%, rgba(191, 219, 254, 0.45), transparent 55%);
    opacity: 0.9;
    z-index: -1;
    animation: innerGlow 26s ease-in-out infinite alternate;
}

@keyframes innerGlow {
    0% {
        transform: translate3d(0,0,0) scale(1);
    }
    100% {
        transform: translate3d(-2%, 1%, 0) scale(1.03);
    }
}

/* -------------------- Controles de tema -------------------- */

#theme-controls {
    position: absolute;
    top: 18px;
    right: 22px;
    display: flex;
    gap: 8px;
    z-index: 20;
}

.theme-dot {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.25);
    cursor: pointer;
    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease,
        border-color 0.18s ease,
        filter 0.18s ease;
}

.theme-dot:hover {
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.32);
    filter: brightness(1.05);
}

.theme-soft-dot { background: linear-gradient(145deg, #fee2ff, #bfdbfe); }
.theme-mint-dot { background: linear-gradient(145deg, #bbf7d0, #a5f3fc); }
.theme-lilac-dot { background: linear-gradient(145deg, #e9d5ff, #bfdbfe); }
.theme-neon-dot { background: radial-gradient(circle at 30% 0%, #22c55e, #a855f7, #ef4444); }

/* -------------------- Pantalla de niveles -------------------- */

.hidden {
    display: none !important;
}

.title-wrapper {
    text-align: center;
    margin-bottom: 28px;
}

.game-title {
    font-size: clamp(2.4rem, 4vw, 3rem);
    margin: 0;
    font-weight: 800;
    letter-spacing: 0.03em;
    color: #f97316;
    text-shadow:
        0 4px 10px rgba(248, 250, 252, 0.9),
        0 12px 35px rgba(248, 113, 113, 0.4);
}

.game-subtitle {
    margin: 6px 0 0;
    font-size: 0.95rem;
    color: #9ca3af;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 16px;
    margin-top: 10px;
}

.level-btn {
    position: relative;
    padding: 14px 10px;
    border-radius: 18px;
    background: linear-gradient(145deg, #ffffff, #f3f4ff);
    border: 2px solid #bfdbfe;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    box-shadow: 0 10px 22px rgba(129, 140, 248, 0.35);
    transition: all var(--transition-med);
}

.level-number {
    font-size: 1.5rem;
    font-weight: 800;
    color: #f97316;
}

.level-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.17em;
    text-transform: uppercase;
    color: #9ca3af;
}

.level-btn::after {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 14px;
    background: radial-gradient(circle at top, rgba(129, 140, 248, 0.14), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
    pointer-events: none;
}

.level-btn:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 18px 36px rgba(129, 140, 248, 0.45);
    border-color: #60a5fa;
}

.level-btn:hover::after {
    opacity: 1;
}

/* -------------------- Pantalla de juego -------------------- */

.game-header {
    display: flex;
    justify-content: center;
    gap: 10px;
    align-items: center;
    margin-bottom: 26px;
    flex-wrap: wrap;
}

.chip {
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--chip-bg);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #6b7280;
    box-shadow: 0 4px 12px rgba(148, 163, 253, 0.16);
    border: 1px solid rgba(226, 232, 240, 0.9);
    font-weight: 600;
    backdrop-filter: blur(6px);
}

.chip-level span {
    color: #f97316;
    font-weight: 800;
}

.chip-timer span {
    color: #ef4444;
    font-weight: 800;
}

/* Letras disponibles */

#letter-tiles-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 22px;
}

.letter-tile {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    background: var(--tile-bg);
    color: #0f172a;
    font-weight: 800;
    font-size: 1.4rem;
    box-shadow: var(--tile-shadow);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.letter-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(148, 163, 253, 0.3);
    background: #eff6ff;
}

.letter-tile.disabled {
    background: #e5e7eb;
    color: #9ca3af;
    transform: translateY(1px) scale(0.97);
    box-shadow: 0 2px 4px rgba(148, 163, 253, 0.14);
    cursor: default;
}

@keyframes fadeOutTile {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(0.5); }
}

.letter-tile.consumed {
    animation: fadeOutTile 0.26s ease-out forwards;
}

/* Palabra actual */

#current-word-display-container {
    background: #ffffff;
    border-radius: var(--radius-xl);
    padding: 14px 22px 18px;
    margin: 0 auto 20px;
    max-width: 720px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
    border: 1px solid rgba(226, 232, 240, 0.9);
}

#current-word-display-container .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: #c4b5fd;
    margin-bottom: 4px;
}

#current-word-display {
    min-height: 32px;
    font-size: 2rem;
    letter-spacing: 0.22em;
    font-weight: 700;
    color: #111827;
}

/* Botones acción */

.action-buttons-container {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-bottom: 22px;
}

.btn {
    padding: 11px 30px;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.92rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #ffffff;
    box-shadow: 0 10px 24px rgba(148, 163, 253, 0.26);
    transition: all var(--transition-fast);
}

.btn-primary {
    background: linear-gradient(145deg, #f97316, #fb923c);
}

.btn-danger {
    background: linear-gradient(145deg, #fb7185, #f97316);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(148, 163, 253, 0.34);
    opacity: 0.98;
}

.btn:active {
    transform: translateY(1px) scale(0.97);
    box-shadow: 0 6px 14px rgba(148, 163, 253, 0.24);
}

/* Palabras objetivo */

#target-words-container {
    max-width: 720px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: var(--radius-xl);
    padding: 14px 22px 20px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
    border: 1px solid rgba(226, 232, 240, 0.95);
}

#target-words-container .label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: #9ca3af;
    margin-bottom: 8px;
    text-align: center;
}

#target-words-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

#target-words-list li {
    min-width: 160px;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 1rem;
    letter-spacing: 0.26em;
    text-align: center;
    color: #9ca3af;
    background: #f9fafb;
    border: 1px dashed rgba(209, 213, 219, 0.9);
    transition: all var(--transition-fast);
}

/* estados por longitud (solo visual) */
#target-words-list li.len-4 { background: #eff6ff; }
#target-words-list li.len-5 { background: #fef9c3; }
#target-words-list li.len-6 { background: #e0f2fe; }
#target-words-list li.len-7 { background: #fae8ff; }
#target-words-list li.len-8,
#target-words-list li.len-9,
#target-words-list li.len-10 { background: #fee2e2; }

/* encontrada */
.found-word {
    color: var(--accent-success) !important;
    font-weight: 800;
    letter-spacing: 0.14em !important;
    text-decoration: none;
    background: #ecfdf5 !important;
    border-color: #bbf7d0 !important;
    box-shadow: 0 8px 20px rgba(22, 163, 74, 0.18);
    transform: translateY(-1px);
}

/* -------------------- Modal -------------------- */

#modal {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 40;
}

#modal.hidden {
    display: none !important;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: #ffffff;
    padding: 26px 30px 24px;
    border-radius: 22px;
    text-align: center;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.4);
    max-width: 420px;
    width: 100%;
    z-index: 41;
    animation: modalIn 0.22s ease-out;
}

@keyframes modalIn {
    from { transform: translateY(12px) scale(0.96); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-content h2 {
    margin: 0 0 10px;
    font-size: 1.9rem;
    font-weight: 800;
    color: #111827;
}

.modal-content p {
    margin: 0 0 14px;
    font-size: 0.98rem;
    color: #6b7280;
}

#missing-words-list {
    list-style: none;
    padding: 0;
    margin: 0 0 10px;
    color: #6366f1;
    font-size: 0.96rem;
    font-weight: 600;
}

#restart-btn {
    margin-top: 8px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 999px;
    font-size: 0.98rem;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    background: linear-gradient(145deg, #6b7280, #4b5563);
    color: #ffffff;
    box-shadow: 0 10px 26px rgba(75, 85, 99, 0.4);
    transition: all var(--transition-fast);
}

#restart-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 32px rgba(75, 85, 99, 0.5);
}

#restart-btn:active {
    transform: translateY(1px) scale(0.97);
}

/* =========================
   Cuenta regresiva 3-2-1-¡YA!
   ========================= */

#countdown-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, rgba(15,23,42,0.32), transparent 70%);
    z-index: 50;
}

#countdown-overlay.hidden {
    display: none !important;
}

#countdown-circle {
    width: 160px;
    height: 160px;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0.8);
    animation: countdownScaleIn 0.25s ease-out forwards;
}

#countdown-number {
    font-size: 4rem;
    font-weight: 900;
    color: #f97316;
    letter-spacing: 0.06em;
    text-shadow:
        0 4px 10px rgba(0,0,0,0.45),
        0 0 16px rgba(252, 211, 77, 0.85);
    animation: countdownPop 0.6s ease-out;
}

@keyframes countdownPop {
    0% {
        transform: scale(0.4);
        opacity: 0;
    }
    40% {
        transform: scale(1.1);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes countdownScaleIn {
    from {
        transform: scale(0.7);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* -------------------- Responsive -------------------- */

@media (max-width: 768px) {
    #app-container {
        padding: 16px;
    }

    #game-card {
        padding: 24px 18px 24px;
        border-radius: 24px;
    }

    .action-buttons-container {
        flex-direction: column;
        gap: 10px;
    }

    #current-word-display {
        font-size: 1.6rem;
    }
}
