/* Stack Runner 3D - Premium Styles */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;500;800&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: 100dvh;
    /* Dynamic Viewport Height for mobile browsers */
    background: #0f0c29;
    background: linear-gradient(to bottom, #24243e, #302b63, #0f0c29);
    font-family: 'Outfit', sans-serif;
    overflow: hidden;
    touch-action: none;
    /* Prevents pull-to-refresh on mobile */
}

#game-container {
    position: relative;

    /* FULLSCREEN on desktop/laptop */
    width: 100vw;
    height: 100vh;
    height: 100dvh;

    /* Remove rounded corners and shadow on fullscreen */
    box-shadow: none;
    border-radius: 0;
    overflow: hidden;
    background: #000;
}

/* Phone-sized frame only on tablets and smaller (or narrow windows) */
@media (max-width: 900px) and (max-height: 1200px) and (orientation: portrait),
(max-width: 600px) {
    #game-container {
        width: 100%;
        height: 100%;
        max-width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }
}

/* Desktop with small window - show phone frame */
@media (min-width: 901px) and (max-width: 1200px) {
    body {
        background: #0f0c29;
    }

    #game-container {
        width: 500px;
        height: 90vh;
        max-height: 900px;
        border-radius: 20px;
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    }
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* UI Overlay Layer */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.5rem;
}

/* HUD */
.hud {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
}

.score-box {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 10px;
    color: white;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    min-width: 55px;
}

.combo-box {
    background: rgba(241, 196, 15, 0.15);
    border-color: rgba(241, 196, 15, 0.3);
    transition: all 0.2s ease;
}

.score-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
}

.score-value {
    font-size: 1.5rem;
    font-weight: 800;
}

.pause-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pause-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Menus */
.menu-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 12, 41, 0.9);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    pointer-events: auto;
    transition: opacity 0.3s ease;
    padding: 2rem;
}

.menu-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, #FFD700 0%, #FF8C00 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.3rem;
    letter-spacing: -1px;
}

.logo-sub {
    font-size: 4rem;
    font-weight: 800;
    background: linear-gradient(135deg, #00C9FF 0%, #92FE9D 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-top: -1rem;
    letter-spacing: 8px;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.8;
    margin-bottom: 1rem;
}

.best-score-display {
    font-size: 1.3rem;
    font-weight: 800;
    color: #f1c40f;
    margin-bottom: 1.5rem;
}

.best-score-small {
    font-size: 0.9rem;
    opacity: 0.6;
    margin-bottom: 1rem;
}

/* Stats Container */
.stats-container {
    display: flex;
    gap: 20px;
    margin: 1.5rem 0;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 12px 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: #00C9FF;
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    opacity: 0.6;
    letter-spacing: 1px;
}

/* New Record Badge */
.new-record-badge {
    background: linear-gradient(135deg, #FFD700 0%, #FF8C00 100%);
    color: #0f0c29;
    padding: 8px 24px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 800;
    margin: 0.5rem 0 1rem;
    animation: pulse 0.5s ease infinite alternate;
}

@keyframes pulse {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.05);
    }
}

/* Buttons */
.menu-buttons {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-top: 0.5rem;
}

.btn-start {
    background: linear-gradient(135deg, #00C9FF 0%, #92FE9D 100%);
    border: none;
    padding: 0.9rem 2.5rem;
    border-radius: 50px;
    font-size: 1.3rem;
    font-weight: 800;
    color: #0f3460;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(0, 201, 255, 0.4);
    transition: transform 0.15s, box-shadow 0.15s;
    font-family: 'Outfit', sans-serif;
}

.btn-shop {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    padding: 0.9rem 1.5rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Outfit', sans-serif;
}

.btn-shop:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    border-color: #ffd700;
    color: #ffd700;
}

.btn-start:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 12px 35px rgba(0, 201, 255, 0.5);
}

.btn-start:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 4px 15px rgba(0, 201, 255, 0.3);
}

.btn-continue {
    background: linear-gradient(135deg, #9b59b6 0%, #e74c3c 100%);
    border: none;
    padding: 0.7rem 2rem;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(155, 89, 182, 0.4);
    transition: transform 0.15s, box-shadow 0.15s;
    font-family: 'Outfit', sans-serif;
    margin-bottom: 0.5rem;
}

.btn-continue:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 10px 30px rgba(155, 89, 182, 0.5);
}

.btn-continue:active {
    transform: translateY(1px) scale(0.98);
}

.controls-hint {
    margin-top: 1.5rem;
    font-size: 0.85rem;
    opacity: 0.5;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.key {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Animations */
@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.logo-anim {
    animation: float 3s ease-in-out infinite;
    text-align: center;
}

/* Mobile Responsive */
@media (max-width: 600px) {
    #game-container {
        border-radius: 0;
        /* Full screen on mobile */
        width: 100%;
        height: 100%;
        max-height: 100%;
    }
}

@media (max-height: 700px) {
    h1 {
        font-size: 2.2rem;
    }

    .logo-sub {
        font-size: 2.8rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .stats-container {
        margin: 1rem 0;
    }

    .stat-item {
        padding: 8px 15px;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .btn-start {
        padding: 0.7rem 2rem;
        font-size: 1.1rem;
    }
}

@media (max-width: 400px) {
    .hud {
        gap: 6px;
    }

    .score-box {
        padding: 5px 8px;
        min-width: 45px;
    }

    .score-value {
        font-size: 1.2rem;
    }

    .stats-container {
        gap: 10px;
    }
}

/* Tutorial */
.tutorial-hand {
    font-size: 4rem;
    animation: swipeHint 1.5s infinite ease-in-out;
    margin-bottom: 1rem;
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.5));
}

.tutorial-text {
    text-align: center;
    color: white;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    font-size: 1.2rem;
}

@keyframes swipeHint {

    0%,
    100% {
        transform: translateX(0) rotate(0deg);
    }

    25% {
        transform: translateX(-40px) rotate(-15deg);
    }

    75% {
        transform: translateX(40px) rotate(15deg);
    }
}

/* Shop Modal */
.shop-container {
    background: rgba(15, 12, 41, 0.95);
    border-radius: 20px;
    padding: 2rem;
    max-width: 90%;
    width: 400px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.shop-container h2 {
    font-size: 1.8rem;
    background: linear-gradient(135deg, #FFD700, #FF8C00);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.3rem;
}

.shop-subtitle {
    opacity: 0.6;
    margin-bottom: 1.5rem;
}

.shop-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 1.5rem;
}

.shop-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s;
}

.shop-item.locked {
    opacity: 0.6;
}

.shop-item-preview {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    flex-shrink: 0;
}

.shop-item-name {
    flex: 1;
    font-weight: 600;
    font-size: 1rem;
}

.shop-item-price {
    font-size: 0.85rem;
    opacity: 0.7;
}

.btn-close {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.7rem 2rem;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Outfit', sans-serif;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.2);
}