﻿/* ============ BASE / LAYOUT ============ */
:root {
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top,0px);
    padding-bottom: env(safe-area-inset-bottom,0px);
    color-scheme: dark;
    --bg: #000;
    --fg: #fff;
    --panel: #17121f;
    --line: #3a3046;
    --acc: #c13ad0;
    --accent: #38bdf8;
    --accent2: #a855f7;
}

html {
    height: 100%;
    scroll-padding-top: env(safe-area-inset-top,0px);
}

body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--fg);
    font: 14px system-ui,sans-serif;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ============ STAGE ============ */
#stage {
    flex: 1;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

canvas {
    height: 100%;
    max-width: 100%;
    aspect-ratio: 720/760;
    display: block;
}

/* ============ PANEL BAWAH ============ */
#panel {
    background: var(--panel);
    border-top: 1px solid var(--line);
    padding: 10px 12px;
    max-height: 42%;
    overflow: auto;
}

.row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

button, input {
    font: inherit;
    color: var(--fg);
    background: #241b30;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 12px;
}

button {
    cursor: pointer;
    flex: 1;
    min-width: 84px;
}

    button:active {
        background: var(--acc);
    }

input {
    flex: 1;
    min-width: 0;
}

#cnt {
    max-width: 70px;
    flex: none;
}

h4 {
    margin: 0 0 8px;
    font-size: 12px;
    opacity: .7;
    font-weight: 600;
}

/* ============ TOP HUD (koneksi) ============ */
.top-hud-bar {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    z-index: 4;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    pointer-events: none;
}

.hud-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(20,15,28,.85);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 11px;
    pointer-events: auto;
    backdrop-filter: blur(8px);
}

.hud-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #666;
    box-shadow: 0 0 6px currentColor;
}

    .hud-dot.online {
        background: #10b981;
        color: #10b981;
    }

    .hud-dot.connecting {
        background: #f59e0b;
        color: #f59e0b;
        animation: pulse 1s infinite;
    }

    .hud-dot.error {
        background: #ef4444;
        color: #ef4444;
    }

@keyframes pulse {
    0%,100% {
        opacity: 1
    }

    50% {
        opacity: .3
    }
}

#btn-open-settings {
    background: none;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    min-width: 0;
    flex: none;
}

    #btn-open-settings:hover {
        color: var(--accent);
    }

/* ============ FULLSCREEN ============ */
#xfs {
    display: none;
    position: fixed;
    top: calc(env(safe-area-inset-top,0px) + 8px);
    right: 8px;
    z-index: 5;
    flex: none;
    min-width: 0;
    padding: 6px 11px;
    opacity: .55;
    border-radius: 20px;
}

body.fs #xfs {
    display: block;
}

body.fs #panel {
    display: none;
}

body.fs .top-hud-bar {
    display: none;
}

/* ============ SETTINGS MODAL ============ */
#settings-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(0,0,0,.75);
    justify-content: center;
    align-items: center;
    padding: 16px;
}

    #settings-modal.show {
        display: flex;
    }

.settings-card {
    background: #1a1425;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 20px;
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 24px 64px rgba(0,0,0,.7);
    animation: modalFadeIn .3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(.92);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

    .settings-header h3 {
        margin: 0;
        font-size: 15px;
    }

.settings-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    min-width: 0;
    flex: none;
    padding: 0 4px;
}

.setting-row {
    margin-bottom: 12px;
}

.setting-label {
    display: block;
    font-size: 12px;
    color: #cbd5e1;
    margin-bottom: 6px;
}

.setting-input-text, .setting-input-select {
    width: 100%;
    box-sizing: border-box;
    font: inherit;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #0f0a1a;
    color: #fff;
}

    .setting-input-text:focus, .setting-input-select:focus {
        outline: none;
        border-color: var(--accent);
        box-shadow: 0 0 0 2px rgba(56,189,248,.25);
    }

.server-btn {
    flex: 1;
    padding: 8px 10px;
    font-size: 11px;
    border-radius: 8px;
    background: #334155;
    border: 1px solid var(--line);
}

    .server-btn.active {
        background: linear-gradient(135deg, var(--accent), var(--accent2));
        border-color: transparent;
        color: #fff;
        font-weight: 800;
    }

.conn-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

#stateText {
    font-size: 11px;
    color: #94a3b8;
    font-family: ui-monospace, monospace;
}

/* ============ ADS MODAL ============ */
#adsModalTikTok {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.85);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

    #adsModalTikTok.show {
        display: flex;
    }

    #adsModalTikTok > div {
        background: #1a1425;
        padding: 22px;
        max-width: 600px;
        width: 100%;
        border-radius: 14px;
        color: #fff;
        box-shadow: 0 24px 64px rgba(0,0,0,.7);
        animation: modalFadeIn .3s ease;
    }

#adsContainerTikTok {
    min-height: 100px;
    margin: 10px 0;
    background: rgba(0,0,0,.25);
    border-radius: 8px;
    padding: 8px;
}

#continueBtnTikTok {
    padding: 10px 40px;
    font-size: 15px;
    font-weight: 800;
    border: none;
    border-radius: 8px;
    background: #28a745;
    color: white;
    transition: all .2s;
    cursor: pointer;
}

    #continueBtnTikTok:hover:not(:disabled) {
        background: #218838;
        transform: scale(1.02);
    }

    #continueBtnTikTok:disabled {
        background: #6c757d;
        cursor: not-allowed;
        opacity: .7;
    }

/* ============ HIDE DOCK ============ */
body.hide-dock #panel {
    display: none;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 480px) {
    #panel {
        max-height: 52%;
    }

    .top-hud-bar {
        font-size: 10px;
    }
}
