:root {
    --primary-color: #ff4d6d;
    --secondary-color: #ff8fa3;
    --accent-color: #7209b7;
    --glass: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(255, 255, 255, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', sans-serif;
    background: #fbc2eb;
    /* Yedek arka plan rengi */
    background: linear-gradient(135deg, #fbc2eb 0%, #a6c1ee 100%);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: transparent;
}

/* UI Elements */
#ui {
    position: fixed;
    top: 25px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    pointer-events: none;
    z-index: 1000;
}

/* Screen overlay for UI elements like win/lose screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    /* Hidden by default */
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    z-index: 100;
    /* Ensure it's above other UI */
    padding: 20px;
}

.heart-container {
    position: relative;
    width: 75px;
    height: 75px;
    filter: drop-shadow(0 0 15px rgba(255, 77, 109, 0.5));
}

.heart-svg {
    position: absolute;
    width: 100%;
    height: 100%;
    fill: rgba(255, 255, 255, 0.2);
    stroke: white;
    stroke-width: 2;
    z-index: 10;
}

/* Kalp barı için yeni temiz yapı */
#heart-fill-wrapper {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, #ff0055, #ff4d6d);
    -webkit-mask-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M16 28.5L14.1 26.75C7.35 20.65 3 16.7 3 11.85C3 7.85 6.15 4.7 10.15 4.7C12.45 4.7 14.65 5.75 16 7.45C17.35 5.75 19.55 4.7 21.85 4.7C25.85 4.7 29 7.85 29 11.85C29 16.7 24.65 20.65 17.9 26.75L16 28.5Z"/></svg>');
    mask-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M16 28.5L14.1 26.75C7.35 20.65 3 16.7 3 11.85C3 7.85 6.15 4.7 10.15 4.7C12.45 4.7 14.65 5.75 16 7.45C17.35 5.75 19.55 4.7 21.85 4.7C25.85 4.7 29 7.85 29 11.85C29 16.7 24.65 20.65 17.9 26.75L16 28.5Z"/></svg>');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    clip-path: inset(100% 0 0 0);
    transition: clip-path 0.5s ease-out;
    z-index: 5;
}

#heart-mask {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.6);
    -webkit-mask-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M16 28.5L14.1 26.75C7.35 20.65 3 16.7 3 11.85C3 7.85 6.15 4.7 10.15 4.7C12.45 4.7 14.65 5.75 16 7.45C17.35 5.75 19.55 4.7 21.85 4.7C25.85 4.7 29 7.85 29 11.85C29 16.7 24.65 20.65 17.9 26.75L16 28.5Z"/></svg>');
    mask-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M16 28.5L14.1 26.75C7.35 20.65 3 16.7 3 11.85C3 7.85 6.15 4.7 10.15 4.7C12.45 4.7 14.65 5.75 16 7.45C17.35 5.75 19.55 4.7 21.85 4.7C25.85 4.7 29 7.85 29 11.85C29 16.7 24.65 20.65 17.9 26.75L16 28.5Z"/></svg>');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
}

.heart-pulse {
    animation: heartPulseAnim 0.4s ease-out;
}

@keyframes heartPulseAnim {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
        filter: brightness(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* Controls */
#controls {
    position: absolute;
    bottom: 80px;
    /* Navigasyon çubuklarının üzerinde kalması için yükseltildi */
    bottom: calc(60px + env(safe-area-inset-bottom));
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 25px;
    z-index: 10;
}

.left-controls {
    display: flex;
    gap: 15px;
}

.ctrl-btn {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    font-size: 1.2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.ctrl-btn:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.92);
}

.jump-btn {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.15);
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: transparent;
    pointer-events: none;
}


.heart-final {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) scale(4) !important;
    transition: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    z-index: 1000;
}

/* Mektup Animasyonu */
.letter-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.5s;
    z-index: 1100;
}

.letter-container.show {
    visibility: visible;
    opacity: 1;
}

.envelope {
    width: 300px;
    height: 180px;
    background: #fdfdfd;
    position: relative;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.5s;
}

.envelope:hover {
    transform: scale(1.02);
}

.envelope-top {
    position: absolute;
    top: 0;
    width: 0;
    height: 0;
    border-left: 150px solid transparent;
    border-right: 150px solid transparent;
    border-top: 110px solid #f0f0f0;
    transform-origin: top;
    transition: transform 0.6s;
    z-index: 10;
}

.click-me {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--primary-color);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    z-index: 11;
    pointer-events: none;
    box-shadow: 0 5px 15px rgba(255, 77, 109, 0.3);
}

.letter {
    position: absolute;
    top: 5px;
    left: 10px;
    right: 10px;
    height: 160px;
    background: #fff;
    padding: 25px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1;
    transform: translateY(150px) scale(0.8);
    /* İyice aşağıda ve küçük */
    opacity: 0;
    pointer-events: none;
    /* Açılmadan tıklanamasın */
    transition: transform 1s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Açılmış Zarf Durumu */
.envelope.opened {
    overflow: visible;
}

.envelope.opened .envelope-top {
    transform: rotateX(180deg);
    z-index: 0;
}

.envelope.opened .letter {
    transform: translateY(-160px) scale(1);
    opacity: 1;
    z-index: 20;
    height: auto;
    min-height: 200px;
    pointer-events: auto;
}

.envelope.opened .click-me {
    display: none;
}

.letter-title {
    font-family: 'Dancing Script', cursive;
    color: var(--primary-color);
    font-size: 1.8rem;
    margin-bottom: 15px;
}

.letter-text {
    font-size: 1rem;
    color: #444;
    line-height: 1.6;
}

.screen.active {
    display: flex;
}

.glass-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 30px;
    padding: 40px 25px;
    text-align: center;
    max-width: 350px;
    animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.game-title {
    font-family: 'Dancing Script', cursive;
    font-size: 2.2rem;
    color: white;
    margin-bottom: 15px;
}

.game-desc {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 25px;
    line-height: 1.5;
}

.avatar-preview {
    width: 100px;
    height: 100px;
    margin: 0 auto 25px;
    border-radius: 50%;
    border: 4px solid white;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(255, 77, 109, 0.5);
}

.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.main-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 15px 35px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(255, 77, 109, 0.4);
}

.love-title {
    font-family: 'Dancing Script', cursive;
    font-size: 3rem;
    color: #ff4d6d;
    margin-bottom: 20px;
}

.secondary-btn {
    background: transparent;
    border: 2px solid white;
    color: white;
    padding: 10px 25px;
    border-radius: 20px;
    margin-top: 20px;
    cursor: pointer;
}

/* Yatay Ekran Koruması */
#landscape-warning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #ff4d6d 0%, #7209b7 100%);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
    padding: 30px;
}

.warning-content {
    animation: pulseWarning 2s infinite;
}

.rotate-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

@keyframes pulseWarning {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

@media screen and (orientation: landscape) and (max-height: 500px) {
    #landscape-warning {
        display: flex;
    }

    #game-container {
        display: none;
    }
}