body {
    font-family: Arial, sans-serif;
    text-align: center;
    margin: 0;
    padding: 0;
    user-select: none;
}

.no-scroll {
    overflow: hidden;
}

/* Popups & Modals */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
}

.popup {
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 100%;
    text-align: center;
    border: 1px solid #ddd;
}

.popup h2 {
    margin-bottom: 15px;
}

.popup input,
.popup select {
    flex: 1;
    width: 95%;
    padding: 10px;
    margin: 10px 0;
    border-radius: 6px;
    font-size: 14px;
}

.ts-control {
    font-size: 14px;
    padding: 10px;
    border-radius: 6px;
}

.ts-wrapper {
    width: 48%;
}

#rounds {
    max-width: 45%;
}

.popup button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.popup-actions {
    margin-top: 15px;
}

#closePopup,
#closePopup2,
#closeDeletePopup {
    margin-left: 10px;
}

#alertPopup {
    z-index: 1200;
}

#alert {
    width: auto;
}

/* 4/5-Player Toggle Switch */
.switch-container {
    text-align: left;
    display: flex;
    align-items: center;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    transition: 0.4s;
    border-radius: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5px;
    box-sizing: border-box;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    transition: 0.4s;
    border-radius: 50%;
    left: 4px;
    bottom: 4px;
}

input:checked + .slider:before {
    transform: translateX(30px);
}

.toggle-label {
    font-size: 14px;
    font-weight: bold;
    z-index: 1;
}

.toggle-label.left {
    margin-left: 5px;
    position: relative;
}

.toggle-label.right {
    margin-right: 5px;
    position: relative;
}

/* Fixed Action & Utility Buttons */
.theme-toggle-button {
    position: fixed;
    top: 70px;
    right: 10px;
    transform: translateX(-50%);
    padding: 10px;
    border: none;
    border-radius: 50%;
    background-color: #f0f0f0;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.theme-toggle-button:hover {
    background-color: #e0e0e0;
}

.dark-mode .theme-toggle-button {
    background-color: #333;
}

.dark-mode .theme-toggle-button:hover {
    background-color: #444;
}

.theme-toggle-button i {
    font-size: 20px;
    color: #000;
}

.dark-mode .theme-toggle-button i {
    color: #fff;
}

.fixed-button {
    position: fixed;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transition: background-color 0.3s;
}

.add-game-button {
    top: 20px;
    left: 20px;
}

.add-player-button {
    top: 20px;
    right: 20px;
}

.openDelete {
    position: absolute;
    top: 10px;
    right: 0;
    font-size: 0.875rem;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 20px;
}

/* Leaderboard & Carousel */
.leaderboard-section {
    padding: 18px 16px 14px;
    border-radius: 0px 0px 12px 12px;;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.leaderboard-title {
    margin-top: 0;
}

.carousel-tabs {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 50px 12px;
}

.carousel-tab {
    background: rgba(255, 255, 255, 0.16);
    color: inherit;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, transform 0.15s;
}

.carousel-tab:hover {
    background: rgba(255, 255, 255, 0.28);
}

.carousel-tab.active {
    background: rgba(255, 255, 255, 0.34);
    border-color: rgba(255, 255, 255, 0.8);
}

.carousel-viewport-wrapper {
    position: relative;
    max-width: 720px;
    margin: 0 auto;
    padding: 0 44px;
    box-sizing: border-box;
}

.leaderboard-carousel,
.sticky-carousel {
    overflow: hidden;
    width: 100%;
    touch-action: pan-y;
}

.leaderboard-carousel {
    transition: height 0.3s ease;
}

.leaderboard-track,
.sticky-track {
    display: flex;
    align-items: flex-start;
    transition: transform 0.35s ease;
    will-change: transform;
}

.leaderboard-slide,
.sticky-slide {
    flex: 0 0 100%;
    min-width: 100%;
    box-sizing: border-box;
}

.carousel-arrow {
    position: absolute;
    top: 2px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.18);
    color: inherit;
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: background-color 0.2s, opacity 0.2s;
}

.carousel-arrow:hover {
    background: rgba(255, 255, 255, 0.32);
}

.carousel-arrow.prev {
    left: 4px;
}

.carousel-arrow.next {
    right: 4px;
}

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: none;
    padding: 0;
    background: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}

.carousel-dot.active {
    background: #ffffff;
    transform: scale(1.2);
}

.sticky-carousel-dots {
    margin-top: 2px;
    padding-bottom: 6px;
}

.empty-leaderboard {
    padding: 24px 16px;
    opacity: 0.85;
    font-style: italic;
}

.empty-sticky {
    padding: 8px 16px;
    opacity: 0.85;
    font-style: italic;
}

.table-container {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 10px;
}

.table-container table {
    margin: 0 auto;
}

.sticky-leaderboard .table-container {
    padding-bottom: 5px;
}

th {
    padding: 1px 8px;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 3px 6px;
}

.period-hidden {
    display: none;
}

.leaderboard-table.hide-trend .trend-col {
    display: none !important;
}

.sort-btn {
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    padding: 2px 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

.sort-indicator {
    font-size: 0.72em;
    opacity: 0.5;
    display: inline-block;
    min-width: 0.9em;
}

.sortable-th.sort-active .sort-indicator {
    opacity: 1;
}

.filter-header {
    padding-left: 0;
    padding-right: 0;
}

.filter-select {
    max-width: 82px;
    overflow: hidden;
    background-color: transparent;
    border: 0;
    text-align: center;
    font-family: Arial, sans-serif;
    font-size: medium;
    color: white;
    font-weight: 600;
}

.filter-select option {
    color: #333;
}

.diff-points-cell {
    padding-right: 5px;
}

.diff-points-wrap {
    width: auto;
    display: flex;
    justify-content: end;
}

.diff-rank-wrap {
    width: 45px;
    display: flex;
    justify-content: start;
}

.diff-positive {
    color: rgb(2, 212, 2);
    font-weight: bold;
}

.diff-negative {
    color: rgb(244, 67, 54);
    font-weight: bold;
}

.diff-neutral {
    color: rgb(185, 185, 185);
    font-weight: bold;
}

.diff-arrow {
    font-size: 15px;
}

.diff-play-icon-wrap {
    display: inline-block;
    width: 15px;
}

.diff-play-icon {
    height: 11px;
}

.player-link {
    color: inherit;
    text-decoration: none;
}

/* Game History */
.game-container {
    position: relative;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-top: 4px solid #4f46e5;
}

.game-container h3 {
    text-align: center;
    margin-top: 10px;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.game-meta-left,
.game-meta-right {
    position: absolute;
    top: 0;
    font-size: 0.875rem;
    color: #6b7280;
}

.game-meta-left {
    left: 0;
    margin-left: 20px;
}

.game-meta-right {
    right: 0;
    margin-right: 20px;
}

.players {
    display: flex;
    justify-content: space-around;
    gap: 1.5rem;
}

.player {
    text-align: center;
    padding: 0.75rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    width: 120px;
}

.player-name {
    font-weight: 600;
    font-size: 1rem;
}

.player-score {
    font-weight: 600;
    font-size: 0.875rem;
}

/* Sticky Top-3 Leaderboard */
.sticky-leaderboard {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 200;
    max-height: 0;
    transition: max-height 0.2s ease-out;
    overflow: hidden;
}

.expanded {
    max-height: 500px;
    transition: max-height 0.5s ease-in;
}

/* Form Labels */
.label,
label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

/* Rules Modal */
.rule-button {
    position: fixed;
    top: 70px;
    left: 10px;
    transform: translateX(50%);
    padding: 12px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: background 0.3s;
}

.rules {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    z-index: 100000000;
    height: 80%;
    overflow-y: auto;
    width: 500px;
    text-align: left;
}

.rules-overlay {
    z-index: 10000000;
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.close-rules {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: inherit;
    font-size: 20px;
    cursor: pointer;
}

.accordion {
    cursor: pointer;
    padding: 10px;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 16px;
    transition: 0.4s;
}

.panel {
    display: block;
    padding: 0 10px;
    overflow: hidden;
}

.rules-example {
    font-size: 15px;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .leaderboard-section {
        padding: 14px 6px;
    }

    .carousel-viewport-wrapper {
        padding: 0;
    }

    .leaderboard-title {
        padding: 0 38px;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 2px 4px;
        font-size: 0.9rem;
    }

    .filter-select {
        max-width: 64px;
        font-size: 0.85rem;
    }

    .diff-rank-wrap {
        width: 38px;
    }

    .sticky-leaderboard .gradient-bg {
        padding: 4px 44px 4px;
        box-sizing: border-box;
    }

    .theme-toggle-button {
        top: 8px;
        right: 0;
    }

    .rule-button {
        top: 8px;
        left: 0;
    }

    .rules {
        width: 80%;
    }

    .players {
        flex-direction: column;
        align-items: center;
    }

    .player {
        flex-direction: row;
        gap: 0.75rem;
        width: 100%;
        justify-content: space-between;
        align-items: center;
    }

    .add-game-button {
        top: unset;
        left: unset;
        right: 20px;
        bottom: 20px;
    }

    .add-player-button {
        top: unset;
        bottom: 70px;
    }
}
