/* style.css — Slope game */

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

:root {
    --neon-green : #00ff99;
    --neon-cyan  : #00e5ff;
    --neon-red   : #ff2255;
    --dark-bg    : #060614;
    --panel-bg   : rgba(4, 6, 28, 0.90);
    --font       : 'Orbitron', 'Courier New', monospace;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--dark-bg);
    color: var(--neon-green);
    font-family: var(--font);
    /* Prevent iOS overscroll bounce and double-tap zoom */
    touch-action: none;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

#canvas {
    position: fixed;
    top: 0; left: 0;
    display: block;
    width: 100%;
    height: 100%;
}

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

#hud {
    position: fixed;
    top: max(20px, env(safe-area-inset-top, 20px));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 32px;
    z-index: 10;
    pointer-events: none;
}

#hud > div {
    background: var(--panel-bg);
    border: 1px solid var(--neon-green);
    border-radius: 6px;
    padding: 8px 22px;
    text-align: center;
    min-width: 120px;
    box-shadow: 0 0 14px rgba(0, 255, 153, 0.18);
}

.label {
    display: block;
    font-size: 0.58rem;
    letter-spacing: 0.22em;
    opacity: 0.65;
    margin-bottom: 3px;
}

#score-val, #speed-val {
    font-size: 1.5rem;
    font-weight: 700;
    text-shadow: 0 0 10px var(--neon-green);
}

/* ── Touch controls ──────────────────────────────────── */

#touch-controls {
    position: fixed;
    bottom: max(24px, env(safe-area-inset-bottom, 24px));
    left: 0; right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 max(24px, env(safe-area-inset-left, 24px));
    padding-right: max(24px, env(safe-area-inset-right, 24px));
    z-index: 10;
    pointer-events: none;
}

.touch-btn {
    width: clamp(80px, 18vw, 120px);
    height: clamp(80px, 18vw, 120px);
    background: var(--panel-bg);
    border: 2px solid var(--neon-cyan);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.6rem, 4.5vw, 2.6rem);
    color: var(--neon-cyan);
    cursor: pointer;
    pointer-events: all;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    text-shadow: 0 0 8px var(--neon-cyan);
    box-shadow: 0 0 14px rgba(0, 229, 255, 0.18);
    transition: background 0.1s, box-shadow 0.1s;
}

.touch-btn:active,
.touch-btn.pressed {
    background: rgba(0, 229, 255, 0.18);
    box-shadow: 0 0 28px rgba(0, 229, 255, 0.50);
}

/* ── Overlays ────────────────────────────────────────── */

.overlay {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    z-index: 20;
    background: rgba(6, 6, 20, 0.82);
    backdrop-filter: blur(5px);
}

.hidden { display: none !important; }

/* ── Title ───────────────────────────────────────────── */

.title {
    font-size: clamp(3rem, 10vw, 6rem);
    font-weight: 900;
    letter-spacing: 0.14em;
    color: var(--neon-green);
    text-shadow:
        0 0 18px var(--neon-green),
        0 0 40px var(--neon-green),
        0 0 80px rgba(0, 255, 153, 0.35);
    animation: pulse 2.6s ease-in-out infinite;
}

.title.glow-red {
    color: var(--neon-red);
    text-shadow:
        0 0 18px var(--neon-red),
        0 0 40px var(--neon-red),
        0 0 80px rgba(255, 34, 85, 0.35);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.78; }
}

/* ── Leaderboard ─────────────────────────────────────── */

#leaderboard {
    background: var(--panel-bg);
    border: 1px solid var(--neon-green);
    border-radius: 8px;
    padding: 16px 28px;
    width: 90%;
    max-width: 360px;
    box-shadow: 0 0 18px rgba(0, 255, 153, 0.12);
}

#leaderboard h2 {
    font-size: 0.68rem;
    letter-spacing: 0.28em;
    text-align: center;
    opacity: 0.6;
    margin-bottom: 12px;
}

#scores-list {
    list-style: none;
    width: 100%;
}

#scores-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(0, 255, 153, 0.10);
    font-size: 0.82rem;
}

#scores-list li:last-child { border-bottom: none; }

#scores-list .empty {
    justify-content: center;
    opacity: 0.38;
    font-size: 0.72rem;
}

#scores-list .rank  { width: 24px; opacity: 0.45; font-size: 0.72rem; }
#scores-list .name  { flex: 1; }
#scores-list .score {
    color: var(--neon-cyan);
    text-shadow: 0 0 7px var(--neon-cyan);
}

/* ── Buttons ─────────────────────────────────────────── */

.btn-primary, .btn-secondary {
    font-family: var(--font);
    font-weight: 700;
    letter-spacing: 0.14em;
    cursor: pointer;
    border: none;
    border-radius: 6px;
    padding: 12px 40px;
    font-size: 0.95rem;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--neon-green);
    color: var(--dark-bg);
    box-shadow: 0 0 22px rgba(0, 255, 153, 0.45);
}

.btn-primary:hover   { box-shadow: 0 0 36px rgba(0, 255, 153, 0.80); transform: scale(1.05); }
.btn-primary:active  { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }

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

.btn-secondary:hover { background: rgba(0, 255, 153, 0.10); }

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

.final-score {
    text-align: center;
    background: var(--panel-bg);
    border: 1px solid var(--neon-red);
    border-radius: 8px;
    padding: 14px 40px;
    min-width: 200px;
}

.final-score .label { color: var(--neon-red); }

#final-score-val {
    font-size: 2.6rem;
    font-weight: 900;
    color: var(--neon-red);
    text-shadow: 0 0 16px var(--neon-red);
}

.submit-row {
    display: flex;
    gap: 10px;
    width: 90%;
    max-width: 360px;
}

#player-name {
    flex: 1;
    background: var(--panel-bg);
    border: 1px solid var(--neon-cyan);
    border-radius: 6px;
    color: var(--neon-cyan);
    font-family: var(--font);
    font-size: 0.88rem;
    padding: 10px 14px;
    outline: none;
}

#player-name::placeholder { opacity: 0.38; }
#player-name:focus { box-shadow: 0 0 12px rgba(0, 229, 255, 0.38); }

.hint {
    font-size: 0.65rem;
    letter-spacing: 0.18em;
    opacity: 0.42;
}

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

/* Phone */
@media (max-width: 600px) {
    .hint { display: none; }
    #hud > div { padding: 6px 14px; min-width: 90px; }
    #score-val, #speed-val { font-size: 1.15rem; }
    .title { font-size: clamp(2.4rem, 13vw, 4rem); }
    #leaderboard { padding: 12px 16px; }
    .overlay { gap: 14px; }
}

/* Tablet / iPad — coarse pointer means touch device */
@media (min-width: 601px) and (pointer: coarse) {
    .hint { display: none; }
    .touch-btn {
        width: clamp(100px, 14vw, 140px);
        height: clamp(100px, 14vw, 140px);
    }
    #hud > div { padding: 10px 28px; min-width: 140px; }
    #score-val, #speed-val { font-size: 1.8rem; }
}
