:root {
            --bg-dark: #0f172a;
            --bg-sidebar: rgba(30, 41, 59, 0.7);
            --bg-card: rgba(30, 41, 59, 0.85);
            --border-glass: rgba(255, 255, 255, 0.08);
            --primary: #3b82f6;
            --primary-hover: #2563eb;
            --accent: #8b5cf6;
            --success: #10b981;
            --success-hover: #059669;
            --danger: #ef4444;
            --danger-hover: #dc2626;
            --text-main: #f8fafc;
            --text-muted: #94a3b8;
        }

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

        body {
            background: radial-gradient(circle at top left, #1e293b, #020617);
            color: var(--text-main);
            font-family: 'Inter', sans-serif;
            display: flex;
            height: 100vh;
            overflow: hidden;
            -webkit-font-smoothing: antialiased;
        }

        /* Scrollbar */
        ::-webkit-scrollbar {
            width: 8px;
        }

        ::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.1);
        }

        ::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.2);
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: rgba(255, 255, 255, 0.3);
        }

        /* --- SIDEBAR (PC) --- */
        .sidebar {
            width: 340px;
            min-width: 340px;
            background: var(--bg-sidebar);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            padding: 24px;
            display: flex;
            flex-direction: column;
            gap: 20px;
            z-index: 20;
            overflow-y: auto;
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
            /* Floating Sidebar */
            margin: 20px;
            height: calc(100vh - 40px);
            border-radius: 16px;
            border: 1px solid var(--border-glass);
        }

        .sidebar-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid var(--border-glass);
            padding-bottom: 15px;
            margin-bottom: 5px;
        }

        .sidebar-header h2 {
            font-size: 20px;
            font-weight: 700;
            background: linear-gradient(135deg, #60a5fa, #c084fc);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            margin: 0;
        }

        .version {
            font-size: 11px;
            color: var(--text-muted);
            font-weight: 500;
            background: rgba(255, 255, 255, 0.1);
            padding: 4px 8px;
            border-radius: 12px;
        }

        .main-content {
            flex: 1;
            padding: 30px;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 25px;
            padding-bottom: 100px;
            position: relative;
            z-index: 10;
        }

        /* Inputs and Buttons */
        .input-group {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        input[type="text"],
        input[type="number"] {
            background: rgba(15, 23, 42, 0.6);
            border: 1px solid var(--border-glass);
            color: var(--text-main);
            padding: 12px 14px;
            border-radius: 8px;
            font-size: 14px;
            width: 100%;
            transition: all 0.2s;
            color-scheme: dark;
        }

        /* Customize spin buttons for WebKit */
        input[type="number"]::-webkit-inner-spin-button,
        input[type="number"]::-webkit-outer-spin-button {
            cursor: pointer;
            opacity: 0.7;
            transition: opacity 0.2s;
        }

        input[type="number"]::-webkit-inner-spin-button:hover,
        input[type="number"]::-webkit-outer-spin-button:hover {
            opacity: 1;
        }

        input:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
        }

        input:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        button {
            background: var(--primary);
            color: white;
            border: none;
            padding: 12px 16px;
            border-radius: 8px;
            cursor: pointer;
            font-weight: 600;
            font-size: 14px;
            width: 100%;
            transition: all 0.2s ease;
            box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
        }

        button:hover {
            background: var(--primary-hover);
            transform: translateY(-1px);
            box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
        }

        button:active {
            transform: translateY(1px);
        }

        button:disabled {
            background: rgba(255, 255, 255, 0.1);
            cursor: not-allowed;
            color: var(--text-muted);
            box-shadow: none;
        }

        button.leave {
            background: var(--danger);
            box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
        }

        button.leave:hover {
            background: var(--danger-hover);
            box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
        }

        #randomizeBtn,
        #randomizeBtnDesktop {
            background: linear-gradient(135deg, var(--success), #059669);
            box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
            font-size: 16px;
            letter-spacing: 0.5px;
            text-transform: uppercase;
        }

        #randomizeBtnDesktop {
            margin-top: 15px;
            display: none;
        }

        #randomizeBtn {
            display: none;
            margin-bottom: 25px;
        }

        #randomizeBtn:hover,
        #randomizeBtnDesktop:hover {
            box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
        }

        /* --- MOBILE ELEMENTS --- */
        #menuBtn {
            display: none;
            position: fixed;
            top: 20px;
            left: 20px;
            z-index: 30;
            background: var(--bg-card);
            backdrop-filter: blur(10px);
            border: 1px solid var(--border-glass);
            color: white;
            padding: 10px 14px;
            border-radius: 8px;
            font-size: 20px;
            cursor: pointer;
            width: auto;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }

        #overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.6);
            z-index: 15;
            backdrop-filter: blur(4px);
            -webkit-backdrop-filter: blur(4px);
            transition: opacity 0.3s;
        }

        /* --- MODAL --- */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.6);
            z-index: 50;
            backdrop-filter: blur(4px);
            align-items: center;
            justify-content: center;
        }

        .modal.active {
            display: flex;
            animation: fadeIn 0.2s ease-out;
        }

        .modal-content {
            background: var(--bg-card);
            border: 1px solid var(--border-glass);
            border-radius: 12px;
            padding: 24px;
            width: 90%;
            max-width: 450px;
            max-height: 90vh;
            overflow-y: auto;
            position: relative;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
            animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        }

        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            border-bottom: 1px solid var(--border-glass);
            padding-bottom: 10px;
        }

        .modal-header h3 {
            margin: 0;
            font-size: 18px;
            color: white;
        }

        .close-btn {
            background: rgba(255, 255, 255, 0.1);
            border: none;
            color: var(--text-muted);
            font-size: 16px;
            cursor: pointer;
            width: 32px;
            height: 32px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
            box-shadow: none;
        }

        .close-btn:hover {
            background: rgba(255, 255, 255, 0.2);
            color: white;
            transform: none;
            box-shadow: none;
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
            }

            to {
                opacity: 1;
            }
        }

        @keyframes slideUp {
            from {
                transform: translateY(20px);
                opacity: 0;
            }

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

        /* Tabs */
        .modal-nav {
            display: flex;
            gap: 8px;
            border-bottom: 1px solid var(--border-glass);
            padding-bottom: 15px;
            margin-bottom: 20px;
            overflow-x: auto;
            scrollbar-width: none;
        }

        .modal-nav::-webkit-scrollbar {
            display: none;
        }

        .tab-btn {
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid transparent;
            color: var(--text-muted);
            padding: 8px 14px;
            border-radius: 6px;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            white-space: nowrap;
            box-shadow: none;
        }

        .tab-btn:hover {
            background: rgba(255, 255, 255, 0.1);
            color: white;
            transform: none;
            box-shadow: none;
        }

        .tab-btn.active {
            background: var(--primary);
            color: white;
            border-color: var(--primary-hover);
        }

        .tab-pane {
            display: none;
        }

        .tab-pane.active {
            display: block;
            animation: fadeIn 0.2s;
        }

        .ban-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
            gap: 10px;
            max-height: 400px;
            overflow-y: auto;
            padding-right: 5px;
        }

        .ban-grid .checkbox-item {
            background: rgba(15, 23, 42, 0.4);
            padding: 8px;
            border-radius: 6px;
            border: 1px solid var(--border-glass);
        }

        /* --- SETTINGS & SECTIONS --- */
        .mobile-row {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .settings-box {
            background: rgba(15, 23, 42, 0.4);
            border-radius: 12px;
            padding: 16px;
            margin-bottom: 5px;
            border: 1px solid var(--border-glass);
        }

        .settings-label {
            font-size: 11px;
            font-weight: 700;
            margin-bottom: 12px;
            color: var(--text-muted);
            display: block;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .checkbox-group {
            display: flex;
            flex-direction: column;
            gap: 10px;
            margin-bottom: 20px;
        }

        .checkbox-item {
            display: flex;
            align-items: center;
            gap: 12px;
            font-size: 14px;
            cursor: pointer;
            color: var(--text-main);
            transition: color 0.2s;
        }

        .checkbox-item:hover {
            color: white;
        }

        .checkbox-item input[type="checkbox"] {
            appearance: none;
            -webkit-appearance: none;
            width: 18px;
            height: 18px;
            border: 2px solid var(--text-muted);
            border-radius: 4px;
            background: rgba(0, 0, 0, 0.2);
            cursor: pointer;
            position: relative;
            transition: all 0.2s;
        }

        .checkbox-item input[type="checkbox"]:checked {
            background: var(--primary);
            border-color: var(--primary);
        }

        .checkbox-item input[type="checkbox"]:checked::after {
            content: '✓';
            position: absolute;
            color: white;
            font-size: 14px;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }

        .disclaimer {
            margin-top: auto;
            padding-top: 20px;
            font-size: 11px;
            color: var(--text-muted);
            text-align: center;
            line-height: 1.5;
            border-top: 1px solid var(--border-glass);
        }

        .disclaimer a {
            color: var(--primary);
            text-decoration: none;
            transition: color 0.2s;
        }

        .disclaimer a:hover {
            color: #60a5fa;
            text-decoration: underline;
        }

        /* --- TOWER RULES --- */
        .rules-group {
            display: flex;
            flex-direction: column;
            gap: 12px;
            margin-bottom: 20px;
        }

        .category-rule {
            background: rgba(0, 0, 0, 0.2);
            border: 1px solid var(--border-glass);
            border-radius: 8px;
            padding: 12px;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .rule-header {
            display: flex;
            align-items: center;
        }

        .rule-controls {
            display: flex;
            gap: 15px;
            align-items: center;
            background: rgba(255, 255, 255, 0.03);
            padding: 10px;
            border-radius: 6px;
        }

        .slider-label {
            display: flex;
            flex-direction: column;
            gap: 5px;
            font-size: 12px;
            color: var(--text-muted);
            flex: 1;
        }

        .slider-label span {
            color: white;
            font-weight: 600;
        }

        .weight-slider {
            -webkit-appearance: none;
            appearance: none;
            width: 100%;
            height: 6px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 3px;
            outline: none;
            margin-top: 4px;
        }

        .weight-slider::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: var(--primary);
            cursor: pointer;
            transition: transform 0.1s;
        }

        .weight-slider::-webkit-slider-thumb:hover {
            transform: scale(1.2);
        }

        .cap-label {
            display: flex;
            flex-direction: column;
            gap: 5px;
            font-size: 12px;
            color: var(--text-muted);
            width: 70px;
        }

        .cap-label input {
            padding: 6px !important;
            font-size: 13px !important;
        }

        #restoreDefaultsBtn:hover {
            background: rgba(255,255,255,0.1) !important;
            color: white !important;
            transform: translateY(-1px);
        }

        /* Party List */
        .party-list-container {
            background: rgba(15, 23, 42, 0.4);
            border: 1px solid var(--border-glass);
            border-radius: 10px;
            padding: 12px;
        }

        .party-list-title {
            margin-bottom: 10px;
            font-weight: 600;
            font-size: 12px;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .party-list {
            display: flex;
            flex-direction: column;
            gap: 6px;
            min-height: 40px;
        }

        .party-member {
            padding: 8px 12px;
            background: rgba(255, 255, 255, 0.05);
            border-radius: 6px;
            font-size: 14px;
            display: flex;
            align-items: center;
            border-left: 3px solid transparent;
        }

        .is-host {
            border-left-color: #fbbf24;
            color: #fde68a;
            font-weight: 600;
        }

        .is-me {
            border-left-color: var(--primary);
            color: #bfdbfe;
            font-weight: 600;
        }

        /* Results */
        .section-title {
            position: relative;
            font-size: 22px;
            font-weight: 700;
            margin-bottom: 25px;
            padding-bottom: 12px;
            color: white;
            letter-spacing: 0.5px;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        }

        .section-title::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 250px;
            height: 1px;
            background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
        }

        .results-container {
            display: flex;
            gap: 15px;
            flex-wrap: wrap;
            justify-content: center;
        }

        .card {
            background: var(--bg-card);
            border: 1px solid var(--border-glass);
            border-radius: 12px;
            padding: 15px;
            width: 110px;
            text-align: center;
            display: flex;
            flex-direction: column;
            align-items: center;
            box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
            transition: transform 0.2s ease, box-shadow 0.2s ease;
            backdrop-filter: blur(8px);
        }

        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
            border-color: rgba(255, 255, 255, 0.2);
        }

        .card img {
            width: 80px;
            height: 80px;
            object-fit: contain;
            background: rgba(0, 0, 0, 0.2);
            border-radius: 8px;
            padding: 5px;
            margin-bottom: 10px;
        }

        .card span {
            font-size: 13px;
            font-weight: 600;
            line-height: 1.3;
            color: #f1f5f9;
        }

        /* Game Info */
        #gameInfo {
            display: none;
            flex-direction: row;
            gap: 15px;
            flex-wrap: wrap;
            justify-content: center;
            margin-bottom: 10px;
        }

        .info-box {
            background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.9));
            padding: 12px 20px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            gap: 15px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
            border: 1px solid var(--border-glass);
            min-width: 200px;
            flex: 1;
            max-width: 300px;
        }

        .info-label {
            color: var(--text-muted);
            font-size: 12px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .info-icon {
            width: 45px;
            height: 45px;
            object-fit: contain;
            filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
        }

        .info-content {
            display: flex;
            flex-direction: column;
            gap: 4px;
        }

        .info-text {
            font-size: 16px;
            font-weight: 700;
            color: white;
        }

        #teammatesSection {
            margin-top: 10px;
        }

        .teammate-header {
            font-weight: 700;
            margin-top: 25px;
            margin-bottom: 15px;
            font-size: 18px;
            width: 100%;
            text-align: center;
            color: #cbd5e1;
        }

        #waitingMessage {
            text-align: center;
            color: var(--text-muted);
            margin-top: 40px;
            font-size: 16px;
            font-weight: 500;
            line-height: 1.5;
            background: rgba(30, 41, 59, 0.5);
            padding: 30px;
            border-radius: 12px;
            border: 1px dashed var(--border-glass);
            max-width: 400px;
            margin-left: auto;
            margin-right: auto;
        }

        /* --- TRADE MODAL --- */
        .card.trade-option {
            cursor: pointer;
            border-color: var(--primary);
        }

        .card.trade-option:hover {
            box-shadow: 0 12px 24px rgba(59, 130, 246, 0.3);
            border-color: #60a5fa;
            transform: translateY(-5px) scale(1.05);
        }

        .card.trade-disabled {
            opacity: 0.4;
            cursor: not-allowed;
            pointer-events: none;
            filter: grayscale(100%);
        }

        .card.trade-target {
            cursor: pointer;
        }
        
        .card.trade-target:hover {
            box-shadow: 0 12px 24px rgba(139, 92, 246, 0.3);
            border-color: #a78bfa;
        }

        /* --- UPDATE BANNER --- */
        #updateBanner {
            display: none;
            position: fixed;
            bottom: 24px;
            right: 24px;
            z-index: 9999;
            background: linear-gradient(135deg, rgba(59, 130, 246, 0.95), rgba(37, 99, 235, 0.95));
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            padding: 16px 20px;
            border-radius: 12px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
            color: white;
            align-items: center;
            gap: 16px;
            animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        }

        #updateBanner.active {
            display: flex;
        }

        .update-info {
            display: flex;
            flex-direction: column;
            gap: 4px;
        }

        .update-title {
            font-weight: 700;
            font-size: 14px;
        }

        .update-desc {
            font-size: 12px;
            color: rgba(255, 255, 255, 0.85);
        }

        #updateBanner button {
            background: white;
            color: var(--primary);
            width: auto;
            padding: 8px 16px;
            margin: 0;
            white-space: nowrap;
            box-shadow: 0 4px 10px rgba(0,0,0,0.2);
            font-size: 13px;
        }

        #updateBanner button:hover {
            background: #f8fafc;
            transform: scale(1.05);
            box-shadow: 0 6px 14px rgba(0,0,0,0.3);
        }

        /* --- CUSTOM ALERTS & TOASTS --- */
        #toastContainer {
            position: fixed;
            bottom: 24px;
            right: 24px;
            display: flex;
            flex-direction: column;
            gap: 12px;
            z-index: 9999;
        }

        #topToastContainer {
            position: fixed;
            top: 24px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            flex-direction: column;
            gap: 12px;
            z-index: 9999;
            align-items: center;
        }

        .toast {
            background: var(--bg-surface);
            border: 1px solid var(--border-glass);
            border-radius: 8px;
            padding: 12px 20px;
            min-width: 250px;
            color: var(--text-main);
            box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            display: flex;
            flex-direction: column;
            gap: 5px;
            animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
            position: relative;
            overflow: hidden;
        }

        .toast.toast-error { border-color: #ef4444; border-left: 4px solid #ef4444; }
        .toast.toast-success { border-color: #22c55e; border-left: 4px solid #22c55e; }
        .toast.toast-info { border-color: #3b82f6; border-left: 4px solid #3b82f6; }
        .toast.toast-warning { border-color: #eab308; border-left: 4px solid #eab308; }

        .toast.toast-trade { cursor: pointer; border-color: var(--accent); border-left: 4px solid var(--accent); transition: background 0.2s; }
        .toast.toast-trade:hover { background: rgba(139, 92, 246, 0.1); }

        /* Animation */
        @keyframes toastSlideIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }

        @keyframes toastSlideOut {
            from { opacity: 1; transform: scale(1); }
            to { opacity: 0; transform: scale(0.95); }
        }

        .toast.hiding {
            animation: toastSlideOut 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
        }

        .toast-message { font-size: 14px; font-weight: 500; }
        .toast-sub { font-size: 12px; color: var(--text-muted); }

        /* Timer Bar */
        .toast-timer-bar-container {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 3px;
            background: rgba(255, 255, 255, 0.1);
        }
        .toast-timer-bar {
            height: 100%;
            background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ef4444);
            width: 100%;
            transform-origin: left;
        }

        /* Custom Confirm */
        #customConfirmModal .modal-content {
            max-width: 350px;
            text-align: center;
            padding: 25px;
        }
        #customConfirmMessage {
            margin-bottom: 24px;
            font-size: 15px;
            line-height: 1.5;
            color: var(--text-main);
        }
        .confirm-btn-group {
            display: flex;
            gap: 12px;
            justify-content: center;
        }
        .confirm-btn-group button {
            margin: 0;
            flex: 1;
        }

        /* --- MOBILE RESPONSIVE --- */
        @media (max-width: 768px) {
            #menuBtn {
                display: block;
            }

            .sidebar {
                position: fixed;
                top: 0;
                left: 0;
                height: 100vh;
                width: 100%;
                max-width: 100%;
                margin: 0;
                transform: translateX(-100%);
                border-radius: 0;
                border: none;
                padding-top: 80px;
            }

            .sidebar.active {
                transform: translateX(0);
            }

            #overlay.active {
                display: block;
            }

            .main-content {
                padding-top: 80px;
                padding-left: 20px;
                padding-right: 20px;
            }

            #randomizeBtn {
                display: none;
                position: fixed;
                bottom: 5px;
                left: 50%;
                transform: translateX(-50%);
                width: calc(100% - 40px);
                z-index: 100;
                padding: 16px;
                font-size: 18px;
                border-radius: 12px;
            }

            .info-box {
                width: 100%;
                max-width: none;
            }
        }