/* ============================================================
   FIESTA ESPAÑOL — Comic + flat colours + a hand-made feel
   Thick ink outlines, hard offset shadows, plain bright colours.
   One font: Comic Neue. No AI. Vanilla CSS.
   ============================================================ */

/* ---------- COLOURS & TOKENS ---------- */
:root {
    /* plain, flat brand colours */
    --red: #e63946;
    /* main red        */
    --yellow: #ffc300;
    /* sunny yellow    */
    --teal: #2a9d8f;
    /* teal            */
    --green: #43aa5b;
    /* leaf green      */
    --blue: #2274d6;
    /* clear blue      */

    /* surfaces */
    --paper: #fff8ec;
    /* warm off-white background */
    --card: #ffffff;
    --ink: #1e1a17;
    /* near-black outline & text */
    --muted: #7c7166;
    /* soft brown-grey text      */

    /* the "hand-made" hard shadow */
    --line: 3px;
    --shadow: 5px 5px 0 var(--ink);
    --shadow-lg: 8px 8px 0 var(--ink);

    --radius: 14px;
    --pop: all .18s cubic-bezier(.34, 1.56, .64, 1);

    /* legacy aliases still used by inline styles in the HTML */
    --blue-2: #eaf2ff;
    --blue-3: var(--blue);
    --green-2: var(--green);
    --red-2: var(--red);
    --cream: var(--paper);
    --panel: var(--card);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Comic Neue', 'Comic Sans MS', cursive, sans-serif;
    background: var(--paper);
    color: var(--ink);
    line-height: 1.6;
    overflow-x: hidden;
    font-weight: 400;
}

a {
    color: var(--blue);
}

/* ---------- READABILITY PANELS (keep text legible over any background) ---------- */
header,
main {
    position: relative;
    z-index: 1;
}

main::before {
    content: "";
    position: absolute;
    inset: 10px 6px;
    background: rgba(255, 248, 236, .82);
    backdrop-filter: blur(3px);
    border-radius: 24px;
    z-index: -1;
}

/* ---------- HEADER ---------- */
header {
    text-align: center;
    padding: 40px 20px 30px;
    margin: 20px auto 0;
    max-width: 920px;
    background: rgba(255, 248, 236, .82);
    backdrop-filter: blur(3px);
    border: var(--line) solid var(--ink);
    border-radius: 22px;
}

.logo {
    font-size: clamp(2.8rem, 9vw, 5rem);
    font-weight: 700;
    letter-spacing: -1px;
    color: var(--ink);
    line-height: 1;
}

.logo span {
    color: var(--red);
    display: inline-block;
    transform: rotate(-2deg);
}

.tagline {
    margin-top: 14px;
    font-size: 1.15rem;
    color: var(--muted);
    font-weight: 700;
}

/* ---------- STATS ---------- */
.stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    max-width: 900px;
    margin: 0 auto;
    padding: 8px 16px;
}

.stat-pill {
    background: var(--card);
    border: var(--line) solid var(--ink);
    border-radius: 100px;
    padding: 8px 22px;
    font-weight: 700;
    box-shadow: 3px 3px 0 var(--ink);
    transition: var(--pop);
}

.stat-pill:hover {
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0 var(--ink);
}

.stat-pill b {
    color: var(--green);
    margin-left: 5px;
}

/* ---------- NAV ---------- */
nav {
    position: sticky;
    top: 14px;
    z-index: 100;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    max-width: 920px;
    margin: 26px auto;
    padding: 10px;
    background: var(--card);
    border: var(--line) solid var(--ink);
    border-radius: 100px;
    box-shadow: var(--shadow);
}

.tab {
    cursor: pointer;
    border: none;
    background: transparent;
    font-family: inherit;
    font-weight: 700;
    font-size: .95rem;
    color: var(--ink);
    padding: 9px 18px;
    border-radius: 100px;
    transition: var(--pop);
}

.tab:hover {
    background: var(--yellow);
}

.tab.active {
    background: var(--ink);
    color: var(--paper);
}

/* ---------- MAIN ---------- */
main {
    max-width: 920px;
    margin: 0 auto;
    padding: 36px 22px 110px;
}

section {
    display: none;
}

section.show {
    display: block;
    animation: slide .45s cubic-bezier(.16, 1, .3, 1);
}

@keyframes slide {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h2.title {
    font-size: clamp(2rem, 5vw, 2.8rem);
    font-weight: 700;
    text-align: center;
    margin-bottom: 6px;
    letter-spacing: -.5px;
}

h2.title span {
    color: var(--green);
    display: inline-block;
    transform: rotate(-1deg);
}

.subtitle {
    text-align: center;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 34px;
}

.divider {
    height: var(--line);
    background: var(--ink);
    border-radius: 100px;
    margin: 44px auto;
    max-width: 120px;
    opacity: .25;
}

.center {
    text-align: center;
}

.row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

/* ---------- CARDS ---------- */
.card {
    background: var(--card);
    border: var(--line) solid var(--ink);
    border-radius: var(--radius);
    padding: 32px;
    margin: 24px 0;
    box-shadow: var(--shadow);
}

.card.accent-red {
    box-shadow: 6px 6px 0 var(--red);
}

.card.accent-blue {
    box-shadow: 6px 6px 0 var(--blue);
}

.card.accent-green {
    box-shadow: 6px 6px 0 var(--green);
}

/* ---------- BUTTONS ---------- */
.btn {
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    font-size: 1.05rem;
    border: var(--line) solid var(--ink);
    border-radius: 12px;
    padding: 12px 26px;
    background: var(--yellow);
    color: var(--ink);
    box-shadow: 4px 4px 0 var(--ink);
    transition: var(--pop);
    margin: 5px;
}

.btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--ink);
}

.btn:active {
    transform: translate(2px, 2px);
    box-shadow: 0 0 0 var(--ink);
}

.btn.big {
    padding: 16px 40px;
    font-size: 1.2rem;
}

.btn.small {
    padding: 8px 16px;
    font-size: .9rem;
    box-shadow: 3px 3px 0 var(--ink);
}

.btn.blue {
    background: var(--blue);
    color: #fff;
}

.btn.red {
    background: var(--red);
    color: #fff;
}

.btn.ghost {
    background: var(--card);
}

/* ---------- HOME HERO ---------- */
.welcome {
    text-align: center;
    background: var(--green);
    color: #fff;
    border: var(--line) solid var(--ink);
    border-radius: var(--radius);
    padding: 44px 28px;
    box-shadow: var(--shadow-lg);
}

.welcome h3 {
    font-size: 2rem;
    font-weight: 700;
}

.welcome p {
    margin-top: 12px;
    color: #fff;
    max-width: 560px;
    margin-inline: auto;
    font-weight: 700;
}

.hero-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.hero-card {
    background: var(--card);
    border: var(--line) solid var(--ink);
    border-radius: var(--radius);
    padding: 26px;
    cursor: pointer;
    box-shadow: 4px 4px 0 var(--ink);
    transition: var(--pop);
}

.hero-card:nth-child(3n+1):hover {
    box-shadow: 8px 8px 0 var(--red);
}

.hero-card:nth-child(3n+2):hover {
    box-shadow: 8px 8px 0 var(--teal);
}

.hero-card:nth-child(3n+3):hover {
    box-shadow: 8px 8px 0 var(--blue);
}

.hero-card:hover {
    transform: translate(-3px, -3px) rotate(-1deg);
}

.hero-card h3 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--red);
    margin-bottom: 6px;
}

.hero-card p {
    color: var(--muted);
    font-weight: 700;
    font-size: .95rem;
}

/* ---------- FACT ---------- */
.fact {
    position: relative;
    background: #fff5d6;
    border: var(--line) solid var(--ink);
    border-radius: var(--radius);
    padding: 26px 26px 22px;
    margin-top: 26px;
    font-weight: 700;
    box-shadow: 4px 4px 0 var(--yellow);
}

.fact::before {
    content: '¡Sabías que!';
    position: absolute;
    top: -16px;
    left: 20px;
    background: var(--yellow);
    border: var(--line) solid var(--ink);
    border-radius: 8px;
    padding: 2px 12px;
    font-size: .8rem;
    font-weight: 700;
}

.fact b {
    color: var(--red);
}

/* ---------- FLASHCARD ---------- */
.flip {
    perspective: 1200px;
    height: 300px;
    max-width: 480px;
    margin: 30px auto;
    cursor: pointer;
}

.flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform .7s cubic-bezier(.175, .885, .32, 1.275);
    transform-style: preserve-3d;
}

.flip.flipped .flip-inner {
    transform: rotateY(180deg);
}

.face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border: var(--line) solid var(--ink);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 36px;
    text-align: center;
    box-shadow: var(--shadow);
}

.face.front {
    background: var(--card);
}

.face.back {
    background: var(--teal);
    color: #fff;
    transform: rotateY(180deg);
}

.face .big-word {
    font-size: clamp(2.2rem, 7vw, 3.4rem);
    font-weight: 700;
}

.face.front .big-word {
    color: var(--red);
}

.face .small {
    font-weight: 700;
    margin-top: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: .85rem;
    opacity: .65;
}

/* ---------- CHIP GRID ---------- */
.chip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 14px;
}

.chip {
    background: var(--card);
    border: var(--line) solid var(--ink);
    border-radius: 12px;
    padding: 16px 8px;
    text-align: center;
    cursor: pointer;
    box-shadow: 3px 3px 0 var(--ink);
    transition: var(--pop);
}

.chip:hover {
    background: var(--yellow);
    transform: translate(-2px, -2px) rotate(-3deg);
    box-shadow: 5px 5px 0 var(--ink);
}

.chip .letter {
    font-size: 2rem;
    font-weight: 700;
    color: var(--ink);
}

.chip .say {
    font-size: .82rem;
    color: var(--muted);
    font-weight: 700;
    margin-top: 4px;
}

.color-swatch {
    height: 64px;
    border-radius: 9px 9px 0 0;
    border-bottom: var(--line) solid var(--ink);
}

/* ---------- QUIZ OPTIONS ---------- */
.opt {
    display: block;
    width: 100%;
    text-align: left;
    background: var(--card);
    border: var(--line) solid var(--ink);
    border-radius: 12px;
    padding: 18px 22px;
    margin: 12px 0;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 4px 4px 0 var(--ink);
    transition: var(--pop);
}

.opt:hover {
    transform: translateX(8px);
}

.opt.correct {
    background: var(--green);
    color: #fff;
}

.opt.wrong {
    background: var(--red);
    color: #fff;
}

.progress-track {
    height: 14px;
    width: 100%;
    background: #eee9dc;
    border: var(--line) solid var(--ink);
    border-radius: 100px;
    overflow: hidden;
    margin: 18px 0;
}

.progress-fill {
    height: 100%;
    background: var(--green);
    width: 0;
    transition: width .5s;
}

/* ---------- TABLES ---------- */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

th,
td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 2px solid #eee3d0;
}

th {
    color: var(--teal);
    font-weight: 700;
}

input.txt {
    background: var(--card);
    border: var(--line) solid var(--ink);
    color: var(--ink);
    padding: 10px 12px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    width: 100%;
    max-width: 200px;
}

input.txt:focus {
    outline: none;
    box-shadow: 3px 3px 0 var(--yellow);
}

input.ok {
    background: #e4f6e8;
    border-color: var(--green);
}

input.no {
    background: #fde5e5;
    border-color: var(--red);
}

/* ---------- PHRASES ---------- */
.phrase {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 14px 14px;
    border-bottom: 2px solid #eee3d0;
    cursor: pointer;
    border-radius: 10px;
    transition: background .15s;
}

.phrase:hover {
    background: #fff5d6;
}

.phrase .es {
    font-weight: 700;
    color: var(--ink);
    font-size: 1.2rem;
}

.phrase .en {
    color: var(--muted);
    font-weight: 700;
    text-align: right;
}

.phrase .spk {
    color: var(--teal);
    font-weight: 700;
    font-size: .85rem;
    white-space: nowrap;
}

/* ---------- MEMORY ---------- */
.mem-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    max-width: 460px;
    margin: 18px auto;
}

.mem-card {
    aspect-ratio: 1;
    background: var(--blue);
    border: var(--line) solid var(--ink);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    color: transparent;
    box-shadow: 3px 3px 0 var(--ink);
    text-align: center;
    padding: 5px;
    transition: var(--pop);
}

.mem-card.up {
    background: var(--yellow);
    color: var(--ink);
}

.mem-card.matched {
    background: var(--green);
    color: #fff;
    cursor: default;
}

/* ---------- HANGMAN ---------- */
.hang-word {
    font-size: 2.2rem;
    letter-spacing: .4rem;
    text-align: center;
    color: var(--red);
    font-weight: 700;
    margin: 18px 0;
}

.key {
    width: 44px;
    height: 44px;
    margin: 3px;
    border: var(--line) solid var(--ink);
    border-radius: 10px;
    background: var(--card);
    color: var(--ink);
    font-family: inherit;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 2px 2px 0 var(--ink);
    transition: var(--pop);
}

.key:hover:not(:disabled) {
    background: var(--yellow);
    transform: translate(-1px, -1px);
}

.key:disabled {
    opacity: .25;
    cursor: default;
    box-shadow: none;
}

.lives {
    text-align: center;
    color: var(--muted);
    font-weight: 700;
    font-size: 1.1rem;
}

.lives b {
    color: var(--red);
}

/* ---------- SCRAMBLE ---------- */
.scramble {
    font-size: 2.4rem;
    font-weight: 700;
    letter-spacing: .5rem;
    text-align: center;
    color: var(--teal);
    margin: 20px 0;
}

/* ---------- MATCH ---------- */
.match-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.match-item {
    background: var(--card);
    border: var(--line) solid var(--ink);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    font-weight: 700;
    box-shadow: 3px 3px 0 var(--ink);
    transition: var(--pop);
}

.match-item:hover {
    transform: translate(-2px, -2px);
}

.match-item.sel {
    background: var(--yellow);
}

.match-item.done {
    background: var(--green);
    color: #fff;
    cursor: default;
    opacity: .75;
}

/* ---------- BIG NUMBER + FEEDBACK ---------- */
.big-num {
    font-size: 4.4rem;
    font-weight: 700;
    text-align: center;
    color: var(--red);
}

.feedback {
    text-align: center;
    font-size: 1.15rem;
    font-weight: 700;
    margin-top: 16px;
    min-height: 1.5em;
}

.feedback.good {
    color: var(--green);
}

.feedback.bad {
    color: var(--red);
}

/* ---------- TOAST ---------- */
#toast {
    position: fixed;
    bottom: 34px;
    left: 50%;
    transform: translateX(-50%) translateY(160px);
    background: var(--ink);
    color: var(--paper);
    border: var(--line) solid var(--ink);
    padding: 15px 32px;
    border-radius: 100px;
    font-weight: 700;
    z-index: 2000;
    transition: transform .45s cubic-bezier(.68, -.55, .265, 1.55);
    box-shadow: 5px 5px 0 var(--yellow);
}

#toast.show {
    transform: translateX(-50%) translateY(0);
}

/* ---------- FOOTER ---------- */
footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 40px 24px;
    color: var(--muted);
    margin: 40px auto 24px;
    max-width: 920px;
    background: rgba(255, 248, 236, .82);
    backdrop-filter: blur(3px);
    border: var(--line) solid var(--ink);
    border-radius: 22px;
    font-weight: 700;
}

/* ---------- BACKGROUND SWITCHER BUTTON ---------- */
#bgBtn {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 1500;
    cursor: pointer;
    border: var(--line) solid var(--ink);
    border-right: none;
    border-radius: 14px 0 0 14px;
    background: var(--green);
    color: #fff;
    font-family: inherit;
    font-weight: 700;
    font-size: .95rem;
    line-height: 1.2;
    padding: 20px 14px;
    box-shadow: -4px 4px 0 var(--ink);
    transition: var(--pop);
}

#bgBtn:hover {
    transform: translateY(-50%) translateX(-4px);
    background: var(--teal);
}

#bgBtn:active {
    transform: translateY(-50%) translateX(2px);
    box-shadow: 0 0 0 var(--ink);
}

/* ---------- MOBILE ---------- */
@media(max-width:560px) {
    main {
        padding: 26px 16px 80px;
    }

    .card {
        padding: 22px;
    }

    .btn {
        width: 100%;
        margin: 6px 0;
    }

    .mem-grid {
        gap: 8px;
    }

    .key {
        width: 38px;
        height: 38px;
        font-size: .9rem;
    }

    .phrase .en {
        font-size: .85rem;
    }
}