@import url('https://fonts.googleapis.com/css2?family=Cutive+Mono:wght@400;700&family=Delicious+Handrawn&display=swap');

/* PWA specific styles */
@media all and (display-mode: standalone) {
    html {
        height: 100%;
        overflow-y: auto;
        overscroll-behavior-y: none;
    }
    
    body {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
        overscroll-behavior-y: none;
    }
}

body {
    background-image: url('/assets/ui/bg.webp');
    background-repeat: repeat;
    background-size: auto;
    background-color: #fdfcf6;
    margin: 0;
    padding: 0;
    font-family: "Cutive Mono", monospace;
    min-height: 100vh;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.1), rgba(0, 0, 0, 0) 70%);
    opacity: 0.2;
    pointer-events: none;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    background-image: url('/assets/ui/bg.webp');
    mix-blend-mode: multiply;
    opacity: 0.15;
    pointer-events: none;
}

#app {
    width: 100%;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.error-container,
.about-container {
    max-width: 800px;
    margin: 50px auto;
    text-align: center;
    padding: 20px;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: #FFFAE6; /* Match loading screen background */
}

#game-back-button {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 2001;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: transform 0.2s ease;
}

#game-back-button img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

#game-back-button:hover {
    transform: scale(1.1);
}

#game-back-button:active {
    transform: scale(0.95);
}

.back-button {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 70px;
    height: auto;
    cursor: pointer;
    transition: transform 0.2s ease;
    z-index: 1000;
}

.back-button:hover {
    transform: scale(1.1);
}

#rotation-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.rotation-message {
    color: white;
    font-size: 24px;
    text-align: center;
    padding: 20px;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 10px;
    max-width: 80%;
}

.content {
    min-height: calc(100vh - 120px);
    padding-bottom: 40px;
    box-sizing: border-box;
    padding: 80px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

h1 {
    font-family: 'Delicious Handrawn', cursive;
    font-size: 2.5rem;
    margin-bottom: 2rem;
}

h2 {
    font-size: 1.8rem;
    margin: 1.5rem 0;
}

p {
    line-height: 1.6;
    margin-bottom: 1rem;
}

.footer {
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    bottom: 0;
    width: 100%;
}

.footer .nav-link {
    margin: 0;
    background-color: transparent;
    color: #444;
    font-family: 'Delicious Handrawn', cursive;
    font-size: 24px;
    padding: 8px 15px;
    transition: all 0.3s ease;
    text-decoration: none;
}

.footer .nav-link:hover {
    background-color: transparent;
    color: #000;
    transform: scale(1.2);
}

#level-selector {
    text-align: center;
    padding: 20px;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 60px;
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px;
}

.level-card {
    position: relative;
    background: white;
    text-decoration: none;
    color: #333;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    padding: 15px 15px 60px 15px;
    width: 100%;
    box-sizing: border-box;
}

/* Fixed rotations for cards */
.level-card:nth-child(1) {
    transform: rotate(-12deg);
}

.level-card:nth-child(2) {
    transform: rotate(8deg);
}

.level-card:nth-child(3) {
    transform: rotate(2deg);
}

.level-card:hover {
    transform: scale(1.02) rotate(0deg);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    z-index: 1;
}

.level-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    margin-bottom: 10px;
    border: none;
}

.level-card h2 {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    margin: 0;
    padding: 0 20px;
    font-family: 'Delicious Handrawn', cursive;
    font-size: 2rem;
    color: #2b2b2b;
}

/* Random text alignments */
.level-card:nth-child(1) h2 {
    text-align: left;
    transform: rotate(-3deg);
}

.level-card:nth-child(2) h2 {
    text-align: right;
    transform: rotate(2deg);
}

.level-card:nth-child(3) h2 {
    text-align: center;
    transform: rotate(-1deg);
}

.level-card:first-child::before {
    content: "";
    position: absolute;
    top: -25px;
    left: -25px;
    width: 70px;
    height: 70px;
    background-image: url('/assets/ui/go.webp');
    background-size: contain;
    background-repeat: no-repeat;
    z-index: 1;
}

.start-here-img {
    position: relative;
    top: 268px;
    left: -535px;
    transform: rotate(-90deg);
    width: 160px;
}

@media (min-width: 769px) and (max-width: 1024px) {
    .start-here-img {
        left: -440px;
    }
}

@media (max-width: 768px) {
    #game-back-button {
        top: 10px;
        left: 10px;
    }

    #game-back-button img {
        width: 32px;
        height: 32px;
    }

    .content {
        padding: 60px 15px;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .footer {
        height: 60px;
        gap: 15px;
    }

    .footer .nav-link {
        font-size: 16px;
        padding: 6px 12px;
    }

    .back-button {
        width: 40px;
        height: auto;
        top: 15px;
        left: 15px;
    }

    .level-grid {
        grid-template-columns: 1fr;
        gap: 40px;
        padding: 20px;
        max-width: 400px;
    }

    .level-card {
        padding: 10px 10px 50px 10px;
    }

    .level-card h2 {
        padding: 0 15px;
        font-size: 1.6rem;
        bottom: 15px;
    }

    .level-card:first-child::before {
        width: 30px;
        height: 30px;
        top: 20px;
        left: 20px;
    }

    /* Adjust rotation angles for better mobile display */
    .level-card:nth-child(1) {
        transform: rotate(-8deg);
    }

    .level-card:nth-child(2) {
        transform: rotate(5deg);
    }
    .start-here-img {
        top: 268px;
        left: -229px;
    }
}

@media (max-width: 480px) {
    .content {
        padding: 50px 10px;
    }

    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.3rem;
    }
}

@media (orientation: portrait) {
    #rotation-overlay {
        display: flex;
        opacity: 1;
    }
}