/* Floating Header Styles */
#floating-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #4ec0ca;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    box-sizing: border-box;
}

#header-content {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
}

#header-logo-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

#header-logo {
    font-family: 'Rubik', sans-serif;
    font-weight: 700;
    font-size: 24px;
    color: white;
    text-shadow: 
        2px 2px 0 #00008B,
        -2px -2px 0 #00008B,
        2px -2px 0 #00008B,
        -2px 2px 0 #00008B,
        0 4px 8px rgba(0,0,0,0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
    cursor: pointer;
    transition: transform 0.2s;
}

#header-logo:hover {
    transform: scale(1.05);
}

#menu-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    z-index: 1001;
}

#side-menu {
    position: fixed;
    top: 70px;
    left: 0;
    width: 250px;
    height: calc(100vh - 70px);
    background-color: #4ec0ca;
    padding: 20px;
    box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    transition: transform 0.3s ease;
    z-index: 999;
    transform: translateX(-100%);
}

#side-menu.menu-open {
    transform: translateX(0);
}

#side-menu-ad {
    width: 100%;
    height: 200px;
    background-color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    overflow: hidden;
    margin-top: 15px;
}

.menu-difficulty-button {
    background-color: #00008B;
    color: white;
    border: none;
    border-radius: 25px;
    padding: 8px 15px;
    font-size: 16px;
    font-family: Arial, sans-serif;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
    display: block;
    width: 100%;
    text-align: left;
}

.menu-difficulty-button:hover {
    background-color: #000066;
}

#menu-difficulty-easy {
    background-color: #4ec0ca;
    border: 2px solid #E40078;
}

#menu-difficulty-medium {
    background-color: #FFA500;
}

#menu-difficulty-insane {
    background-color: #E40078;
}

/* Main Content Styles */
body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    margin: 0;
    background-color: #4ec0ca;
    position: relative;
    touch-action: pan-y;
    padding-top: 80px;
    overscroll-behavior: none;
    overflow-x: hidden;
}

#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    position: relative;
    margin-top: 20px;
}

/* Fixed Ad Styles with proper spacing and no stretching */
.ad-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin: 0 auto;
}

#ad-container, .ad-container {
    width: 320px;
    height: 50px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #4ec0ca;
    flex-shrink: 0; /* Prevent shrinking */
}

#ad-container {
    margin-bottom: 1px; /* 1px spacing as requested */
}

.ad-container {
    margin-top: 0; /* Remove top margin to maintain 1px spacing */
}

/* Fix for SusManga ad - prevent stretching and cropping */
.ad-container img {
    width: auto;
    height: auto;
    max-width: 320px; /* Match container width exactly */
    max-height: 50px; /* Match container height exactly */
    object-fit: contain; /* Maintain aspect ratio without cropping */
    object-position: center; /* Center the image */
}

/* Ensure iframe ads don't stretch */
.ad-container iframe {
    max-width: 320px;
    max-height: 50px;
    width: auto;
    height: auto;
}

canvas {
    width: 90%;
    max-width: 600px;
    height: auto;
    border: 1px solid black;
    display: block;
    -webkit-tap-highlight-color: transparent;
}

#score {
    font-size: 6vw;
    font-family: Arial;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    position: relative;
    margin-bottom: 20px;
    z-index: 5;
}

#global-top-score {
    font-size: 4vw;
    font-family: Arial;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin-top: 20px;
    text-align: center;
    padding: 0 10px;
}

#start-screen {
    font-size: 5vw;
    font-family: Arial;
    color: white;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    position: absolute;
    top: 228px;
    left: 50%;
    transform: translateX(-50%);
    padding: 0 20px;
    max-width: 100%;
    box-sizing: border-box;
    z-index: 10;
    width: 100%;
}

/* Game Over Overlay */
#game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

#game-over-content {
    background-color: #4ec0ca;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    max-width: 80%;
    width: 350px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

#game-over-title {
    font-size: 28px;
    font-family: Arial;
    color: white;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

#final-score {
    font-size: 24px;
    font-family: Arial;
    color: white;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

#ad-label {
    font-size: 12px;
    color: white;
    margin-bottom: 5px;
    opacity: 0.7;
}

#ad-square-container {
    width: 300px;
    height: 350px;
    background-color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 15px;
    border-radius: 10px;
    position: relative;
}

/* Play Again Button with Rubik Font */
#restart-button {
    background-color: #E40078;
    color: white !important;
    border: none;
    border-radius: 25px;
    padding: 15px 25px;
    font-size: 22px;
    font-family: 'Rubik', sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    text-shadow: 
        2px 2px 0 #00008B,
        -2px -2px 0 #00008B,
        2px -2px 0 #00008B,
        -2px 2px 0 #00008B,
        0 4px 8px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
    animation: wiggle 5s infinite;
    text-transform: uppercase;
    letter-spacing: 1px;
}

@keyframes wiggle {
    0% { transform: rotate(0deg) scale(1); }
    5% { transform: rotate(-3deg) scale(1.05); }
    10% { transform: rotate(3deg) scale(1.05); }
    15% { transform: rotate(-3deg) scale(1.05); }
    20% { transform: rotate(3deg) scale(1.05); }
    25% { transform: rotate(0deg) scale(1.05); }
    100% { transform: rotate(0deg) scale(1.05); }
}

#restart-button:hover {
    background-color: #ff0099;
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
}

#restart-button:active {
    transform: scale(0.98);
}

#restart-button::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: -100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: 0.5s;
}

#restart-button:hover::after {
    left: 100%;
}

/* Share score button in game over overlay */
#share-score-button {
    background-color: #00008B;
    color: white;
    border: none;
    border-radius: 25px;
    padding: 12px 20px;
    font-size: 18px;
    font-family: Arial;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 auto 15px;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 300px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

#share-score-button:hover {
    background-color: #000066;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

#share-score-button svg {
    width: 20px;
    height: 20px;
}

/* Share button styles */
#share-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    width: 100%;
}

#share-button {
    background-color: #00008B;
    color: white;
    border: none;
    border-radius: 25px;
    padding: 12px 20px;
    font-size: 18px;
    font-family: Arial;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

#share-button:hover {
    background-color: #000066;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

#share-button svg {
    width: 20px;
    height: 20px;
}

/* Difficulty buttons styles */
.difficulty-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px 0;
    width: 100%;
    max-width: 600px;
}

.difficulty-title {
    font-size: 28px;
    font-family: Arial, sans-serif;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin-bottom: 15px;
    text-align: center;
}

.buttons-row {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    width: 100%;
}

.difficulty-button {
    background-color: #00008B;
    color: white;
    border: none;
    border-radius: 25px;
    padding: 12px 20px;
    font-size: 18px;
    font-family: Arial, sans-serif;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
    min-width: 120px;
    position: relative;
    overflow: hidden;
}

.difficulty-button:hover {
    background-color: #000066;
    transform: translateY(-3deg);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

.difficulty-button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.difficulty-button::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: -100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: 0.5s;
}

.difficulty-button:hover::after {
    left: 100%;
}

#easy-button {
    background-color: #4ec0ca;
    border: 2px solid #E40078;
}

#medium-button {
    background-color: #FFA500;
}

#insane-button {
    background-color: #E40078;
}

/* Desktop Menu Styles */
@media (min-width: 769px) {
    #side-menu {
        transform: translateX(-100%);
        left: 0;
        top: 70px;
        width: 250px;
        height: auto;
        box-shadow: none;
        position: absolute;
    }
    
    #header-logo {
        font-size: 28px;
    }
}

/* Mobile Menu Styles */
@media (max-width: 768px) {
    #header-logo {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    #score {
        font-size: 32px;
        margin-bottom: 15px;
    }

    #global-top-score {
        font-size: 22px;
    }

    #start-screen {
        font-size: 24px;
    }

    canvas {
        width: 95%;
        margin-top: 20px;
    }
    
    /* Mobile-specific ad fixes */
    #ad-container, .ad-container {
        width: 320px;
        height: 50px;
        min-width: 320px; /* Prevent shrinking */
        min-height: 50px; /* Prevent shrinking */
    }
    
    .ad-container img {
        max-width: 320px;
        max-height: 50px;
        width: auto;
        height: auto;
    }
    
    .desktop-ad {
        display: none;
    }
    
    .mobile-ad {
        display: block;
    }
    
    #share-button {
        font-size: 16px;
        padding: 8px 16px;
    }
    
    #game-container {
        margin-top: 10px;
    }
    
    .difficulty-title {
        font-size: 22px;
    }

    .difficulty-button {
        font-size: 16px;
        padding: 10px 16px;
        min-width: 100px;
    }
    
    .buttons-row {
        gap: 10px;
    }
    
    #game-over-content {
        width: 280px;
        padding: 15px;
    }
    
    #game-over-title {
        font-size: 24px;
    }
    
    #final-score {
        font-size: 20px;
    }
    
    #ad-square-container {
        width: 250px;
        height: 300px;
    }
    
    #restart-button {
        font-size: 18px;
        padding: 12px 20px;
        max-width: 250px;
    }
    
    #share-score-button {
        font-size: 16px;
        padding: 8px 16px;
        max-width: 250px;
    }
    
    #header-logo {
        font-size: 18px;
    }
}

@media (min-width: 481px) and (max-width: 767px) {
    #score {
        font-size: 36px;
    }

    #global-top-score {
        font-size: 20px;
    }

    #start-screen {
        font-size: 28px;
    }
    
    #ad-container {
        margin-bottom: 1px; /* Maintain 1px spacing */
    }
    
    .ad-container img {
        max-width: 320px;
        max-height: 50px;
    }
    
    .desktop-ad {
        display: none;
    }
    
    .mobile-ad {
        display: block;
    }
    
    #game-container {
        margin-top: 10px;
    }
    
    .difficulty-title {
        font-size: 24px;
    }
}

@media (min-width: 768px) {
    #score {
        font-size: 40px;
    }

    #global-top-score {
        font-size: 20px;
    }

    #start-screen {
        font-size: 30px;
    }
    
    #ad-container {
        margin-bottom: 1px; /* Maintain 1px spacing on desktop too */
    }
    
    .ad-container img {
        max-width: 320px;
        max-height: 50px;
    }
    
    .desktop-ad {
        display: block;
    }
    
    .mobile-ad {
        display: none;
    }
}

@media (orientation: portrait) and (max-height: 600px) {
    canvas {
        height: 60vh;
        width: auto;
    }
    
    #ad-container {
        margin-bottom: 1px;
    }
    
    #game-container {
        margin-top: 10px;
    }
}