:root {
    --bg-dark: #0f1722;
    --panel: #0f1722;
    --text: #e6eef8;
    --muted: #98a0b3;
    --accent: #f0b90b;
    --tile: #24282b;
    --correct: #6aaa64;
    --present: #c9b458;
    --absent: #313131;
    --icon-color: #ffffff;
}

/* Light theme */
body.light {
    --bg-dark: #b7d4ff;
    --panel: #f7f9fc;
    --text: #0b1320;
    --muted: #6483cd;
    --accent: #b77900;
    --tile: #e6eef8;
    --icon-color: #000000;
}

.home-icon {
    filter: brightness(0) invert(1);
    transition: filter 0.3s ease;
}

body.light .home-icon {
    filter: brightness(0) invert(0);
}

* {
    box-sizing: border-box
}

body {
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    margin: 0;
    background: var(--bg-dark);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 640px;
    margin: 20px auto;
    padding: 16px;
}

.top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.controls {
    display: flex;
    align-items: center;
}

.small {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text);
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    padding: 10px;
    margin-left: 8px;
    margin-right: 8px;
}

.small.danger {
    background: transparent;
    border: 1px solid rgba(255, 80, 80, 0.15);
    color: #ffdddd
}

.small.hidden {
    display: none
}

.small.green {
    background: transparent;
    border: 1px solid rgba(5, 47, 3, 0.15);
    color: #1aa305
}

.muted {
    color: var(--muted);
    font-size: 0.9rem
}

.homeScreen {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.btnMain {
    width: 50dvh;
    height: 60px;
    margin: 4px;
    font-weight: bold;
    text-transform: uppercase;
    color: #fff;
    background-color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    gap: 10px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.btnMain:hover {
    background-color: #444;
}

.btnMain .home-icon {
    width: 28px;
    height: 28px;
    filter: brightness(0) invert(1);
    transition: filter 0.3s ease;
}

body.light .btnMain .home-icon {
    filter: brightness(0) invert(0);
}

.logo {
    width: 80dvw;
    height: 50dvh;
    margin: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--panel);
}

.center {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 18px;
}

.shuffled {
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.6rem;
    font-size: 1.6rem;
    color: var(--muted);
    margin: 10px 0;
}

.board {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 8px;
}

.board.hidden {
    display: none;
}

.row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.tile {
    width: 60px;
    height: 60px;
    margin: 4px;
    font-size: 2rem;
    font-weight: bold;
    text-transform: uppercase;
    color: #fff;
    background-color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transform-style: preserve-3d;
    transition: transform 0.3s ease-in-out, background-color 0.3s ease;
}

.tile.flip-half {
    transform: rotateX(90deg);
}

.tile.flip-done {
    transform: rotateX(0deg);
}

.tile.correct {
    background: var(--correct);
    border-color: var(--correct);
    color: #fff;
}

.tile.present {
    background: var(--present);
    color: #111;
}

.tile.absent {
    background: var(--absent);
    color: #ddd;
}

.keyboard {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 6px;
    margin-top: 18px;
    width: 100%;
}

.keyboard.hidden {
    display: none;
}

.key {
    height: 48px;
    border-radius: 8px;
    border: none;
    background: #6b6f73;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.key.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: #444;
}

.key.special {
    grid-column: span 2;
    background: #2b2f33;
}

body.light .key.special {
    --text: #ffffff;
}

.footer {
    margin-top: 18px;
    text-align: center;
    font-size: 0.9rem;
}

/* Overlay */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 10, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 120;
}

.overlay.hidden {
    display: none
}

.overlay-card {
    background: var(--panel);
    color: var(--text);
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    text-align: center;
}

.overlay-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
}

#levelButtons button:hover {
    background-color: #b77900;
}

/* ======= General ======= */
#levels {
    text-align: center;
    color: #fff;
    max-width: 600px;
    margin: 0 auto;
    font-family: 'Inter', sans-serif;
}

#levels h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    font-weight: 600;
}

/* ======= Level Grid ======= */
.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
    gap: 10px;
    justify-items: center;
    margin-bottom: 20px;
}

.level-grid button {
    width: 50px;
    height: 50px;
    background-color: #1f1f1f;
    color: #f0f0f0;
    border: 1px solid #333;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.level-grid button:hover {
    background-color: #333;
    transform: scale(1.08);
    border-color: #555;
}

/* ======= Pagination ======= */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.page-btn {
    background-color: #1f1f1f;
    color: #f0f0f0;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 60px;
}

.page-btn:hover {
    background-color: #333;
    transform: scale(1.05);
}

#pageIndicator {
    font-size: 1rem;
    opacity: 0.8;
}

button {
    background: #333;
    color: white;
    border: 1px solid #666;
    border-radius: 8px;
    font-size: 1.2em;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

button:hover {
    background: var(--accent);
    border-color: var(--accent);
}

body.light button:hover {
    background: #f0b90b;
}

body.light button {
    background: #eee;
    color: #222;
    border-color: #ccc;
}

.hidden {
    display: none;
}

/* === BLOQUE DE TÍTULO === */
.title-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    margin-bottom: 2rem;
    padding: 0;
}


.word {
    margin: 0.3rem 0;
}

/* === LETRAS === */
.letter-tile {
    display: inline-block;
    background: #fff;
    color: #222;
    border-radius: 10px;
    font-weight: 700;
    font-size: 2rem;
    padding: 0.5rem 0.75rem;
    margin: 0.2rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.letter-tile:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

/* === FLECHA ANIMADA === */
.arrow {
    font-size: 2.5rem;
    color: #2f80ed;
    margin: 0.8rem 0;
    animation: bounce 1.5s infinite;
}

/* confetti */
.confetti {
    position: fixed;
    top: -10vh;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    pointer-events: none;
    z-index: 9999;
    animation: fall linear forwards;
}


@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

@keyframes fall {
    to {
        transform: translateY(120vh) rotate(720deg);
        opacity: 0
    }
}

/* responsive */
@media (max-width:600px) {
    .title {
        width: 48px;
        height: 48px;
        font-size: 1.1rem;
    }

    .keyboard {
        grid-template-columns: repeat(8, 1fr)
    }

    .shuffled {
        font-size: 1.2rem;
        letter-spacing: 0.45rem
    }

    h1 {
        font-size: 1.8rem;
    }

    .letter-tile {
        font-size: 1.4rem;
        padding: 0.4rem 0.6rem;
    }

    button {
        width: 80%;
        font-size: 0.9rem;
    }
}