@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

.game-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.brick-border {
    position: relative;
    padding: 0;
    background-color: #000;
}

.game-header {
    width: 393px;
    background-color: #2a2a2a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 4px solid #1a4d8f;
    position: relative;
    z-index: 1;
}

.score-display {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.score-label {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    color: #888;
    letter-spacing: 1px;
}

.score-value {
    font-family: 'Press Start 2P', monospace;
    font-size: 16px;
    color: #fff;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.5);
}

.jump-meter {
    display: flex;
    align-items: center;
}

.meter-bar {
    display: flex;
    gap: 2px;
    background-color: #1a1a1a;
    padding: 4px;
    border-radius: 12px;
    border: 2px solid #444;
}

.meter-segment {
    width: 8px;
    height: 20px;
    border-radius: 4px;
    background-color: #333;
    transition: background 0.1s ease;
}

.meter-segment.filled:nth-child(1),
.meter-segment.filled:nth-child(2),
.meter-segment.filled:nth-child(3),
.meter-segment.filled:nth-child(4),
.meter-segment.filled:nth-child(5) {
    background: linear-gradient(to bottom, #4ade80, #22c55e);
}

.meter-segment.filled:nth-child(6),
.meter-segment.filled:nth-child(7),
.meter-segment.filled:nth-child(8),
.meter-segment.filled:nth-child(9),
.meter-segment.filled:nth-child(10),
.meter-segment.filled:nth-child(11) {
    background: linear-gradient(to bottom, #fbbf24, #f59e0b);
}

.meter-segment.filled:nth-child(12),
.meter-segment.filled:nth-child(13),
.meter-segment.filled:nth-child(14),
.meter-segment.filled:nth-child(15),
.meter-segment.filled:nth-child(16) {
    background: linear-gradient(to bottom, #f87171, #ef4444);
}

#gameCanvas {
    display: block;
    background-color: #2a2a2a;
    width: 393px;
    height: 852px;
    position: relative;
    z-index: 1;
}

/* Desktop styling with brick border */
@media (min-width: 500px) {
    .brick-border {
        padding: 40px;
        background:
            repeating-linear-gradient(
                0deg,
                #1a4d8f 0px,
                #1a4d8f 32px,
                #2563b8 32px,
                #2563b8 34px,
                #1a4d8f 34px,
                #1a4d8f 66px,
                #2563b8 66px,
                #2563b8 68px
            ),
            repeating-linear-gradient(
                90deg,
                #1a4d8f 0px,
                #1a4d8f 64px,
                #2563b8 64px,
                #2563b8 66px,
                #1a4d8f 66px,
                #1a4d8f 130px,
                #2563b8 130px,
                #2563b8 132px
            );
        background-size: 100% 100%;
        box-shadow:
            inset 0 0 0 2px #0d2847,
            inset 0 0 0 4px #2563b8,
            0 0 0 2px #0d2847;
        border-radius: 4px;
    }

    .brick-border::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background:
            repeating-linear-gradient(
                0deg,
                transparent 0px,
                transparent 16px,
                rgba(255, 255, 255, 0.05) 16px,
                rgba(255, 255, 255, 0.05) 17px,
                transparent 17px,
                transparent 33px,
                rgba(0, 0, 0, 0.1) 33px,
                rgba(0, 0, 0, 0.1) 34px
            ),
            repeating-linear-gradient(
                90deg,
                transparent 0px,
                transparent 32px,
                rgba(255, 255, 255, 0.05) 32px,
                rgba(255, 255, 255, 0.05) 33px,
                transparent 33px,
                transparent 65px,
                rgba(0, 0, 0, 0.1) 65px,
                rgba(0, 0, 0, 0.1) 66px
            );
        pointer-events: none;
    }

    /* Reduce padding on viewports shorter than 1000px */
    @media (max-height: 1000px) {
        .brick-border {
            padding: 20px;
        }
    }

    /* Further reduce on viewports shorter than 950px (13" MacBook Pro) */
    @media (max-height: 950px) {
        .brick-border {
            padding: 10px;
        }
    }

    /* Ensure canvas fits in remaining space */
    #gameCanvas {
        max-height: calc(100vh - 100px);  /* Leave room for header and padding */
    }
}

/* Mobile styling - full screen, no brick border */
@media (max-width: 499px) {
    body {
        height: 100dvh; /* Use dynamic viewport height to avoid gap from browser chrome */
        align-items: flex-start;
        overflow: hidden;
    }

    .brick-border {
        padding: 0;
        background: transparent;
    }

    .game-header {
        width: 100vw;
        max-width: 393px;
    }

    #gameCanvas {
        width: 100vw;
        height: calc(100vh - 70px);
        height: calc(100dvh - 70px); /* Dynamic viewport height for iOS - accounts for browser chrome */
        max-width: 393px;
    }
}
