/* Stack Tower - Mobile-first Styles */

:root {
    --color-bg-start: #1a1a2e;
    --color-bg-end: #16213e;
    --color-text: #ffffff;
    --color-text-muted: #a0a0a0;
    --color-primary: #ff6b6b;
    --color-secondary: #4ecdc4;
    --color-perfect: #ffd93d;
    --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition-speed: 0.3s;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    font-family: var(--font-main);
    background: linear-gradient(180deg, var(--color-bg-start) 0%, var(--color-bg-end) 100%);
    color: var(--color-text);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Screens */
.screen {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.screen.active {
    display: flex;
}

/* Menu Screen */
.menu-content {
    text-align: center;
    padding: 20px;
}

.menu-content h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1.2rem;
    color: var(--color-text-muted);
    margin-bottom: 2rem;
}

.high-score {
    font-size: 1.1rem;
    color: var(--color-secondary);
    margin-bottom: 2rem;
}

.high-score span:last-child {
    font-weight: bold;
    font-size: 1.3rem;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    min-height: 48px;
    padding: 14px 48px;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform var(--transition-speed), opacity var(--transition-speed);
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-text);
}

.btn-secondary {
    background: transparent;
    color: var(--color-secondary);
    border: 2px solid var(--color-secondary);
}

.btn-primary:active,
.btn-secondary:active {
    transform: scale(0.95);
    opacity: 0.9;
}

/* Game Screen */
#screen-game {
    background: transparent;
}

.hud {
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    text-align: center;
    z-index: 10;
    pointer-events: none;
}

#score {
    font-size: 3rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    height: 100dvh;
    object-fit: contain;
}

.perfect-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 2rem;
    font-weight: bold;
    color: var(--color-perfect);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    opacity: 0;
    transition: none;
    z-index: 20;
}

.perfect-indicator.show {
    animation: perfectPop 0.6s ease-out forwards;
}

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

/* Game Over Screen */
.gameover-content {
    text-align: center;
    padding: 20px;
}

.gameover-content h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--color-primary);
}

.final-score,
.best-score {
    margin-bottom: 1rem;
}

.score-label {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
}

#final-score {
    font-size: 4rem;
    font-weight: bold;
}

#final-best {
    font-size: 2rem;
    font-weight: bold;
    color: var(--color-secondary);
}

.new-record {
    font-size: 1.2rem;
    color: var(--color-perfect);
    margin: 1rem 0;
    animation: bounce 0.5s ease infinite alternate;
}

.new-record.hidden {
    display: none;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-5px); }
}

.gameover-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 2rem;
}

/* Responsive */
@media (min-width: 768px) {
    .menu-content h1 {
        font-size: 3rem;
    }

    #score {
        font-size: 4rem;
    }

    .gameover-buttons {
        flex-direction: row;
        justify-content: center;
    }
}
