/* static/css/styles.css */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&family=Poppins:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #7b68fa;
    --primary-hover: #6651e8;
    --secondary: #ff8bcb;
    --secondary-hover: #f05faf;
    --accent: #6ee7b7;
    --accent-hover: #45c8a0;
    --sun: #fcd34d;
    --bg-soft: #f8f5ff;
    --bg-card: rgba(255, 255, 255, 0.88);
    --text-main: #1f2937;
    --text-muted: #5d6476;
    --text-soft: #8790a5;
    --glass-border: rgba(123, 104, 250, 0.14);
    --glass-shadow: 0 18px 45px rgba(123, 104, 250, 0.12);
    --card-radius: 8px;
}

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

html { scroll-behavior: smooth; }

body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    color: var(--text-main);
    font-family: 'Nunito', sans-serif;
    background:
        radial-gradient(circle at 12% 8%, rgba(255, 139, 203, 0.16), transparent 26rem),
        radial-gradient(circle at 88% 15%, rgba(123, 104, 250, 0.14), transparent 30rem),
        linear-gradient(135deg, #fbfbff 0%, var(--bg-soft) 52%, #f2eefc 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image: radial-gradient(rgba(123, 104, 250, 0.2) 1.5px, transparent 1.5px);
    background-size: 32px 32px;
    mask-image: linear-gradient(120deg, transparent 0%, black 10%, transparent 42%, black 72%, transparent 100%);
    opacity: 0.35;
    pointer-events: none;
}

h1,
h2,
h3,
.logo,
.btn {
    font-family: 'Poppins', sans-serif;
}

header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    min-height: 76px;
    padding: 1rem clamp(1rem, 4vw, 3rem);
    border-bottom: 1px solid rgba(123, 104, 250, 0.14);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--primary);
    text-decoration: none;
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1;
    transition: transform 0.25s ease;
}

.logo:hover {
    transform: translateY(-1px);
}

.logo-emoji {
    display: inline-flex;
    width: 2.35rem;
    height: 2.35rem;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 139, 203, 0.24), rgba(123, 104, 250, 0.14));
    font-size: 1.45rem;
}

nav ul {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    list-style: none;
}

nav ul li a {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0.55rem 0.85rem;
    border-radius: 8px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 700;
    transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

nav ul li a:hover {
    color: var(--primary);
    background: rgba(123, 104, 250, 0.08);
    transform: translateY(-1px);
}

nav ul li:last-child a {
    color: #fff;
    background: linear-gradient(135deg, var(--secondary), var(--secondary-hover));
    box-shadow: 0 10px 24px rgba(255, 139, 203, 0.28);
}

main {
    flex: 1;
    width: min(100%, 1500px);
    margin: clamp(2.25rem, 4vw, 3.5rem) auto 0;
    padding: 0px;
}

.home-main {
    margin-top: 50px;
}

.hero {
    position: relative;
    width: 100%;
    min-height: 170px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-bottom: 50px;
    padding: 45px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: var(--card-radius);
    background:
        radial-gradient(circle at 78% 38%, rgba(123, 104, 250, 0.16), transparent 8rem),
        radial-gradient(circle at 66% 88%, rgba(255, 139, 203, 0.22), transparent 13rem),
        linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(246, 238, 255, 0.94));
    box-shadow: var(--glass-shadow);
    animation: fadeInDown 0.7s ease-out;
}

.hero::after {
    content: "✦";
    position: absolute;
    right: clamp(1.2rem, 6vw, 5rem);
    top: 50%;
    width: 4.4rem;
    height: 4.4rem;
    display: grid;
    place-items: center;
    border-radius: 18px;
    color: var(--sun);
    background: rgba(255, 255, 255, 0.58);
    box-shadow: 0 14px 34px rgba(123, 104, 250, 0.16);
    font-size: 2.45rem;
    transform: translateY(-50%) rotate(10deg);
}

.hero h1 {
    max-width: 780px;
    margin-bottom: 0.7rem;
    font-size: clamp(2.1rem, 4.8vw, 4rem);
    font-weight: 800;
    line-height: 1.12;
}

.hero h1::first-letter {
    color: var(--primary);
}

.hero p {
    max-width: 760px;
    color: var(--text-muted);
    font-size: 1.05rem;
    line-height: 1.55;
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0.85rem;
    animation: fadeInUp 0.7s ease-out 0.1s both;
}

.game-card,
.auth-box,
.ranking-card {
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: var(--card-radius);
    background: var(--bg-card);
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.game-card {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 1.4rem 1.6rem 1.5rem;
    text-align: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.game-card::before {
    content: "";
    position: absolute;
    inset: 0;
    height: 5px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
}

.game-card:hover {
    transform: translateY(-6px);
    border-color: rgba(123, 104, 250, 0.3);
    box-shadow: 0 24px 52px rgba(123, 104, 250, 0.18);
}

.game-icon {
    display: inline-grid;
    place-items: center;
    width: 4.25rem;
    height: 4.25rem;
    margin: 0 auto 0.9rem;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(123, 104, 250, 0.14), rgba(255, 139, 203, 0.2));
    font-size: 2.25rem;
    transition: transform 0.25s ease;
}

.game-card:hover .game-icon {
    transform: rotate(5deg) scale(1.06);
}

.game-card h2,
.game-card h3 {
    margin-bottom: 0.55rem;
    font-size: 1.45rem;
    font-weight: 800;
}

.game-card p {
    flex-grow: 1;
    margin-bottom: 1.1rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0.75rem 1.4rem;
    border: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    box-shadow: 0 12px 24px rgba(123, 104, 250, 0.26);
    cursor: pointer;
    font-size: 0.98rem;
    font-weight: 700;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn:hover {
    transform: translateY(-2px);
    filter: saturate(1.05);
    box-shadow: 0 16px 28px rgba(123, 104, 250, 0.34);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary), var(--secondary-hover));
    box-shadow: 0 12px 24px rgba(255, 139, 203, 0.28);
}

.btn-secondary:hover {
    box-shadow: 0 16px 28px rgba(255, 139, 203, 0.38);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    box-shadow: 0 12px 24px rgba(110, 231, 183, 0.28);
}

.btn-accent:hover {
    box-shadow: 0 16px 28px rgba(110, 231, 183, 0.38);
}

footer {
    margin: auto 0 0;
    padding: 1rem clamp(1rem, 4vw, 3rem);
    background: linear-gradient(135deg, var(--primary), #9a7efa);
    color: #fff;
    text-align: center;
    box-shadow: var(--glass-shadow);
}

footer p {
    font-size: 0.95rem;
    font-weight: 700;
}

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 700px;
    padding-top: 200px;
}

.auth-main {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100dvh - 76px - 57px);
    margin-top: 0;
    padding: 1.5rem;
}

.auth-main .auth-container {
    width: 100%;
    min-height: 0;
    padding-top: 0;
}

.auth-box {
    width: 100%;
    max-width: 460px;
    padding: 2.4rem;
    text-align: center;
    animation: fadeInUp 0.7s ease-out;
}

.auth-box h2 {
    margin-bottom: 1.6rem;
    font-size: 2rem;
    font-weight: 800;
}

.form-group {
    margin-bottom: 1.2rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 800;
}

.form-group input,
.typing-input {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1px solid rgba(123, 104, 250, 0.18);
    border-radius: 8px;
    outline: none;
    background: rgba(255, 255, 255, 0.86);
    color: var(--text-main);
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.form-group input:focus,
.typing-input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(123, 104, 250, 0.12);
}

.flash-messages {
    margin-bottom: 1.5rem;
    padding: 1rem;
    border: 1px solid rgba(255, 139, 203, 0.28);
    border-left: 5px solid var(--secondary);
    border-radius: 8px;
    background: rgba(255, 139, 203, 0.14);
    list-style: none;
    text-align: left;
    font-size: 0.95rem;
    line-height: 1.5;
}

.auth-link {
    margin-top: 1.6rem;
    color: var(--text-muted);
}

.auth-link a {
    color: var(--primary);
    font-weight: 800;
    text-decoration: none;
}

.auth-link a:hover {
    color: var(--secondary-hover);
}

.mouse-game-shell {
    max-width: 980px;
    margin: 0 auto;
    padding: 1.25rem 1.5rem;
    text-align: left;
}

.game-hero {
    min-height: 104px;
    margin: 15px;
    padding: 35px;
}

.game-hero + .game-board,
.game-hero + .mouse-game-container,
.game-hero + .play-area {
    margin-top: clamp(1.1rem, 2.4vw, 2rem);
}

.game-hero h1 {
    max-width: 900px;
    font-size: clamp(2.25rem, 4.4vw, 4rem);
}

.game-hero p {
    max-width: 920px;
    font-size: 1rem;
    line-height: 1.45;
}

.mouse-game-container {
    min-height: auto;
    align-items: flex-start;
    padding-top: 0;
}

.mouse-game-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.9rem;
    flex-wrap: wrap;
    margin-bottom: 0.55rem;
}

.mouse-game-target {
    max-width: 540px;
}

.mouse-game-score {
    min-width: 135px;
    text-align: right;
}

#mouse-game-status {
    margin-bottom: 0.85rem !important;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
}

.mouse-game-board {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 70px));
    justify-content: center;
    gap: 0.45rem;
    margin: 0.65rem 0 0;
}

.mouse-figure {
    position: relative;
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid rgba(123, 104, 250, 0.14);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(243, 244, 246, 0.82));
    box-shadow: 0 12px 28px rgba(31, 41, 55, 0.08);
    cursor: pointer;
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.mouse-figure:hover {
    transform: translateY(-5px);
    border-color: rgba(123, 104, 250, 0.28);
    box-shadow: 0 18px 34px rgba(123, 104, 250, 0.14);
}

.mouse-figure-icon {
    position: relative;
    z-index: 1;
    font-size: 2.1rem;
    transition: transform 0.22s ease;
}

.mouse-figure:hover .mouse-figure-icon {
    transform: scale(1.08);
}

.mouse-figure-star .mouse-figure-icon,
.mouse-figure-sun .mouse-figure-icon {
    filter: drop-shadow(0 8px 10px rgba(252, 211, 77, 0.35));
}

.mouse-figure-heart .mouse-figure-icon,
.mouse-figure-square .mouse-figure-icon,
.mouse-figure-diamond .mouse-figure-icon {
    filter: drop-shadow(0 8px 10px rgba(125, 211, 252, 0.35));
}

.mouse-figure-moon .mouse-figure-icon,
.mouse-figure-hexagon .mouse-figure-icon {
    filter: drop-shadow(0 8px 10px rgba(123, 104, 250, 0.28));
}

.mouse-figure-leaf .mouse-figure-icon {
    filter: drop-shadow(0 8px 10px rgba(110, 231, 183, 0.35));
}

.mouse-figure-fire .mouse-figure-icon,
.mouse-figure-circle .mouse-figure-icon,
.mouse-figure-triangle .mouse-figure-icon {
    filter: drop-shadow(0 8px 10px rgba(255, 139, 203, 0.32));
}

.mouse-game-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    margin-top: 0.75rem;
}

.game-board {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 0.8rem 0 1.2rem;
    animation: fadeInUp 0.7s ease-out;
}

.keyboard-game-card {
    width: min(100%, 760px);
    margin: 0 auto;
    padding: 1.6rem 1.8rem;
}

.keyboard-game-card h2 {
    margin-bottom: 0.45rem;
}

.keyboard-game-card > p {
    margin-bottom: 0.9rem;
}

.game-stats {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
}

.keyboard-actions {
    margin-top: 1.2rem;
}

.phrase-display {
    margin: 0.9rem 0 0.75rem;
    padding: 1rem;
    border: 1px solid rgba(123, 104, 250, 0.14);
    border-radius: 8px;
    background: rgba(243, 244, 246, 0.72);
    font-size: 1.08rem;
    line-height: 1.45;
    text-align: left;
    user-select: none;
}

.typing-input {
    font-size: 1.12rem;
}

.typing-input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.lletra-correcta {
    color: #079678;
    font-weight: 800;
}

.lletra-incorrecta {
    padding: 0 2px;
    border-radius: 3px;
    background-color: rgba(255, 139, 203, 0.22);
    color: #e8348b;
}

.ranking-hero {
    min-height: 220px;
    margin-bottom: 1rem;
}

.ranking-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    animation: fadeInUp 0.7s ease-out;
}

.ranking-card {
    padding: 1.6rem;
}

.ranking-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.ranking-card-header h2 {
    margin-top: 0.2rem;
    font-size: 1.45rem;
}

.ranking-label {
    color: var(--text-soft);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ranking-badge {
    min-width: 52px;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    background: rgba(110, 231, 183, 0.24);
    color: #079678;
    font-weight: 800;
    text-align: center;
}

.ranking-table-wrapper {
    overflow-x: auto;
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
}

.ranking-table th,
.ranking-table td {
    padding: 0.85rem 0.65rem;
    border-bottom: 1px solid rgba(123, 104, 250, 0.1);
    text-align: left;
}

.ranking-table th {
    color: var(--text-soft);
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.ranking-table tbody tr:last-child td {
    border-bottom: none;
}

.ranking-table tbody tr:hover {
    background: rgba(123, 104, 250, 0.05);
}

.ranking-position {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(123, 104, 250, 0.12);
    color: var(--primary);
    font-weight: 800;
}

.ranking-position-1 {
    background: linear-gradient(135deg, #fcd34d, #f9b642);
    color: #fff;
}

.ranking-position-2 {
    background: linear-gradient(135deg, #93c5fd, #7b9efa);
    color: #fff;
}

.ranking-position-3 {
    background: linear-gradient(135deg, #6ee7b7, #45c8a0);
    color: #fff;
}

.ranking-empty {
    padding: 1.25rem 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 820px) {
    nav {
        align-items: flex-start;
        flex-direction: column;
    }

    nav ul {
        width: 100%;
        flex-wrap: wrap;
    }

    main {
        padding-inline: 0.75rem;
    }

    .hero {
        min-height: 160px;
        padding: 1.25rem 1.5rem;
    }

    .hero::after {
        opacity: 0.18;
        right: 1rem;
    }

    .auth-box,
    .game-card,
    .ranking-card {
        padding: 1.4rem;
    }

    .mouse-game-score {
        text-align: left;
    }

    .mouse-game-board {
        grid-template-columns: repeat(5, minmax(0, 62px));
    }

    .mouse-figure {
        width: 62px;
        height: 62px;
    }
}

@media (max-width: 520px) {
    .logo {
        font-size: 1.22rem;
    }

    nav ul {
        gap: 0.35rem;
    }

    nav ul li a {
        min-height: 34px;
        padding: 0.45rem 0.65rem;
        font-size: 0.88rem;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .game-grid,
    .ranking-grid {
        grid-template-columns: 1fr;
    }

    .mouse-game-board {
        grid-template-columns: repeat(3, minmax(0, 82px));
        gap: 0.7rem;
    }

    .mouse-figure {
        width: 82px;
        height: 82px;
    }

    .mouse-figure-icon {
        font-size: 2.35rem;
    }

    .mouse-game-actions .btn {
        width: 100%;
    }
}
