/* ======================================= */
/*            RESET & VARIABLES            */
/* ======================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-1: #FFF0F3;
    --bg-2: #FDE2E4;
    --bg-3: #FAD2E1;
    --primary: #C9184A;
    --primary-soft: #FF758F;
    --accent: #800F2F;
    --rose: #FFB3C1;
    --rose-light: #FFE5EC;
    --white: #FFFFFF;
    --text: #3D0C11;
    --text-muted: #9E6B7B;
    --glass-bg: rgba(255, 255, 255, 0.52);
    --glass-border: rgba(255, 255, 255, 0.65);
    --shadow: 0 8px 32px rgba(89, 13, 34, 0.10);
    --shadow-lg: 0 16px 48px rgba(89, 13, 34, 0.15);
    --radius: 20px;
    --radius-sm: 12px;
    --radius-xs: 8px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(160deg, var(--bg-1), var(--bg-2) 45%, var(--bg-3));
    background-attachment: fixed;
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--text);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ======================================= */
/*              SCREEN SYSTEM              */
/* ======================================= */
.screen {
    display: none;
    min-height: 100vh;
    min-height: 100dvh;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ======================================= */
/*             GLASS MORPHISM              */
/* ======================================= */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ======================================= */
/*             INTRO SCREEN                */
/* ======================================= */
#intro {
    position: relative;
    padding: 24px;
    text-align: center;
}

/* Floating hearts background */
.hearts-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.floating-heart {
    position: absolute;
    bottom: -50px;
    opacity: 0.12;
    animation: floatUp linear infinite;
    will-change: transform;
}

@keyframes floatUp {
    0%   { transform: translateY(0) rotate(0deg) scale(1); opacity: 0; }
    8%   { opacity: 0.12; }
    88%  { opacity: 0.12; }
    100% { transform: translateY(-110vh) rotate(540deg) scale(0.4); opacity: 0; }
}

/* Intro card */
.intro-card {
    position: relative;
    z-index: 1;
    max-width: 380px;
    width: 100%;
    padding: 48px 32px;
    text-align: center;
    animation: fadeSlideUp 0.8s ease-out;
}

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

.intro-label {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--primary);
    background: var(--rose-light);
    padding: 6px 18px;
    border-radius: 20px;
    margin-bottom: 20px;
}

.intro-title {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--accent);
    margin-bottom: 8px;
}

.intro-heart {
    font-size: 3rem;
    margin: 16px 0;
    animation: heartbeat 1.4s ease-in-out infinite;
    display: block;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    14%      { transform: scale(1.18); }
    28%      { transform: scale(1); }
    42%      { transform: scale(1.12); }
}

.intro-desc {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 32px;
}

.intro-desc strong {
    color: var(--primary);
    font-weight: 600;
}

/* ======================================= */
/*               BUTTONS                   */
/* ======================================= */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--white);
    background: linear-gradient(135deg, var(--primary), var(--primary-soft));
    border: none;
    border-radius: 50px;
    padding: 14px 40px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(201, 24, 74, 0.30);
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(201, 24, 74, 0.40);
}

.btn-primary:active {
    transform: translateY(0) scale(0.97);
}

/* ======================================= */
/*              GAME SCREEN                */
/* ======================================= */
#game.active {
    justify-content: flex-start;
    padding: 16px 10px 24px;
    gap: 14px;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 500px;
    padding: 0 6px;
}

.game-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
}

.game-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Progress ring */
.progress-ring {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.progress-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.progress-ring-bg {
    fill: none;
    stroke: var(--rose-light);
    stroke-width: 3;
}

.progress-ring-fill {
    fill: none;
    stroke: var(--primary);
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dasharray 0.6s ease;
}

.progress-ring span {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
}

/* ======================================= */
/*                 GRID                    */
/* ======================================= */
.grid-container {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    gap: 2px;
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1;
    padding: 6px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.52rem, 2.1vw, 0.85rem);
    font-weight: 600;
    color: var(--text);
    background: rgba(255, 255, 255, 0.72);
    border-radius: 3px;
    aspect-ratio: 1;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
    line-height: 1;
    will-change: background, color;
}

.cell.selecting {
    background: var(--rose);
    color: var(--white);
    box-shadow: 0 0 0 1.5px var(--primary-soft);
    z-index: 1;
}

.cell.found {
    color: var(--white);
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.cell.pop {
    animation: cellPop 0.4s ease;
}

@keyframes cellPop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* ======================================= */
/*              WORD LIST                  */
/* ======================================= */
.word-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    width: 100%;
    max-width: 500px;
    padding: 2px 4px;
}

.word-chip {
    font-family: 'Poppins', sans-serif;
    font-size: 0.68rem;
    font-weight: 500;
    padding: 5px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--rose);
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.45);
    transition: var(--transition);
    letter-spacing: 0.5px;
}

.word-chip.found {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
    text-decoration: line-through;
    text-decoration-thickness: 1.5px;
}

/* ======================================= */
/*                MODAL                    */
/* ======================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(61, 12, 17, 0.35);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: relative;
    max-width: 420px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 36px 24px 28px;
    text-align: center;
    transform: translateY(24px) scale(0.94);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.55);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary);
}

.modal-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--rose-light);
    padding: 5px 16px;
    border-radius: 16px;
    margin-bottom: 14px;
    letter-spacing: 0.3px;
}

.modal-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 10px;
}

.modal-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.65;
    margin-bottom: 20px;
}

.modal-media {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.modal-media img,
.modal-media video {
    width: 100%;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
}

.modal-media img {
    object-fit: cover;
}

.modal-media video {
    max-height: 300px;
    object-fit: contain;
    background: #000;
}

.media-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
}

.media-grid img {
    aspect-ratio: 1;
    object-fit: cover;
}

/* Scrollbar */
.modal::-webkit-scrollbar { width: 4px; }
.modal::-webkit-scrollbar-track { background: transparent; }
.modal::-webkit-scrollbar-thumb { background: var(--rose); border-radius: 4px; }

/* ======================================= */
/*            VICTORY SCREEN               */
/* ======================================= */
#victory.active {
    justify-content: center;
    padding: 24px;
}

.victory-card {
    max-width: 400px;
    width: 100%;
    padding: 48px 28px;
    text-align: center;
    animation: fadeSlideUp 0.8s ease-out;
}

.victory-emoji {
    font-size: 2.6rem;
    margin-bottom: 16px;
}

.victory-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 16px;
}

.victory-text {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.75;
    margin-bottom: 24px;
}

.victory-sign {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    line-height: 1.9;
    margin-bottom: 32px;
}

/* ======================================= */
/*            RESPONSIVE                   */
/* ======================================= */
@media (min-width: 480px) {
    .intro-title { font-size: 2rem; }
    .cell { font-size: 0.82rem; }
    .grid-container { gap: 3px; padding: 8px; }
}

@media (min-width: 768px) {
    .intro-card { padding: 56px 48px; }
    .game-title { font-size: 1.25rem; }
    .cell { font-size: 0.95rem; }
    .grid-container { gap: 3px; padding: 10px; }
    .word-chip { font-size: 0.78rem; padding: 7px 18px; }
    .modal { padding: 40px 32px 32px; }
}

@media (min-width: 1024px) {
    #game.active {
        padding: 24px;
        gap: 20px;
    }
    .grid-container {
        max-width: 560px;
        gap: 4px;
        padding: 12px;
    }
    .cell { font-size: 1rem; border-radius: 4px; }
    .word-list { max-width: 560px; }
}
