/* Snowboard Rush — Stylesheet */

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

html, body {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
}

body {
    background: #0a0a1a;
    overflow: hidden;
    position: fixed;
    inset: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    touch-action: none;
}

@supports (height: 100dvh) {
    canvas { height: 100dvh; }
}

/* ─── UI Overlay ─────────────────────────────── */

#ui-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#ui-overlay button,
#ui-overlay input {
    pointer-events: auto;
}

.hidden {
    display: none !important;
}

/* ─── HUD ────────────────────────────────────── */

#hud {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
}

#score-display {
    text-align: center;
}

#score {
    font-size: 3rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 20px rgba(79,195,247,0.3);
    letter-spacing: 2px;
}

#combo-display {
    text-align: center;
    margin-top: 4px;
    animation: combo-pulse 0.6s ease-in-out infinite alternate;
}

#combo-count {
    font-size: 1.5rem;
    font-weight: 800;
    color: #FFD700;
    text-shadow: 0 0 10px rgba(255,215,0,0.5);
}

#combo-multiplier {
    font-size: 1.2rem;
    font-weight: 700;
    color: #FF7043;
    margin-left: 8px;
}

#combo-timer-ring {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid rgba(255,215,0,0.3);
    border-top-color: #FFD700;
    margin: 4px auto 0;
    transition: transform 0.1s linear;
}

@keyframes combo-pulse {
    to { transform: scale(1.05); }
}

/* ─── Pause Button (HUD) ────────────────────── */

.pause-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(0,0,0,0.35);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.15s;
    z-index: 5;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.pause-btn:active {
    transform: scale(0.9);
    background: rgba(0,0,0,0.55);
}

/* ─── Speed Lines Overlay ───────────────────── */

#speed-lines {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.4s ease;
}

#speed-lines.active {
    opacity: 1;
}

#speed-lines .speed-line {
    position: absolute;
    width: 2px;
    background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,0.5), rgba(255,255,255,0));
    animation: speed-line-fall linear infinite;
    will-change: transform;
}

@keyframes speed-line-fall {
    0%   { transform: translateY(-100%); }
    100% { transform: translateY(100vh); }
}

/* ─── Powerup Indicator ──────────────────────── */

#powerup-indicator {
    position: absolute;
    top: 16px;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#powerup-icon {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

#powerup-bar {
    width: 60px;
    height: 6px;
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
    overflow: hidden;
}

#powerup-bar::after {
    content: '';
    display: block;
    height: 100%;
    width: var(--powerup-remaining, 100%);
    background: #4FC3F7;
    border-radius: 3px;
    transition: width 0.1s linear;
}

/* ─── Zone & Milestone Announcements ─────────── */

#zone-announce,
#milestone-announce {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    animation: announce-in 0.5s ease-out forwards;
}

#zone-name {
    font-size: 2rem;
    font-weight: 800;
    color: #fff;
    text-transform: uppercase;
    text-shadow: 0 0 30px rgba(79,195,247,0.6);
    letter-spacing: 4px;
}

#milestone-text {
    font-size: 2.5rem;
    font-weight: 900;
    color: #FFD700;
    text-shadow: 0 0 30px rgba(255,215,0,0.6);
}

@keyframes announce-in {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    60% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
}

/* ─── Menu Screens ───────────────────────────── */

#menu-screen,
#pause-screen,
#gameover-screen,
#loading-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(10,10,26,0.85), rgba(10,10,26,0.95));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    pointer-events: auto;
}

#menu-screen {
    background:
        radial-gradient(circle at 20% 85%, rgba(79,195,247,0.07) 0%, transparent 45%),
        radial-gradient(circle at 80% 15%, rgba(255,112,67,0.05) 0%, transparent 45%),
        radial-gradient(ellipse at center, rgba(10,10,26,0.85), rgba(10,10,26,0.95));
}

/* ─── Menu Snow Particles ──────────────────── */

.menu-snow {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.snowflake {
    position: absolute;
    top: -5%;
    left: var(--x);
    width: var(--size);
    height: var(--size);
    background: rgba(255,255,255,0.5);
    border-radius: 50%;
    animation: snowfall var(--dur) linear var(--delay) infinite;
    filter: blur(0.5px);
}

@keyframes snowfall {
    0%   { transform: translateY(-10px) translateX(0); opacity: 0; }
    10%  { opacity: 0.6; }
    90%  { opacity: 0.4; }
    100% { transform: translateY(105vh) translateX(var(--drift)); opacity: 0; }
}

#game-title {
    font-size: 3.5rem;
    font-weight: 900;
    text-align: center;
    line-height: 1.1;
    letter-spacing: 3px;
    background: linear-gradient(135deg, #4FC3F7, #fff, #FF7043);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    animation: title-glow 3s ease-in-out infinite alternate;
    position: relative;
    z-index: 1;
}

@keyframes title-glow {
    0%   { filter: drop-shadow(0 0 8px rgba(79,195,247,0.15)); }
    100% { filter: drop-shadow(0 0 20px rgba(79,195,247,0.35)); }
}

#tagline {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.5);
    margin-bottom: 32px;
    font-style: italic;
    z-index: 1;
}

#menu-stats {
    margin-bottom: 24px;
    text-align: center;
    z-index: 1;
}

#best-score-display {
    font-size: 1.1rem;
    color: rgba(255,255,255,0.7);
    font-weight: 600;
}

#streak-display {
    font-size: 0.9rem;
    color: #FF7043;
    margin-top: 4px;
}

.menu-btn {
    display: block;
    width: 220px;
    padding: 14px 0;
    margin: 6px auto;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 2px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    transition: transform 0.15s, box-shadow 0.15s;
    background: linear-gradient(135deg, #4FC3F7, #0288D1);
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
    box-shadow: 0 4px 15px rgba(79,195,247,0.3);
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.menu-btn:not(.secondary)::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -75%;
    width: 50%;
    height: 200%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255,255,255,0.15),
        transparent
    );
    animation: btn-shimmer 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes btn-shimmer {
    0%, 100% { left: -75%; }
    50%      { left: 125%; }
}

.menu-btn:active {
    transform: scale(0.96);
}

.menu-btn.secondary {
    background: rgba(255,255,255,0.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.15);
}

#menu-bottom {
    display: flex;
    gap: 16px;
    margin-top: 24px;
    z-index: 1;
}

#ios-install-hint {
    margin-top: 16px;
    padding: 8px 16px;
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    text-align: center;
    z-index: 1;
    cursor: pointer;
}

.icon-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.06);
    font-size: 1.3rem;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.15s, background 0.15s, border-color 0.2s;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1;
}

.icon-btn:active {
    transform: scale(0.92);
    background: rgba(255,255,255,0.15);
    border-color: rgba(79,195,247,0.4);
}

/* ─── Game Over ──────────────────────────────── */

#gameover-title {
    font-size: 2.5rem;
    font-weight: 900;
    margin-bottom: 20px;
}

#gameover-stats {
    width: 260px;
    margin-bottom: 16px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-size: 1rem;
}

.stat-row span:last-child {
    font-weight: 700;
    color: #4FC3F7;
}

#new-record {
    font-size: 1.8rem;
    font-weight: 900;
    color: #FFD700;
    text-shadow: 0 0 20px rgba(255,215,0,0.5);
    animation: record-pulse 0.8s ease-in-out infinite alternate;
    margin-bottom: 12px;
}

@keyframes record-pulse {
    to { transform: scale(1.1); text-shadow: 0 0 40px rgba(255,215,0,0.8); }
}

#name-input-row {
    margin-bottom: 16px;
}

#player-name {
    width: 200px;
    padding: 10px 16px;
    border: 2px solid rgba(79,195,247,0.4);
    border-radius: 8px;
    background: rgba(0,0,0,0.3);
    color: #fff;
    font-size: 1rem;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}

#player-name:focus {
    border-color: #4FC3F7;
}

#leaderboard-preview {
    margin-top: 16px;
    width: 280px;
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.6);
}

/* ─── Instructions Screen ────────────────────── */

#instructions-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(10,10,26,0.88), rgba(10,10,26,0.96));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    pointer-events: auto;
    gap: 0;
    padding: 24px;
}

#instructions-title {
    font-size: 1.6rem;
    font-weight: 900;
    letter-spacing: 4px;
    text-transform: uppercase;
    background: linear-gradient(135deg, #4FC3F7, #fff, #FF7043);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 28px;
}

.controls-group {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 14px;
    justify-content: center;
}

.control-row-coins {
    margin-top: 8px;
    margin-bottom: 28px;
    opacity: 0.8;
}

.control-keys {
    display: flex;
    align-items: center;
    gap: 6px;
}

.key-cap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 38px;
    padding: 0 10px;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    border-bottom: 3px solid rgba(255,255,255,0.15);
    font-size: 0.9rem;
    font-weight: 700;
    color: #4FC3F7;
    font-family: 'Segoe UI', system-ui, -apple-system, monospace;
    letter-spacing: 1px;
}

.key-divider {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.control-icon {
    font-size: 1.5rem;
    width: 40px;
    text-align: center;
    flex-shrink: 0;
}

.control-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: rgba(255,255,255,0.8);
    letter-spacing: 0.5px;
}

.instructions-start-btn {
    margin-top: 4px;
    animation: start-btn-pulse 2s ease-in-out infinite;
}

@keyframes start-btn-pulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(79,195,247,0.3); }
    50% { box-shadow: 0 4px 25px rgba(79,195,247,0.6), 0 0 40px rgba(79,195,247,0.15); }
}

/* ─── Modal Overlay ─────────────────────────── */

#modal-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(10,10,26,0.88), rgba(10,10,26,0.96));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    pointer-events: auto;
    z-index: 15;
}

#modal-box {
    width: 320px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #fff;
}

#modal-title {
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #4FC3F7, #fff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#modal-content {
    width: 100%;
    max-height: 55vh;
    overflow-y: auto;
    margin-bottom: 20px;
    font-size: 0.9rem;
    line-height: 1.6;
}

.modal-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.modal-row span:last-child {
    font-weight: 700;
    color: #4FC3F7;
}

.modal-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.4);
    margin: 16px 0 8px;
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    gap: 10px;
}

.leaderboard-rank {
    width: 28px;
    text-align: center;
    font-weight: 800;
    color: #FF7043;
}

.leaderboard-name {
    flex: 1;
    color: rgba(255,255,255,0.8);
}

.leaderboard-score {
    font-weight: 700;
    color: #FFD700;
}

.skin-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
}

.skin-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    border-radius: 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    font-size: 0.75rem;
    color: rgba(255,255,255,0.6);
}

.skin-item.unlocked {
    border-color: #4FC3F7;
    color: #fff;
}

.skin-item.selected {
    background: rgba(79,195,247,0.15);
    border-color: #4FC3F7;
    box-shadow: 0 0 12px rgba(79,195,247,0.3);
}

.skin-item .skin-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.skin-item .skin-label {
    text-align: center;
    font-weight: 600;
}

.skin-locked {
    opacity: 0.4;
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.settings-row label {
    color: rgba(255,255,255,0.8);
    font-weight: 600;
}

.settings-row input[type="range"] {
    width: 120px;
    accent-color: #4FC3F7;
}

/* ─── Countdown Overlay ──────────────────────── */

#countdown-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(10,10,26,0.5), rgba(10,10,26,0.7));
    pointer-events: none;
    z-index: 20;
}

#countdown-number {
    font-size: 8rem;
    font-weight: 900;
    color: #fff;
    text-shadow:
        0 0 40px rgba(79,195,247,0.6),
        0 0 80px rgba(79,195,247,0.3),
        0 4px 8px rgba(0,0,0,0.5);
    animation: countdown-pop 0.7s ease-out forwards;
    will-change: transform, opacity;
}

#countdown-number.go-text {
    font-size: 5rem;
    letter-spacing: 8px;
    background: linear-gradient(135deg, #FF7043, #FFD700, #FF7043);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 0 30px rgba(255,112,67,0.5));
}

@keyframes countdown-pop {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
    70% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1.0);
        opacity: 1;
    }
}

@keyframes countdown-fade {
    0% { opacity: 1; transform: scale(1.0); }
    100% { opacity: 0; transform: scale(1.8); }
}

/* ─── Loading Screen ─────────────────────────── */

#loading-screen h2 {
    font-size: 2rem;
    margin-bottom: 24px;
    letter-spacing: 3px;
}

#loading-bar-container {
    width: 200px;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 12px;
}

#loading-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #4FC3F7, #FF7043);
    border-radius: 2px;
    transition: width 0.3s ease;
}

#loading-text {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.4);
}

/* ─── Mobile Responsive ──────────────────────── */

@media (max-width: 480px) {
    #game-title { font-size: 2.5rem; }
    #score { font-size: 2.5rem; }
    .menu-btn { width: 180px; padding: 12px 0; font-size: 1rem; }
    #gameover-stats { width: 220px; }
    #instructions-title { font-size: 1.3rem; margin-bottom: 20px; }
    .control-label { font-size: 0.85rem; }
    .key-cap { min-width: 34px; height: 32px; font-size: 0.8rem; }
    #countdown-number { font-size: 6rem; }
    #countdown-number.go-text { font-size: 3.5rem; }
}

@media (max-height: 600px) {
    #tagline { display: none; }
    #menu-stats { margin-bottom: 12px; }
    .menu-btn { margin: 4px auto; padding: 10px 0; }
}

/* ─── Portrait Warning ──────────────────────── */

.portrait-warning {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,0.92);
    color: white;
    font-family: inherit;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    font-size: 1.5rem;
}

.portrait-warning .rotate-icon {
    font-size: 4rem;
    animation: rotate-hint 1.5s ease-in-out infinite;
}

.portrait-dismiss {
    margin-top: 12px;
    padding: 10px 28px;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 10px;
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.7);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    transition: background 0.15s, color 0.15s;
}

.portrait-dismiss:active {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

@keyframes rotate-hint {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

@media (orientation: portrait) and (hover: none) and (pointer: coarse) {
    .portrait-warning { display: flex; }
}
