@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,600;0,800;1,600&family=Lato:wght@400;700;900&display=swap');

:root {
    /* Paleta de Cores e Estilos Comuns */
    --bg-color: #fdf6f5;
    --bg-darker: #f9e8e8;
    --text-main: #5d2a42;
    --text-light: #8a5a70;
    --cursor-heart-default: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2228%22 height=%2228%22 viewBox=%220 0 28 28%22%3E%3Ctext x=%2250%25%22 y=%2255%25%22 text-anchor=%22middle%22 dominant-baseline=%22middle%22 font-size=%2222%22%3E%E2%9D%A4%EF%B8%8F%3C/text%3E%3C/svg%3E") 14 14, auto;
    --cursor-heart-active: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2236%22 height=%2236%22 viewBox=%220 0 36 36%22%3E%3Ctext x=%2250%25%22 y=%2255%25%22 text-anchor=%22middle%22 dominant-baseline=%22middle%22 font-size=%2224%22%3E%F0%9F%92%96%3C/text%3E%3C/svg%3E") 18 18, pointer;
    
    --exact-match: #d81b60;   
    --present-match: #eaaa79;  
    --absent-match: #d2b8c3;   
    
    --dist-far: #f4dcd9;
    --dist-medium: #f2b5c4;
    --dist-close: #e57399;

    --empty-border: #e8d0d5;
    --shadow: rgba(93, 42, 66, 0.08);
    --radius: 12px;
    --motion-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --motion-smooth: cubic-bezier(0.22, 1, 0.36, 1);
    --motion-soft: cubic-bezier(0.4, 0, 0.2, 1);
    --motion-fast: 0.18s;
    --motion-base: 0.34s;
    --motion-slow: 0.72s;
}

html {
    scroll-behavior: smooth;
}

body {
    cursor: var(--cursor-heart-default);
}

a,
button:not(:disabled),
[role="button"],
summary,
label[for],
input[type="button"]:not(:disabled),
input[type="submit"]:not(:disabled),
input[type="reset"]:not(:disabled),
input[type="range"]:not(:disabled),
.icon-btn,
.btn-play,
.btn-reset,
.btn-finish,
.btn-accept,
.btn-close,
.login-btn,
.submit-btn,
.music-btn,
.music-mini-btn,
.music-collapse-toggle,
.btn-enter,
.key,
.card,
.mini-tile,
.board-wrapper,
.ghost-btn,
.tile,
.solved-groups.finished {
    cursor: var(--cursor-heart-active);
}

.heart-trail {
    position: fixed;
    pointer-events: none;
    z-index: 99999;
    animation: floatHeartTrail 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    text-shadow: 0 0 5px rgba(255, 64, 129, 0.4);
}

@keyframes floatHeartTrail {
    0% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
    100% { transform: translate(-50%, -100px) scale(0) rotate(var(--spin, 20deg)); opacity: 0; }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
html, body { 
    overscroll-behavior-y: none;
    overflow: hidden;
}

body {
    background: linear-gradient(-45deg, #fdf6f5, #fce4ec, #f8bbd0, #fdf6f5);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    color: var(--text-main);
    font-family: 'Lato', sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
}

body > header:not(.home-header) {
    animation: surfaceReveal var(--motion-slow) var(--motion-smooth) both;
}

body > header:not(.home-header) > * {
    animation: surfaceRevealSoft 0.6s var(--motion-smooth) both;
}

body > header:not(.home-header) > *:nth-child(1) { animation-delay: 0.04s; }
body > header:not(.home-header) > *:nth-child(2) { animation-delay: 0.1s; }
body > header:not(.home-header) > *:nth-child(3) { animation-delay: 0.16s; }

body > main:not(.home-main) {
    animation: surfaceReveal var(--motion-slow) var(--motion-smooth) both 0.08s;
}

input[type="text"],
input[type="password"],
textarea,
select {
    background: rgba(255, 255, 255, 0.92);
    transition:
        transform var(--motion-fast) var(--motion-bounce),
        border-color var(--motion-base) var(--motion-soft),
        box-shadow var(--motion-base) var(--motion-soft),
        background-color var(--motion-base) var(--motion-soft);
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
    transform: translateY(-2px);
    background: #fff;
    box-shadow: 0 14px 28px rgba(216, 27, 96, 0.12);
}

button:not(:disabled),
a,
input[type="button"]:not(:disabled),
input[type="submit"]:not(:disabled),
input[type="reset"]:not(:disabled) {
    transition:
        transform var(--motion-fast) var(--motion-bounce),
        box-shadow var(--motion-base) var(--motion-soft),
        background-color var(--motion-base) var(--motion-soft),
        border-color var(--motion-base) var(--motion-soft),
        color var(--motion-base) var(--motion-soft),
        opacity var(--motion-base) var(--motion-soft),
        filter var(--motion-base) var(--motion-soft);
}

.icon-btn svg,
.key svg,
.music-btn svg,
.music-mini-btn svg,
.music-collapse-toggle svg {
    transition: transform var(--motion-fast) var(--motion-bounce);
}

@media (hover: hover) {
    .icon-btn:hover svg,
    .music-btn:hover svg,
    .music-mini-btn:hover svg,
    .music-collapse-toggle:hover svg {
        transform: scale(1.08);
    }
}

/* --- MESH DE ORBES DINÃMICAS NO FUNDO --- */
body::before {
    content: "";
    position: fixed;
    top: -100vmax; left: -100vmax; width: 300vmax; height: 300vmax;
    background: radial-gradient(circle at 50% 50%, rgba(216, 27, 96, 0.05), transparent 60%),
                radial-gradient(circle at 80% 20%, rgba(240, 98, 146, 0.08), transparent 50%),
                radial-gradient(circle at 20% 80%, rgba(255, 128, 171, 0.08), transparent 50%);
    animation: rotateOrbs 30s linear infinite;
    z-index: -1;
    pointer-events: none;
}

@keyframes rotateOrbs {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

header {
    background-color: var(--bg-color);
    padding: 16px 20px;
    text-align: center;
    border-bottom: 2px solid var(--bg-darker);
    box-shadow: 0 4px 15px var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 50;
    position: sticky;
    top: 0;
    transition:
        box-shadow var(--motion-base) var(--motion-soft),
        background-color var(--motion-base) var(--motion-soft),
        transform var(--motion-fast) var(--motion-bounce);
}

header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    font-weight: 800;
    color: var(--exact-match);
    flex: 1;
    text-align: center;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* --- TOASTS (Avisos) --- */
.toast-container {
    position: fixed;
    top: 75px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
    pointer-events: none;
}

.toast {
    background-color: var(--text-main);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    animation: fadeInOut 2.5s forwards;
    white-space: nowrap;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(-10px); }
    15%, 85% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-10px); }
}

/* --- ANIMAÇÃO DE ERRO (TREMER) --- */
.shake { animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* --- MODAIS COMUNS --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(253, 246, 245, 0.35); /* Glassmorphism tint */
    backdrop-filter: blur(14px); /* Glassmorphism jateado pesado */
    -webkit-backdrop-filter: blur(14px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.4s ease; padding: 20px;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-content {
    background: #ffffff; width: 100%; max-width: 380px; max-height: 90vh; overflow-y: auto;
    padding: 32px 24px; border-radius: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    transform: scale(0.9) translateY(20px); transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
}
.modal-overlay.active .modal-content { transform: scale(1) translateY(0); }
.modal-title { font-family: 'Playfair Display', serif; font-size: 24px; color: var(--exact-match); margin-bottom: 12px; }
.btn-finish, .btn-accept, .btn-close {
    width: 100%; padding: 16px; background: var(--exact-match); color: white; border: none;
    border-radius: 50px; font-size: 16px; font-weight: 900; text-transform: uppercase; cursor: var(--cursor-heart-active);
    box-shadow: 0 4px 15px rgba(216, 27, 96, 0.3); margin-top: 10px; transition: transform 0.1s;
}
.btn-finish:active, .btn-accept:active, .btn-close:active { transform: scale(0.96); }

/* --- BOTÕES DE ÍCONE GERAIS --- */
.icon-btn {
    width: 44px; height: 44px; border-radius: 50%; border: none;
    background: var(--bg-darker); color: var(--exact-match); font-size: 20px;
    font-weight: 900; cursor: var(--cursor-heart-active); display: flex; align-items: center;
    justify-content: center; transition: transform 0.1s, background-color 0.2s;
    flex-shrink: 0; box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.icon-btn:active { transform: scale(0.92); }

#confetti-canvas { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2000; }

/* --- BRANDING --- */
.brand-footer {
    text-align: center;
    padding: 16px;
    font-family: 'Playfair Display', serif;
    font-size: 14px;
    color: var(--text-main);
    opacity: 0; 
    margin-top: auto;
    width: 100%;
    z-index: 10;
    animation: footerFadeIn 1.5s ease-out forwards;
}

@keyframes footerFadeIn {
    0% { opacity: 0; }
    100% { opacity: 0.8; }
}

/* --- TECLADO UNIVERSAL & GLAMOUR MICRO-INTERAÇÕES --- */
.keyboard {
    width: 100%; margin: 0 auto;
    max-width: 500px;
    padding: 12px 8px calc(12px + env(safe-area-inset-bottom)) 8px;
    display: flex; flex-direction: column; gap: 8px;
    background-color: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(216, 27, 96, 0.08);
    z-index: 10;
}
.keyboard-row { display: flex; justify-content: center; gap: 6px; width: 100%; }
.key {
    flex: 1; height: 52px; min-width: 26px; border-radius: 8px; border: none;
    background-color: rgba(253, 246, 245, 0.85); color: var(--text-main);
    font-size: 1.15rem; font-weight: 900; font-family: 'Lato', sans-serif; cursor: var(--cursor-heart-active);
    display: flex; justify-content: center; align-items: center;
    text-transform: uppercase; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.25s, color 0.25s, box-shadow 0.15s !important;
    box-shadow: 0 4px 0 rgba(216, 27, 96, 0.08);
}
.key.large { flex: 1.5; font-size: 0.9rem; }
.key:active { transform: translateY(4px) scale(0.96) !important; box-shadow: 0 0 0 rgba(0,0,0,0) !important; }

.key.exact, .key.right { background-color: var(--exact-match); color: #ffffff; }
.key.present, .key.place { background-color: var(--present-match); color: #ffffff; }
.key.other { background-color: #7c4dff; color: #ffffff; }
.key.wrong, .key.absent { background-color: rgba(216, 168, 185, 0.3); color: #a38c95; }

@media (max-width: 400px) {
    .keyboard { padding: 8px 4px calc(8px + env(safe-area-inset-bottom)) 4px; gap: 6px; border-radius: 12px; }
    .key { height: 46px; font-size: 1rem; border-radius: 6px; box-shadow: 0 3px 0 rgba(216,27,96,0.08); }
    .key.large { font-size: 0.8rem; }
    .keyboard-row { gap: 4px; }
}

@keyframes surfaceReveal {
    0% {
        opacity: 0;
        transform: translateY(18px) scale(0.985);
        filter: blur(8px);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

@keyframes surfaceRevealSoft {
    0% {
        opacity: 0;
        transform: translateY(12px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes levitate { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes breatheGlow { 0%, 100% { box-shadow: 0 4px 15px rgba(216, 27, 96, 0.2); } 50% { box-shadow: 0 4px 25px rgba(216, 27, 96, 0.55); } }
@keyframes tilePop { 0% { transform: scale(0.85); opacity: 0.5; } 40% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
