:root {
    --bg-color: #ffd8df;
    --primary-color: #ff4b72;
    --text-color: #4a1525;
    --card-bg: rgba(255, 255, 255, 0.85);
    --gold: #d4af37;
    --scratch-bg: linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Montserrat', sans-serif;
    background: linear-gradient(135deg, #ffe6eb 0%, #ffb6c1 100%);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.app-container {
    width: 100%;
    max-width: 480px;
    height: 100vh;
    max-height: 900px;
    display: flex;
    flex-direction: column;
    padding: 10px 20px 40px 20px;
    position: relative;
    z-index: 10;
}

.header {
    text-align: center;
    margin-bottom: 20px;
    flex-shrink: 0;
    z-index: 21;
    position: relative;
}

.lang-switcher {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 100;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.7);
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 4px 12px;
    /* Shrunk vertical padding */
    border-radius: 20px;
    font-size: 0.75rem;
    /* Slightly smaller text */
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(255, 75, 114, 0.1);
    transition: all 0.3s ease;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
}

.header h1 {
    font-family: 'Pacifico', cursive;
    color: var(--primary-color);
    font-size: 2.0rem;
    /* Slightly smaller to prevent wider text wrap */
    text-shadow: 2px 2px 4px rgba(255, 75, 114, 0.2);
    margin-bottom: 5px;
    margin-top: 20px;
    /* Reduced vertical space */
    animation: pulse 2.5s infinite;
    position: relative;
    z-index: 20;
}

.subtitle {
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0.8;
}

.game-area {
    position: relative;
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    z-index: 20;
    transition: opacity 0.5s ease;
    padding: 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(255, 75, 114, 0.15);
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 360px;
    aspect-ratio: 1 / 1;
    position: relative;
    z-index: 15;
    margin: 0 auto;
}

.grid.hidden {
    display: none;
}

.card {
    position: relative;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(255, 75, 114, 0.1);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
}

.card.shuffling {
    animation: shuffle-shake 0.4s ease-in-out infinite;
}

.card.selected {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(255, 75, 114, 0.3);
    z-index: 5;
}

.card.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.card-inner {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-color);
    background: #fff;
    word-break: keep-all;
}

canvas.scratch-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    touch-action: none;
    /* Prevent scrolling when scratching */
}

button {
    font-family: 'Montserrat', sans-serif;
    border: none;
    border-radius: 30px;
    padding: 15px 35px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 6px 20px rgba(255, 75, 114, 0.3);
}

.primary-btn {
    background: linear-gradient(135deg, #ff4b72 0%, #ff758c 100%);
    color: white;
}

.primary-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(255, 75, 114, 0.4);
}

.primary-btn:active {
    transform: translateY(1px) scale(0.98);
}

.secondary-btn {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    margin-top: 25px;
    box-shadow: none;
}

.secondary-btn:hover {
    background: #fff0f3;
    transform: translateY(-2px);
}

.romantic-text {
    font-family: 'Pacifico', cursive;
    font-size: 1.8rem;
    color: var(--primary-color);
    line-height: 1.4;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
    padding: 0 20px;
}

/* Animations */
@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.03);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes shuffle-shake {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    25% {
        transform: translate(-3px, 3px) rotate(-2deg);
    }

    50% {
        transform: translate(3px, -3px) rotate(2deg);
    }

    75% {
        transform: translate(-3px, -3px) rotate(-2deg);
    }

    100% {
        transform: translate(0, 0) rotate(0deg);
    }
}

/* Floating Hearts Background */
.floating-hearts-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.heart {
    position: absolute;
    width: 15px;
    height: 15px;
    background: rgba(255, 75, 114, 0.15);
    transform: rotate(45deg);
    animation: float 12s infinite linear;
}

.heart::before,
.heart::after {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    background: rgba(255, 75, 114, 0.15);
    border-radius: 50%;
}

.heart::before {
    top: -7.5px;
    left: 0;
}

.heart::after {
    top: 0;
    left: -7.5px;
}

@keyframes float {
    0% {
        transform: translateY(110vh) rotate(45deg) scale(0.5);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        transform: translateY(-100px) rotate(405deg) scale(1.5);
        opacity: 0;
    }
}

/* Easter Egg */
.easter-egg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    width: 90%;
    max-width: 320px;
    background: white;
    padding: 10px;
    border-radius: 15px;
    box-shadow: 0 15px 40px rgba(255, 75, 114, 0.4);
    text-align: center;
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.easter-egg.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -40%) scale(0.8);
}

.easter-egg.active {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.easter-egg img {
    width: 100%;
    height: auto;
    border-radius: 10px;
    display: block;
}