/* ===== Base Reset & Typography ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-dark: #000;
    --bg-underground: #000;
    --brick-dark: #6b4423;
    --brick-light: #b87333;
    --question-orange: #e76d18;
    --question-dark: #c45a10;
    --pipe-green: #30b020;
    --pipe-dark: #208010;
    --pipe-light: #50d040;
    --floor-blue: #5c94fc;
    --floor-dark: #3070d0;
    --coin-gold: #ffc000;
    --text-white: #fcfcfc;
    --text-orange: #e76d18;
    --star-yellow: #ffc000;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Press Start 2P', cursive;
    background-color: var(--bg-dark);
    color: var(--text-white);
    min-height: 100vh;
    overflow-x: hidden;
    image-rendering: pixelated;
}

/* ===== HUD Header ===== */
.hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding: 12px 20px;
    background-color: var(--bg-dark);
    border-bottom: 4px solid #222;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.hud-label {
    font-size: 0.625rem;
    letter-spacing: 1px;
}

.hud-value {
    font-size: 0.625rem;
}

.hud-coin {
    color: var(--coin-gold);
    font-size: 0.75rem;
}

/* ===== Main Underground Area ===== */
.underground {
    background-color: var(--bg-underground);
    padding-top: 70px;
    min-height: 100vh;
}

/* ===== Hero Section ===== */
.hero {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 60px 20px 80px;
    min-height: 60vh;
}

.title {
    text-align: center;
    margin-bottom: 20px;
    line-height: 1.8;
}

.title-pick {
    display: block;
    font-size: clamp(1rem, 4vw, 2rem);
    color: var(--text-white);
    text-shadow: 4px 4px 0 #000;
}

.title-booger {
    display: block;
    font-size: clamp(1.5rem, 6vw, 3rem);
    color: var(--text-orange);
    text-shadow: 4px 4px 0 #000;
}

.tagline {
    font-size: clamp(0.5rem, 2vw, 0.75rem);
    color: var(--floor-blue);
    margin-bottom: 40px;
    letter-spacing: 2px;
}

/* ===== Block Row ===== */
.block-row {
    display: flex;
    gap: 0;
    margin-bottom: 60px;
}

.brick {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--brick-light) 0%, var(--brick-dark) 100%);
    border: 3px solid #000;
    position: relative;
    image-rendering: pixelated;
}

.brick::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 3px;
    background: #000;
    transform: translateY(-50%);
}

.brick::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 3px;
    background: #000;
    transform: translateX(-50%);
}

/* ===== Question Block ===== */
.question-block {
    width: 48px;
    height: 48px;
    background: var(--question-orange);
    border: 4px solid #000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: transform 0.1s;
    box-shadow:
        inset 4px 4px 0 rgba(255,255,255,0.3),
        inset -4px -4px 0 rgba(0,0,0,0.3);
}

.question-block::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    border: 2px solid var(--question-dark);
}

.question-mark {
    font-size: 1.5rem;
    color: #000;
    animation: blink 0.5s infinite;
    text-shadow: 2px 2px 0 var(--question-dark);
}

@keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0.3; }
}

.question-block:hover {
    transform: scale(1.05);
}

.question-block.bounce {
    animation: blockBounce 0.3s ease-out;
}

@keyframes blockBounce {
    0% { transform: translateY(0); }
    30% { transform: translateY(-20px); }
    50% { transform: translateY(-20px); }
    100% { transform: translateY(0); }
}

.question-block.hit {
    background: var(--brick-dark);
    box-shadow:
        inset 4px 4px 0 rgba(0,0,0,0.3),
        inset -4px -4px 0 rgba(0,0,0,0.2);
}

.question-block.hit .question-mark {
    display: none;
}

/* ===== Floating Coins ===== */
.coin {
    position: absolute;
    width: 20px;
    height: 24px;
    background: var(--coin-gold);
    border-radius: 50%;
    border: 3px solid #b08800;
    box-shadow: inset -4px 0 0 rgba(0,0,0,0.2);
}

.coin::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 12px;
    background: #b08800;
    border-radius: 2px;
}

.coin-1 {
    top: 120px;
    left: 15%;
    animation: float 2s ease-in-out infinite;
}

.coin-2 {
    top: 180px;
    right: 20%;
    animation: float 2s ease-in-out infinite 0.5s;
}

.coin-3 {
    top: 100px;
    right: 30%;
    animation: float 2s ease-in-out infinite 1s;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-15px) rotate(10deg); }
}

/* Coin pop animation when question block is hit */
.coin-pop {
    position: absolute;
    width: 20px;
    height: 24px;
    background: var(--coin-gold);
    border-radius: 50%;
    border: 3px solid #b08800;
    animation: coinPop 0.6s ease-out forwards;
    pointer-events: none;
    z-index: 50;
}

@keyframes coinPop {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateY(-80px) scale(1.2);
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) scale(0);
        opacity: 0;
    }
}

/* ===== Press Start Button ===== */
.press-start {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(0.75rem, 2vw, 1rem);
    color: var(--text-white);
    background: transparent;
    border: 4px solid var(--text-white);
    padding: 16px 32px;
    cursor: pointer;
    animation: pulse 1.5s ease-in-out infinite;
    transition: all 0.2s;
    margin-top: 20px;
}

.press-start:hover {
    background: var(--text-white);
    color: var(--bg-dark);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== Pipe Section ===== */
.pipes-section {
    padding: 60px 20px;
    position: relative;
}

.pipe-container {
    display: flex;
    justify-content: center;
    gap: 60px;
    flex-wrap: wrap;
}

.pipe {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.pipe::before {
    content: attr(data-label);
    position: absolute;
    top: -30px;
    font-size: 0.625rem;
    color: var(--text-white);
    white-space: nowrap;
}

.pipe-top {
    width: 80px;
    height: 24px;
    background: var(--pipe-green);
    border: 4px solid #000;
    border-radius: 4px 4px 0 0;
    position: relative;
    box-shadow:
        inset 8px 0 0 var(--pipe-light),
        inset -8px 0 0 var(--pipe-dark);
}

.pipe-body {
    width: 64px;
    height: 60px;
    background: var(--pipe-green);
    border: 4px solid #000;
    border-top: none;
    box-shadow:
        inset 6px 0 0 var(--pipe-light),
        inset -6px 0 0 var(--pipe-dark);
}

/* ===== Level Map Section ===== */
.level-map-section {
    padding: 40px 20px;
    text-align: center;
}

.map-link {
    display: inline-block;
    text-decoration: none;
    transition: transform 0.2s;
}

.map-link:hover {
    transform: scale(1.02);
}

.level-preview {
    max-width: 100%;
    width: 600px;
    height: auto;
    border: 4px solid var(--brick-light);
    image-rendering: auto;
}

.map-hint {
    display: block;
    margin-top: 16px;
    font-size: 0.5rem;
    color: var(--floor-blue);
    animation: pulse 2s ease-in-out infinite;
}

/* ===== Warp Zone Footer ===== */
.warp-zone {
    position: relative;
    padding: 60px 20px 0;
    margin-top: 60px;
}

.warp-header {
    text-align: center;
    margin-bottom: 40px;
}

.warp-text {
    font-size: clamp(0.75rem, 3vw, 1.25rem);
    color: var(--text-white);
    letter-spacing: 2px;
}

.warp-pipes {
    display: flex;
    justify-content: center;
    gap: 40px;
    padding-bottom: 0;
    position: relative;
    z-index: 2;
}

.warp-pipe {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    position: relative;
    transition: transform 0.2s;
}

.warp-pipe:hover {
    transform: translateY(-8px);
}

.warp-number {
    font-size: 1.5rem;
    color: var(--text-white);
    margin-bottom: 12px;
}

.warp-pipe .pipe-top {
    width: 70px;
    height: 20px;
}

.warp-pipe .pipe-body {
    width: 56px;
    height: 80px;
}

/* Checkered Floor */
.floor {
    height: 48px;
    background: repeating-linear-gradient(
        90deg,
        var(--floor-blue) 0px,
        var(--floor-blue) 24px,
        var(--floor-dark) 24px,
        var(--floor-dark) 48px
    );
    background-size: 48px 48px;
    position: relative;
    margin-top: -40px;
}

.floor::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 24px,
        rgba(0,0,0,0.2) 24px,
        rgba(0,0,0,0.2) 48px
    );
}

/* ===== Star Power Overlay ===== */
.star-power {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 200;
    opacity: 0;
}

.star-power.active {
    animation: starFlash 2s ease-out forwards;
}

@keyframes starFlash {
    0% {
        opacity: 1;
        background: var(--star-yellow);
    }
    10% { background: #ff0000; }
    20% { background: var(--star-yellow); }
    30% { background: #00ff00; }
    40% { background: var(--star-yellow); }
    50% { background: #0000ff; }
    60% { background: var(--star-yellow); }
    70% { background: #ff00ff; }
    80% { background: var(--star-yellow); }
    90% { background: #00ffff; }
    100% {
        opacity: 0;
        background: var(--star-yellow);
    }
}

/* ===== Secret Message ===== */
.secret-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.secret-message.show {
    opacity: 1;
    animation: secretPop 0.5s ease-out;
}

.secret-message p {
    font-size: clamp(1rem, 4vw, 2rem);
    color: var(--star-yellow);
    text-shadow: 4px 4px 0 #000;
    margin-bottom: 16px;
}

.secret-message .secret-sub {
    font-size: clamp(0.5rem, 2vw, 0.75rem);
    color: var(--text-white);
}

@keyframes secretPop {
    0% { transform: translate(-50%, -50%) scale(0); }
    50% { transform: translate(-50%, -50%) scale(1.2); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

/* ===== Press Start Active State ===== */
.underground.started {
    animation: screenFlash 0.5s ease-out;
}

@keyframes screenFlash {
    0% { filter: brightness(1); }
    50% { filter: brightness(2); }
    100% { filter: brightness(1); }
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .hud {
        padding: 8px 10px;
    }

    .hud-label, .hud-value {
        font-size: 0.5rem;
    }

    .block-row {
        transform: scale(0.8);
    }

    .brick, .question-block {
        width: 40px;
        height: 40px;
    }

    .pipe-container {
        gap: 30px;
    }

    .pipe-top {
        width: 60px;
        height: 18px;
    }

    .pipe-body {
        width: 48px;
        height: 50px;
    }

    .warp-pipes {
        gap: 20px;
    }

    .warp-pipe .pipe-top {
        width: 50px;
        height: 16px;
    }

    .warp-pipe .pipe-body {
        width: 40px;
        height: 60px;
    }

    .warp-number {
        font-size: 1rem;
    }

    .coin-1, .coin-2, .coin-3 {
        display: none;
    }
}

@media (max-width: 480px) {
    .hud {
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .hud-item {
        flex: 0 0 45%;
        margin-bottom: 4px;
    }

    .underground {
        padding-top: 90px;
    }

    .block-row {
        transform: scale(0.6);
    }

    .press-start {
        padding: 12px 20px;
        font-size: 0.625rem;
    }
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
.press-start:focus,
.warp-pipe:focus,
.map-link:focus,
.question-block:focus {
    outline: 4px solid var(--star-yellow);
    outline-offset: 4px;
}
