:root {
    --bg-0: #05050a;
    --bg-1: #0b0b14;
    --bg-2: #11111d;
    --line: rgba(255, 255, 255, 0.07);
    --line-strong: rgba(255, 255, 255, 0.14);
    --text: #ececf5;
    --muted: #8a8aa3;
    --muted-2: #5d5d76;
    --accent: #a78bfa;
    --accent-2: #f472b6;
    --twitch: #9146ff;
    --tiktok: #ff0050;
    --tiktok-2: #00f2ea;
    --live: #ef4444;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --shadow-lg: 0 24px 80px rgba(0, 0, 0, 0.55);
    --trans: cubic-bezier(0.2, 0.8, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-0);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

.bg-glow {
    position: fixed; inset: 0; z-index: -2; pointer-events: none;
    background:
        radial-gradient(1100px 700px at 15% -10%, rgba(124, 58, 237, 0.28), transparent 55%),
        radial-gradient(900px 600px at 110% 20%, rgba(236, 72, 153, 0.22), transparent 55%),
        radial-gradient(700px 500px at 50% 120%, rgba(59, 130, 246, 0.18), transparent 55%);
    animation: glow-drift 18s ease-in-out infinite alternate;
}
@keyframes glow-drift {
    0%   { transform: translate3d(0,0,0) scale(1); }
    100% { transform: translate3d(-20px, 10px, 0) scale(1.05); }
}

.bg-grid {
    position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: 0.35;
    background-image:
        linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
    -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}

.site-header {
    display: flex; align-items: center; gap: 20px;
    padding: 20px 32px;
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
    background: rgba(7, 7, 14, 0.55);
    position: sticky; top: 0; z-index: 50;
    animation: fade-down .6s var(--trans);
}
@keyframes fade-down { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }

.brand {
    display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text);
    font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 700; font-size: 20px; letter-spacing: -0.01em;
    transition: transform .2s var(--trans);
}
.brand:hover { transform: translateY(-1px); }
.brand-mark { display: inline-flex; filter: drop-shadow(0 6px 14px rgba(167, 139, 250, 0.45)); }
.brand-text { background: linear-gradient(90deg, #c4b5fd, #f472b6); -webkit-background-clip: text; background-clip: text; color: transparent; }

.top-nav { display: flex; gap: 8px; margin-left: auto; }
.chip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 14px; border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
    color: var(--muted);
    text-decoration: none; font-size: 13px; font-weight: 500;
    transition: color .2s, background .2s, border-color .2s, transform .15s;
}
.chip:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); border-color: var(--line-strong); transform: translateY(-1px); }

.account { display: flex; align-items: center; }

.login-group { display: flex; gap: 8px; }
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600;
    color: white; text-decoration: none; cursor: pointer; border: none;
    transition: transform .15s var(--trans), box-shadow .25s var(--trans), filter .2s;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn:active { transform: translateY(0); }
.btn-twitch { background: linear-gradient(135deg, #a855f7, #7c3aed); box-shadow: 0 10px 30px rgba(124, 58, 237, 0.35); }
.btn-twitch:hover { box-shadow: 0 16px 40px rgba(124, 58, 237, 0.55); }
.btn-tiktok { background: linear-gradient(135deg, #ff0050 0%, #ff2e5f 40%, #00f2ea 140%); box-shadow: 0 10px 30px rgba(255, 0, 80, 0.35); }
.btn-tiktok:hover { box-shadow: 0 16px 40px rgba(255, 0, 80, 0.55); }

.me { display: flex; align-items: center; gap: 12px; }
.avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background-size: cover; background-position: center;
    background-color: #1a1a2e;
    border: 2px solid rgba(255, 255, 255, 0.12);
    position: relative;
}
.platform-badge {
    position: absolute; bottom: -3px; right: -3px;
    width: 18px; height: 18px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: white; border: 2px solid var(--bg-0);
}
.platform-twitch { background: var(--twitch); }
.platform-tiktok { background: #111; }
.me-text { display: flex; flex-direction: column; line-height: 1.15; }
.me-name { font-size: 14px; font-weight: 600; }
.me-logout { font-size: 11px; color: var(--muted); text-decoration: none; transition: color .2s; }
.me-logout:hover { color: var(--accent-2); }

.stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 24px;
    padding: 28px 32px;
    max-width: 1600px;
    margin: 0 auto;
    align-items: stretch;
}

.stream-card, .chat-card {
    background: linear-gradient(180deg, rgba(25, 25, 40, 0.75), rgba(15, 15, 25, 0.75));
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: rise .7s var(--trans) both;
}
.chat-card { animation-delay: .1s; display: flex; flex-direction: column; height: calc(100vh - 180px); min-height: 540px; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.stream-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 18px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
}

.live-dot-wrap {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 999px;
    transition: background .4s, border-color .4s, opacity .4s;
}
.stream-card[data-live="0"] .live-dot-wrap {
    background: rgba(138, 138, 163, 0.08);
    border-color: rgba(138, 138, 163, 0.25);
}
.stream-card[data-live="0"] .live-dot { background: var(--muted); box-shadow: none; animation: none; }
.stream-card[data-live="0"] .live-label { color: var(--muted); }

.live-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--live);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
    animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
    70%  { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.live-label { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; color: #fca5a5; }

.stream-title-row { display: flex; align-items: center; gap: 14px; min-width: 0; }
.stream-title {
    margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stream-game {
    font-size: 12px; color: var(--accent); font-weight: 500;
    padding: 4px 10px; border-radius: 999px;
    background: rgba(167, 139, 250, 0.1);
    border: 1px solid rgba(167, 139, 250, 0.2);
    white-space: nowrap;
}

.stream-meta { font-size: 13px; color: var(--muted); }
.viewers { display: inline-flex; align-items: center; gap: 7px; }
.viewer-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--live); box-shadow: 0 0 8px var(--live);
}
.v-count { color: var(--text); font-weight: 600; }

.player-wrap { padding: 14px; }
.player-frame {
    position: relative;
    aspect-ratio: 16 / 9;
    width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
    border: 1px solid var(--line);
}
#twitch-player { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.offline-overlay {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background:
        radial-gradient(800px 500px at 50% 30%, rgba(124, 58, 237, 0.25), transparent 55%),
        linear-gradient(180deg, rgba(10, 10, 20, 0.9), rgba(5, 5, 12, 0.98));
    backdrop-filter: blur(12px);
    z-index: 5;
    animation: fade-in .5s var(--trans);
}
.offline-overlay[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.offline-inner { text-align: center; padding: 28px; max-width: 520px; }
.offline-inner h2 {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: clamp(22px, 3.2vw, 34px);
    margin: 18px 0 8px;
    background: linear-gradient(90deg, #e9e9f5, #a78bfa 60%, #f472b6);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    letter-spacing: -0.02em; font-weight: 700;
}
.offline-inner p { color: var(--muted); margin: 0 0 22px; font-size: 14px; }

.offline-links { display: inline-flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.offline-orb {
    position: relative; width: 90px; height: 90px; margin: 0 auto;
}
.offline-orb span {
    position: absolute; inset: 0; border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: rgba(167, 139, 250, 0.8);
    border-right-color: rgba(244, 114, 182, 0.6);
    animation: spin 2.8s linear infinite;
}
.offline-orb span:nth-child(2) { inset: 10px; animation-duration: 2.2s; animation-direction: reverse; opacity: 0.6; }
.offline-orb span:nth-child(3) { inset: 22px; animation-duration: 3.5s; opacity: 0.4; border-top-color: rgba(59, 130, 246, 0.8); }
@keyframes spin { to { transform: rotate(360deg); } }

.chat-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}
.chat-head-left { display: flex; flex-direction: column; line-height: 1.2; }
.chat-title { font-size: 14px; font-weight: 600; letter-spacing: 0.02em; }
.chat-sub { font-size: 11px; color: var(--muted); margin-top: 2px; letter-spacing: 0.02em; }

.chat-head-right { display: flex; gap: 6px; }
.pill {
    width: 22px; height: 22px; border-radius: 7px;
    display: inline-flex; align-items: center; justify-content: center;
    color: white;
    transition: transform .2s;
}
.pill:hover { transform: translateY(-1px) scale(1.05); }
.pill-twitch { background: var(--twitch); }
.pill-tiktok { background: #111; border: 1px solid #222; }

.chat-stream {
    flex: 1; min-height: 0;
    overflow-y: auto;
    padding: 10px 10px 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
    mask-image: linear-gradient(180deg, transparent 0, #000 16px, #000 calc(100% - 8px), transparent 100%);
    -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 16px, #000 calc(100% - 8px), transparent 100%);
}
.chat-stream::-webkit-scrollbar { width: 8px; }
.chat-stream::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 8px; }

.msg {
    display: grid;
    grid-template-columns: 30px 1fr;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    transition: background .25s;
    animation: msg-in .35s var(--trans);
}
.msg:hover { background: rgba(255, 255, 255, 0.03); }
@keyframes msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

.msg-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background-size: cover; background-position: center;
    background-color: #1a1a2e;
    position: relative;
    flex-shrink: 0;
}
.msg-avatar .mini-platform {
    position: absolute; right: -3px; bottom: -3px;
    width: 14px; height: 14px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: white;
    border: 2px solid var(--bg-1);
}
.mini-platform.platform-twitch { background: var(--twitch); }
.mini-platform.platform-tiktok { background: #111; }

.msg-body { min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.msg-user { font-size: 13px; font-weight: 600; letter-spacing: -0.005em; }
.msg-user.platform-twitch { color: #c4b5fd; }
.msg-user.platform-tiktok { color: #ff7ba4; }
.msg-time { font-size: 10px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.msg-text {
    font-size: 13px; color: #dcdce8; margin-top: 2px;
    word-wrap: break-word; overflow-wrap: break-word;
    line-height: 1.45;
}

.chat-empty {
    text-align: center; color: var(--muted-2);
    padding: 40px 20px; font-size: 13px;
}

.chat-form {
    display: flex; align-items: center; gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--line);
    background: rgba(10, 10, 18, 0.35);
}
.chat-form[data-disabled="1"] { padding: 14px 16px; }
.chat-you { position: relative; flex-shrink: 0; }
.mini-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background-size: cover; background-position: center;
    background-color: #1a1a2e;
    border: 1px solid var(--line-strong);
}
.you-platform {
    position: absolute; right: -3px; bottom: -3px;
    width: 14px; height: 14px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: white;
    border: 2px solid var(--bg-1);
}
.you-twitch { background: var(--twitch); }
.you-tiktok { background: #111; }

#chat-input {
    flex: 1; min-width: 0;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-family: inherit;
    transition: border-color .2s, box-shadow .2s, background .2s;
}
#chat-input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.12);
}
#chat-send {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: white; border: none; cursor: pointer;
    transition: transform .15s var(--trans), box-shadow .2s, filter .2s;
}
#chat-send:hover { transform: translateY(-1px); filter: brightness(1.08); box-shadow: 0 8px 24px rgba(167, 139, 250, 0.4); }
#chat-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.chat-signin {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; gap: 10px;
    color: var(--muted); font-size: 13px;
}
.chat-signin-actions { display: flex; gap: 6px; }
.tiny-btn {
    font-size: 11px; font-weight: 600;
    padding: 6px 12px; border-radius: 7px;
    color: white; text-decoration: none;
    transition: transform .15s, filter .2s;
}
.tiny-btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.tiny-twitch { background: var(--twitch); }
.tiny-tiktok { background: linear-gradient(135deg, var(--tiktok), var(--tiktok-2)); }

.site-footer {
    text-align: center;
    padding: 28px 24px 36px;
    color: var(--muted);
    font-size: 13px;
    display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap;
}
.site-footer a { color: var(--muted); text-decoration: none; transition: color .2s; }
.site-footer a:hover { color: var(--text); }
.site-footer .dot { color: var(--muted-2); }

.msg.new-flash { background: rgba(167, 139, 250, 0.08); }

@media (max-width: 980px) {
    .stage { grid-template-columns: 1fr; padding: 20px 16px; gap: 18px; }
    .chat-card { height: 520px; min-height: 0; }
    .site-header { padding: 14px 18px; flex-wrap: wrap; }
    .top-nav { order: 3; width: 100%; justify-content: center; margin: 8px 0 0; }
    .account { margin-left: auto; }
    .stream-header { grid-template-columns: 1fr; gap: 10px; }
}
@media (max-width: 520px) {
    .btn { padding: 9px 12px; font-size: 12px; }
    .brand-text { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
