/* Mario-style theme - same to same */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&display=swap');

:root {
    /* Mario palette */
    --sky-top: #5c94fc;
    --sky-bottom: #7eb8fa;
    --cloud: #fff;
    --cloud-shadow: #e8e8e8;
    --hill-green: #5a9c47;
    --hill-green-mid: #6bb555;
    --hill-green-far: #8bc76a;
    --brick: #b85c38;
    --brick-dark: #8b4520;
    --brick-line: #9a4a2a;
    --grass: #5a9c47;
    --grass-highlight: #6bb555;
    --pipe-green: #00a651;
    --pipe-green-dark: #008c44;
    --ground-brown: #8b6914;
    --text: #fff;
    --mario-red: #e52521;
    --mario-blue: #0066b3;
    --gold: #ffd700;
    --coin-gold: #f7dc0a;
    --target: #e52521;
    --perfect: #ffd700;
}

body {
    margin: 0;
    background: linear-gradient(to bottom, var(--sky-top) 0%, var(--sky-bottom) 100%);
    color: var(--text);
    font-family: 'Fredoka', sans-serif;
    overflow: hidden;
    touch-action: none;
    height: 100vh;
    width: 100vw;
    user-select: none;
}

.material-symbols-rounded {
    font-variation-settings:
      'FILL' 0,
      'wght' 300,
      'GRAD' 0,
      'opsz' 24;
}

#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(to bottom, var(--sky-top) 0%, var(--sky-bottom) 50%, #87ceeb 100%);
    overflow: hidden;
}

/* cinematic vignette & soft glow over the canvas */
#game-container::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 50% 12%, rgba(255,255,255,0.35), transparent 55%),
        radial-gradient(circle at 0% 110%, rgba(9,9,30,0.85), transparent 60%),
        radial-gradient(circle at 100% 110%, rgba(4,9,28,0.9), transparent 60%);
    mix-blend-mode: soft-light;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* UI - Mario style */
#ui-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    padding: 40px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Hide home button on start screen */
#game-container.start-screen-visible .top-right-controls {
    display: none;
}

.top-right-controls {
    position: fixed;
    top: 20px;
    left: 20px;
    right: auto;
    pointer-events: auto;
    z-index: 100;
}

/* Home button - Mario red circle with white house */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid #c41e1a;
    background: linear-gradient(180deg, var(--mario-red) 0%, #c41e1a 100%);
    box-shadow:
        0 4px 0 #8b0000,
        0 6px 8px rgba(0,0,0,0.3),
        inset 0 1px 0 rgba(255,255,255,0.3);
    color: #fff;
    cursor: pointer;
}

.icon-btn:hover {
    background: linear-gradient(180deg, #ff3333 0%, var(--mario-red) 100%);
    transform: translateY(1px);
    box-shadow: 0 3px 0 #8b0000, 0 5px 8px rgba(0,0,0,0.3);
}

.icon-btn .material-symbols-rounded {
    font-size: 26px;
    line-height: 1;
    color: #fff;
}

/* Title banner (legacy - logo now on start screen) */
#ui-layer .game-title-banner {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(180deg, var(--mario-blue) 0%, #005a9e 50%, #004080 100%);
    padding: 8px 24px 10px;
    border-radius: 8px;
    border: 3px solid #003366;
    box-shadow:
        0 4px 0 #002244,
        0 6px 10px rgba(0,0,0,0.35),
        inset 0 1px 0 rgba(255,255,255,0.2);
    pointer-events: none;
}

#ui-layer .game-title-banner span {
    font-size: 22px;
    font-weight: 700;
    color: var(--gold);
    text-shadow:
        2px 2px 0 #b8860b,
        -1px -1px 0 #8b6914,
        0 0 8px rgba(255,215,0,0.5);
    letter-spacing: 2px;
}

.score-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.score-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: rgba(0,0,0,0.7);
    text-shadow:
        0 2px 0 rgba(255,255,255,0.8),
        0 0 8px rgba(255,255,255,0.6);
}

#score,
.score-value {
    font-size: 40px;
    font-weight: 900;
    color: #fff;
    text-align: right;
    text-shadow:
        0 3px 0 rgba(0,0,0,0.85),
        0 0 16px rgba(0,0,0,0.9);
    transition: transform 0.12s, color 0.12s;
}

#score.bump {
    transform: scale(1.18);
    color: var(--perfect);
    text-shadow:
        0 4px 0 rgba(120,80,0,0.9),
        0 0 22px rgba(255,215,0,0.95);
}

#best-score,
.best-score {
    font-size: 11px;
    color: rgba(255,255,255,0.95);
    letter-spacing: 0.18em;
    text-shadow:
        0 2px 0 rgba(0,0,0,0.85),
        0 0 10px rgba(0,0,0,0.8);
    text-transform: uppercase;
}

/* Hint - dark banner like Mario HUD */
#hint-text {
    position: absolute;
    bottom: 80px;
    width: 100%;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.6);
    padding: 10px 24px;
    background:
        linear-gradient(145deg, rgba(6,8,20,0.92), rgba(20,40,90,0.96));
    border-radius: 999px;
    margin: 0 auto;
    max-width: 360px;
    left: 50%;
    transform: translateX(-50%);
    box-sizing: border-box;
    box-shadow:
        0 8px 18px rgba(0,0,0,0.7),
        0 0 0 2px rgba(255,255,255,0.18);
    animation: pulse 2.2s infinite;
}

#hint-text.hidden {
    opacity: 0;
    animation: none;
}

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

/* Perfect indicator */
.perfect-text {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 30px;
    font-weight: 700;
    color: var(--perfect);
    text-shadow:
        0 0 16px rgba(0,0,0,0.85),
        0 0 24px rgba(255,215,0,0.9);
    opacity: 0;
    transform-origin: center;
    transition: opacity 0.45s, transform 0.45s;
}

.perfect-text.show {
    opacity: 1;
    transform: translate(-50%, -120%) scale(1.08);
}

/* Screens - Start & Game Over (Mario style) */
.screen {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background:
        radial-gradient(circle at 50% 0%, rgba(255,255,255,0.4), transparent 60%),
        linear-gradient(180deg, rgba(33, 64, 154, 0.96), rgba(10, 22, 64, 0.98));
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    transition: opacity 0.35s ease, transform 0.35s ease;
    transform: translateY(0) scale(1);
    box-shadow: inset 0 0 120px rgba(0,0,0,0.65);
    backdrop-filter: blur(10px);
}

.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transform: translateY(10px) scale(0.98);
}

.screen .game-logo {
    display: block;
    max-width: 56%;
    max-height: 32vh;
    width: auto;
    height: auto;
    margin: 0 0 16px 0;
    object-fit: contain;
    filter: drop-shadow(0 18px 26px rgba(0,0,0,0.7));
}

.screen h1 {
    font-size: 42px;
    margin: 0 0 16px 0;
    color: var(--gold);
    text-shadow:
        3px 3px 0 #b8860b,
        -1px -1px 0 #5a4a0a;
    text-transform: uppercase;
    letter-spacing: 4px;
    background: none;
    -webkit-text-fill-color: var(--gold);
}

.game-over-title {
    color: var(--mario-red);
    -webkit-text-fill-color: var(--mario-red);
    text-shadow: 3px 3px 0 #8b0000;
}
 
.screen p {
    color: #f6fbff;
    margin-bottom: 32px;
    font-size: 17px;
    text-align: center;
    line-height: 1.6;
    text-shadow:
        0 2px 6px rgba(0,0,0,0.75),
        0 0 18px rgba(0,0,0,0.8);
}

.final-score-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 40px;
}

.final-score-label {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.24em;
    color: rgba(255,255,255,0.8);
    margin-bottom: 8px;
    text-shadow: 0 1px 0 rgba(0,0,0,0.9);
}

.final-score-value,
#final-score {
    font-size: 54px;
    font-weight: 800;
    line-height: 1;
    color: #ffe66d;
    text-shadow:
        0 0 18px rgba(0,0,0,0.95),
        0 0 32px rgba(0,0,0,0.95),
        0 0 36px rgba(255,215,0,0.9);
}

.btn {
    background:
        radial-gradient(circle at 30% 0%, rgba(255,255,255,0.35), transparent 55%),
        linear-gradient(180deg, var(--mario-red) 0%, #c41e1a 100%);
    color: #fff;
    border: 3px solid #8b0000;
    padding: 14px 56px;
    font-size: 21px;
    font-family: inherit;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 12px;
    box-shadow:
        0 6px 0 #8b0000,
        0 12px 26px rgba(0,0,0,0.7),
        inset 0 1px 0 rgba(255,255,255,0.25);
    text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
    letter-spacing: 0.14em;
    transition: transform 0.11s, box-shadow 0.11s, filter 0.11s;
}

.btn:hover {
    background:
        radial-gradient(circle at 30% 0%, rgba(255,255,255,0.55), transparent 55%),
        linear-gradient(180deg, #ff3333 0%, var(--mario-red) 100%);
    transform: translateY(2px);
    box-shadow: 0 4px 0 #8b0000, 0 8px 18px rgba(0,0,0,0.8);
    filter: brightness(1.05);
}

#final-score {
    color: var(--mario-red);
    font-weight: 700;
}

/* Responsive tweaks */

/* Small Mobile (≤480px) */
@media (max-width: 480px) {
    #ui-layer {
        padding: 16px 12px;
    }

    .score-container {
        top: 8px;
    }

    #score {
        font-size: 30px;
    }

    #best-score,
    .best-score {
        font-size: 9px;
    }

    #hint-text {
        bottom: 52px;
        font-size: 12px;
        max-width: 260px;
        padding-inline: 16px;
    }

    .screen .game-logo {
        max-width: 76%;
    }

    .screen h1 {
        font-size: 30px;
    }

    .btn {
        padding: 10px 34px;
        font-size: 16px;
    }
}

/* Mobile (≤640px, above very small phones) */
@media (min-width: 481px) and (max-width: 640px) {
    #ui-layer {
        padding: 20px 16px;
    }

    .score-container {
        top: 10px;
    }

    #score {
        font-size: 34px;
    }

    #hint-text {
        bottom: 60px;
        font-size: 13px;
        max-width: 320px;
    }

    .screen .game-logo {
        max-width: 72%;
    }

    .screen h1 {
        font-size: 32px;
    }

    .btn {
        padding: 12px 40px;
        font-size: 18px;
    }
}

/* Tablet Portrait (641px–768px) */
@media (min-width: 641px) and (max-width: 768px) {
    #ui-layer {
        padding: 24px 24px;
    }

    .score-container {
        top: 14px;
    }

    #score {
        font-size: 38px;
    }

    #hint-text {
        bottom: 70px;
        font-size: 14px;
        max-width: 360px;
    }
}

/* Tablet Landscape (769px–1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    #ui-layer {
        padding: 32px 40px;
    }

    .score-container {
        top: 18px;
    }

    #score {
        font-size: 42px;
    }

    #hint-text {
        bottom: 80px;
        font-size: 15px;
        max-width: 400px;
    }
}

/* Desktop (≥1025px) – base styles already target desktop, so only small tweaks */
@media (min-width: 1025px) {
    #ui-layer {
        padding: 40px 52px;
    }
}

/* Landscape Mobile (orientation: landscape) */
@media (max-width: 768px) and (orientation: landscape) {
    #ui-layer {
        padding: 12px 18px;
    }

    .score-container {
        top: 6px;
    }

    #score {
        font-size: 30px;
    }

    #hint-text {
        bottom: 36px;
        font-size: 12px;
        max-width: 320px;
    }

    .screen .game-logo {
        max-width: 60%;
    }

    .btn {
        padding: 10px 32px;
        font-size: 16px;
    }
}
