/* Mobile-first with CSS variables */
:root {
    --bg-color: #1a1a2e;
    --ball-color: #00d9ff;
    --ball-glow: rgba(0, 217, 255, 0.3);
    --obstacle-color: #ff4757;
    --coin-color: #ffd700;
    --text-color: #ffffff;
    --text-secondary: #8892b0;
    --accent-color: #00d9ff;
    --overlay-bg: rgba(26, 26, 46, 0.95);
    --transition-speed: 0.3s;
}

/* Reset and base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* Canvas fullscreen */
#gameCanvas {
    display: block;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-color);
}

/* Screen overlays */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    display: none;
    justify-content: center;
    align-items: center;
    background: var(--overlay-bg);
    z-index: 100;
    padding: 20px;
}

.screen.active {
    display: flex;
}

/* Menu screen */
.menu-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.game-title {
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: 4px;
    line-height: 1.1;
    background: linear-gradient(135deg, var(--ball-color), #00ffaa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px var(--ball-glow);
}

.ball-preview {
    width: 40px;
    height: 40px;
    background: radial-gradient(circle at 30% 30%, #4de8ff, var(--ball-color));
    border-radius: 50%;
    box-shadow: 0 0 20px var(--ball-glow), 0 0 40px var(--ball-glow);
    animation: bounce-preview 1s ease-in-out infinite;
}

@keyframes bounce-preview {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.high-score-display {
    font-size: 1.25rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.trophy {
    font-size: 1.5rem;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    min-height: 56px;
    min-width: 200px;
    padding: 16px 32px;
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: 1px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--ball-color), #00a8cc);
    color: var(--bg-color);
    box-shadow: 0 4px 15px rgba(0, 217, 255, 0.4);
}

.btn-primary:active {
    transform: scale(0.95);
    box-shadow: 0 2px 10px rgba(0, 217, 255, 0.3);
}

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

.btn-secondary:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.1);
}

/* Pause screen */
.pause-content {
    text-align: center;
}

.pause-content h2 {
    font-size: 2.5rem;
    margin-bottom: 16px;
}

.pause-content p {
    color: var(--text-secondary);
    font-size: 1.125rem;
}

/* Game over screen */
.gameover-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.gameover-content h2 {
    font-size: 2.5rem;
    color: var(--obstacle-color);
    text-shadow: 0 0 20px rgba(255, 71, 87, 0.5);
}

.score-display {
    font-size: 1.5rem;
}

.score-display p {
    margin: 8px 0;
}

.new-record {
    padding: 8px 20px;
    background: linear-gradient(135deg, var(--coin-color), #ffaa00);
    color: var(--bg-color);
    font-weight: 700;
    font-size: 1rem;
    border-radius: 20px;
    animation: pulse-record 0.5s ease-in-out infinite alternate;
}

@keyframes pulse-record {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

.hidden {
    display: none !important;
}

/* HUD */
.hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    z-index: 50;
    pointer-events: none;
}

.score-current {
    font-size: 2rem;
    font-weight: 700;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.score-best {
    font-size: 1rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Tap hint */
.tap-hint {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.6);
    color: var(--text-secondary);
    font-size: 0.875rem;
    letter-spacing: 1px;
    border-radius: 8px;
    z-index: 50;
    pointer-events: none;
    animation: fade-hint 3s ease-in-out forwards;
}

@keyframes fade-hint {
    0%, 70% { opacity: 1; }
    100% { opacity: 0; }
}

/* Tap flash effect */
.tap-flash {
    position: fixed;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 217, 255, 0.4) 0%, transparent 70%);
    pointer-events: none;
    z-index: 40;
    animation: tap-flash-anim 0.3s ease-out forwards;
}

@keyframes tap-flash-anim {
    from {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
    }
    to {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* Coin collect effect */
.coin-collect {
    position: fixed;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--coin-color);
    pointer-events: none;
    z-index: 60;
    animation: coin-collect-anim 0.6s ease-out forwards;
}

@keyframes coin-collect-anim {
    from {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
    }
    to {
        transform: translate(-50%, -100px) scale(1);
        opacity: 0;
    }
}

/* Responsive */
@media (min-width: 768px) {
    .game-title {
        font-size: 4rem;
    }

    .btn-primary,
    .btn-secondary {
        min-width: 240px;
    }
}

/* Landscape warning for very small heights */
@media (max-height: 400px) and (orientation: landscape) {
    .menu-content {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 16px;
    }

    .game-title {
        font-size: 2rem;
    }

    .ball-preview {
        width: 30px;
        height: 30px;
    }
}
