/* Sky Stack — layout and UI (no inline styles) */

:root {
    --bg: #0b1c4a;
    --text: #ffffff;
    --perfect: #ffe76b;
    --overlay: rgba(7, 18, 56, 0.85);
    --btn-bg: linear-gradient(135deg, #ffdf4a, #ff9b2a);
    --btn-color: #3b2300;
    --btn-shadow: 0 12px 26px rgba(0, 0, 0, 0.45);
    --score-shadow: 0 7px 18px rgba(0, 0, 0, 0.4);
    --combo-glow: 0 0 18px rgba(255, 231, 107, 0.8);
    --menu-blur: 4px;
    --radius-round: 50px;
    --radius-circle: 50%;
    --z-canvas: 5;
    --z-hud: 10;
    --z-menu: 20;
    --z-buttons: 30;
    --spacing-tight: 16px;
    --icon-size: 42px;
    --transition-fast: 0.1s;
    --transition-menu: 0.3s;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Trebuchet MS', sans-serif;
    user-select: none;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    cursor: pointer;
    background: url('../img/bg.png') center center / cover no-repeat;
}

canvas {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-canvas);
    -webkit-tap-highlight-color: transparent;
}

.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.is-removed {
    display: none !important;
}

/* Top bar: home (left), score (right) */
#top-bar {
    position: absolute;
    top: var(--spacing-tight);
    left: var(--spacing-tight);
    right: var(--spacing-tight);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: var(--z-buttons);
    pointer-events: none;
    opacity: 1;
    transition: opacity var(--transition-menu);
}

#top-bar .btn-icon {
    pointer-events: auto;
}

body.menu-open #top-bar {
    opacity: 0;
}

#score-container {
    position: relative;
    transform: none;
    text-align: right;
    pointer-events: none;
    z-index: var(--z-hud);
    min-width: 72px;
}

#score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    margin: 0;
    font-size: clamp(22px, 3.2vw, 34px);
    font-weight: 800;
    line-height: 1;
    letter-spacing: 1px;
    color: #164273;
    background: linear-gradient(135deg, #fdfb72, #ffb347);
    border-radius: 999px;
    box-shadow: var(--score-shadow);
    border: 3px solid rgba(255, 255, 255, 0.9);
}

#combo-msg {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(1);
    font-size: 26px;
    font-weight: bold;
    color: var(--perfect);
    opacity: 0;
    text-shadow: var(--combo-glow);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    white-space: nowrap;
    z-index: var(--z-hud);
}

#combo-msg.is-active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.5);
}

/* Icon buttons */
.btn-icon {
    position: relative;
    flex-shrink: 0;
    z-index: var(--z-buttons);
    width: var(--icon-size);
    height: var(--icon-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: none;
    border-radius: 18px;
    cursor: pointer;
    background: var(--btn-bg);
    color: var(--btn-color);
    box-shadow: var(--btn-shadow);
    border: 3px solid rgba(255, 255, 255, 0.9);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.btn-icon:active {
    transform: translateY(2px) scale(0.97);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

#home-btn {
    margin-left: 0;
}

/* Menu popup */
#menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 32px 48px 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: min(420px, 90vw);
    max-width: 520px;
    background: linear-gradient(180deg, rgba(89, 139, 255, 0.98), rgba(18, 40, 99, 0.98));
    backdrop-filter: blur(var(--menu-blur));
    border-radius: 32px;
    box-shadow:
        0 26px 60px rgba(0, 0, 0, 0.85),
        0 0 0 2px rgba(255, 255, 255, 0.8);
    z-index: var(--z-menu);
    transition: opacity var(--transition-menu), transform var(--transition-menu);
}

@media (max-width: 600px) {
    #menu {
        width: calc(100% - 40px);
        padding: 24px 20px 28px;
    }
}

#logo-img {
    width: min(300px, 60vw);
    max-width: 340px;
    height: auto;
    margin-bottom: 8px;
    filter:
        drop-shadow(0 14px 28px rgba(0, 0, 0, 0.8))
        drop-shadow(0 0 0 rgba(255, 255, 255, 0.8));
}

#menu h1 {
    margin: 0 0 8px;
    font-size: 44px;
    letter-spacing: 6px;
    text-transform: uppercase;
    color: #ffffff;
    text-shadow:
        0 4px 0 rgba(0, 0, 0, 0.4),
        0 10px 20px rgba(0, 0, 0, 0.9);
    display: none; /* shown only on game over */
}

#menu p {
    margin: 6px 0 30px;
    color: #f5f7ff;
    font-size: 18px;
}

body.game-over #logo-img {
    display: none;
}

body.game-over #menu h1 {
    display: block;
}

body.game-over #subtitle {
    font-size: 32px;
    font-weight: 900;
    margin: 10px 0 30px;
}

.btn {
    padding: 15px 50px;
    font-size: 20px;
    font-weight: 900;
    text-transform: uppercase;
    color: var(--btn-color);
    background: var(--btn-bg);
    border: none;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.45);
    border: 3px solid rgba(255, 255, 255, 0.92);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), filter var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: translateY(2px) scale(0.97);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.4);
    filter: brightness(0.98);
}

/* =========================
   Responsive Breakpoints
   ========================= */

/* Small Mobile (≤480px) */
@media (max-width: 480px) {
    :root {
        --spacing-tight: 10px;
        --icon-size: 34px;
        --menu-blur: 3px;
    }

    body {
        font-size: 14px;
    }

    #top-bar {
        top: var(--spacing-tight);
        left: var(--spacing-tight);
        right: var(--spacing-tight);
    }

    #score {
        padding: 6px 14px;
        font-size: clamp(18px, 4vw, 22px);
    }

    #combo-msg {
        font-size: 20px;
    }

    #menu {
        width: calc(100% - 32px);
        padding: 20px 18px 24px;
        border-radius: 24px;
        min-width: auto;
        max-width: 420px;
    }

    #logo-img {
        width: min(220px, 70vw);
        margin-bottom: 4px;
    }

    #menu p {
        font-size: 15px;
        margin: 4px 0 22px;
        text-align: center;
    }

    .btn {
        padding: 12px 30px;
        font-size: 16px;
    }
}

/* Mobile (≤640px) - shared tweaks for small & medium phones */
@media (max-width: 640px) {
    #menu {
        box-shadow:
            0 18px 40px rgba(0, 0, 0, 0.8),
            0 0 0 1px rgba(255, 255, 255, 0.8);
    }
}

/* Tablet Portrait (641px–768px) */
@media (min-width: 641px) and (max-width: 768px) {
    :root {
        --spacing-tight: 14px;
        --icon-size: 40px;
    }

    #menu {
        min-width: min(420px, 80vw);
        padding: 28px 32px 32px;
    }

    #logo-img {
        width: min(280px, 55vw);
    }

    #menu p {
        font-size: 17px;
    }

    .btn {
        padding: 14px 44px;
        font-size: 18px;
    }
}

/* Tablet Landscape (769px–1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    :root {
        --spacing-tight: 18px;
        --icon-size: 40px;
    }

    #menu {
        min-width: 420px;
        max-width: 520px;
        padding: 30px 40px 34px;
    }

    #logo-img {
        width: min(300px, 45vw);
    }
}

/* Desktop (≥1025px) */
@media (min-width: 1025px) {
    body {
        font-size: 16px;
    }

    #menu {
        min-width: 420px;
        max-width: 540px;
    }
}

/* Landscape Mobile (orientation: landscape) */
@media (max-width: 812px) and (orientation: landscape) {
    :root {
        --spacing-tight: 8px;
        --icon-size: 30px;
    }

    body {
        align-items: stretch;
    }

    #menu {
        padding: 16px 18px 20px;
        border-radius: 22px;
        width: calc(100% - 40px);
        max-width: 520px;
        transform: translate(-50%, -45%);
    }

    #logo-img {
        width: min(200px, 45vw);
    }

    #menu p {
        font-size: 14px;
        margin-bottom: 18px;
    }

    .btn {
        padding: 10px 28px;
        font-size: 15px;
    }
}
