:root {

    --bg-dark: #0f172a;

    --bg-card: rgba(30, 41, 59, 0.7);

    --primary: #f97316;

    --primary-hover: #ea580c;

    --success: #10b981;

    --danger: #ef4444;

    --text-main: #f8fafc;

    --text-muted: #94a3b8;

    --glass-border: rgba(255, 255, 255, 0.1);

    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);

}



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



body {

    font-family: 'Outfit', sans-serif;

    background-color: var(--bg-dark);

    color: var(--text-main);

    min-height: 100vh;

    overflow-x: hidden;

}



.background-blobs { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; overflow: hidden; }

.blob { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.5; animation: float 10s ease-in-out infinite alternate; }

.blob-1 { top: -10%; left: -10%; width: 500px; height: 500px; background: #4f46e5; }

.blob-2 { bottom: -10%; right: -10%; width: 600px; height: 600px; background: #f97316; animation-delay: -5s; }



@keyframes float {

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

    100% { transform: translate(30px, 50px) scale(1.1); }

}



.modal {

    position: fixed; top: 0; left: 0; width: 100%; height: 100%;

    background: rgba(0,0,0,0.8);

    backdrop-filter: blur(5px);

    display: none;

    justify-content: center;

    align-items: center;

    z-index: 100;

}

.modal.active { display: flex; }



.modal-content {

    background: var(--bg-card);

    padding: 3rem; border-radius: 30px;

    border: 1px solid var(--glass-border);

    text-align: center;

    box-shadow: var(--glass-shadow);

    width: 90%;

    max-width: 500px;

}

.modal-content input, .create-form input, .lobby-username-section input {

    margin: 1rem 0; padding: 1rem; width: 100%; border-radius: 12px;

    border: 1px solid var(--glass-border); background: rgba(255,255,255,0.05); color: white;

    font-size: 1.1rem; outline: none; transition: 0.2s;

}

.modal-content input:focus, .create-form input:focus, .lobby-username-section input:focus {

    border-color: var(--primary); background: rgba(255,255,255,0.1);

}



.modal-actions {

    display: flex; gap: 1rem; margin-top: 1.5rem;

}



.lobby-portal {

    background: var(--bg-card);

    width: 90%;

    max-width: 700px;

    border-radius: 30px;

    border: 1px solid var(--glass-border);

    box-shadow: var(--glass-shadow);

    display: flex;

    flex-direction: column;

    overflow: hidden;

    animation: panelSlideIn 0.4s cubic-bezier(0.17, 0.67, 0.12, 0.99);

}



.lobby-header {

    background: rgba(255,255,255,0.03);

    padding: 2rem;

    text-align: center;

    border-bottom: 1px solid var(--glass-border);

}



.lobby-tabs {

    display: flex;

    background: rgba(0,0,0,0.2);

    padding: 0.4rem;

    border-radius: 15px;

    margin-top: 1.5rem;

    gap: 0.5rem;

}



.tab-btn {

    flex: 1;

    padding: 0.75rem;

    border: none;

    background: transparent;

    color: var(--text-muted);

    border-radius: 10px;

    cursor: pointer;

    font-weight: 600;

    transition: 0.2s;

    font-family: 'Outfit';

}



.tab-btn.active {

    background: var(--primary);

    color: white;

    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);

}



.tab-content {

    display: none;

    padding: 2rem;

    max-height: 450px;

    overflow-y: auto;

}



.tab-content.active {

    display: block;

}



.lobby-username-section {

    padding: 0 2rem;

    margin-top: 1rem;

}



.room-list {

    display: grid;

    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));

    gap: 1rem;

    margin-top: 1rem;

}



.room-card {

    background: rgba(255,255,255,0.04);

    border: 1px solid var(--glass-border);

    border-radius: 16px;

    padding: 1.25rem;

    cursor: pointer;

    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    position: relative;

    overflow: hidden;

}



.room-card:hover {

    background: rgba(255,255,255,0.08);

    border-color: var(--primary);

    transform: translateY(-3px);

}



.room-card .room-info {

    display: flex;

    justify-content: space-between;

    align-items: center;

}



.room-name {

    font-weight: bold;

    font-size: 1.2rem;

}



.room-count {

    background: rgba(0,0,0,0.3);

    padding: 0.3rem 0.7rem;

    border-radius: 20px;

    font-size: 0.85rem;

    color: var(--primary);

}



.room-join-hint {

    font-size: 0.75rem;

    color: var(--text-muted);

    margin-top: 0.5rem;

    opacity: 0;

    transition: 0.2s;

}



.room-card:hover .room-join-hint {

    opacity: 1;

}



.room-card.protected {

    border-left: 4px solid #facc15;

}



.no-rooms {

    grid-column: 1 / -1;

    text-align: center;

    padding: 3rem;

    color: var(--text-muted);

    border: 2px dashed var(--glass-border);

    border-radius: 20px;

}



.btn {

    padding: 1rem 2rem; border: none; border-radius: 12px; cursor: pointer;

    font-weight: bold; font-size: 1.1rem; transition: 0.2s; font-family: 'Outfit';

}

.primary-btn { background: var(--primary); color: white; width: 100%; }

.primary-btn:hover { background: var(--primary-hover); }



.approve-btn { background: var(--glass-border); color: white; width: 100%; margin-top: 1rem; border: 1px solid var(--success); }

.approve-btn.approved { background: var(--success); color: white; }



.danger-btn { background: var(--danger); color: white; padding: 1rem 3rem; font-size: 1.5rem; border-radius: 50px; }

.danger-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.outline-btn {

    background: transparent;

    color: var(--text-main);

    border: 2px solid var(--glass-border);

    padding: 0.85rem 1.25rem;

    width: auto;

}

.outline-btn:hover { border-color: var(--primary); color: var(--primary); }



.app-layout {

    display: flex; height: 100vh;

}

.shop-area { flex: 1; padding: 2rem; overflow-y: auto; }

.cart-area { 

    width: 350px; background: rgba(15, 23, 42, 0.8); 

    border-left: 1px solid var(--glass-border);

    padding: 2rem; display: flex; flex-direction: column; overflow-y:auto;

}



h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: 0.5rem; }

.highlight { color: var(--primary); }



.search-container { margin: 2rem 0; }

#search-input {

    width: 100%; padding: 1rem 1.5rem; font-size: 1.1rem; background: var(--bg-card);

    border: 1px solid var(--glass-border); border-radius: 50px; color: var(--text-main); outline: none;

}

#search-input:focus { border-color: var(--primary); }



.category-filters {

    display: flex;

    flex-wrap: wrap;

    gap: 0.75rem;

    margin-bottom: 2rem;

}



.cat-btn {

    padding: 0.6rem 1.2rem;

    border: 1px solid var(--glass-border);

    border-radius: 50px;

    background: var(--bg-card);

    color: var(--text-muted);

    font-family: 'Outfit', sans-serif;

    font-size: 0.95rem;

    cursor: pointer;

    transition: all 0.2s ease;

    backdrop-filter: blur(8px);

}

.cat-btn:hover {

    border-color: var(--primary);

    color: var(--text-main);

}

.cat-btn.active {

    background: var(--primary);

    border-color: var(--primary);

    color: white;

    font-weight: 600;

}



.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.5rem; }

.product-card {

    background: var(--bg-card); border: 1px solid var(--glass-border); border-radius: 15px;

    padding: 1.5rem; display: flex; flex-direction: column; justify-content: space-between;

}

.product-img {

    width: 100%;

    height: 180px;

    object-fit: contain;

    border-radius: 12px;

    margin-bottom: 1rem;

    transition: transform 0.3s ease;

}



.product-emoji {

    width: 100%;

    height: 180px;

    display: flex;

    align-items: center;

    justify-content: center;

    font-size: 5rem;

    background: rgba(255,255,255,0.05);

    border-radius: 12px;

    margin-bottom: 1rem;

}

.product-card h3 { font-size: 1.1rem; margin-bottom: 1rem; }

.price-row { display: flex; justify-content: space-between; align-items: center; }

.price { color: var(--success); font-weight: bold; font-size: 1.2rem; }

.add-btn { background: var(--primary); color: white; border: none; padding: 0.5rem 1rem; border-radius: 8px; cursor: pointer; font-weight: bold; }

.add-btn:hover { background: var(--primary-hover); }



.create-form, .auth-box {

    display: flex;

    flex-direction: column;

    max-width: 400px;

    margin: 0 auto;

}



.auth-box h3 { margin-bottom: 1rem; }



.stat-card {

    background: rgba(255,255,255,0.05);

    padding: 1.5rem;

    border-radius: 16px;

    text-align: center;

    border: 1px solid var(--glass-border);

}

.stat-label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; text-transform: uppercase; }

.stat-card strong { font-size: 1.5rem; display: block; }



.profile-stats-grid {

    display: grid;

    grid-template-columns: repeat(3, 1fr);

    gap: 1rem;

    margin: 2rem 0;

}



.profile-header { text-align: center; margin-bottom: 2rem; }

.profile-avatar { font-size: 4rem; margin-bottom: 1rem; }

.profile-badges { display: flex; gap: 0.5rem; justify-content: center; margin-top: 0.5rem; }

.badge {

    background: var(--primary);

    color: white;

    padding: 0.2rem 0.6rem;

    border-radius: 20px;

    font-size: 0.75rem;

    font-weight: bold;

}



.profile-history-section h3 { margin-bottom: 1rem; border-bottom: 1px solid var(--glass-border); padding-bottom: 0.5rem; }

.profile-history-list { max-height: 200px; overflow-y: auto; }

.mini-history-card {

    display: flex;

    justify-content: space-between;

    padding: 0.75rem;

    background: rgba(255,255,255,0.03);

    margin-bottom: 0.5rem;

    border-radius: 10px;

    font-size: 0.9rem;

}



.users-section, .cart-section { margin-bottom: 2rem; }

.users-section h3, .cart-section h3 { border-bottom: 1px solid var(--glass-border); padding-bottom: 0.5rem; margin-bottom: 1rem; }



#users-list, #cart-list { list-style: none; }

#users-list li, #cart-list li { margin-bottom: 0.5rem; display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,0.05); padding: 0.5rem; border-radius: 8px; }

.status-check { color: var(--success); }

.status-cross { color: var(--danger); }



.cart-item-info { display: flex; flex-direction: column; font-size: 0.9rem; }

.cart-item-price { color: var(--success); font-weight: bold; }

.remove-btn { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 1.2rem; }



.cart-total { display: flex; justify-content: space-between; font-size: 1.2rem; font-weight: bold; margin-top: 1rem; }

.wait-msg { font-size: 0.8rem; color: var(--text-muted); text-align: center; margin-top: 0.5rem; display: block; }



.wheel-container { text-align: center; background: var(--bg-card); padding: 2rem; border-radius: 20px; border: 1px solid var(--glass-border); }

.wheel-top-bar {

    display: flex;

    flex-wrap: wrap;

    align-items: center;

    justify-content: center;

    gap: 0.75rem 1rem;

    margin-bottom: 0.5rem;

}

.wheel-top-bar h2 { margin-bottom: 0; }

.wheel-cart-btn { padding: 0.65rem 1.1rem; width: auto; font-size: 0.95rem; }

.wheel-end-actions {

    display: none;

    flex-wrap: wrap;

    justify-content: center;

    gap: 0.75rem;

    margin-top: 1.5rem;

}

.wheel-end-actions .primary-btn { width: auto; flex: 1 1 160px; min-width: 140px; }

.wheel-end-actions .outline-btn { flex: 1 1 140px; min-width: 120px; }

.wheel-controls { margin: 1rem 0; display: flex; gap: 1rem; justify-content: center; }

.canvas-wrapper { position: relative; width: 400px; height: 400px; margin: 2rem auto; }

.pointer { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 3rem; color: white; z-index: 10; text-shadow: 0 2px 5px black; }

canvas { border-radius: 50%; transition: transform 4s cubic-bezier(0.17, 0.67, 0.12, 0.99); border: 5px solid white; box-shadow: var(--glass-shadow); }

#winner-text { margin-top: 1rem; font-size: 1.5rem; font-weight: bold; color: var(--primary); min-height: 2rem; }



.winner-cart-summary {

    margin-top: 1.25rem;

    text-align: left;

    max-width: 420px;

    margin-left: auto;

    margin-right: auto;

    padding: 1rem 1.25rem;

    background: rgba(15, 23, 42, 0.9);

    border: 1px solid var(--glass-border);

    border-radius: 14px;

    max-height: min(45vh, 320px);

    overflow-y: auto;

}

.winner-cart-summary h4 {

    font-size: 0.95rem;

    font-weight: 600;

    color: var(--text-muted);

    margin-bottom: 0.75rem;

    text-align: center;

}

.winner-cart-list {

    display: flex;

    flex-direction: column;

    gap: 0.5rem;

}

.winner-cart-row {

    display: flex;

    align-items: center;

    gap: 0.75rem;

    padding: 0.5rem;

    background: rgba(255,255,255,0.06);

    border-radius: 10px;

}

.winner-cart-thumb-wrap {

    flex-shrink: 0;

    width: 48px;

    height: 48px;

    display: flex;

    align-items: center;

    justify-content: center;

    background: rgba(255,255,255,0.05);

    border-radius: 8px;

    overflow: hidden;

}

.winner-cart-thumb {

    width: 100%;

    height: 100%;

    object-fit: contain;

}

.winner-cart-emoji, .winner-cart-emoji-fallback {

    font-size: 1.75rem;

    width: 48px;

    height: 48px;

    display: flex;

    align-items: center;

    justify-content: center;

}

.winner-cart-meta {

    flex: 1;

    min-width: 0;

    display: flex;

    flex-direction: column;

    gap: 0.2rem;

    font-size: 0.88rem;

}

.winner-cart-meta strong {

    color: var(--text-main);

    font-weight: 600;

    line-height: 1.25;

}

.winner-cart-meta span {

    color: var(--text-muted);

    font-size: 0.8rem;

}

.winner-cart-total {

    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-top: 0.75rem;

    padding-top: 0.75rem;

    border-top: 1px solid var(--glass-border);

    font-size: 1rem;

    color: var(--text-main);

}

.winner-cart-total strong { color: var(--success); }

.winner-cart-empty {

    text-align: center;

    color: var(--text-muted);

    font-size: 0.9rem;

}



/* History Section */

.history-section {

    margin-top: 4rem;

    padding-top: 2rem;

    border-top: 2px dashed var(--glass-border);

}

.history-section h2 { margin-bottom: 0.5rem; }

.section-header { margin-bottom: 2rem; }



.history-container {

    display: grid;

    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));

    gap: 1.5rem;

}



.history-card {

    background: var(--bg-card);

    border: 1px solid var(--glass-border);

    border-radius: 16px;

    padding: 1.5rem;

    display: flex;

    flex-direction: column;

    gap: 1rem;

    transition: transform 0.2s;

}

.history-card:hover { transform: translateY(-5px); border-color: var(--primary); }



.history-card-header {

    display: flex;

    justify-content: space-between;

    align-items: center;

}

.history-date { font-size: 0.85rem; color: var(--text-muted); }

.history-price { color: var(--success); font-weight: bold; font-size: 1.1rem; }



.history-loser {

    display: flex;

    align-items: center;

    gap: 0.5rem;

    font-size: 1.2rem;

    font-weight: bold;

}

.history-loser-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }



.history-items-summary {

    font-size: 0.9rem;

    color: var(--text-muted);

    background: rgba(255,255,255,0.03);

    padding: 0.75rem;

    border-radius: 8px;

    max-height: 100px;

    overflow-y: auto;

}

.history-items-summary ul { list-style: none; padding: 0; }

.history-items-summary li { margin-bottom: 0.25rem; display: flex; justify-content: space-between; font-size: 0.8rem; }

.hist-item-name { 

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;

    max-width: 180px;

}



.app-header {

    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-bottom: 2rem;

    background: var(--bg-card);

    padding: 1.5rem 2rem;

    border-radius: 20px;

    border: 1px solid var(--glass-border);

}

.header-left h1 { margin-bottom: 0.25rem; }

.header-left p { font-size: 0.9rem; color: var(--text-muted); }



.history-toggle-btn {

    display: flex;

    align-items: center;

    gap: 0.5rem;

    background: rgba(255,255,255,0.05);

    border-color: var(--primary);

    border-radius: 12px;

    font-size: 1rem;

    white-space: nowrap;

}

.history-toggle-btn:hover { background: var(--primary); color: white; }



/* History Overlay */

.history-panel {

    position: relative;

    width: 90%;

    max-width: 1000px;

    height: 85vh;

    background: var(--bg-dark);

    background-image: radial-gradient(circle at top right, rgba(79, 70, 229, 0.15), transparent),

                      radial-gradient(circle at bottom left, rgba(249, 115, 22, 0.15), transparent);

    border: 1px solid var(--glass-border);

    border-radius: 30px;

    padding: 3rem;

    display: flex;

    flex-direction: column;

    box-shadow: 0 0 100px rgba(0,0,0,0.5);

    animation: panelSlideIn 0.4s cubic-bezier(0.17, 0.67, 0.12, 0.99);

}



@keyframes panelSlideIn {

    from { transform: translateY(50px) scale(0.95); opacity: 0; }

    to { transform: translateY(0) scale(1); opacity: 1; }

}



.close-modal-btn {

    position: absolute;

    top: 1.5rem;

    right: 1.5rem;

    width: 48px;

    height: 48px;

    background: rgba(255, 255, 255, 0.05);

    backdrop-filter: blur(10px);

    border: 1px solid var(--glass-border);

    border-radius: 50%;

    color: var(--text-muted);

    font-size: 1.8rem;

    display: flex;

    align-items: center;

    justify-content: center;

    cursor: pointer;

    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    z-index: 100;

}



.close-modal-btn:hover {

    background: var(--danger);

    color: white;

    transform: rotate(90deg) scale(1.1);

    border-color: rgba(255, 255, 255, 0.3);

    box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);

}



/* Toast Notifications */

.toast-container {

    position: fixed;

    top: 2rem;

    right: 2rem;

    z-index: 9999;

    display: flex;

    flex-direction: column;

    gap: 1rem;

    pointer-events: none;

}



.toast {

    background: rgba(15, 23, 42, 0.9);

    backdrop-filter: blur(12px);

    border: 1px solid var(--primary);

    color: white;

    padding: 1rem 1.5rem;

    border-radius: 12px;

    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);

    display: flex;

    align-items: center;

    gap: 0.75rem;

    min-width: 250px;

    animation: toastIn 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);

    pointer-events: auto;

    border-left: 4px solid var(--primary);

}



.toast.success { border-left-color: var(--success); }

.toast.error { border-left-color: var(--danger); }



@keyframes toastIn {

    from { transform: translateX(100%) scale(0.8); opacity: 0; }

    to { transform: translateX(0) scale(1); opacity: 1; }

}



.toast.fade-out {

    animation: toastOut 0.4s forwards;

}



@keyframes toastOut {

    to { transform: translateX(100%); opacity: 0; }

}



.history-panel-header {

    margin-bottom: 2.5rem;

    text-align: center;

}

.history-panel-header h2 { font-size: 2.5rem; }



.history-overlay-content {

    flex: 1;

    overflow-y: auto;

    padding-right: 1rem;

}

.history-overlay-content::-webkit-scrollbar { width: 8px; }

.history-overlay-content::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 10px; }



.panel-divider {

    border: none;

    height: 1px;

    background: linear-gradient(to right, transparent, var(--glass-border), transparent);

    margin: 2.5rem 0;

}



.history-container {

    display: grid;

    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));

    gap: 1.5rem;

    margin-top: 1.5rem;

}



/* History Card in Overlay */

.history-card {

    background: rgba(255,255,255,0.03);

    border: 1px solid var(--glass-border);

    border-radius: 16px;

    padding: 1.5rem;

    transition: transform 0.2s, background 0.2s;

}

.history-card:hover { transform: scale(1.02); background: rgba(255,255,255,0.05); border-color: var(--primary); }



.last-result-section {

    padding: 2.5rem;

    background: linear-gradient(135deg, rgba(249, 115, 22, 0.1), rgba(79, 70, 229, 0.1));

    border: 1px solid var(--primary);

    border-radius: 24px;

    margin-bottom: 2rem;

}



/* --- Responsive Design --- */



@media (max-width: 1024px) {

    .app-layout {

        flex-direction: column;

        height: auto;

    }

    .shop-area {

        height: auto;

        padding: 1.5rem;

    }

    .cart-area {

        width: 100%;

        border-left: none;

        border-top: 1px solid var(--glass-border);

        position: fixed;

        bottom: 0;

        left: 0;

        z-index: 50;

        height: 60px; /* Collapsed state */

        border-radius: 25px 25px 0 0;

        background: rgba(15, 23, 42, 0.95);

        backdrop-filter: blur(20px);

        transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);

        padding: 0.75rem 1.5rem;

        overflow: hidden;

    }

    .cart-area.mobile-open {

        height: 80vh;

        overflow-y: auto;

    }

    

    .cart-mobile-handle {

        display: block;

        width: 40px;

        height: 4px;

        background: var(--glass-border);

        margin: 0 auto 1rem;

        border-radius: 2px;

    }



    .cart-section {

        flex-grow: 1;

    }



    /* Pull grid away from bottom nav */

    .shop-area {

        padding-bottom: 80px;

    }



    .cat-btn {

        padding: 0.5rem 1rem;

        font-size: 0.85rem;

    }

}



@media (max-width: 640px) {

    h1 { font-size: 2rem; }

    .header-left p { display: none; }

    .header-right { margin-top: 0.5rem; }

    

    .app-header {

        flex-direction: column;

        align-items: flex-start;

        padding: 1rem;

    }



    .canvas-wrapper {

        width: 90vw;

        height: 90vw;

        max-width: 320px;

        max-height: 320px;

    }

    canvas {

        width: 100% !important;

        height: 100% !important;

    }



    .history-panel {

        padding: 1.5rem;

        width: 95%;

        height: 90vh;

    }

    .history-panel-header h2 { font-size: 1.75rem; }



    .modal-content {

        width: 90%;

        padding: 1.5rem;

    }

}



.cart-mobile-toggle {

    display: none;

}



@media (max-width: 1024px) {

    .cart-mobile-toggle {

        display: flex;

        justify-content: space-between;

        align-items: center;

        width: 100%;

        cursor: pointer;

    }

    .cart-mobile-toggle h3 { margin: 0; font-size: 1.1rem; }

    .users-section, .cart-section h3, .wait-msg {

        display: none;

    }

    .cart-area.mobile-open .users-section, 

    .cart-area.mobile-open .cart-section h3,

    .cart-area.mobile-open .wait-msg {

        display: block;

    }

    .cart-area.mobile-open .cart-mobile-toggle {

        margin-bottom: 1rem;

    }

}