:root {
    --bg: #0f0f0f;
    --card-bg: #1a1a1a;
    --accent: #ff6b35;
    --text: #f0f0f0;
    --text-muted: #aaaaaa;
}

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

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    position: relative;
}

#loading {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    z-index: 100 !important;
    transition: opacity 0.4s ease;
    font-size: 1.2rem;
}

#loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.spin {
    width: 50px;
    height: 50px;
    border: 4px solid #333;
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#simulator {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 1;
}

/* ———————————————— TOP BAR: Perfect Layout ———————————————— */
#top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 90px;
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 999;
    pointer-events: none;
}

#top-bar>* {
    pointer-events: auto;
}

/* LEFT: Robot Selector */
#robot-selector-panel {
    position: relative;
}

#robot-toggle {
    width: 64px;
    height: 64px;
    background: rgba(30, 30, 40, 0.01);
    border: 2px solid var(--accent);
    border-radius: 50%;
    color: var(--accent);
    font-size: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.28s ease;
    animation: pulse-shadow 2s infinite ease-in-out;
}

#robot-toggle:hover,
#robot-toggle.active {
    background: rgba(0, 0, 0, 0.01);
    /* warm orange fill */
    border-color: #ff8b5b;
    transform: translateY(-3px) scale(1.08);
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(255, 107, 53, 0.6),
        0 0 40px rgba(255, 107, 53, 0.4),
        0 0 70px rgba(255, 107, 53, 0.25),
        inset 0 0 20px rgba(255, 140, 91, 0.3);
    z-index: 10;
}

#robot-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    width: 230px;
    max-width: calc(100vw - 40px);
    right: auto;
    background: rgba(0, 0, 0, .01);
    border: 1px solid rgba(255, 107, 53, 0.3);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: none;
    overflow: hidden;
}

#robot-dropdown.show {
    display: block;
}

.robot-option {
    padding: 1rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    color: var(--text);
    transition: background 0.2s;
}

.robot-option:hover {
    background: rgba(255, 107, 53, 0.15);
}

.robot-option i {
    width: 26px;
    text-align: center;
    color: var(--accent);
}

/* CENTER: Username */
#top-center {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

#username-container {
    background: rgba(0, 0, 0, 0.01);
    border: 1.5px solid rgb(46, 46, 46);
    border-radius: 16px;
    padding: 10px 20px;
    min-width: 180px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

#username {
    background: transparent;
    border: none;
    outline: none;
    color: white;
    font-size: 1.15rem;
    font-weight: 600;
    width: 100%;
    text-align: center;
    font-family: 'Courier New', monospace;
}

/* RIGHT: AI */
#brain-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 100;
    background: rgba(80, 40, 140, 0.01);
    color: #00f310;
    border: 1.5px solid #00f310;
    border-radius: 50%;
    width: 64px;
    height: 64px;
    font-size: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.35s ease;
}

#brain-toggle:hover,
#brain-toggle.active {
    background: rgba(0, 0, 0, 0.01);
    transform: translateY(-3px) scale(1.06);
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(144, 238, 144, 0.4),
        0 0 40px rgba(144, 238, 144, 0.25),
        inset 0 0 20px rgba(144, 238, 144, 0.2);
    transition: all 0.3s ease;
}

#brain-toggle:not(.active) i {
    animation: bigPulse 2.3s ease-in-out infinite;
}

#brain-toggle.active i {
    animation: smallPulse 3.5s ease-in-out infinite;
}

#robot-toggle.no-pulse,
#brain-toggle.no-pulse {
    animation: none !important;
}

#robot-toggle.active,
#brain-toggle.active {
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(0, 0, 0, 0.01),
        0 0 30px rgba(144, 238, 144, 0.5);
}

@keyframes bigPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.22);
    }
}

@keyframes smallPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.07);
    }
}

@keyframes pulse-shadow {

    0%,
    100% {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }

    50% {
        box-shadow: 0 2px 20px rgba(255, 107, 53, 1);
    }
}

@keyframes pulse-green-shadow {

    0%,
    100% {
        box-shadow: 0 0 15px rgba(0, 255, 0, 0);
    }

    50% {
        box-shadow:
            0 0 20px rgba(0, 255, 0, 0.8),
            0 0 40px rgba(0, 255, 0, 0.6),
            0 0 60px rgba(0, 255, 0, 0.4);
    }
}
/* Keyframes: Icon scale pulse (subtle breathing effect) */
@keyframes pulse-icon {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

/* Scene elements */

/* ============================================================= */
/* 1. MODAL BACKDROP (shared) */
/* ============================================================= */
.billboard-modal-backdrop,
.payment-modal-backdrop {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease-out;
}

.billboard-modal-backdrop.show,
.payment-modal-backdrop.show {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ============================================================= */
/* 2. MODAL CONTENT (shared base) */
/* ============================================================= */
.billboard-modal-content,
.payment-modal-content {
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    position: relative;
}

/* Country Flag in Top-Right */
.billboard-modal-content::after,
.payment-modal-content::after {
    content: '';
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 20px;
    background-size: cover;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    opacity: 0.9;
}

/* US Flag */
[data-country="us"] .billboard-modal-content::after,
[data-country="us"] .payment-modal-content::after {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 741 496"><rect fill="%23b22234" width="741" height="496"/><path fill="none" stroke="%23fff" stroke-width="38" d="M0 57h741M0 115h741M0 172h741M0 230h741M0 287h741M0 345h741M0 402h741M0 460h741"/><path fill="%2300295c" d="M0 0h370v265H0z"/><g fill="%23fff"><path d="M46 22l8 24 8-24-16 0zm30 0l8 24 8-24-16 0zm30 0l8 24 8-24-16 0zm30 0l8 24 8-24-16 0zm30 0l8 24 8-24-16 0zm30 0l8 24 8-24-16 0zm-150 38l8 24 8-24-16 0zm30 0l8 24 8-24-16 0zm30 0l8 24 8-24-16 0zm30 0l8 24 8-24-16 0zm30 0l8 24 8-24-16 0zm-120 38l8 24 8-24-16 0zm30 0l8 24 8-24-16 0zm30 0l8 24 8-24-16 0zm30 0l8 24 8-24-16 0zm-90 38l8 24 8-24-16 0zm30 0l8 24 8-24-16 0zm30 0l8 24 8-24-16 0zm-60 38l8 24 8-24-16 0zm30 0l8 24 8-24-16 0z"/></g></svg>');
}

/* Add more countries later */
/*
[data-country="ca"] .billboard-modal-content::after { background-image: url('...'); }
[data-country="gb"] .billboard-modal-content::after { background-image: url('...'); }
*/

/* ============================================================= */
/* 3. TEXT INPUT & COUNTER */
/* ============================================================= */
.billboard-modal-input {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    margin: 8px 0 12px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.billboard-modal-input:focus {
    outline: none;
    border-color: rgba(255, 107, 53, 0.7);
}

.billboard-modal-counter {
    text-align: right;
    font-size: 14px;
    color: #666;
    margin-bottom: 16px;
    transition: color 0.2s;
}

.billboard-modal-counter.warning {
    color: #e74c3c;
}

/* ============================================================= */
/* 4. BUTTONS */
/* ============================================================= */
/* --------------------------------------------------------------
   BUTTONS – CENTERED in Payment Modal
   -------------------------------------------------------------- */
.billboard-modal-buttons,
.payment-modal-buttons {
    display: flex;
    justify-content: center;
    /* ← CENTERED */
    gap: 12px;
    margin-top: 16px;
    /* Slightly more breathing room */
    padding: 0 12px;
}

/* Base button style */
.billboard-modal-btn,
.payment-modal-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    /* Slightly rounder */
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    min-width: 100px;
    /* Equal width */
    text-align: center;
}

/* OK / I Paid Button */
.billboard-modal-ok,
.payment-modal-buttons #paidBtn {
    background: linear-gradient(135deg, #00ff9d, #00cc7a);
    color: #000;
    box-shadow: 0 2px 6px rgba(0, 255, 157, 0.3);
}

.billboard-modal-ok:hover,
.payment-modal-buttons #paidBtn:hover {
    background: linear-gradient(135deg, #00cc7a, #00a865);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 255, 157, 0.4);
}

/* Cancel Button */
.billboard-modal-cancel,
.payment-modal-buttons #cancelBtn {
    background: #333;
    color: #fff;
    border: 1px solid #555;
}

.billboard-modal-cancel:hover,
.payment-modal-buttons #cancelBtn:hover {
    background: #444;
    border-color: #666;
    transform: translateY(-1px);
}

/* Wallet Pay Button (optional) */
.payment-modal-buttons #walletPayBtn {
    background: #00a3ff;
    color: #fff;
    box-shadow: 0 2px 6px rgba(0, 163, 255, 0.4);
}

.payment-modal-buttons #walletPayBtn:hover {
    background: #0088d4;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 163, 255, 0.5);
}

/* --------------------------------------------------------------
   PAYMENT MODAL TEXT
   -------------------------------------------------------------- */
.payment-modal-content h3 {
    margin: 0 0 12px;
    text-align: center;
    color: #00ff9d;
    font-size: 1.4rem;
    font-weight: 700;
    text-shadow: 0 0 8px rgba(0, 255, 157, 0.3);
}

.payment-modal-content p {
    margin: 8px 0;
    color: #ddd;
    font-size: 15px;
    text-align: center;
}

/* Price line – make it pop */
#priceLine {
    margin: 12px 0 16px !important;
    font-size: 1.3rem !important;
    font-weight: 700 !important;
    color: #00ff9d !important;
    text-shadow: 0 0 8px rgba(0, 255, 157, 0.4);
}

#qrCode {
    margin: 16px auto;
    padding: 12px;
    background: white;
    border-radius: 8px;
    display: inline-block;
}

/* JOINT PANEL */
.joint-panel {
    position: absolute;
    right: 16px;
    top: 100px;
    bottom: 100px;
    width: 160px;
    background: rgba(0, 0, 0, 0);
    border-radius: 20px;
    padding: 18px 14px;
    z-index: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.joint-panel::-webkit-scrollbar {
    width: 6px;
}

.joint-panel::-webkit-scrollbar-track {
    background: transparent;
}

.joint-panel::-webkit-scrollbar-thumb {
    background: rgba(183, 183, 183, 0.4);
    border-radius: 3px;
}

.joint-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 107, 53, 0.4);
}

.joint-control {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.joint-label {
    color: gray;
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    letter-spacing: .6px;
    text-shadow: 0 0 4px rgba(255, 107, 53, .4);
}

.joint-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, .15);
    outline: none;
    cursor: pointer;
}

.joint-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: gray;
    box-shadow: 0 0 10px rgba(255, 107, 53, 0.4), 0 0 16px rgba(255, 107, 53, 0.4);
    cursor: grab;
    transition: all .15s;
}

.joint-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.15);
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.4), 0 0 28px rgba(255, 107, 53, 0.4);
}

.joint-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 107, 53, 0.4);
    border: none;
    box-shadow: 0 0 10px rgba(255, 107, 53, 0.4);
    cursor: grab;
}

.joint-value {
    color: gray;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    text-align: center;
    text-shadow: 0 0 4px rgba(255, 107, 53, .4);
}

/* CAMERA */
#camera-feed-container {
    display: none;
    position: absolute;
    bottom: 16px;
    left: 16px;
    width: 240px;
    height: 180px;
    background: rgba(0, 0, 0, .75);
    border-radius: 12px;
    overflow: hidden;
    z-index: 0;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 255, 0, .25);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
    flex-direction: column;
}

#camera-feed {
    width: 100%;
    height: calc(100% - 26px);
    object-fit: cover;
    background: #000;
}

#camera-label {
    color: #0f0;
    font: bold 11px 'Courier New', monospace;
    text-align: center;
    padding: 4px 0;
    background: rgba(0, 0, 0, .6);
    text-shadow: 0 0 4px rgba(0, 255, 0, .4);
}

#ai-panel-mobile {
    position: fixed;
    bottom: 12px;
    right: 12px;
    z-index: 99999;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 18px;
    color: #0f0;
    background: rgba(0, 0, 0, 0.85);
    padding: 6px 12px;
    border: 2px solid #0f0;
    border-radius: 10px;
    text-shadow: 0 0 10px #0f0;
    backdrop-filter: blur(4px);
    pointer-events: none;
}

/* Mobile top bar adjustments */
@media (max-width: 768px) {
    #top-bar {
        height: 80px;
        padding: 0 20px;
    }

    #robot-toggle,
    #brain-toggle {
        width: 48px;
        height: 48px;
        font-size: 24px;
    }

    #username-container {
        padding: 8px 16px;
        min-width: 140px;
    }

    #username {
        font-size: 1rem;
    }

    #robot-dropdown {
        width: 210px;
    }
    #ai-panel, #camera-feed-container, #camera-feed {
        display: none;
    }

    #ai-panel-mobile {
        display: flex;
        font-size: 22px;
        padding: 8px 16px;
        bottom: 8px;
        right: 8px;
    }
}
