:root {
    --bg-dark: #09090e;
    --panel-bg: rgba(20, 20, 29, 0.85);
    --panel-solid: #14141d;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(124, 92, 255, 0.35);
    --accent-purple: #7c5cff;
    --accent-purple-light: #a58fff;
    --accent-green: #00f082;
    --accent-gold: #ffca28;
    --text-main: #f5f5fa;
    --text-muted: #9090a8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 15% 20%, rgba(124, 92, 255, 0.16) 0%, transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(0, 240, 130, 0.09) 0%, transparent 45%);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100dvh;
    padding: 14px;
    overflow: hidden;
    touch-action: pan-x pan-y;
}

.main-wrapper {
    width: 100%;
    max-width: 1100px;
    height: 100%;
    max-height: 920px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ad-banner {
    width: fit-content;
    max-width: 100%;
    min-width: 320px;
    min-height: 60px;
    margin: 0 auto;
    padding: 4px;
    background: rgba(20, 20, 29, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    backdrop-filter: blur(8px);
}

.content-grid {
    display: grid;
    grid-template-columns: 370px 1fr;
    gap: 14px;
    flex: 1;
    min-height: 0;
}

.panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.game-panel {
    justify-content: space-between;
    align-items: center;
    text-align: center;
    background: linear-gradient(180deg, rgba(26, 24, 40, 0.9) 0%, rgba(16, 16, 24, 0.95) 100%);
    border-color: rgba(124, 92, 255, 0.2);
}

.timer-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.phase-badge {
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 1.4px;
    padding: 5px 14px;
    border-radius: 20px;
    background: rgba(124, 92, 255, 0.16);
    border: 1px solid rgba(124, 92, 255, 0.35);
    color: #d4c8ff;
    text-transform: uppercase;
    box-shadow: 0 2px 10px rgba(124, 92, 255, 0.15);
}

.timer {
    font-size: 36px;
    font-weight: 900;
    color: var(--accent-green);
    font-variant-numeric: tabular-nums;
    background: rgba(0, 240, 130, 0.08);
    padding: 6px 26px;
    border-radius: 24px;
    border: 1px solid rgba(0, 240, 130, 0.28);
    text-shadow: 0 0 16px rgba(0, 240, 130, 0.45);
    box-shadow: inset 0 0 12px rgba(0, 240, 130, 0.08);
}

.chest-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    gap: 14px;
}

.winner-banner {
    background: linear-gradient(145deg, rgba(124, 92, 255, 0.18), rgba(45, 32, 95, 0.22));
    border: 1px solid rgba(165, 143, 255, 0.35);
    padding: 14px;
    border-radius: 14px;
    width: 100%;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.winner-tag {
    font-size: 10.5px;
    color: #c2b2ff;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.8px;
    display: block;
}

.winner-banner p {
    margin-top: 6px;
    font-size: 14.5px;
    font-weight: 600;
    color: #ffffff;
    word-break: break-word;
    max-height: 64px;
    overflow-y: auto;
    line-height: 1.4;
}
.poll-controls { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; width: 100%; }
.poll-buttons-row { display: flex; gap: 10px; justify-content: center; width: 100%; }

.poll-bar-wrapper { width: 100%; display: flex; flex-direction: column; gap: 5px; }

.poll-bar-track {
    width: 100%;
    height: 12px;
    background: #0b0b10;
    border-radius: 999px;
    overflow: hidden;
    display: flex;
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.75);
}

.poll-bar-fill {
    height: 100%;
    transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.yes-fill {
    background: linear-gradient(90deg, #00b84b, #00f082);
    box-shadow: 0 0 12px rgba(0, 240, 130, 0.55);
    border-right: 2px solid #ffffff;
}

.no-fill {
    background: linear-gradient(90deg, #ff5252, #ff1744);
    box-shadow: 0 0 12px rgba(255, 77, 77, 0.55);
}

.poll-bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11.5px;
    font-weight: 800;
    padding: 0 4px;
}

.yes-pct { color: #00f082; text-shadow: 0 0 8px rgba(0, 240, 130, 0.3); }
.no-pct { color: #ff6b6b; text-shadow: 0 0 8px rgba(255, 107, 107, 0.3); }

.vote-btn {
    flex: 1;
    padding: 9px 12px;
    border: none;
    border-radius: 10px;
    font-weight: 800;
    font-size: 13px;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.2s ease, opacity 0.2s;
    touch-action: manipulation;
}

.vote-btn:active { transform: scale(0.94); }
.vote-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.yes-btn {
    background: linear-gradient(180deg, rgba(0, 240, 130, 0.24), rgba(0, 200, 100, 0.14));
    color: #00f082;
    border: 1px solid rgba(0, 240, 130, 0.45);
    box-shadow: 0 4px 12px rgba(0, 240, 130, 0.12);
}

.no-btn {
    background: linear-gradient(180deg, rgba(255, 82, 82, 0.24), rgba(220, 40, 40, 0.14));
    color: #ff7575;
    border: 1px solid rgba(255, 82, 82, 0.45);
    box-shadow: 0 4px 12px rgba(255, 82, 82, 0.12);
}

@keyframes floatChest {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

.chest-btn {
    font-size: 82px;
    background: radial-gradient(circle, rgba(255, 202, 40, 0.16) 0%, transparent 70%);
    border: 2px solid rgba(255, 202, 40, 0.18);
    border-radius: 50%;
    width: 132px;
    height: 132px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.06s cubic-bezier(0.2, 0.9, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    will-change: transform;
    box-shadow: 0 0 25px rgba(255, 202, 40, 0.18), inset 0 0 15px rgba(255, 202, 40, 0.08);
    animation: floatChest 3s ease-in-out infinite;
}

.chest-btn:hover:not(:disabled) {
    border-color: rgba(255, 202, 40, 0.45);
    box-shadow: 0 0 35px rgba(255, 202, 40, 0.28), inset 0 0 20px rgba(255, 202, 40, 0.15);
}

.chest-btn:active:not(:disabled) {
    transform: scale(0.84);
    animation: none;
    box-shadow: 0 0 40px rgba(255, 202, 40, 0.5);
}

.chest-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(0.8);
    animation: none;
    border-color: rgba(255, 255, 255, 0.06);
    box-shadow: none;
}

.click-counter {
    font-size: 14px;
    color: #d8d8eb;
    background: rgba(11, 11, 16, 0.85);
    padding: 7px 20px;
    border-radius: 20px;
    border: 1px solid rgba(124, 92, 255, 0.28);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.click-counter strong {
    color: var(--accent-gold);
    font-size: 16px;
    margin-left: 4px;
}

.status-text {
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.4;
    max-width: 92%;
}

.mode-selector { display: flex; gap: 10px; margin-bottom: 14px; }
.mode-btn {
    flex: 1;
    padding: 11px;
    background: #0d0d14;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn:hover { border-color: rgba(124, 92, 255, 0.4); color: #e0d7ff; }

.mode-btn.active {
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.28), rgba(90, 60, 220, 0.18));
    border-color: var(--accent-purple);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(124, 92, 255, 0.25);
}

.chat-panel { min-height: 0; }

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 12px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header h2 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.3px;
    background: linear-gradient(90deg, #ffffff, #c8bcff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.online-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 240, 130, 0.1);
    border: 1px solid rgba(0, 240, 130, 0.3);
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 800;
    color: var(--accent-green);
    box-shadow: 0 0 12px rgba(0, 240, 130, 0.12);
}

.online-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-green);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-green);
    animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.45; transform: scale(0.85); }
    100% { opacity: 1; transform: scale(1); }
}

#messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 6px;
    min-height: 0;
}

#messages::-webkit-scrollbar { width: 5px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: rgba(124, 92, 255, 0.25); border-radius: 4px; }
#messages::-webkit-scrollbar-thumb:hover { background: rgba(124, 92, 255, 0.45); }

.message {
    font-size: 13.5px;
    line-height: 1.45;
    word-break: break-word;
    background: rgba(255, 255, 255, 0.035);
    padding: 9px 13px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.15s ease, border-color 0.15s ease;
}

.message:hover {
    background: rgba(255, 255, 255, 0.055);
    border-color: rgba(124, 92, 255, 0.22);
}

.message .user {
    font-weight: 700;
    color: var(--accent-purple-light);
    margin-right: 6px;
    transition: color 0.15s ease;
}

.message .user:hover {
    color: #ffffff;
    text-decoration: underline;
}
#form-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.profile-tag {
    background: rgba(124, 92, 255, 0.12);
    border: 1px solid rgba(124, 92, 255, 0.3);
    padding: 9px 13px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    color: #d8ceff;
    white-space: nowrap;
}

input[type="text"], select {
    background-color: #0c0c12;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 10px 14px;
    border-radius: 10px;
    outline: none;
    font-size: 15px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus, select:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
}

#messageInput { flex: 1; min-width: 0; }

.setup-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.btn-primary {
    background: linear-gradient(135deg, #7c5cff 0%, #5c3be8 100%);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 10px 18px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.2s ease, opacity 0.2s;
    white-space: nowrap;
    touch-action: manipulation;
    box-shadow: 0 4px 15px rgba(124, 92, 255, 0.32);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(124, 92, 255, 0.48);
    filter: brightness(1.06);
}

.btn-primary:active:not(:disabled) { transform: scale(0.96); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.btn-clear {
    background: rgba(255, 82, 82, 0.1);
    border: 1px solid rgba(255, 82, 82, 0.32);
    color: #ff7575;
    border-radius: 8px;
    font-size: 11.5px;
    font-weight: 600;
    padding: 5px 11px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-clear:hover {
    background: rgba(255, 82, 82, 0.18);
    border-color: rgba(255, 82, 82, 0.55);
}

.footer-legal { text-align: center; font-size: 11px; color: var(--text-muted); padding: 2px 0; }
.footer-legal a { color: var(--accent-purple-light); text-decoration: none; transition: color 0.15s; }
.footer-legal a:hover { color: #ffffff; text-decoration: underline; }

.legal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(9, 9, 14, 0.85);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    padding: 20px;
}

.landing-screen {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: #09090e;
    background-image: 
        radial-gradient(circle at 20% 15%, rgba(124, 92, 255, 0.22) 0%, transparent 45%),
        radial-gradient(circle at 80% 85%, rgba(0, 240, 130, 0.12) 0%, transparent 45%);
    z-index: 100;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 32px 16px;
}

.landing-container {
    width: 100%;
    max-width: 820px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    margin: auto 0;
}

.landing-hero {
    text-align: center;
    max-width: 640px;
}

.landing-pill {
    display: inline-block;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.2px;
    color: var(--accent-green);
    background: rgba(0, 240, 130, 0.1);
    border: 1px solid rgba(0, 240, 130, 0.3);
    padding: 5px 14px;
    border-radius: 20px;
    margin-bottom: 14px;
}

.landing-hero h1 {
    font-size: 36px;
    font-weight: 900;
    letter-spacing: -0.5px;
    margin-bottom: 12px;
    color: #ffffff;
}

.text-gradient {
    background: linear-gradient(90deg, #9d85ff, #00f082);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.landing-subtitle {
    font-size: 15px;
    color: #b8b8ce;
    line-height: 1.6;
}

.landing-features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    width: 100%;
}

.feature-card {
    background: rgba(20, 20, 29, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 18px 16px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.35);
}

.feature-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.feature-card h3 {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 6px;
}

.feature-card p {
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.45;
}

.landing-access-card {
    background: linear-gradient(180deg, #191924 0%, #12121a 100%);
    border: 1px solid rgba(124, 92, 255, 0.35);
    border-radius: 18px;
    padding: 24px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.landing-access-card h2 {
    font-size: 18px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 14px;
    color: #ffffff;
}

.landing-rules {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(124, 92, 255, 0.1);
    border: 1px solid rgba(124, 92, 255, 0.25);
    border-radius: 10px;
    padding: 11px 13px;
    font-size: 12px;
    color: #dcd4ff;
    line-height: 1.45;
    margin-bottom: 16px;
}

.landing-access-card a {
    color: var(--accent-purple-light);
    text-decoration: underline;
}

.landing-footer {
    font-size: 11.5px;
    color: var(--text-muted);
    text-align: center;
}

.legal-box {
    background: linear-gradient(180deg, #191924 0%, #12121a 100%);
    border: 1px solid rgba(124, 92, 255, 0.3);
    max-width: 400px;
    width: 100%;
    padding: 26px;
    border-radius: 18px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.legal-box h3 { margin-bottom: 12px; font-size: 18px; }
.legal-text { font-size: 13px; color: #c4c4d4; margin-bottom: 16px; line-height: 1.55; }
.legal-label { display: block; margin-bottom: 16px; font-size: 13px; cursor: pointer; color: #dcdce8; }

.toast-banner {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(24, 24, 34, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--accent-purple);
    color: #ffffff;
    padding: 11px 20px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    text-align: center;
    max-width: 90%;
}

.toast-banner.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 768px) {
    body { height: auto; min-height: 100dvh; overflow-y: auto; padding: 10px; }
    .main-wrapper { height: auto; max-height: none; gap: 10px; }
    .ad-banner { min-height: 50px; padding: 2px; }
    .content-grid { grid-template-columns: 1fr; height: auto; gap: 10px; }
    .game-panel { padding: 16px; }
    .chest-btn { font-size: 68px; width: 114px; height: 114px; }
    .chat-panel { height: 430px; }
    .landing-hero h1 { font-size: 28px; }
    .landing-subtitle { font-size: 13.5px; }
    .landing-features { grid-template-columns: 1fr; gap: 10px; }
    .feature-card { padding: 14px; text-align: left; display: flex; flex-direction: column; gap: 4px; }
}
