:root {
    --bg-pink: #FFD1DC;
    --bg-mint: #D1FFDC;
    --bg-blue: #D1F2FF;
    --primary-color: #ff8fa3;
    --text-color: #555;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Fredoka', sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

body {
    overflow: hidden;
    background-color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-pink);
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Overlays */
.overlay,
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    transition: opacity 0.3s ease;
}

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

.content,
.modal-content {
    background: var(--glass-bg);
    padding: 2rem;
    border-radius: 20px;
    text-align: center;
    border: 2px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    max-width: 90%;
    width: 400px;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

h1,
h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

p {
    color: var(--text-color);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

button:active {
    transform: scale(0.95);
}

#modal-image {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin-bottom: 1rem;
    max-height: 200px;
    object-fit: cover;
}

#poem-container {
    font-style: italic;
    color: #777;
    margin-bottom: 1rem;
    white-space: pre-line;
}

/* Mobile Controls */
#mobile-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 5;
}

@media (min-width: 1024px) {
    #mobile-controls {
        display: none;
    }
}

.d-pad,
.action-btn {
    pointer-events: auto;
    display: flex;
    gap: 15px;
}

#mobile-controls button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    color: #333;
    font-size: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

#mobile-controls button:active {
    background: rgba(255, 255, 255, 0.9);
}

@keyframes popIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Collage Page */
.collage-body {
    background: linear-gradient(135deg, #FFD1DC 0%, #D1F2FF 100%);
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
    padding: 2rem 0;
}

.collage-container {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
    padding: 20px;
}

.collage-title {
    font-family: 'Dancing Script', cursive;
    font-size: 4rem;
    color: #ff6b81;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 3rem;
    animation: fadeInDown 1s ease-out;
}

.photo-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 40px;
    padding: 20px;
}

.polaroid {
    background: white;
    padding: 15px 15px 40px 15px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
    width: 280px;
    transition: transform 0.3s ease, z-index 0.3s;
    position: relative;
    cursor: pointer;
    animation: floatIn 1s ease-out backwards;
}

.polaroid:nth-child(1) {
    animation-delay: 0.2s;
}

.polaroid:nth-child(2) {
    animation-delay: 0.4s;
}

.polaroid:nth-child(3) {
    animation-delay: 0.6s;
}

.polaroid:nth-child(4) {
    animation-delay: 0.8s;
}

.polaroid:nth-child(5) {
    animation-delay: 1.0s;
}

.polaroid:nth-child(6) {
    animation-delay: 1.2s;
}

.polaroid:hover {
    transform: scale(1.1) rotate(0deg) !important;
    z-index: 10;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.25);
}

.polaroid img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    border: 1px solid #eee;
}

.caption {
    font-family: 'Dancing Script', cursive;
    font-size: 1.5rem;
    color: #555;
    margin-top: 15px;
    margin-bottom: 0;
}

.final-message {
    margin-top: 4rem;
    font-family: 'Dancing Script', cursive;
    font-size: 3rem;
    color: #ff6b81;
    animation: fadeInUp 1s ease-out 1.5s backwards;
}

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

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes floatIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Music Player Styles */
.music-player {
    width: 100%;
    max-width: 500px;
    margin: 2rem auto;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 15px 20px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.player-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.track-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.track-art {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.track-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.track-details {
    display: flex;
    flex-direction: column;
}

.track-name {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    line-height: 1.2;
}

.track-artist {
    font-size: 0.8rem;
    color: #666;
}

.lyrics-display {
    flex: 2;
    text-align: center;
    min-width: 0;
}

#current-lyric {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    font-size: 1rem;
    color: #ff6b81;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s ease;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
}

.player-controls button {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #333;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
    box-shadow: none;
}

.player-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.progress-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    cursor: pointer;
    overflow: hidden;
}

.progress {
    width: 0%;
    height: 100%;
    background: #ff6b81;
    border-radius: 3px;
    transition: width 0.1s linear;
}

/* Mobile Optimization */
@media (max-width: 768px) {
    body {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }

    /* Allow scrolling for collage page */
    body.collage-body {
        overflow-y: auto;
        position: relative;
        height: auto;
        min-height: 100vh;
    }

    #game-container {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        padding: 0;
        margin: 0;
        overflow: hidden;
    }

    h1 {
        font-size: 2.2rem;
        margin-bottom: 1rem;
    }

    h2 {
        font-size: 1.9rem;
    }

    p {
        font-size: 1.2rem;
        line-height: 1.6;
    }

    button {
        font-size: 1.4rem;
        padding: 18px 36px;
        margin-top: 1rem;
    }

    #modal-image {
        max-height: 400px;
        width: 100%;
        object-fit: contain;
    }

    #poem-container {
        font-size: 1.1rem;
        line-height: 1.8;
    }

    #mobile-controls {
        bottom: 30px;
        padding: 0 30px;
    }

    #mobile-controls button {
        width: 75px;
        height: 75px;
        font-size: 2rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }

    .collage-title {
        font-size: 3rem;
    }

    .photo-grid {
        gap: 20px;
    }

    .polaroid {
        width: 100%;
        max-width: 300px;
    }

    .final-message {
        font-size: 2rem;
        margin-top: 2rem;
    }
}

@media (max-width: 480px) {

    .content,
    .modal-content {
        width: 90%;
        font-size: 1.1rem;
        padding: 1.5rem 1rem;
    }

    h1 {
        font-size: 1.8rem;
    }

    h2 {
        flex-direction: column;
        align-items: center;
        justify-content: space-between;
        padding: 20px;
    }
}

/* Decoration Page Styles */
.decorate-body {
    background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
    min-height: 100vh;
    height: 100dvh;
    width: 100vw;
    margin: 0;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    background-attachment: fixed;
}

#decoration-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    box-sizing: border-box;
}

.decorate-title {
    font-family: 'Dancing Script', cursive;
    font-size: 3rem;
    color: #ff6b81;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin: 10px 0;
    text-align: center;
    z-index: 10;
}

.tree-area {
    flex: 1;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

canvas#treeCanvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    cursor: crosshair;
}

.controls-panel {
    background: rgba(255, 255, 255, 0.9);
    width: 100%;
    max-width: 600px;
    border-radius: 20px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.2);
    z-index: 10;
    flex-shrink: 0;
}

.items-scroll {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 10px;
    scrollbar-width: thin;
}

.item {
    font-size: 2.5rem;
    cursor: pointer;
    padding: 10px;
    border-radius: 10px;
    transition: transform 0.2s, background 0.2s;
    user-select: none;
}

.item:hover {
    transform: scale(1.1);
    background: rgba(0, 0, 0, 0.05);
}

.item.selected {
    background: #ffeb3b;
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

#complete-btn {
    width: 100%;
    background: linear-gradient(45deg, #ff6b6b, #ff8e53);
    font-family: 'Fredoka', sans-serif;
    font-weight: bold;
    letter-spacing: 1px;
    color: white;
    border: none;
    padding: 15px;
    border-radius: 50px;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

#complete-btn:active {
    transform: scale(0.98);
}

.decorate-btn {
    display: inline-block;
    background: #2d5a27;
    color: white;
    padding: 15px 30px;
    border-radius: 50px;
    text-decoration: none;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.2rem;
    margin-top: 20px;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.decorate-btn:hover {
    transform: scale(1.05);
    background: #3d7a37;
}

/* Decoration Desktop Overrides */
@media (min-width: 769px) {
    .decorate-body {
        height: 100vh;
    }

    #decoration-container {
        max-width: 1200px;
        margin: 0 auto;
    }

    .tree-area {
        max-height: 80vh;
    }

    .decorate-title {
        font-size: 4rem;
        margin-bottom: 20px;
    }
}

/* Decoration Mobile Overrides */
@media (max-width: 768px) {
    .decorate-title {
        font-size: 2rem;
        margin-top: 5px;
    }

    #decoration-container {
        padding: 10px;
    }

    .controls-panel {
        padding: 10px;
    }

    .item {
        font-size: 2rem;
        padding: 5px;
    }
}