/* 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; }
}

/* ════════════════════════════════════════════════════════
   EMBEDDED MOCK DEVTOOLS  (cloned from console5 mock panel)
   ════════════════════════════════════════════════════════ */

.inspect-btn {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 40;
    padding: .55rem 1.1rem;
    border: none;
    background: #1a73e8;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: .88rem;
    font-family: "Roboto Mono", "Menlo", "Consolas", monospace;
    letter-spacing: .02em;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
.inspect-btn:hover { background: #1765cc; }

/* ── Pause button ── */
.pause-btn {
    position: fixed;
    top: max(16px, env(safe-area-inset-top, 16px));
    right: max(16px, env(safe-area-inset-right, 16px));
    z-index: 30;
    width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
    background: var(--panel-bg);
    border: 1px solid var(--neon-cyan);
    border-radius: 8px;
    color: var(--neon-cyan);
    font-size: 1rem; line-height: 1;
    cursor: pointer;
    box-shadow: 0 0 14px rgba(0, 229, 255, .18);
    text-shadow: 0 0 8px var(--neon-cyan);
    -webkit-tap-highlight-color: transparent;
    user-select: none; -webkit-user-select: none;
    touch-action: manipulation;
}
.pause-btn:hover  { box-shadow: 0 0 22px rgba(0, 229, 255, .4); }
.pause-btn:active { background: rgba(0, 229, 255, .18); }

/* ── DevTools panel shell ── */
.mini-inspect {
    position: fixed; top: 0; right: 0; bottom: 0; width: 460px; z-index: 50;
    border-left: 1px solid #3c4043; background: #202124;
    display: none; flex-direction: column;
    box-shadow: -6px 0 28px rgba(0, 0, 0, .75);
    font-family: "Roboto Mono", "Menlo", "Consolas", monospace;
    color: #d4d4d4;
}
.mini-inspect.open { display: flex; }
.inspect-resizer { position: absolute; top: 0; left: -3px; bottom: 0; width: 6px; cursor: col-resize; z-index: 10; }
.inspect-resizer:hover, .inspect-resizer.active { background: rgba(138, 180, 248, .4); }

.inspect-toolbar {
    height: 28px; background: #292a2d; display: flex; align-items: center;
    padding: 0 6px; border-bottom: 1px solid #3c4043; flex-shrink: 0; gap: 2px;
}
.ti { width: 16px; height: 16px; cursor: pointer; flex-shrink: 0; opacity: .65; }
.ti:hover { opacity: 1; }
.ti-sep { width: 1px; height: 14px; background: #4a4b4f; margin: 0 3px; flex-shrink: 0; }
.ti-label { font-family: Arial, sans-serif; font-size: .7rem; color: #9aa0a6; margin-left: 2px; letter-spacing: .04em; }
.ti-spacer { flex: 1; }
.inspect-close { border: none; background: transparent; color: #9aa0a6; font-size: .9rem; line-height: 1; cursor: pointer; padding: 3px 7px; border-radius: 3px; flex-shrink: 0; }
.inspect-close:hover { background: #3c4043; color: #e8eaed; }

.inspect-topbar { height: 30px; background: #292a2d; display: flex; align-items: stretch; border-bottom: 1px solid #3c4043; flex-shrink: 0; overflow: hidden; }
.inspect-tabs { display: flex; }
.inspect-tab { display: flex; align-items: center; padding: 0 14px; color: #8ab4f8; font-size: .72rem; border-bottom: 2px solid #8ab4f8; background: transparent; user-select: none; font-family: Arial, sans-serif; white-space: nowrap; letter-spacing: .02em; cursor: pointer; }
.inspect-tab-dim { display: flex; align-items: center; padding: 0 12px; color: #9aa0a6; font-size: .72rem; border-bottom: 2px solid transparent; font-family: Arial, sans-serif; cursor: pointer; white-space: nowrap; user-select: none; }
.inspect-tab-dim:hover { background: #35363a; color: #bdc1c6; }

/* Sources */
.inspect-breadcrumb { height: 22px; background: #292a2d; border-bottom: 1px solid #3c4043; display: flex; align-items: center; padding: 0 10px; flex-shrink: 0; color: #9aa0a6; font-size: .69rem; gap: 4px; font-family: Arial, sans-serif; overflow: hidden; }
.bc-item { color: #8ab4f8; white-space: nowrap; }
.bc-sep { color: #5f6368; }
.inspect-body { flex: 1; overflow: auto; background: #1e1e1e; }
.source-view { margin: 0; padding: 4px 0; }
.code-line { display: flex; min-height: 1.55em; font-size: .775rem; line-height: 1.55; }
.code-line:hover { background: #2a2d2e; }
.line-num { min-width: 44px; padding: 0 10px 0 6px; text-align: right; color: #4e5254; user-select: none; border-right: 1px solid #2e2e2e; background: #1e1e1e; flex-shrink: 0; font-size: .72rem; line-height: 1.55; }
.line-code { padding: 0 .9rem; white-space: pre; flex: 1; color: #d4d4d4; }
.hl-comment { color: #6a9955; font-style: italic; }
.hl-kw { color: #569cd6; }
.hl-str { color: #ce9178; }
.hl-num { color: #b5cea8; }
.hl-fn { color: #dcdcaa; }

/* ── Elements ── */
#obstacle-wall { display: none; }

.el-tree {
    flex: 1; overflow: auto; background: #1e1e1e; padding: 4px 0;
    font-size: .775rem; line-height: 1.55;
    font-family: "Roboto Mono", "Menlo", "Consolas", monospace;
    color: #d4d4d4;
}
.el-node.collapsed > .el-children { display: none; }
.el-row { display: flex; align-items: flex-start; white-space: pre; cursor: default; padding-right: 8px; }
.el-row:hover { background: #2a2d2e; }
.el-row.selected { background: #073655; }
.el-toggle { display: inline-block; width: 12px; flex-shrink: 0; text-align: center; color: #9aa0a6; cursor: pointer; user-select: none; }
.el-toggle.empty { visibility: hidden; cursor: default; }
.el-name { color: #5db0d7; }

.el-ctx {
    position: fixed; z-index: 60; display: none;
    min-width: 190px; padding: 4px 0;
    background: #2b2b2b; border: 1px solid #3c4043; border-radius: 4px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .55);
    font-family: Arial, sans-serif; font-size: .72rem; color: #e8eaed;
}
.el-ctx.open { display: block; }
.el-ctx-item {
    display: flex; justify-content: space-between; gap: 28px;
    padding: 5px 14px; cursor: default; white-space: nowrap;
}
.el-ctx-item:hover { background: #3c4043; }
.el-ctx-key { color: #9aa0a6; }
.el-ctx-sep { height: 1px; background: #3c4043; margin: 4px 0; }
.el-attr-name { color: #9cdcfe; }
.el-attr-val { color: #ce9178; }
.el-punc { color: #808080; }

/* ── Console ── */
.con-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: #1e1e1e; }
.con-toolbar { height: 26px; background: #202124; border-bottom: 1px solid #3c4043; display: flex; align-items: center; gap: 8px; padding: 0 8px; flex-shrink: 0; }
.con-clear { cursor: pointer; opacity: .7; }
.con-clear:hover { opacity: 1; }
.con-filterlbl { color: #9aa0a6; font-size: .68rem; font-family: Arial, sans-serif; }
.con-log { flex: 1; overflow: auto; padding: 2px 0; font-size: .77rem; line-height: 1.5; }
.con-msg { display: flex; align-items: flex-start; padding: 3px 10px; border-bottom: 1px solid #252525; white-space: pre-wrap; word-break: break-word; }
.con-ic { flex-shrink: 0; margin-right: 7px; color: #5f6368; }
.con-msg.log { color: #d4d4d4; }
.con-msg.info { color: #9cdcfe; }
.con-msg.warn { color: #e2c08d; background: #322a16; }
.con-msg.warn .con-ic { color: #e2c08d; }
.con-msg.err { color: #f48771; background: #2d1f1f; }
.con-msg.inp { color: #e8eaed; }
.con-msg.inp .con-ic { color: #8ab4f8; }
.con-msg.out { color: #9aa0a6; }
.con-msg.out .con-ic { color: #9aa0a6; transform: scaleX(-1); }
.con-flag { color: #81c995; font-weight: bold; }
.con-inputline { display: flex; align-items: center; padding: 4px 10px; border-top: 1px solid #3c4043; background: #1b1b1b; flex-shrink: 0; }
.con-prompt { color: #8ab4f8; margin-right: 7px; flex-shrink: 0; }
.con-input { flex: 1; background: transparent; border: none; outline: none; color: #e8eaed; font-family: "Roboto Mono", monospace; font-size: .8rem; caret-color: #8ab4f8; }

@media (max-width: 900px) {
    .mini-inspect { width: 100vw; top: auto; bottom: 0; height: 72vh; border-left: none; border-top: 1px solid #3c4043; }
    .inspect-resizer { display: none; }
}

/* ── Touch devices: bigger tap targets, no layout clashes ── */
@media (pointer: coarse) {
    /* Inspect button moves to top-left so it never sits under the steer/pause buttons */
    .inspect-btn {
        top: max(16px, env(safe-area-inset-top, 16px));
        left: max(12px, env(safe-area-inset-left, 12px));
        right: auto; bottom: auto;
        padding: .7rem 1.1rem; font-size: .95rem;
        -webkit-tap-highlight-color: transparent; touch-action: manipulation;
    }
    .pause-btn { width: 54px; height: 54px; font-size: 1.1rem; }

    /* Roomier DevTools so fingers can hit rows and menu items */
    .el-tree { font-size: .9rem; line-height: 1.9; }
    .el-row { padding-top: 5px; padding-bottom: 5px; }
    .el-toggle { width: 22px; }
    .inspect-tab, .inspect-tab-dim { padding: 0 18px; font-size: .85rem; height: 38px; }
    .inspect-topbar { height: 40px; }
    .el-ctx { min-width: 230px; font-size: .92rem; }
    .el-ctx-item { padding: 12px 18px; }
    .con-input { font-size: 1rem; }
}

/* iPad / large touch screens: keep the panel a usable side dock */
@media (min-width: 768px) and (pointer: coarse) {
    .mini-inspect { width: min(56vw, 560px); top: 0; bottom: 0; height: auto; border-left: 1px solid #3c4043; border-top: none; }
}
