:root {
    --bg: #060b14;
    --sidebar-bg: linear-gradient(180deg, #11182b 0%, #0b1020 100%);
    --border: #1b2440;
    --text-main: #f4f7ff;
    --text-soft: #7f90b8;
    --green: #18f08b;
    --green-2: #14c872;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text-main);
}

body {
    min-height: 100vh;
}

button,
input {
    font: inherit;
}

select {
    font: inherit;
}

img {
    display: block;
    max-width: 100%;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    background:
        radial-gradient(circle at top left, rgba(24, 240, 139, 0.06), transparent 18%),
        linear-gradient(180deg, #050a12 0%, #060b14 100%);
}

.sidebar {
    width: 230px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 18px 8px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 4px 10px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    margin-bottom: 12px;
}

.brand-name {
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    color: #ffffff;
    line-height: 1.2;
}

.brand-name span {
    color: var(--green);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: #95a4cb;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    text-align: left;
    font-weight: 600;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: #dfe7ff;
}

/* The Top Wins entry is a real link to the public page, not a tab switch, so
   it never takes the active state the tab buttons use. */
.nav-item-link {
    text-decoration: none;
    box-sizing: border-box;
}
.nav-item-link .nav-dot { background: rgba(149, 164, 203, 0.35); }
.nav-item-link:hover .nav-dot { background: rgba(24, 240, 139, 0.6); }

.nav-item.active {
    background: linear-gradient(90deg, rgba(24, 240, 139, 0.14) 0%, rgba(24, 240, 139, 0.06) 100%);
    border-color: rgba(24, 240, 139, 0.4);
    color: #ffffff;
}

.nav-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.9;
}

.sidebar-footer {
    margin-top: auto;
    padding: 14px 10px 4px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.start-stop-btn {
    border: 0;
    border-radius: 8px;
    background: linear-gradient(180deg, var(--green) 0%, var(--green-2) 100%);
    color: #03110a;
    font-weight: 800;
    padding: 12px 18px;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(24, 240, 139, 0.18);
}

.start-stop-btn.running {
    background: linear-gradient(180deg, #ff8a8a 0%, #ff5858 100%);
    color: #180404;
}

.run-status {
    color: var(--text-soft);
    font-size: 0.92rem;
    font-weight: 600;
}

.main-content {
    flex: 1;
    padding: 22px 28px 40px;
}

.page-section {
    display: none;
    max-width: 1600px;
}

.page-section.active {
    display: block;
}

.page-title {
    margin: 0 0 22px;
    font-size: 2rem;
    font-weight: 800;
    color: #ffffff;
}

.profile-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.content-card {
    background: linear-gradient(180deg, rgba(15, 21, 38, 0.98) 0%, rgba(10, 15, 29, 0.98) 100%);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 18px;
}

.card-header {
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.card-header-no-border {
    border-bottom: none;
    padding: 0;
}

.card-header h2 {
    margin: 0 0 10px;
    font-size: 1.1rem;
    font-weight: 800;
    color: #ffffff;
}

.card-header p {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.6;
    font-size: 0.95rem;
}

.card-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.field-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-block label {
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: #d8e0f8;
}

.field-block.twitch label {
    color: #c7b0ff;
}

.field-block.kick label {
    color: #90ff84;
}

.field-block.hypebet label {
    color: #51f8aa;
}

.input-wrapper {
    position: relative;
}

.input-wrapper input {
    width: 100%;
    height: 46px;
    border-radius: 8px;
    border: 1px solid #18233e;
    background: #070d19;
    color: #ffffff;
    padding: 0 14px 0 40px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-wrapper input::placeholder {
    color: #516282;
}

.input-wrapper input:focus {
    border-color: rgba(24, 240, 139, 0.5);
    box-shadow: 0 0 0 3px rgba(24, 240, 139, 0.08);
}

.input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    font-weight: 800;
    opacity: 0.9;
}

.twitch-icon {
    color: #a970ff;
}

.kick-icon {
    color: #54fc45;
}

.hype-icon {
    color: #18f08b;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.save-btn {
    border: 0;
    border-radius: 8px;
    background: linear-gradient(180deg, var(--green) 0%, var(--green-2) 100%);
    color: #03110a;
    font-weight: 800;
    padding: 12px 20px;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(24, 240, 139, 0.18);
}

.feedback {
    font-weight: 600;
    font-size: 0.95rem;
}

.feedback.success {
    color: #79ffb7;
}

.feedback.error {
    color: #ff8d8d;
}

/* ── Twitch Bot Setup ──────────────────────────────────────────────────── */

.setup-details {
    margin-bottom: 16px;
}

.setup-summary {
    cursor: pointer;
    color: var(--green);
    font-weight: 700;
    font-size: 0.9rem;
    padding: 8px 0;
    user-select: none;
}

.setup-summary:hover {
    opacity: 0.85;
}

.setup-steps {
    margin-top: 10px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--text-soft);
}

.setup-steps p {
    margin: 6px 0;
}

.setup-steps strong {
    color: var(--text-main);
}

.setup-steps code {
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.84rem;
    color: var(--green);
    word-break: break-all;
}

.setup-steps a {
    color: var(--green);
    text-decoration: none;
    font-weight: 600;
}

.setup-steps a:hover {
    text-decoration: underline;
}

.setup-hint {
    font-size: 0.82rem;
    color: #e8a640;
    font-style: italic;
    display: inline-block;
    margin-top: 2px;
}

.copy-inline-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-soft);
    font-size: 0.76rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 6px;
    vertical-align: middle;
}

.copy-inline-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.twitch-bot-status-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 4px;
    margin-bottom: 8px;
}

.bot-status {
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bot-status strong {
    color: #a970ff;
}

.bot-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.bot-status-dot.connected {
    background: var(--green);
    box-shadow: 0 0 6px rgba(24, 240, 139, 0.5);
}

.bot-status-dot.disconnected {
    background: #ff8d8d;
    box-shadow: 0 0 6px rgba(255, 141, 141, 0.3);
}

.btn-twitch-connect {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #a970ff;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.2s;
}

.btn-twitch-connect:hover {
    opacity: 0.85;
}

.btn-twitch-connect.btn-reconnect {
    background: rgba(169, 112, 255, 0.15);
    color: #a970ff;
    border: 1px solid rgba(169, 112, 255, 0.3);
    font-size: 0.82rem;
    padding: 6px 12px;
}

.btn-twitch-disconnect {
    background: rgba(255, 141, 141, 0.1);
    color: #ff8d8d;
    border: 1px solid rgba(255, 141, 141, 0.2);
    font-weight: 700;
    font-size: 0.82rem;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-twitch-disconnect:hover {
    opacity: 0.85;
}

.relay-toggle-block {
    margin-top: 4px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-switch {
    width: 40px;
    height: 22px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 11px;
    position: relative;
    transition: background 0.25s;
    flex-shrink: 0;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 0.25s;
}

.toggle-label input:checked + .toggle-switch {
    background: var(--green);
}

.toggle-label input:checked + .toggle-switch::after {
    transform: translateX(18px);
}

.toggle-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.session-layout {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 18px;
    align-items: center;
    padding: 20px;
}

.session-media-side {
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-wrap {
    width: 92px;
    height: 92px;
}

.host-avatar-image {
    width: 92px;
    height: 92px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.avatar-empty {
    color: var(--text-soft);
    font-size: 0.9rem;
    text-align: center;
}

.session-info-side {
    min-width: 0;
}

.section-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 0 20px;
}

.room-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: 14px;
}

.room-grid-compact {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    width: 100%;
}

.room-stat {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 14px;
}

.room-stat-full {
    grid-column: 1 / -1;
}

.room-stat-label {
    color: var(--text-soft);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
    font-weight: 700;
}

.room-stat-value {
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    word-break: break-word;
}

.room-stat-value.small {
    font-size: 0.88rem;
}

.game-layout {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 18px;
    align-items: start;
}

.game-thumb-side {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.game-image-wrap {
    width: 140px;
    height: 190px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-image {
    width: 140px;
    height: 190px;
    object-fit: contain;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
}

.game-image-empty {
    color: var(--text-soft);
    font-size: 0.9rem;
    text-align: center;
}

.room-message {
    margin-top: 16px;
    color: var(--text-soft);
    font-size: 0.95rem;
    font-weight: 600;
}

.room-message.error {
    color: #ff8d8d;
}

.room-message.success {
    color: #79ffb7;
}

.hidden {
    display: none !important;
}

.reset-btn {
    background: #2a3142;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #ffffff;
    margin-left: 10px;
}

.reset-btn:hover {
    background: #394258;
}

@media (max-width: 820px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .main-content {
        padding: 18px;
    }

    .room-grid,
    .room-grid-compact {
        grid-template-columns: 1fr;
    }

    .room-stat-full {
        grid-column: auto;
    }

    .session-layout,
    .game-layout {
        grid-template-columns: 1fr;
    }

    .session-media-side,
    .game-thumb-side {
        justify-content: flex-start;
    }

    .section-divider {
        margin: 0 20px;
    }
}

.select-wrapper select {
    width: 100%;
    height: 46px;
    border-radius: 8px;
    border: 1px solid #18233e;
    background: #070d19;
    color: #ffffff;
    padding: 0 14px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    appearance: none;
}

.select-wrapper select:focus {
    border-color: rgba(24, 240, 139, 0.5);
    box-shadow: 0 0 0 3px rgba(24, 240, 139, 0.08);
}

.secondary-btn {
    background: #20283b;
    color: #ffffff;
    box-shadow: none;
}

.secondary-btn:hover {
    background: #283146;
}

.danger-btn {
    background: linear-gradient(180deg, #ff8a8a 0%, #ff5858 100%);
    color: #210707;
    box-shadow: none;
}

.reset-btn {
    background: #2a3142;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #ffffff;
    box-shadow: none;
}

.reset-btn:hover {
    background: #394258;
}

.overlay-toolbar-row,
.overlay-form-grid,
.overlay-check-grid,
.overlay-url-list {
    display: grid;
    gap: 16px;
}

.overlay-toolbar-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.overlay-form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.overlay-check-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 6px;
}

.overlay-font-card {
    margin-bottom: 4px;
}

.font-selector-row {
    display: flex;
    align-items: flex-end;
    gap: 24px;
}

.font-selector-row .field-block {
    min-width: 250px;
}

.font-preview {
    flex: 1;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 1rem;
    line-height: 1.5;
    transition: font-family 0.2s;
}

.overlay-split-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.15fr);
    gap: 22px;
    align-items: stretch;
}

.overlay-split-grid > .content-card {
    height: 100%;
}

/* ── Slot Tracker ─────────────────────────────────────────────────────── */

.tracker-stats-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.tracker-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.tracker-stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}

.tracker-stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.tracker-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.tracker-stat-value.positive {
    color: #18f08b;
}

.tracker-stat-value.negative {
    color: #ff5c5c;
}

/* ── Overlay Mode Selector ─── */

.overlay-mode-selector {
    display: flex;
    gap: 8px;
}

.overlay-mode-btn {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-soft);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.overlay-mode-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.overlay-mode-btn.active {
    background: rgba(24, 240, 139, 0.1);
    border-color: var(--green);
    color: var(--green);
}

.overlay-mode-panel {
    display: none;
}

.overlay-mode-panel.active {
    display: contents;
}

#overlay-tab .content-card {
    width: 100%;
}

#overlay-tab .overlay-preview-stage {
    min-height: 420px;
}

#overlay-tab .overlay-preview-host {
    width: 100%;
}

.overlay-url-sections {
    display: grid;
    gap: 22px;
}

.overlay-url-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.overlay-url-section-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    color: #ffffff;
}

.overlay-preview-stage-players .overlay-preview-host {
    justify-content: flex-start;
}

.checkbox-tile {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #0b1120;
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #d8e0f8;
    cursor: pointer;
    font-weight: 600;
}

.checkbox-tile input {
    width: 16px;
    height: 16px;
    accent-color: #18f08b;
}

.overlay-preview-stage {
    min-height: 300px;
    border-radius: 14px;
    border: 1px dashed rgba(255, 255, 255, 0.1);
    background:
        linear-gradient(180deg, rgba(8, 12, 22, 0.94) 0%, rgba(13, 20, 34, 0.94) 100%),
        radial-gradient(circle at top left, rgba(24, 240, 139, 0.08), transparent 40%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 24px;
}

.overlay-preview-host {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.overlay-url-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.overlay-url-input {
    font-size: 0.88rem;
}

@media (max-width: 1100px) {
    .overlay-form-grid,
    .overlay-check-grid,
    .overlay-url-list,
    .overlay-toolbar-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .overlay-split-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .overlay-form-grid,
    .overlay-check-grid,
    .overlay-url-list,
    .overlay-toolbar-row {
        grid-template-columns: 1fr;
    }
}

.overlay-url-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.overlay-url-row .input-wrapper {
    flex: 1;
}

.copy-url-btn {
    flex: 0 0 auto;
    min-width: 82px;
    height: 46px;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: #1a2336;
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
}

.copy-url-btn:hover {
    background: #24304a;
}

.copy-url-btn:active {
    transform: translateY(1px);
}

.copy-url-btn.copied {
    background: #18f08b;
    color: #04130b;
    border-color: rgba(24, 240, 139, 0.5);
}

.players-topbar {
    display: flex;
    align-items: stretch;
    gap: 14px;
    flex-wrap: wrap;
}

.players-count-card {
    min-width: 180px;
    min-height: 62px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.players-count-label {
    color: var(--text-soft);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
    font-weight: 700;
}

.players-count-value {
    color: #ffffff;
    font-size: 1.35rem;
    font-weight: 800;
}

.players-sort-controls {
    display: flex;
    gap: 14px;
    align-items: stretch;
    flex-wrap: wrap;
}

.players-sort-group {
    min-width: 170px;
    min-height: 62px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.players-sort-group label {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(162, 189, 255, 0.85);
    padding: 0 2px;
}

.players-sort-group .select-wrapper {
    position: relative;
}

.players-sort-group .select-wrapper::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 14px;
    width: 10px;
    height: 6px;
    transform: translateY(-50%);
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23ffffff' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
}

.players-sort-select {
    width: 100%;
    height: 34px;
    border-radius: 8px;
    border: 1px solid #18233e;
    background: #070d19;
    color: #ffffff;
    padding: 0 40px 0 14px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    font-weight: 700;
}

.players-sort-select:focus {
    border-color: rgba(24, 240, 139, 0.5);
    box-shadow: 0 0 0 3px rgba(24, 240, 139, 0.08);
}

.players-sort-select option {
    background: #0b1120;
    color: #ffffff;
}

.players-table-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.players-table-header,
.player-row {
    display: grid;
    grid-template-columns: minmax(250px, 2fr) minmax(120px, 1fr) minmax(120px, 1fr) minmax(90px, 0.8fr) minmax(120px, 1fr) minmax(90px, 0.8fr) 44px;
    gap: 14px;
    align-items: center;
}

.player-warning-cell {
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-warning-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: rgba(255, 184, 77, 0.16);
    border: 1px solid rgba(255, 184, 77, 0.4);
    color: #ffb84d;
    font-size: 0.9rem;
    font-weight: 900;
    line-height: 1;
}

.players-table-header {
    padding: 0 14px;
    color: var(--text-soft);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 800;
}

.players-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.player-row {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 12px 14px;
}

.player-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.player-avatar {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    object-fit: cover;
    background: #0d1424;
    border: 1px solid rgba(255, 255, 255, 0.08);
    flex: 0 0 auto;
}

.player-name-wrap {
    min-width: 0;
}

.player-name {
    color: #ffffff;
    font-size: 0.98rem;
    font-weight: 700;
    word-break: break-word;
}

.player-cell {
    color: #dfe7ff;
    font-size: 0.94rem;
    font-weight: 600;
    word-break: break-word;
}

.players-empty {
    padding: 20px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.08);
    color: var(--text-soft);
    font-size: 0.95rem;
}

.players-convert-group {
    min-width: 230px;
}

.players-convert-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.players-convert-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #dfe7ff;
    font-size: 0.88rem;
    font-weight: 700;
    white-space: nowrap;
}

.players-convert-toggle input {
    accent-color: #18f08b;
}

.players-convert-row .select-wrapper {
    flex: 1;
}

@media (max-width: 980px) {
    .players-table-header {
        display: none;
    }

    .player-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .player-cell::before {
        content: attr(data-label);
        display: inline-block;
        min-width: 92px;
        color: var(--text-soft);
        font-size: 0.78rem;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        font-weight: 800;
        margin-right: 8px;
    }

    .players-sort-controls {
        width: 100%;
    }

    .players-sort-group {
        min-width: 0;
        flex: 1 1 170px;
    }
}

#overlay-tab .overlay-preview-stage-players {
    overflow: hidden;
}

#overlay-tab .overlay-preview-stage-players .overlay-preview-host {
    width: 100%;
    height: 100%;
    justify-content: flex-start;
    align-items: flex-start;
    overflow: hidden;
    position: relative;
}

#overlay-tab .overlay-preview-stage-players .hbc-type-players {
    width: max-content;
    min-width: 0;
    max-width: none;
}

/* ── Chat Tab ──────────────────────────────────────────────────────────── */

.chat-card {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
}

.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 0;
}

.chat-body .room-message {
    margin-top: 4px;
    margin-bottom: 0;
}

.chat-body .room-message:empty {
    display: none;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 0 0;
    min-height: 200px;
}

.chat-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border-radius: 6px;
    line-height: 1.5;
    word-break: break-word;
}

.chat-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.chat-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    background: #1b2440;
}

.chat-row-event {
    opacity: 0.7;
}

.chat-row-event .chat-name::after {
    content: '';
}

.chat-row-event .chat-text {
    color: var(--text-soft);
    font-style: italic;
}

.chat-name {
    font-weight: 700;
    color: var(--green);
    margin-right: 8px;
    font-size: 0.9rem;
}

.chat-source-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
}

.chat-source-icon svg,
.chat-source-icon img {
    width: 16px;
    height: 16px;
    display: block;
}

.chat-source-twitch {
    color: #9146ff;
}

.chat-source-hype img {
    border-radius: 2px;
}

.chat-name::after {
    content: ':';
}

.chat-text {
    color: var(--text-main);
    font-size: 0.9rem;
}

.chat-input-row {
    display: flex;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--green);
}

.chat-input::placeholder {
    color: var(--text-soft);
}

.chat-send-btn {
    background: var(--green);
    color: #060b14;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.chat-send-btn:hover {
    opacity: 0.85;
}

/* ── Calls Tab ─────────────────────────────────────────────────────────── */

.calls-card {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
}

.calls-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.calls-toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.calls-toggle-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-soft);
    white-space: nowrap;
}

.calls-peruser-input {
    width: 58px;
    padding: 7px 8px;
    border-radius: 8px;
    border: 1px solid var(--border, #1b2440);
    background: var(--input-bg, #0d1424);
    color: var(--text-main, #e6ecfb);
    font-family: inherit;
    font-size: 0.9rem;
    text-align: center;
}
.calls-peruser-input:focus {
    outline: none;
    border-color: var(--green, #18f08b);
}

.switch-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
    flex-shrink: 0;
}

.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.switch-slider {
    position: absolute;
    inset: 0;
    background: #3a3f55;
    border-radius: 24px;
    transition: background 0.2s;
}

.switch-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.switch-toggle input:checked + .switch-slider {
    background: var(--green);
}

.switch-toggle input:checked + .switch-slider::before {
    transform: translateX(20px);
}

.calls-clear-btn {
    padding: 6px 14px !important;
    font-size: 0.8rem !important;
}

.calls-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 0;
}

.calls-body .room-message {
    margin-top: 4px;
    margin-bottom: 0;
}

.calls-body .room-message:empty {
    display: none;
}

.calls-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 0 0;
}

.calls-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    line-height: 1.5;
}

.calls-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.calls-source {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.calls-source-icon {
    width: 18px;
    height: 18px;
}

.calls-source-twitch {
    color: #9146ff;
}

.calls-source-hype {
    color: var(--green);
}

.calls-username {
    font-weight: 700;
    color: var(--green);
    font-size: 0.9rem;
    white-space: nowrap;
}

.calls-slot {
    color: var(--text-main);
    font-size: 0.9rem;
    flex: 1;
}

.calls-delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-soft);
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.calls-delete-btn svg {
    width: 14px;
    height: 14px;
}

.calls-row:hover .calls-delete-btn {
    opacity: 1;
}

.calls-delete-btn:hover {
    color: #ff4d4d;
    background: rgba(255, 77, 77, 0.1);
}

/* ── Giveaway ─────────────────────────────────────────────────────────── */
.giveaway-card {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
}

.giveaway-topbar {
    display: flex;
    align-items: stretch;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.giveaway-topbar-card {
    min-height: 62px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
}

.giveaway-keyword-card {
    min-width: 200px;
}

.giveaway-topbar-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-soft);
}

.giveaway-topbar-value {
    color: #ffffff;
    font-size: 1.35rem;
    font-weight: 800;
}

.giveaway-topbar-input {
    width: 100%;
    height: 34px;
    border-radius: 8px;
    border: 1px solid #18233e;
    background: #070d19;
    color: #ffffff;
    padding: 0 12px;
    outline: none;
    font-size: 0.9rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.giveaway-topbar-input::placeholder {
    color: #516282;
}

.giveaway-topbar-input:focus {
    border-color: rgba(24, 240, 139, 0.5);
    box-shadow: 0 0 0 3px rgba(24, 240, 139, 0.08);
}

.giveaway-topbar-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.giveaway-sources-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.giveaway-source-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-soft);
    white-space: nowrap;
}

.giveaway-source-icon {
    width: 16px;
    height: 16px;
}

.giveaway-source-option svg.giveaway-source-icon {
    color: #9146ff;
}

.giveaway-exclude-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.giveaway-winners-count {
    font-size: 0.75rem;
    color: #f59e0b;
    white-space: nowrap;
}

.giveaway-run-status {
    color: var(--text-soft);
}

.giveaway-run-status.running {
    color: var(--green);
}

.giveaway-start-btn {
    white-space: nowrap;
    align-self: center;
}

.giveaway-start-btn.running {
    background: #e74c3c;
}

.giveaway-start-btn.running:hover {
    background: #c0392b;
}

.giveaway-winner-btn {
    align-self: center;
    white-space: nowrap;
    background: #f59e0b;
    color: #000;
    font-weight: 700;
}

.giveaway-winner-btn:hover {
    background: #d97706;
}

.giveaway-winner-modal {
    position: relative;
    z-index: 1;
}

.giveaway-winner-trophy {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 8px;
}

.giveaway-winner-modal p {
    font-size: 1.15rem;
}

.giveaway-confetti {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.giveaway-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 0;
}

.giveaway-body .room-message {
    margin-top: 4px;
    margin-bottom: 0;
}

.giveaway-body .room-message:empty {
    display: none;
}

.giveaway-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 0 0;
}

.giveaway-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    line-height: 1.5;
}

.giveaway-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.giveaway-source {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.giveaway-source .calls-source-icon {
    width: 18px;
    height: 18px;
}

.giveaway-source-twitch {
    color: #9146ff;
}

.giveaway-source-hype {
    color: var(--green);
}

.giveaway-username {
    font-weight: 700;
    color: var(--green);
    font-size: 0.9rem;
    white-space: nowrap;
}

/* ── Start confirmation modal ─────────────────────────────────────────── */
.start-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.start-modal {
    background: #1e1e2e;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 32px 40px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.start-modal p {
    font-size: 1.05rem;
    line-height: 1.6;
    margin: 0 0 24px;
    color: #e0e0e0;
}

.start-modal .btn-primary {
    padding: 10px 28px;
    font-size: 0.95rem;
    border-radius: 6px;
    cursor: pointer;
}

