/* ================================================================
   PurrTube — synchronized cat viewing
   ================================================================ */

* { box-sizing: border-box; }

:root {
    --bg0: #120d1f;
    --bg1: #1b1330;
    --ink: #f6f0ff;
    --ink-dim: #a99bc7;
    --accent: #ff9a3d;
    --accent-2: #ff5e7e;
    --accent-3: #ffd166;
    --good: #5eead4;
    --card: rgba(255, 255, 255, 0.045);
    --card-2: rgba(255, 255, 255, 0.075);
    --border: rgba(255, 255, 255, 0.11);
    --shadow: 0 24px 60px -18px rgba(0, 0, 0, 0.65);
    --radius: 22px;
    --font-head: 'Fredoka', 'Baloo 2', 'Comic Sans MS', cursive, sans-serif;
    --font-body: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
}

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--ink);
    background:
        radial-gradient(1200px 700px at 15% -10%, rgba(255, 122, 61, 0.16), transparent 60%),
        radial-gradient(1000px 700px at 110% 10%, rgba(255, 94, 126, 0.14), transparent 55%),
        radial-gradient(900px 800px at 50% 120%, rgba(122, 90, 255, 0.18), transparent 60%),
        linear-gradient(160deg, var(--bg0), var(--bg1) 55%, var(--bg0));
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
}

[hidden] { display: none !important; }
::selection { background: rgba(255, 154, 61, 0.35); }

/* ---------- ambient background ---------- */
.bg-paws {
    position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
}
.bg-paws::before,
.bg-paws::after {
    position: absolute; opacity: 0.10; animation: drift 22s ease-in-out infinite;
}
.bg-paws::before { content: '🐾'; left: 5%; top: 12%; font-size: 64px; }
.bg-paws::after  { content: '🐈'; right: 7%; bottom: 12%; font-size: 84px; animation-delay: -11s; }
@keyframes drift {
    0%, 100% { transform: translateY(0) rotate(-8deg); }
    50%      { transform: translateY(-26px) rotate(10deg); }
}

/* ---------- top bar ---------- */
.topbar {
    position: relative; z-index: 5;
    display: flex; align-items: center; gap: 14px;
    max-width: 1280px; margin: 0 auto;
    padding: 18px 20px 6px;
}
.logo {
    font-family: var(--font-head); font-size: 26px; font-weight: 700;
    letter-spacing: 0.2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.live-badge {
    display: inline-flex; align-items: center; gap: 8px;
    margin-left: auto;
    background: var(--card); border: 1px solid var(--border);
    padding: 6px 14px; border-radius: 999px;
    font-size: 13px; color: var(--ink-dim);
}
.live-badge .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--good); box-shadow: 0 0 10px var(--good);
    animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.me-badge {
    background: var(--card-2); border: 1px solid var(--border);
    padding: 6px 14px; border-radius: 999px;
    font-size: 13px; cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease;
}
.me-badge:hover { transform: translateY(-1px); border-color: rgba(255, 154, 61, 0.55); }

/* ---------- layout ---------- */
.layout {
    position: relative; z-index: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 18px;
    max-width: 1280px; margin: 0 auto;
    padding: 14px 20px 40px;
}

/* ---------- cat stage ---------- */
.cat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 14px;
    box-shadow: var(--shadow);
}
.cat-frame {
    position: relative;
    display: grid; place-items: center;
    min-height: 380px; max-height: 60vh;
    border-radius: 20px;
    overflow: hidden;
    background:
        radial-gradient(600px 300px at 50% 0%, rgba(255, 154, 61, 0.10), transparent 70%),
        radial-gradient(500px 400px at 50% 110%, rgba(122, 90, 255, 0.14), transparent 70%),
        #171026;
}
.cat-frame::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.5);
}
.cat-frame.glowing { animation: frameGlow 0.9s ease-out; }
@keyframes frameGlow {
    0% { box-shadow: 0 0 0 0 rgba(255, 209, 102, 0.55); }
    100% { box-shadow: 0 0 0 40px rgba(255, 209, 102, 0); }
}
.cat-frame img {
    max-width: 100%; max-height: 58vh;
    object-fit: contain;
    border-radius: 14px;
    position: relative; z-index: 1;
    transition: opacity 0.25s ease;
}
.cat-frame img.in { animation: catIn 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.15); }
@keyframes catIn {
    0% { opacity: 0; transform: scale(0.92) translateY(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}
.cat-spinner {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    color: var(--ink-dim); font-size: 15px;
}
.spinner-emoji { font-size: 56px; animation: bounce 1s ease-in-out infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
.cat-meta {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 8px 2px;
}
.source-badge {
    font-size: 12px; color: var(--ink-dim);
    background: var(--card-2); border: 1px solid var(--border);
    padding: 4px 10px; border-radius: 999px;
}
.cat-timer { font-size: 12px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }

/* ---------- vote panel ---------- */
.vote-panel {
    margin-top: 18px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px 18px;
    text-align: center;
}
.vote-head h2 {
    margin: 0 0 4px;
    font-family: var(--font-head); font-size: 22px; font-weight: 600;
}
.vote-head p { margin: 0 0 16px; color: var(--ink-dim); font-size: 14px; min-height: 1.4em; }

.progress {
    position: relative;
    height: 14px; border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    overflow: hidden;
}
.progress-fill {
    height: 100%; width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    box-shadow: 0 0 18px rgba(255, 94, 126, 0.55);
    transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.progress-mark {
    position: absolute; top: -4px; bottom: -4px; left: 66%;
    width: 2px; background: rgba(255, 255, 255, 0.25);
    transform: translateX(-1px);
}
.progress-mark span {
    position: absolute; top: 100%; left: 50%; transform: translate(-50%, 2px);
    font-size: 12px; opacity: 0.9;
}

.vote-row {
    display: flex; align-items: center; justify-content: center;
    gap: 14px; margin-top: 18px;
}
.vote-btn {
    font-family: var(--font-head); font-size: 17px; font-weight: 600;
    color: #241304;
    border: none; cursor: pointer;
    padding: 13px 30px;
    border-radius: 999px;
    background: linear-gradient(120deg, var(--accent), var(--accent-3));
    box-shadow: 0 8px 24px -8px rgba(255, 154, 61, 0.7);
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.vote-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px -8px rgba(255, 154, 61, 0.9);
    filter: brightness(1.05);
}
.vote-btn:active:not(:disabled) { transform: scale(0.96); }
.vote-btn:disabled {
    cursor: default;
    background: var(--card-2);
    color: var(--good);
    box-shadow: none;
    border: 1px solid rgba(94, 234, 212, 0.35);
}
.vote-count {
    font-family: var(--font-head); font-size: 18px;
    color: var(--accent-3);
    font-variant-numeric: tabular-nums;
}
.hint { margin: 12px 0 0; font-size: 12px; color: var(--ink-dim); }

/* ---------- sidebar panels ---------- */
.sidebar { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.panel-title {
    font-family: var(--font-head); font-weight: 600; font-size: 15px;
    margin-bottom: 12px;
}

.chat-list {
    height: clamp(220px, 36vh, 340px);
    overflow-y: auto;
    display: flex; flex-direction: column; gap: 8px;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.chat-row {
    display: flex; gap: 6px; align-items: baseline;
    font-size: 13.5px; line-height: 1.45;
    animation: chatIn 0.25s ease-out;
}
.chat-row.mine { background: rgba(255, 154, 61, 0.08); border-radius: 10px; padding: 3px 8px; }
.chat-row.pending { opacity: 0.55; }
@keyframes chatIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.chat-name { font-weight: 600; white-space: nowrap; }
.chat-msg { color: var(--ink); word-break: break-word; }
.chat-empty { color: var(--ink-dim); font-size: 13px; }

.chat-form { display: flex; gap: 8px; margin-top: 12px; }
.chat-form input {
    flex: 1; min-width: 0;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--ink);
    padding: 10px 16px;
    font-family: var(--font-body); font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease;
}
.chat-form input:focus { border-color: rgba(255, 154, 61, 0.6); }
.chat-form input::placeholder { color: var(--ink-dim); }
.chat-form button {
    border: none; cursor: pointer;
    width: 42px; border-radius: 999px;
    background: linear-gradient(120deg, var(--accent), var(--accent-2));
    color: #241304; font-size: 16px;
    transition: transform 0.15s ease;
}
.chat-form button:hover { transform: translateY(-1px); }

.who-list { display: flex; flex-wrap: wrap; gap: 8px; }
.who-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--card-2); border: 1px solid var(--border);
    padding: 4px 10px 4px 4px; border-radius: 999px;
    font-size: 12.5px;
    animation: chatIn 0.25s ease-out;
}
.who-av {
    width: 22px; height: 22px; border-radius: 50%;
    display: grid; place-items: center;
    font-size: 11px; font-weight: 700; color: #fff;
}
.who-empty { color: var(--ink-dim); font-size: 13px; }

.stats-panel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-family: var(--font-head); font-size: 22px; color: var(--accent-3); }
.stat span { font-size: 11px; color: var(--ink-dim); }

/* ---------- new-cat splash ---------- */
.splash {
    position: fixed; inset: 0; z-index: 40;
    display: grid; place-items: center;
    pointer-events: none;
    background: radial-gradient(circle at 50% 45%, rgba(18, 13, 31, 0.55), rgba(18, 13, 31, 0.85));
    opacity: 0; transition: opacity 0.3s ease;
}
.splash.show { opacity: 1; }
.splash-inner { text-align: center; animation: splashPop 0.6s cubic-bezier(0.2, 1.4, 0.4, 1); }
.splash-inner span { display: block; font-size: 110px; animation: splashEmoji 0.9s ease-in-out; }
.splash-inner p {
    font-family: var(--font-head); font-size: 28px; font-weight: 600; margin: 8px 0 0;
    background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
@keyframes splashPop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes splashEmoji { 0% { transform: scale(0.4) rotate(-20deg); } 60% { transform: scale(1.15) rotate(6deg); } 100% { transform: scale(1) rotate(0); } }

/* ---------- paw burst ---------- */
.burst span {
    position: fixed; z-index: 45; pointer-events: none;
    animation: pawFly 1.3s ease-out forwards;
}
@keyframes pawFly {
    0% { transform: translate(0, 0) scale(0.4) rotate(0); opacity: 0; }
    15% { opacity: 1; }
    100% { transform: translate(var(--dx, 0), var(--dy, -180px)) scale(1.1) rotate(var(--rot, 20deg)); opacity: 0; }
}

/* ---------- name modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 50;
    display: grid; place-items: center;
    background: rgba(10, 6, 20, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0; transition: opacity 0.25s ease;
    padding: 20px;
}
.modal-backdrop.show { opacity: 1; }
.modal {
    width: 100%; max-width: 420px;
    background: linear-gradient(165deg, #241a3d, #1a1330);
    border: 1px solid var(--border);
    border-radius: 26px;
    padding: 30px 28px 24px;
    text-align: center;
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
    transform: scale(0.92) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.2, 1.2, 0.4, 1);
}
.modal-backdrop.show .modal { transform: scale(1) translateY(0); }
.modal-emoji { font-size: 60px; animation: bounce 1.4s ease-in-out infinite; }
.modal h1 { font-family: var(--font-head); font-size: 26px; margin: 10px 0 6px; }
.modal-sub { color: var(--ink-dim); font-size: 14px; margin: 0 0 20px; }
.name-row { display: flex; gap: 8px; }
.name-row input {
    flex: 1; min-width: 0;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--ink);
    padding: 12px 16px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s ease;
}
.name-row input:focus { border-color: rgba(255, 154, 61, 0.6); }
.ghost-btn {
    border: 1px solid var(--border); background: var(--card-2);
    color: var(--ink); font-size: 16px;
    border-radius: 14px; width: 48px; cursor: pointer;
    transition: transform 0.15s ease;
}
.ghost-btn:hover { transform: rotate(-8deg) scale(1.08); }
.remember {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    margin: 14px 0 18px;
    font-size: 13px; color: var(--ink-dim);
    cursor: pointer;
}
.remember input { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }
.join-btn {
    width: 100%;
    font-family: var(--font-head); font-size: 17px; font-weight: 600;
    color: #241304; border: none; cursor: pointer;
    padding: 14px;
    border-radius: 16px;
    background: linear-gradient(120deg, var(--accent), var(--accent-2));
    box-shadow: 0 10px 28px -10px rgba(255, 94, 126, 0.8);
    transition: transform 0.15s ease, filter 0.2s ease;
}
.join-btn:hover { transform: translateY(-2px); filter: brightness(1.06); }
.join-btn:active { transform: scale(0.97); }
.modal-foot { margin: 18px 0 0; font-size: 11.5px; color: var(--ink-dim); line-height: 1.5; }

/* ---------- toast ---------- */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(16px);
    z-index: 60;
    background: #2a2140; border: 1px solid var(--border);
    color: var(--ink);
    padding: 11px 20px; border-radius: 999px;
    font-size: 13.5px;
    box-shadow: var(--shadow);
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- responsive ---------- */
@media (max-width: 940px) {
    .layout { grid-template-columns: 1fr; }
    .cat-frame { min-height: 300px; max-height: 52vh; }
    .chat-list { height: 220px; }
    .sidebar { order: 3; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
