:root {
    --bg-rose: #fff3ef;
    --bg-peach: #ffd9c7;
    --bg-coral: #ff9f8a;
    --bg-berry: #9b365e;
    --ink: #4a2033;
    --ink-soft: #7c4d62;
    --panel: rgba(255, 251, 248, 0.74);
    --panel-strong: rgba(255, 248, 244, 0.9);
    --line: rgba(155, 54, 94, 0.16);
    --shadow: 0 24px 60px rgba(122, 49, 80, 0.18);
    --shadow-soft: 0 16px 30px rgba(122, 49, 80, 0.12);
    --green: #6aaa64;
    --yellow: #c9b458;
    --gray: #787c7e;
    --key: #f3dfe4;
    --key-hover: #ebc6d1;
    --puzzle-piece-size: 84px;
    --puzzle-gap: 8px;
    --page-bg-start: var(--bg-rose);
    --page-bg-mid: var(--bg-peach);
    --page-bg-end: #ffc4b5;
    --page-glow-left: rgba(255, 255, 255, 0.9);
    --page-glow-right: rgba(255, 190, 170, 0.5);
    --page-orb-top: rgba(255, 255, 255, 0.34);
    --page-orb-bottom: rgba(255, 126, 120, 0.2);
    --nav-bg: rgba(255, 250, 247, 0.66);
    --nav-border: rgba(255, 255, 255, 0.6);
    --nav-hover-bg: rgba(255, 255, 255, 0.72);
    --nav-hover-shadow: rgba(155, 54, 94, 0.12);
    --logo-bg-start: #fffaf8;
    --logo-bg-end: #ffd7de;
    --content-bg: var(--panel);
    --content-border: rgba(255, 255, 255, 0.62);
    --surface-bg: rgba(255, 255, 255, 0.5);
    --surface-border: rgba(255, 255, 255, 0.78);
    --surface-shadow: rgba(122, 49, 80, 0.1);
    --game-title: var(--bg-berry);
    --game-text: var(--ink-soft);
    --wordle-cell-border: rgba(155, 54, 94, 0.18);
    --wordle-cell-border-filled: rgba(155, 54, 94, 0.4);
    --wordle-cell-bg-top: rgba(255, 255, 255, 0.95);
    --wordle-cell-bg-bottom: rgba(255, 244, 246, 0.85);
    --wordle-cell-shadow: rgba(122, 49, 80, 0.08);
    --wordle-key-bg-top: var(--key);
    --wordle-key-bg-bottom: #f7e8ec;
    --wordle-key-hover-top: var(--key-hover);
    --wordle-key-hover-bottom: #f4d7de;
    --wordle-key-shadow: rgba(122, 49, 80, 0.1);
    --wordle-key-hover-shadow: rgba(122, 49, 80, 0.14);
    --wordle-mode-button-bg: rgba(255, 255, 255, 0.64);
    --wordle-mode-button-border: rgba(255, 255, 255, 0.78);
    --wordle-mode-button-shadow: rgba(122, 49, 80, 0.08);
    --wordle-mode-button-hover-bg: rgba(255, 255, 255, 0.82);
    --wordle-mode-button-hover-shadow: rgba(122, 49, 80, 0.12);
    --wordle-mode-button-active-border: rgba(155, 54, 94, 0.28);
    --wordle-mode-button-active-top: rgba(255, 255, 255, 0.96);
    --wordle-mode-button-active-bottom: rgba(255, 235, 242, 0.84);
}

body.theme-quimica {
    --ink: #d7ece2;
    --ink-soft: #b1cec0;
    --page-bg-start: #173126;
    --page-bg-mid: #244a39;
    --page-bg-end: #10241b;
    --page-glow-left: rgba(222, 244, 233, 0.1);
    --page-glow-right: rgba(79, 139, 111, 0.16);
    --page-orb-top: rgba(122, 175, 147, 0.1);
    --page-orb-bottom: rgba(10, 28, 20, 0.34);
    --nav-bg: rgba(24, 47, 36, 0.76);
    --nav-border: rgba(79, 139, 111, 0.22);
    --nav-hover-bg: rgba(37, 70, 55, 0.92);
    --nav-hover-shadow: rgba(7, 20, 15, 0.26);
    --logo-bg-start: #244836;
    --logo-bg-end: #3f6f57;
    --content-bg: rgba(20, 39, 30, 0.82);
    --content-border: rgba(88, 140, 114, 0.2);
    --surface-bg: rgba(24, 48, 37, 0.68);
    --surface-border: rgba(94, 149, 121, 0.18);
    --surface-shadow: rgba(7, 19, 14, 0.26);
    --game-title: #8dc9a9;
    --game-text: #b6d5c5;
    --wordle-cell-border: rgba(102, 154, 127, 0.24);
    --wordle-cell-border-filled: rgba(125, 181, 151, 0.34);
    --wordle-cell-bg-top: rgba(33, 63, 49, 0.96);
    --wordle-cell-bg-bottom: rgba(25, 49, 38, 0.94);
    --wordle-cell-shadow: rgba(6, 17, 12, 0.24);
    --wordle-key-bg-top: #355d49;
    --wordle-key-bg-bottom: #284939;
    --wordle-key-hover-top: #3d6a53;
    --wordle-key-hover-bottom: #315441;
    --wordle-key-shadow: rgba(6, 17, 12, 0.22);
    --wordle-key-hover-shadow: rgba(6, 17, 12, 0.28);
    --wordle-mode-button-bg: rgba(31, 59, 45, 0.86);
    --wordle-mode-button-border: rgba(97, 151, 122, 0.24);
    --wordle-mode-button-shadow: rgba(7, 19, 14, 0.22);
    --wordle-mode-button-hover-bg: rgba(41, 74, 58, 0.94);
    --wordle-mode-button-hover-shadow: rgba(7, 19, 14, 0.3);
    --wordle-mode-button-active-border: rgba(129, 190, 157, 0.32);
    --wordle-mode-button-active-top: rgba(57, 95, 75, 0.96);
    --wordle-mode-button-active-bottom: rgba(36, 64, 50, 0.96);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    padding: 110px 18px 32px;
    font-family: 'Poppins', sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, var(--page-glow-left), transparent 30%),
        radial-gradient(circle at top right, var(--page-glow-right), transparent 28%),
        linear-gradient(135deg, var(--page-bg-start) 0%, var(--page-bg-mid) 52%, var(--page-bg-end) 100%);
    overflow-x: hidden;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: auto;
    border-radius: 999px;
    filter: blur(10px);
    pointer-events: none;
    z-index: 0;
}

body::before {
    top: 90px;
    left: -70px;
    width: 240px;
    height: 240px;
    background: var(--page-orb-top);
}

body::after {
    right: -50px;
    bottom: 40px;
    width: 220px;
    height: 220px;
    background: var(--page-orb-bottom);
}

.navbar,
#contenido {
    position: relative;
    z-index: 1;
}

.navbar {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: min(1120px, calc(100% - 24px));
    min-height: 74px;
    padding: 14px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background: var(--nav-bg);
    border: 1px solid var(--nav-border);
    border-radius: 24px;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: var(--shadow-soft);
}

.logo {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--logo-bg-start), var(--logo-bg-end));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    font-size: 1.45rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-links a {
    padding: 10px 16px;
    border-radius: 999px;
    text-decoration: none;
    color: var(--ink);
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.nav-links a:hover,
.nav-links a:focus-visible {
    background: var(--nav-hover-bg);
    color: var(--game-title);
    box-shadow: 0 10px 18px var(--nav-hover-shadow);
    transform: translateY(-1px);
    outline: none;
}

#contenido {
    width: min(920px, 100%);
    margin: 0 auto;
    min-height: calc(100dvh - 160px);
    padding: 34px 28px 38px;
    text-align: center;
    background: var(--content-bg);
    border: 1px solid var(--content-border);
    border-radius: 32px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    isolation: isolate;
    overflow-x: clip;
    animation: aparecer 0.55s ease;
}

#contenido h2 {
    margin-bottom: 12px;
    font-size: clamp(2rem, 3vw, 2.8rem);
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--game-title);
}

#contenido p {
    max-width: 650px;
    margin: 0 auto;
    color: var(--game-text);
    font-size: 1.05rem;
    line-height: 1.7;
}

#contenido h3 {
    color: var(--game-title);
}

.subtexto-juego {
    margin-bottom: 12px;
}

.juego-superficie {
    position: relative;
    width: fit-content;
    max-width: 100%;
    margin: 26px auto 0;
    padding: 18px;
    border-radius: 28px;
    background: var(--surface-bg);
    border: 1px solid var(--surface-border);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 18px 32px var(--surface-shadow);
    overflow: visible;
}

.mensaje-juego {
    min-height: 30px;
    margin-top: 18px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--game-title);
}

.victory-canvas {
    position: absolute;
    left: 0;
    pointer-events: none;
    z-index: 3;
    overflow: visible;
}

/* Inicio */
.inicio-hero {
    display: grid;
    grid-template-columns: minmax(260px, 0.9fr) minmax(280px, 1.1fr);
    align-items: center;
    gap: 24px;
    text-align: left;
}

.inicio-copy {
    padding: 14px 6px 14px 2px;
}

.inicio-etiqueta {
    display: inline-block;
    margin-bottom: 14px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.76);
    color: var(--bg-berry);
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    box-shadow: 0 10px 18px rgba(155, 54, 94, 0.1);
}

.inicio-copy h2 {
    margin-bottom: 14px;
}

.inicio-copy p {
    margin: 0;
    font-size: 1.08rem;
}

.corazon-particulas-card {
    position: relative;
    min-height: 340px;
    padding: 16px;
    border-radius: 28px;
    background:
        radial-gradient(circle at top, rgba(255, 255, 255, 0.95), rgba(255, 239, 243, 0.82) 48%, rgba(255, 223, 227, 0.7) 100%);
    border: 1px solid rgba(255, 255, 255, 0.78);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.85),
        0 18px 36px rgba(122, 49, 80, 0.12);
    overflow: hidden;
}

.corazon-particulas-card::before,
.corazon-particulas-card::after {
    content: "";
    position: absolute;
    border-radius: 999px;
    pointer-events: none;
}

.corazon-particulas-card::before {
    top: -18px;
    right: -8px;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.5);
    filter: blur(8px);
}

.corazon-particulas-card::after {
    bottom: 22px;
    left: 18px;
    width: 76px;
    height: 76px;
    background: rgba(255, 150, 170, 0.18);
    filter: blur(10px);
}

#heart-particles {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 360px;
}

/* Puzzle */
#tablero {
    position: relative;
    display: grid;
    grid-template-columns: repeat(4, var(--puzzle-piece-size));
    grid-template-rows: repeat(4, var(--puzzle-piece-size));
    gap: var(--puzzle-gap);
    justify-content: center;
    margin: 0 auto;
    padding: 14px;
    width: fit-content;
    max-width: 100%;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.68);
    border-radius: 16px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.pieza {
    width: var(--puzzle-piece-size);
    height: var(--puzzle-piece-size);
    background-size: calc(var(--puzzle-piece-size) * 4) calc(var(--puzzle-piece-size) * 4);
    cursor: pointer;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.75);
    box-shadow: 0 8px 16px rgba(122, 49, 80, 0.12);
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.pieza:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 14px 20px rgba(122, 49, 80, 0.18);
    filter: saturate(1.08);
}

.vacia {
    background: rgba(255, 255, 255, 0.22);
    border-style: dashed;
    box-shadow: inset 0 0 0 1px rgba(155, 54, 94, 0.08);
}

/* Wordle */
.wordle-toolbar {
    position: absolute;
    top: 34px;
    right: 28px;
    display: flex;
    gap: 10px;
    z-index: 2;
}

.wordle-toolbar + h2 {
    padding-top: 26px;
}

.wordle-mode-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid var(--wordle-mode-button-border);
    border-radius: 999px;
    background: var(--wordle-mode-button-bg);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 18px var(--wordle-mode-button-shadow);
    transition: transform 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.wordle-mode-button:hover,
.wordle-mode-button:focus-visible {
    transform: translateY(-1px);
    background: var(--wordle-mode-button-hover-bg);
    box-shadow: 0 14px 22px var(--wordle-mode-button-hover-shadow);
    outline: none;
}

.wordle-mode-button.activo {
    border-color: var(--wordle-mode-button-active-border);
    background: linear-gradient(180deg, var(--wordle-mode-button-active-top), var(--wordle-mode-button-active-bottom));
}

.wordle-mode-button-emoji {
    font-size: 1rem;
}

.wordle-tablero {
    position: relative;
    display: grid;
    gap: var(--wordle-gap, 6px);
    margin-top: 0;
    justify-content: center;
    width: 100%;
}

.wordle-superficie {
    width: 100%;
    margin: 26px auto 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.wordle-fila {
    display: grid;
    gap: var(--wordle-gap, 6px);
    justify-content: center;
    margin-bottom: 0;
    width: 100%;
}

.wordle-casilla {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--wordle-cell-border);
    border-radius: 12px;
    background:
        linear-gradient(180deg, var(--wordle-cell-bg-top), var(--wordle-cell-bg-bottom));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        0 8px 18px var(--wordle-cell-shadow);
    color: var(--ink);
    font-size: 1.7rem;
    font-weight: 700;
    text-transform: uppercase;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.wordle-casilla:not(:empty) {
    border-color: var(--wordle-cell-border-filled);
    transform: translateY(-1px);
}

.wordle-teclado {
    margin-top: 26px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.teclado-fila {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: nowrap;
    width: min(100%, 640px);
    max-width: 100%;
}

.tecla {
    min-width: 0;
    flex: 1 1 0;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 12px;
    background: linear-gradient(180deg, var(--wordle-key-bg-top), var(--wordle-key-bg-bottom));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.7),
        0 8px 16px var(--wordle-key-shadow);
    color: var(--ink);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    cursor: pointer;
    user-select: none;
    text-align: center;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.tecla-accion {
    flex: 1.45 1 0;
}

.tecla:hover {
    background: linear-gradient(180deg, var(--wordle-key-hover-top), var(--wordle-key-hover-bottom));
    transform: translateY(-1px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.75),
        0 10px 18px var(--wordle-key-hover-shadow);
}

.tecla[style*="#6aaa64"]:hover,
.tecla[style*="#c9b458"]:hover,
.tecla[style*="#787c7e"]:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
}

.mensaje-wordle-definicion {
    display: block;
    margin-top: 6px;
    font-weight: 500;
    line-height: 1.5;
}

.tecla:active {
    transform: translateY(1px);
}

/* Animaciones */
@keyframes aparecer {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        position: sticky;
        top: 10px;
        left: auto;
        transform: none;
        width: 100%;
        margin: 0 auto 14px;
        padding: 12px 14px;
        border-radius: 20px;
    }

    body {
        padding-top: 14px;
    }

    .nav-links {
        gap: 6px;
        justify-content: flex-end;
    }

    .nav-links a {
        padding: 8px 12px;
        font-size: 0.92rem;
    }

    #contenido {
        min-height: calc(100dvh - 120px);
        padding: 26px 16px 28px;
        border-radius: 26px;
    }

    .inicio-hero {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .inicio-copy {
        padding: 0;
    }

    .inicio-copy p {
        margin: 0 auto;
    }

    .corazon-particulas-card {
        min-height: 300px;
        padding: 12px;
    }

    #heart-particles {
        height: 320px;
    }

    #tablero {
        --puzzle-piece-size: min(16vw, 68px);
        --puzzle-gap: 6px;
        padding: 10px;
    }

    .pieza {
        border-radius: 10px;
    }

    .wordle-casilla {
        font-size: 1.35rem;
        border-radius: 10px;
    }

    .wordle-toolbar {
        top: 16px;
        right: 16px;
        left: 16px;
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    .juego-superficie {
        padding: 12px;
        border-radius: 22px;
    }

    .tecla {
        padding: 10px 10px;
        font-size: 0.82rem;
        border-radius: 10px;
    }
}

@media (max-width: 480px) {
    body {
        padding-inline: 8px;
    }

    .navbar {
        width: 100%;
        max-width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .logo {
        align-self: center;
    }

    .nav-links {
        width: 100%;
        justify-content: center;
    }

    .corazon-particulas-card {
        min-height: 260px;
        border-radius: 22px;
    }

    .juego-superficie {
        padding: 10px;
        border-radius: 20px;
    }

    .wordle-superficie {
        padding: 0;
    }

    .wordle-toolbar {
        justify-content: center;
    }

    #heart-particles {
        height: 280px;
    }

    .wordle-casilla {
        font-size: 1.2rem;
    }

    .teclado-fila {
        gap: 4px;
    }

    .tecla {
        padding: 9px 8px;
        font-size: 0.76rem;
        border-radius: 9px;
    }

    #tablero {
        --puzzle-piece-size: min(20vw, 58px);
        --puzzle-gap: 5px;
        padding: 8px;
    }

    #contenido {
        min-height: calc(100dvh - 110px);
        padding-inline: 12px;
    }
}
