/* Theme Variables */
:root {
    /* Dark Theme (default) */
    --bg-primary: linear-gradient(135deg, #1e1e2e 0%, #2d2d44 100%);
    --bg-secondary: rgba(255, 255, 255, 0.05);
    --bg-tertiary: rgba(255, 255, 255, 0.08);
    --dropdown-bg: #252537;
    --text-primary: #e0e0e0;
    --text-secondary: #667eea;
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --accent-tertiary: #e0e0e0;
    --border-color: rgba(255, 255, 255, 0.1);
    --border-color-light: rgba(255, 255, 255, 0.2);
    --hover-bg: rgba(102, 126, 234, 0.2);
    --table-even-bg: rgba(255, 255, 255, 0.02);
    --box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    --thead-sticky-bg: #2d325a;
}

body.light-theme {
    /* Light Theme */
    --bg-primary: linear-gradient(135deg, #ffffff 0%, #f8f8ff 100%);
    --bg-secondary: rgba(102, 126, 234, 0.08);
    --bg-tertiary: rgba(102, 126, 234, 0.12);
    --dropdown-bg: #f0f0ff;
    --text-primary: #1a1a1a;
    --text-secondary: #5a5fce;
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --accent-tertiary: #1a1a1a;
    --border-color: rgba(102, 126, 234, 0.3);
    --border-color-light: rgba(102, 126, 234, 0.4);
    --hover-bg: rgba(102, 126, 234, 0.1);
    --table-even-bg: rgba(0, 0, 0, 0.02);
    --box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    --thead-sticky-bg: #d4d7f5;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: left;
    margin-bottom: 15px;
    padding: 8px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    box-shadow: var(--box-shadow);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #ffffff;
}

header h1 {
    font-size: 1.4em;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    color: #ffffff;
    flex: 1;
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.refresh-btn {
    background: #fff;
    color: #667eea;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.refresh-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Theme Toggle Button */
.theme-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.theme-toggle span {
    font-size: 1em;
}

.last-update {
    font-size: 0.8em;
    opacity: 0.95;
    color: #ffffff;
    display: block;
    margin-top: 3px;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.tab-btn {
    padding: 12px 20px;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    color: var(--text-primary);
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

.tab-btn:hover {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
}

.tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #764ba2;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    color: #fff;
}

.content {
    width: 100%;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tab-content h2 {
    font-size: 2em;
    margin-bottom: 30px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.chart-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.chart-box {
    background: var(--bg-tertiary);
    border-radius: 10px;
    padding: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    box-shadow: var(--box-shadow);
    transition: all 0.3s ease;
}

.chart-box:hover {
    background: var(--bg-secondary);
    border-color: rgba(102, 126, 234, 0.5);
    transform: translateY(-5px);
}

.chart-box h3 {
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-size: 1.2em;
}

.chart-box canvas {
    min-height: 300px;
}


/* Gold + Watchtime: bar/line chart gets 2/3, pie gets 1/3 */
#gold-tab .chart-container,
#watchtime-tab .chart-container {
    grid-template-columns: 2fr 1fr;
}

/* Let Chart.js control the canvas; just centre the box contents */
#gold-tab .chart-container > div:last-child,
#watchtime-tab .chart-container > div:last-child {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.leaderboard-table {
    background: var(--bg-tertiary);
    border-radius: 10px;
    padding: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    overflow-x: auto;
}

.leaderboard-table h3 {
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-size: 1.2em;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table thead {
    background: rgba(102, 126, 234, 0.3);
}

table th {
    padding: 15px;
    text-align: left;
    font-weight: bold;
    color: var(--text-secondary);
    border-bottom: 2px solid rgba(102, 126, 234, 0.5);
}

table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

table tbody tr {
    transition: all 0.3s ease;
}

table tbody tr:hover {
    background: var(--hover-bg);
}

table tbody tr:nth-child(even) {
    background: var(--table-even-bg);
}

/* Profile Picture Styling */
.player-cell {
    display: flex;
    align-items: center;
    gap: 12px !important;
    padding: 8px 12px !important;
}

.profile-pic {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(102, 126, 234, 0.5);
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.player-cell:hover .profile-pic {
    transform: scale(1.1);
    border-color: rgba(102, 126, 234, 1);
}

.player-cell span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

/* Podium entrance animation */
@keyframes podiumRise {
    from {
        opacity: 0;
        transform: translateY(60px) scale(0.85);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Podium Section */
.podium-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 28px 20px 0;
    margin-bottom: 24px;
    overflow: hidden;
}

.podium-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 10px;
    max-width: 520px;
    margin: 0 auto;
}

.podium-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex: 1;
    max-width: 160px;
    opacity: 0; /* hidden until .podium-ready triggers */
}

/* Triggered by JS — 3rd → 2nd → 1st reveal order */
.podium-section.podium-ready .podium-slot.third-place {
    animation: podiumRise 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: 0.05s;
}

.podium-section.podium-ready .podium-slot.second-place {
    animation: podiumRise 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: 0.25s;
}

.podium-section.podium-ready .podium-slot.first-place {
    animation: podiumRise 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: 0.48s;
}

.podium-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    background: var(--bg);
}

.podium-slot.first-place .podium-avatar {
    width: 68px;
    height: 68px;
    border-color: #ffd700;
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.25);
}

.podium-slot.second-place .podium-avatar { border-color: #c0c0c0; }
.podium-slot.third-place .podium-avatar  { border-color: #cd7f32; }

.podium-medal {
    font-size: 1.3em;
    line-height: 1;
    margin-top: 2px;
}

.podium-name {
    font-size: 0.82em;
    font-weight: 600;
    color: var(--text);
    text-align: center;
    word-break: break-word;
    max-width: 100%;
    line-height: 1.2;
}

.podium-score {
    font-size: 0.75em;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg);
    border-radius: 20px;
    padding: 2px 10px;
    margin-bottom: 8px;
}

.podium-step {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3em;
    font-weight: 700;
    border-radius: 8px 8px 0 0;
}

.podium-slot.first-place { order: 2; }
.podium-slot.second-place { order: 1; }
.podium-slot.third-place  { order: 3; }

.podium-slot.first-place .podium-step {
    height: 80px;
    background: linear-gradient(180deg, rgba(255, 215, 0, 0.28) 0%, rgba(255, 165, 0, 0.15) 100%);
    border-top: 2px solid rgba(255, 215, 0, 0.55);
    color: #ffd700;
}

.podium-slot.second-place .podium-step {
    height: 55px;
    background: linear-gradient(180deg, rgba(192, 192, 192, 0.25) 0%, rgba(169, 169, 169, 0.12) 100%);
    border-top: 2px solid rgba(192, 192, 192, 0.45);
    color: #b0b0b0;
}

.podium-slot.third-place .podium-step {
    height: 35px;
    background: linear-gradient(180deg, rgba(205, 127, 50, 0.25) 0%, rgba(184, 115, 51, 0.12) 100%);
    border-top: 2px solid rgba(205, 127, 50, 0.45);
    color: #cd7f32;
}

/* Player Stats Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.85);
    animation: fadeIn 0.3s ease;
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: linear-gradient(135deg, rgba(30, 30, 46, 0.95) 0%, rgba(45, 45, 68, 0.95) 100%);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    max-width: 900px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 2px solid rgba(102, 126, 234, 0.6);
    position: relative;
}

body.light-theme .modal-content {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 248, 255, 0.98) 100%);
    border: 2px solid rgba(102, 126, 234, 0.7);
}

.close-modal {
    color: #e0e0e0;
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-modal:hover {
    color: #fff;
    text-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

body.light-theme .close-modal {
    color: #333333;
}

body.light-theme .close-modal:hover {
    color: #667eea;
}

.player-header {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid rgba(102, 126, 234, 0.6);
}

body.light-theme .player-header {
    border-bottom: 2px solid rgba(102, 126, 234, 0.7);
}

.player-modal-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #667eea;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.player-header h2 {
    font-size: 2.5em;
    color: #e0e0e0;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

body.light-theme .player-header h2 {
    color: #333333;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
}

.stats-category {
    background: rgba(255, 255, 255, 0.08);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid rgba(102, 126, 234, 0.5);
    transition: all 0.3s ease;
}

body.light-theme .stats-category {
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.6);
}

.stats-category:hover {
    background: rgba(102, 126, 234, 0.1);
    border-color: rgba(102, 126, 234, 0.5);
    transform: translateY(-3px);
}

.stats-category h3 {
    color: #667eea;
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.3em;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(102, 126, 234, 0.5);
}

body.light-theme .stats-category h3 {
    color: #5a5fce;
    border-bottom: 2px solid rgba(102, 126, 234, 0.6);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
}

body.light-theme .stat-row {
    border-bottom: 1px solid rgba(102, 126, 234, 0.2);
    color: #333333;
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row span {
    font-weight: 500;
    opacity: 0.95;
}

.stat-row strong {
    color: #667eea;
    font-weight: bold;
    font-size: 1.1em;
}

/* Make table rows clickable */
table tbody tr {
    cursor: pointer;
}

table tbody tr.clickable:hover {
    background: var(--hover-bg) !important;
}

/* ===== HISTORY TAB STYLES ===== */

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}
.history-header h2 { margin: 0 0 4px; }
.history-meta {
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.history-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

/* Shared dropdown */
.search-box-wrapper {
    position: relative;
}
.hidden { display: none !important; }

.player-dropdown-list {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--dropdown-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    max-height: 260px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

/* Never show broken image icon */
.history-avatar[src=""], .history-avatar:not([src]) { display: none; }
.player-dropdown-list.active { display: block; }
.player-option {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.12s;
    border-bottom: 1px solid var(--border-color);
}
.player-option:last-child { border-bottom: none; }
.player-option:hover, .player-option.active {
    background: var(--hover-bg);
    color: #667eea;
}
.player-option.no-results {
    color: var(--text-secondary);
    cursor: default;
    font-style: italic;
}

/* Search */
.history-search-section {
    margin-bottom: 24px;
}
.history-search-box {
    max-width: 500px;
    margin: 0 auto;
    position: relative;
}
.history-player-search {
    width: 100%;
    box-sizing: border-box;
    padding: 14px 20px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: border-color 0.2s;
}
.history-player-search:focus {
    outline: none;
    border-color: #667eea;
}

/* Player card */
.history-player-card {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px 24px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.history-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #667eea;
    flex-shrink: 0;
}
.history-player-info {
    flex: 1;
    min-width: 160px;
}
.history-player-name {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 10px;
}
.history-rank-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.history-rank-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color 0.15s;
}
.history-rank-pill:hover { border-color: #667eea; }
.pill-cat {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.pill-rank { color: #667eea; font-weight: 700; }

/* Compare section */
.history-compare-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 220px;
}
.history-compare-search {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 14px;
    font-size: 0.85rem;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transition: border-color 0.2s, border-style 0.2s;
}
.history-compare-search:focus {
    outline: none;
    border-color: #667eea;
    border-style: solid;
}
.history-compare-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.history-compare-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 0.8rem;
}
.compare-remove {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-size: 0.95rem;
    line-height: 1;
}

/* Category tabs */
.history-cat-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.history-cat-tab {
    padding: 8px 18px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.15s;
}
.history-cat-tab:hover { border-color: #667eea; color: #667eea; }
.history-cat-tab.active { border-color: #667eea; background: #667eea; color: #fff; }

/* Chart card */
.history-chart-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px 24px;
    margin-bottom: 20px;
}
.history-chart-card h3 {
    margin: 0 0 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.history-chart-wrap {
    position: relative;
    height: 280px;
}

/* Table card */
.history-table-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px 24px;
    margin-bottom: 24px;
}
.history-table-card h3 {
    margin: 0 0 14px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.history-table-scroll {
    max-height: 300px;
    overflow-y: auto;
}
.history-data-table {
    width: 100%;
    border-collapse: collapse;
}
.history-data-table thead th {
    position: sticky;
    top: 0;
    background: var(--bg-tertiary);
    padding: 10px 14px;
    text-align: left;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
}
.history-data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}
.history-data-table tbody tr:hover { background: var(--hover-bg); }
.rank-up   { color: #4caf50; font-weight: 600; }
.rank-down { color: #f44336; font-weight: 600; }
.rank-neutral { color: var(--text-secondary); }

/* Empty state */
.history-empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}
.history-empty-icon { font-size: 4rem; margin-bottom: 16px; }
.history-empty-sub  { font-size: 0.85rem; opacity: 0.65; margin-top: 6px; }


/* ===== BOT CONTROL STYLES ===== */

.bot-status-indicator {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: center;
    justify-content: space-between;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: fit-content;
}

.status-circle {
    font-size: 16px;
    animation: pulse 2s infinite;
}

.status-text {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}

.live-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin-left: 8px;
    vertical-align: middle;
    transition: background 0.3s, color 0.3s;
}

.live-badge--live {
    background: #1db954;
    color: #fff;
    animation: livePulse 2s ease-in-out infinite;
}

.live-badge--offline {
    background: #c0392b;
    color: #fff;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}

.status-value {
    color: var(--accent-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    font-size: 13px;
    word-break: break-all;
    font-weight: 500;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-secondary, .btn-danger {
    padding: 10px 20px;
    border: none;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-secondary {
    background: var(--accent-primary);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#botReconnectBtn {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
}

#botReconnectBtn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.45);
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

.btn-switch {
    padding: 10px 20px;
    border: none;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    background: #27ae60;
    color: white;
}

.btn-switch:hover {
    background: #219a52;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.4);
}

@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

.btn-loading {
    opacity: 0.75;
    pointer-events: none;
    cursor: not-allowed !important;
}

.btn-loading::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.65s linear infinite;
    margin-right: 7px;
    vertical-align: middle;
}

.btn-secondary-outline {
    padding: 10px 20px;
    border: 2px solid var(--accent-primary);
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    color: var(--accent-primary);
}

.btn-secondary-outline:hover {
    background: var(--accent-primary);
    color: white;
}

/* Switch Channel Modal */
.switch-channel-modal-content {
    max-width: 420px;
    width: 90%;
}

.switch-channel-modal-content h3 {
    margin: 0 0 8px 0;
    font-size: 20px;
}

.switch-channel-hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 20px 0;
    line-height: 1.5;
}

.switch-channel-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.switch-channel-form label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.switch-channel-input {
    padding: 12px 14px;
    border-radius: 10px;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.switch-channel-input:focus {
    border-color: var(--accent-primary);
}

.switch-channel-error {
    font-size: 12px;
    color: #e74c3c;
    min-height: 16px;
}

.switch-channel-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

/* Settings button */
.btn-settings {
    padding: 10px 20px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-settings:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-1px);
}

/* Bot Settings Modal */
.settings-modal-content {
    max-width: 460px;
    width: 90%;
}

.settings-modal-content h3 {
    margin: 0 0 8px 0;
    font-size: 20px;
}

.settings-hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-form label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: -4px;
}

.settings-input {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
}

.settings-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.settings-token-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.settings-token-row .settings-input {
    flex: 1;
}

.btn-icon {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

.btn-icon:hover {
    background: var(--hover-bg);
}

.settings-token-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin: -4px 0 0 0;
}

.settings-status {
    font-size: 13px;
    min-height: 18px;
}

.settings-status.success { color: #4caf50; }
.settings-status.error   { color: #e74c3c; }

.settings-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

.bot-control-container {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 25px;
    padding: 0;
}

/* ===== LIVE CHAT STATS PANEL ===== */
.chat-stats-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px 24px;
    margin-top: 20px;
}

.chat-stats-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.chat-stats-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.chat-stats-session {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 3px 10px;
    border-radius: 20px;
}

.chat-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.chat-stat-card {
    background: rgba(102, 126, 234, 0.08);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 12px;
    padding: 14px 16px;
    text-align: center;
}

.chat-stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--accent-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.chat-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    font-weight: 600;
}

.chat-stats-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.chat-stats-col-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.chat-stats-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 162px; /* ~5 rows at ~30px each */
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-primary) transparent;
    padding-right: 4px;
}

.chat-stats-list::-webkit-scrollbar {
    width: 4px;
}

.chat-stats-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-stats-list::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 2px;
}

.chatter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.chatter-rank {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.chatter-name {
    flex: 1;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chatter-bar-wrap {
    flex: 1;
    height: 5px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.chatter-bar {
    height: 100%;
    background: var(--accent-primary);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.chatter-count {
    font-size: 11px;
    color: var(--text-secondary);
    min-width: 24px;
    text-align: right;
    flex-shrink: 0;
}

.top-emotes-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 162px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-primary) transparent;
    padding-right: 4px;
}

.top-emotes-container::-webkit-scrollbar { width: 4px; }
.top-emotes-container::-webkit-scrollbar-track { background: transparent; }
.top-emotes-container::-webkit-scrollbar-thumb { background: var(--accent-primary); border-radius: 2px; }

.top-emote-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 6px;
    background: rgba(102,126,234,0.08);
}

.top-emote-name {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
}

.top-emote-count {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-primary);
}

.hot-words-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-content: flex-start;
}

.hot-word-tag {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid;
    transition: transform 0.2s;
    cursor: default;
}

.hot-word-tag:hover { transform: scale(1.05); }
.hot-word-tag.size-1 { font-size: 11px; opacity: 0.6; background: rgba(102,126,234,0.08); border-color: rgba(102,126,234,0.2); color: var(--text-secondary); }
.hot-word-tag.size-2 { font-size: 12px; opacity: 0.75; background: rgba(102,126,234,0.12); border-color: rgba(102,126,234,0.3); color: var(--accent-primary); }
.hot-word-tag.size-3 { font-size: 13px; background: rgba(102,126,234,0.18); border-color: rgba(102,126,234,0.4); color: var(--accent-primary); }
.hot-word-tag.size-4 { font-size: 14px; background: rgba(102,126,234,0.25); border-color: rgba(102,126,234,0.5); color: var(--accent-primary); font-weight: 700; }
.hot-word-tag.size-5 { font-size: 15px; background: rgba(102,126,234,0.35); border-color: var(--accent-primary); color: white; font-weight: 800; }

.chat-stats-empty {
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
}

.bot-chat-section {
    grid-column: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bot-chat-section h3 {
    margin: 0 0 8px 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.chat-channel-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 400;
    color: var(--text-secondary);
}

.simple-chat-display {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    overflow-y: auto;
    font-size: 0.9em;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 400px;
    max-height: 400px;
    min-height: 400px;
}

/* Chat scrollbar styling */
.simple-chat-display::-webkit-scrollbar {
    width: 8px;
}

.simple-chat-display::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.simple-chat-display::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 4px;
}

.simple-chat-display::-webkit-scrollbar-thumb:hover {
    background: var(--accent-secondary);
}

.chat-message {
    padding: 6px 8px;
    background: rgba(102, 126, 234, 0.1);
    border-left: 3px solid #667eea;
    border-radius: 4px;
    word-wrap: break-word;
    line-height: 1.4;
}

.twitch-emote {
    display: inline-block;
    vertical-align: middle;
    height: 28px;
    width: auto;
    margin: 0 1px;
}

.chat-status {
    padding: 8px 10px;
    background: rgba(120, 120, 120, 0.15);
    border-left: 3px solid #888888;
    border-radius: 4px;
    text-align: center;
    color: #999999;
    font-size: 0.85em;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    letter-spacing: 0.3px;
    font-weight: 500;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bot-controls-section {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.bot-send-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: 8px;
}

.bot-send-panel h3 {
    margin: 0 0 8px 0;
    color: var(--text-primary);
}

.bot-message-textarea {
    width: 100%;
    padding: 10px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-family: inherit;
    font-size: 0.95em;
    resize: vertical;
    text-align: left;
}

.bot-message-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px rgba(102, 126, 234, 0.3);
}

.bot-message-textarea:disabled {
    background: rgba(255, 255, 255, 0.03);
    color: #888;
    cursor: not-allowed;
    opacity: 0.6;
}

.send-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    justify-content: space-between;
    align-items: center;
}

.btn-primary {
    padding: 10px 20px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
    flex: 1;
}

.btn-primary:hover {
    background: var(--accent-secondary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: #999;
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-primary:disabled:hover {
    background: #999;
    transform: none;
    box-shadow: none;
}

.char-count {
    color: var(--text-secondary);
    font-size: 0.85em;
}

.quick-commands {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: 8px;
}

.quick-commands h3 {
    margin-top: 0;
    color: var(--text-primary);
}

.command-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.quick-cmd {
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9em;
}

.quick-cmd:hover {
    background: var(--hover-bg);
    border-color: var(--accent-primary);
}

.bot-history-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.bot-history-panel h3 {
    margin: 0 0 8px 0;
    color: var(--text-primary);
}

.bot-control-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    height: 200px;
    max-height: 200px;
    min-height: 200px;
}

/* Scrollbar styling */
.bot-control-actions::-webkit-scrollbar {
    width: 8px;
}

.bot-control-actions::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.bot-control-actions::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 4px;
}

.bot-control-actions::-webkit-scrollbar-thumb:hover {
    background: var(--accent-secondary);
}

.bot-control-actions .empty-state {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 20px;
}

.bot-control-action-item {
    display: flex;
    gap: 8px;
    padding: 8px;
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent-primary);
    border-radius: 3px;
    font-size: 0.85em;
}

.bot-action-time {
    color: var(--text-secondary);
    font-weight: bold;
    min-width: 50px;
}

.bot-action-msg {
    color: var(--text-primary);
    flex: 1;
    word-break: break-word;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }

    .chart-container {
        grid-template-columns: 1fr;
    }

    .tabs {
        flex-direction: column;
    }

    .tab-btn {
        width: 100%;
        text-align: center;
    }

    table {
        font-size: 0.9em;
    }

    table th,
    table td {
        padding: 8px 10px;
    }

    .modal-content {
        padding: 20px;
        width: 95%;
        border-radius: 10px;
    }

    .player-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .player-modal-avatar {
        width: 80px;
        height: 80px;
    }

    .player-header h2 {
        font-size: 1.8em;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .history-controls {
        flex-direction: column;
        gap: 15px;
    }

    .control-group {
        min-width: auto;
        width: 100%;
    }

    .control-group select,
    .btn-secondary {
        width: 100%;
    }

    .history-stats {
        grid-template-columns: 1fr;
    }

    .history-mode-toggle {
        flex-direction: row;
        gap: 8px;
    }

    .mode-btn {
        flex: 1;
        padding: 10px 12px;
        font-size: 0.9em;
    }

    .comparison-controls {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    .selected-players {
        padding: 15px;
    }

    .player-tags {
        gap: 8px;
    }

    .player-tag {
        padding: 6px 12px;
        font-size: 0.85em;
    }

    .chart-box.full-width {
        grid-column: 1;
    }

    #comparisonTable {
        font-size: 0.85em;
    }

    #comparisonTable th,
    #comparisonTable td {
        padding: 8px 6px;
    }

    .bot-control-container {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 15px;
    }

    .bot-chat-section {
        grid-column: 1;
        min-height: 300px;
    }

    .bot-controls-section {
        grid-column: 1;
    }

    .quick-commands {
        padding: 15px;
    }

    .command-buttons {
        grid-template-columns: 1fr 1fr;
    }

    .bot-history-panel {
        min-height: 200px;
    }

    .bot-control-action-item {
        font-size: 0.75em;
        padding: 6px;
    }
}
