/* ============================================
   CUSTOM FONT
   ============================================ */
@font-face {
    font-family: 'Boogaloo';
    src: url('fonts/Boogaloo-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Boogaloo', Arial, sans-serif;
    background: #0a0a0f;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    /* Prevent scrollbars */
}

/* ============================================
   GAME CONTAINER
   ============================================ */
#game-container {
    position: relative;
    width: min(100vw, min(100vh, 750px) * 3 / 2);
    height: min(100vh, 750px, 100vw * 2 / 3);
    aspect-ratio: 3 / 2;
    container-type: size;
}

#game-container:fullscreen {
    background: #000;
    width: min(100vw, 100vh * 3 / 2);
    height: min(100vh, 100vw * 2 / 3);
    margin: auto;
}

#game-container::backdrop {
    background: #000;
}

/* ============================================
   CANVAS - Fixed 720x480 internal, scales to fill container
   ============================================ */
#canvas {
    background-color: #000000;
    width: 100%;
    height: 100%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: block;
}

#canvas.hidden {
    display: none;
}

/* ============================================
   LANDING PAGE
   ============================================ */
.landing-page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    background: transparent;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    overflow: hidden;
}

.landing-page.hidden {
    display: none;
}

.landing-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(100cqh - 100cqw * 9 / 16);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 clamp(8px, 2cqw, 20px);
    color: #fff;
    font-size: clamp(16px, 3cqh, 1.3rem);
    z-index: 2;
}

.footer-buttons {
    display: flex;
    gap: clamp(5px, 1cqw, 15px);
}

.footer-left,
.footer-right {
    flex: 1;
    text-align: center;
    color: #fff;
}

.footer-right {
    text-decoration: none;
}

.footer-right:hover {
    text-decoration: underline;
}

/* ============================================
   ANIMATED GRADIENT WAVE BACKGROUND
   ============================================ */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    background: #0a0a0f;
}

.bg-gradient-sphere {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    will-change: transform;
    pointer-events: none;
    translate: var(--parallax-x, 0px) var(--parallax-y, 0px);
}

.sphere-1 {
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(255, 107, 53, 0.4), transparent 70%);
    top: -20%;
    left: -15%;
    animation: bg-float-1 20s ease-in-out infinite;
}

.sphere-2 {
    width: 50%;
    height: 50%;
    background: radial-gradient(circle, rgba(247, 147, 30, 0.35), transparent 70%);
    top: 40%;
    right: -10%;
    animation: bg-float-2 25s ease-in-out infinite;
}

.sphere-3 {
    width: 55%;
    height: 55%;
    background: radial-gradient(circle, rgba(255, 140, 50, 0.3), transparent 70%);
    bottom: -25%;
    left: 25%;
    animation: bg-float-3 22s ease-in-out infinite;
}

.sphere-4 {
    width: 40%;
    height: 40%;
    background: radial-gradient(circle, rgba(255, 90, 30, 0.3), transparent 70%);
    top: 20%;
    left: 50%;
    animation: bg-float-4 18s ease-in-out infinite;
}

.bg-grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
}

.bg-noise-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.04;
}

#bg-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.landing-hero {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: top;
    z-index: 1;
    pointer-events: none;
}

@keyframes bg-float-1 {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(5%, 3%) scale(1.05);
    }

    50% {
        transform: translate(2%, 6%) scale(0.95);
    }

    75% {
        transform: translate(-3%, 2%) scale(1.02);
    }
}

@keyframes bg-float-2 {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(-4%, 5%) scale(1.03);
    }

    50% {
        transform: translate(-6%, -2%) scale(0.97);
    }

    75% {
        transform: translate(3%, -4%) scale(1.05);
    }
}

@keyframes bg-float-3 {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(6%, -3%) scale(0.98);
    }

    50% {
        transform: translate(-3%, -5%) scale(1.04);
    }

    75% {
        transform: translate(-5%, 4%) scale(0.96);
    }
}

@keyframes bg-float-4 {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(-3%, -4%) scale(1.06);
    }

    50% {
        transform: translate(5%, 3%) scale(0.94);
    }

    75% {
        transform: translate(4%, -2%) scale(1.03);
    }
}

/* ============================================
   DIALOG / INSTRUCTIONS
   ============================================ */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    backdrop-filter: blur(5px);
}

.dialog-overlay.hidden {
    display: none;
}

.dialog {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    border-radius: 20px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    color: white;
}

.dialog-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s;
}

.dialog-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.dialog h2 {
    color: #ff6b35;
    font-size: 3rem;
    margin-bottom: 20px;
    text-align: center;
}

.dialog h3 {
    color: #f7931e;
    font-size: 1.4rem;
    margin-top: 20px;
    margin-bottom: 10px;
}

.instructions-content p {
    font-size: 1.2rem;
    margin-bottom: 15px;
    line-height: 1.6;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 15px;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1.2rem;
}

.key {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    min-width: 60px;
    text-align: center;
}

/* ============================================
   OVERLAY SCREENS (Pause, GameOver, Win)
   ============================================ */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 90;
}

.overlay.hidden {
    display: none;
}

.overlay-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0.4;
    pointer-events: none;
}

.overlay-content {
    position: relative;
    text-align: center;
    color: white;
    max-width: 80%;
    max-height: 90%;
    padding: clamp(10px, 4cqh, 40px) clamp(15px, 3cqw, 40px);
    background: linear-gradient(135deg, rgba(44, 62, 80, 0.366), rgba(52, 73, 94, 0.273));
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.overlay-content h1 {
    font-size: clamp(1.5rem, 8cqh, 64px);
    color: #ffcc00;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8);
    margin-bottom: clamp(5px, 2cqh, 20px);
}

.overlay-content h2 {
    font-size: clamp(1.2rem, 7cqh, 4.5rem);
    color: #e74c3c;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8);
    margin-bottom: clamp(5px, 2cqh, 20px);
}

#win-screen .overlay-content h2 {
    color: #2ecc71;
}

.overlay-content p {
    font-size: clamp(16px, 4cqh, 32px);
    margin-bottom: clamp(5px, 2cqh, 20px);
    color: #fff;
}

.subtitle {
    font-size: clamp(16px, 3cqh, 20px);
    margin-bottom: clamp(10px, 3cqh, 30px);
    color: #fff;
}

.game-screen-buttons {
    display: flex;
    gap: clamp(8px, 2cqw, 20px);
    justify-content: center;
    margin-top: clamp(5px, 2cqh, 30px);
    flex-wrap: wrap;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    padding: clamp(6px, 2cqh, 15px) clamp(16px, 4cqw, 40px);
    font-size: clamp(16px, 3cqh, 1.5rem);
    font-family: inherit;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: auto;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.6);
}

.btn-secondary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.game-btn {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    font-size: clamp(16px, 3cqh, 1.5rem);
    font-weight: bold;
    padding: clamp(5px, 2cqh, 15px) clamp(15px, 4cqw, 40px);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
    transition: all 0.3s ease;
    margin-top: clamp(3px, 1cqh, 10px);
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: auto;
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.6);
}

.game-btn:active {
    transform: translateY(0);
    box-shadow: 0 3px 10px rgba(255, 107, 53, 0.3);
}

/* ============================================
   SOUND CONTROL
   ============================================ */
.mute-btn,
.fullscreen-btn,
.pause-btn {
    position: absolute;
    top: clamp(5px, 2cqh, 20px);
    width: clamp(30px, 8cqh, 50px);
    height: clamp(30px, 8cqh, 50px);
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 50;
    color: white;
    font-size: clamp(16px, 4cqh, 20px);
}

/* Between coin bar (~45%) and endboss bar (~77%), centered at ~61% */
.pause-btn {
    left: calc(61% - clamp(30px, 8cqh, 50px) * 1.5 - clamp(5px, 1cqw, 10px));
}

.fullscreen-btn {
    left: calc(61% - clamp(30px, 8cqh, 50px) / 2);
}

.mute-btn {
    left: calc(61% + clamp(30px, 8cqh, 50px) / 2 + clamp(5px, 1cqw, 10px));
}

.mute-btn.hidden,
.fullscreen-btn.hidden,
.pause-btn.hidden {
    display: none;
}

.mute-btn:hover,
.fullscreen-btn:hover,
.pause-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

#pause-screen .overlay-content h2 {
    color: #f39c12;
}

/* ============================================
   MOBILE TOUCH CONTROLS
   ============================================ */
#mobile-controls {
    position: absolute;
    bottom: clamp(5px, 2cqh, 20px);
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 clamp(5px, 2cqw, 20px);
    z-index: 5;
}

#mobile-controls.hidden {
    display: none;
}

.touch-btn {
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid white;
    border-radius: 50%;
    width: clamp(40px, 14cqh, 75px);
    height: clamp(40px, 14cqh, 75px);
    font-size: clamp(10px, 3cqh, 18px);
    font-weight: bold;
    color: white;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

.touch-btn:active {
    background: rgba(255, 255, 255, 0.5);
    transform: scale(0.95);
}

/* Position touch buttons — movement left, actions stacked right */
.left-btn {
    position: absolute;
    left: clamp(5px, 2cqw, 20px);
    bottom: clamp(5px, 2cqh, 20px);
}

.right-btn {
    position: absolute;
    left: calc(clamp(5px, 2cqw, 20px) + clamp(40px, 14cqh, 75px) + clamp(5px, 1cqw, 10px));
    bottom: clamp(5px, 2cqh, 20px);
}

.jump-btn {
    position: absolute;
    right: clamp(5px, 2cqw, 20px);
    bottom: calc(clamp(5px, 2cqh, 20px) + clamp(40px, 14cqh, 75px) + clamp(3px, 1cqh, 8px));
}

.throw-btn {
    position: absolute;
    right: clamp(5px, 2cqw, 20px);
    bottom: clamp(5px, 2cqh, 20px);
}

/* ============================================
   PORTRAIT WARNING
   ============================================ */
#portrait-warning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#portrait-warning.hidden {
    display: none;
}

.warning-content {
    text-align: center;
    color: white;
}

.warning-content h2 {
    font-size: 80px;
    margin-bottom: 20px;
}

.warning-content p {
    font-size: 24px;
    margin: 10px 0;
}

.warning-content .small {
    font-size: 16px;
    color: #ccc;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablets and smaller devices */
@media (max-width: 768px) {
    .overlay-content {
        max-width: 90%;
    }

    .dialog h2 {
        font-size: 2rem;
    }

    .controls-grid {
        grid-template-columns: 1fr;
    }
}

/* Mobile devices in landscape */
@media (max-width: 768px) and (orientation: landscape) {
    body {
        background: #0a0a0f;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */