/* ═══════════════════════════════════════════
   PUKY – THE LOST SPARKS  ·  style.css  (v2)
═══════════════════════════════════════════ */

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

:root {
    --bg:      #06060f;
    --surface: #10101c;
    --accent:  #7c3aed;
    --accent2: #a855f7;
    --text:    #e2e8f0;
    --muted:   #64748b;
    --danger:  #ef4444;
    --success: #10b981;
}

html, body {
    width: 100%; height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    /* respect safe areas (notch / home bar) */
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
             env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ── Canvas wrapper ─────────────────────── */
#game-wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
    /* subtract safe area padding that's applied to body */
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

#gameCanvas {
    display: block;
    /* no pixelated – smoother canvas rendering */
    border: 1px solid #ffffff08;
    box-shadow:
        0 0 0 1px #7c3aed18,
        0 0 40px rgba(124, 58, 237, 0.12),
        0 24px 60px rgba(0,0,0,0.5);
    touch-action: none;
    /* ensure it always fits within viewport */
    max-width: 100%;
    max-height: 100%;
}

/* ── Touch controls ─────────────────────── */
#touch-controls {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0; right: 0;
    padding: 0 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    height: auto;
    pointer-events: none;
    z-index: 10;
}

/* Show on coarse pointer (touch) OR small screens */
@media (pointer: coarse), (max-width: 600px) {
    #touch-controls {
        display: flex;
        align-items: flex-end;
        justify-content: space-between;
    }
}

.touch-group {
    display: flex;
    gap: 8px;
    pointer-events: all;
    padding-bottom: 12px;
}

.touch-btn {
    --btn-size: clamp(52px, 11vw, 70px);
    width:  var(--btn-size);
    height: var(--btn-size);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    font-size: clamp(18px, 4.5vw, 26px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    /* smooth press feedback */
    transition: transform 80ms ease, background 80ms ease, border-color 80ms ease;
    will-change: transform;
}

.touch-btn:active,
.touch-btn.pressed {
    background: rgba(124, 58, 237, 0.38);
    border-color: var(--accent2);
    transform: scale(0.88);
}

/* Jump button slightly larger, different color accent */
#tcJump {
    border-color: rgba(168, 85, 247, 0.4);
    background: rgba(124, 58, 237, 0.12);
}
#tcJump:active,
#tcJump.pressed {
    background: rgba(168, 85, 247, 0.45);
    border-color: #c084fc;
    transform: scale(0.85);
}

/* ── Pause button (top-right) ───────────── */
#btn-pause {
    display: none;
    position: absolute;
    top: max(10px, env(safe-area-inset-top) + 4px);
    right: max(12px, env(safe-area-inset-right) + 4px);
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,0.18);
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    pointer-events: all;
    z-index: 10;
    transition: background 0.1s;
}

@media (pointer: coarse), (max-width: 600px) {
    #btn-pause { display: flex; }
}

#btn-pause:active { background: rgba(124, 58, 237, 0.4); }

/* ── Landscape orientation hint ─────────── */
#orient-hint {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6,6,15,0.97);
    z-index: 99;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: white;
    font-size: 15px;
    text-align: center;
    padding: 24px;
}

#orient-hint .icon { font-size: 52px; animation: rotate-hint 1.2s ease-in-out infinite alternate; }

@keyframes rotate-hint {
    from { transform: rotate(0deg); }
    to   { transform: rotate(90deg); }
}

/* Show orientation hint in portrait on very small screens */
@media (max-width: 480px) and (orientation: portrait) {
    #orient-hint { display: flex; }
}

/* ── Footer ─────────────────────────────── */
footer {
    position: fixed;
    bottom: max(6px, env(safe-area-inset-bottom));
    left: 0; right: 0;
    text-align: center;
    font-size: 10px;
    color: var(--muted);
    pointer-events: none;
    z-index: 1;
    opacity: 0.6;
}

footer a {
    color: var(--muted);
    text-decoration: none;
    pointer-events: all;
    transition: color 0.2s;
}

footer a:hover { color: var(--accent2); }

/* ── Responsive canvas scaling ──────────── */
@media (max-width: 920px) {
    #gameCanvas {
        border-radius: 4px;
    }
}

/* Smooth fade-in for the whole page */
body {
    animation: page-fadein 0.4s ease forwards;
}
@keyframes page-fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}
