:root {
    --bg-color: #f7f7f7;
    --card-bg: #ffffff;
    --text-main: #111111;
    --text-muted: #666666;
    --border-color: #eaeaea;
    --btn-bg: #e5e5e5;
    --btn-hover: #d4d4d4;
    --underline: #cc0000;
    --discord-blue: #5865F2;
    --discord-hover: #4752C4;
    --border-radius: 8px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* viewport safety */
html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 760px;
    display: flex;
    flex-direction: column;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main);
    border-bottom: 2px solid var(--underline);
    padding-bottom: 3px;
    display: inline-block;
}

.actions-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

button {
    background-color: var(--btn-bg);
    color: var(--text-main);
    border: none;
    padding: 0.4rem 1.2rem;
    border-radius: 9999px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

button:hover {
    background-color: var(--btn-hover);
}

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

#discordBtn {
    background-color: var(--discord-blue);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0.4rem 1rem;
}

#discordBtn:hover {
    background-color: var(--discord-hover);
}

#discordBtn img {
    width: 18px;
    height: 18px;
    object-fit: contain;
    filter: none !important;
    opacity: 1 !important;
}

.refresh-icon {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

.leaderboard {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    flex-grow: 1;
}

.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.2rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1.2rem;
    position: relative;
}

.rank {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-main);
    min-width: 45px;
    text-align: left;
    letter-spacing: -1px;
}

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    background-color: var(--border-color);
    flex-shrink: 0;
}

.channel-info {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.channel-meta {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.channel-name {
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-created {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stats-container {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 80px;
}

.stat-value {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.5px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-left: auto;
    flex-shrink: 0;
}

.visit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.visit-btn img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: none !important;
    opacity: 1 !important;
}

.error-message {
    background-color: #fce8e8;
    color: #a31010;
    border: 1px solid #f8caca;
    padding: 1rem;
    border-radius: var(--border-radius);
    text-align: center;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: none;
}

.loading-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.footer-container {
    margin-top: 3rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding-bottom: 1rem;

    cursor: pointer;
    user-select: none;
}

/* =========================================================
   ✅ FIX: floating knox sizing + better boundary physics
========================================================= */

.knox-float {
    position: fixed;

    /* ↓↓↓ SIZE FIX (this is your main request) ↓↓↓ */
    width: 60px;
    height: 60px;

    z-index: 10000;
    cursor: grab;
    user-select: none;

    animation: vibrate 0.12s infinite;
}

/* slightly better feel for edge bouncing */
@keyframes vibrate {
    0% { transform: translate(0,0); }
    25% { transform: translate(2px,-2px); }
    50% { transform: translate(-2px,2px); }
    75% { transform: translate(2px,2px); }
    100% { transform: translate(0,0); }
}

/* mobile */
@media (max-width: 650px) {
    .stats-container {
        gap: 1rem;
    }
    .stat {
        min-width: 70px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 1rem 0.5rem;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 1.5rem;
    }

    .card {
        flex-wrap: wrap;
        padding: 1rem;
        gap: 0.8rem;
    }

    .rank {
        font-size: 1.6rem;
        min-width: 32px;
    }

    .channel-info {
        width: calc(100% - 110px);
    }

    .action-buttons {
        position: absolute;
        top: 1rem;
        right: 1rem;
        margin-left: 0;
    }

    .stats-container {
        width: 100%;
        justify-content: flex-start;
        gap: 1.5rem;
        padding-top: 0.8rem;
        border-top: 1px solid var(--border-color);
    }
}