/* =========================
Base
========================= */
:root {
    --z-dropdown: 30;
    --z-floating: 40;
    --z-notice: 50;
    --z-offline: 60;
}

body {
    font-family: 'pretendard', sans-serif;
    background-color: #0d1117;
    color: #ffffff;
    padding: 20px;
}

* {
    -webkit-user-select: none;
    user-select: none;
}

input {
    -webkit-user-select: text;
    user-select: text;
}

/* =========================
Layout
========================= */
.ranking-board {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

.top-bar {
    display: none;
    position: fixed;
    top: 20px;
    right: 25px;
    z-index: var(--z-floating);
}

.top-bar.is-visible {
    display: block;
}

.top-info {
    font-size: 0.85rem;
    color: #888;
    font-weight: 500;
    text-align: right;
}

/* =========================
Search
========================= */
.search-box {
    background-color: #181e25;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box:focus-within {
    border-color: rgba(99, 102, 241, 0.55);
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.26),
        0 0 0 3px rgba(99, 102, 241, 0.18);
}

.search-box input {
    background: none;
    border: none;
    color: white;
    width: 100%;
    outline: none;
}

.search-area {
    position: relative;
    z-index: var(--z-dropdown);
    margin-bottom: 20px;
}

.command-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background-color: #181e25;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 6px;
    box-shadow:
        0 16px 40px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    z-index: var(--z-dropdown);
    max-height: 120px;
    overflow-y: auto;
}

.command-menu::-webkit-scrollbar {
    width: 8px;
}

.command-menu::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.18);
    border-radius: 999px;
}

.command-menu::-webkit-scrollbar-track {
    background: transparent;
}

.command-menu.is-visible {
    display: block;
}

.command-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    border: none;
    color: #c9d1d9;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font: inherit;
    min-height: 44px;
}

.command-item:hover {
    background-color: rgba(255, 255, 255, 0.06);
}

.command-item.is-active {
    background-color: rgba(255, 255, 255, 0.08);
}

.suggestion-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background-color: #8b949e;
}

.suggestion-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.suggestion-text {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.suggestion-name {
    color: #ffffff;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suggestion-desc {
    color: #8b949e;
    font-size: 13px;
}

.command-name {
    color: #ffffff;
    font-weight: 800;
    min-width: 64px;
}

.command-desc {
    color: #8b949e;
    font-size: 13px;
}

/* =========================
Ranking Wrapper
========================= */
.ranking-wrapper {
    background:
        linear-gradient(180deg, rgba(18, 24, 32, 0.78), rgba(13, 18, 24, 0.68));
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 16px;
    overflow: hidden;
    padding: 8px 8px 20px 8px;
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.38),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.list-header {
    display: flex;
    justify-content: space-between;
    padding: 15px 20px;
    color: #8b949e;
    font-size: 14px;
    border-bottom: 1px solid #30363d;
    position: sticky;
    top: 0;
    background-color: transparent;
    z-index: 10;
}

#ranking-list-container {
    position: relative;
    margin-top: 12px;
}

.loading-msg {
    text-align: center;
    padding: 30px;
    color: #8b949e;
}

/* =========================
Ranking Item
========================= */
.list-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    position: absolute;
    overflow: hidden;
    width: calc(100% - 16px);
    left: 8px;
    box-sizing: border-box;
    border-radius: 10px;
    transition: top 0.9s cubic-bezier(0.25, 0.1, 0.25, 1);
    background:
        linear-gradient(180deg, rgba(25, 32, 43, 0.96), rgba(18, 24, 32, 0.94));
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.rank-number {
    font-size: 24px;
    font-weight: bold;
    font-family: 'Roboto Mono', cursive;
    font-style: italic;
    width: 65px;
    text-align: center;
    margin-left: -20px;
    position: relative;
    font-variant-numeric: tabular-nums;
}

.rank-change {
    font-size: 10px;
    font-style: normal;
    position: absolute;
    top: -8px;
    right: -4px;
}

.rank-change.new {
    color: #2ed573;
    font-size: 13px;
}

.player-info {
    display: flex;
    align-items: center;
    flex-grow: 1;
    margin-left: 10px;
    min-width: 0;
}

img.profile-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 15px;
    object-fit: cover;
    background-color: #8b949e;
}

.player-name {
    font-weight: bold;
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =========================
Item Effects
========================= */
.list-item::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
}

.list-item.rank-up::before {
    background:
        linear-gradient(90deg, rgba(34, 197, 94, 0.22), transparent 42%);
    animation: rank-flash 2.4s ease both;
}

.list-item.rank-down::before {
    background:
        linear-gradient(90deg, rgba(239, 68, 68, 0.20), transparent 42%);
    animation: rank-flash 2.4s ease both;
}

.list-item.search-focus::before {
    background:
        linear-gradient(90deg, rgba(99, 102, 241, 0.24), transparent 42%);
    animation: rank-flash 2.4s ease both;
}

@keyframes rank-flash {
    0% {
        opacity: 0;
    }

    28% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.list-item.special-enter {
    animation: special-enter 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes special-enter {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.list-item.special-shine::after {
    content: "";
    position: absolute;
    inset: -40%;
    z-index: 2;
    pointer-events: none;
    background:
        linear-gradient(
            120deg,
            transparent 35%,
            rgba(255, 255, 255, 0.20) 48%,
            rgba(99, 102, 241, 0.22) 52%,
            transparent 65%
        );
    transform: translateX(-60%) rotate(8deg);
    animation: special-shine 1.1s ease-out forwards;
}

@keyframes special-shine {
    from {
        opacity: 0;
        transform: translateX(-60%) rotate(8deg);
    }

    25% {
        opacity: 1;
    }

    to {
        opacity: 0;
        transform: translateX(60%) rotate(8deg);
    }
}

.list-item.heat-focus::before {
    background:
        linear-gradient(90deg, rgba(249, 115, 22, 0.34), rgba(239, 68, 68, 0.18), transparent 48%);
    animation: heat-flash 2.8s ease both;
}

.list-item.heat-focus .vote-btn {
    box-shadow:
        0 0 22px rgba(249, 115, 22, 0.34),
        inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

@keyframes heat-flash {
    0% {
        opacity: 0;
    }

    18% {
        opacity: 1;
    }

    70% {
        opacity: 0.85;
    }

    100% {
        opacity: 0;
    }
}

.heat-badge {
    position: absolute;
    right: 118px;
    top: 50%;
    transform: translateY(-50%) scale(0.8);
    font-size: 20px;
    opacity: 0;
    pointer-events: none;
    z-index: 3;
    filter: drop-shadow(0 0 10px rgba(249, 115, 22, 0.55));
    animation: heat-badge-pop 2.8s ease forwards;
}

@keyframes heat-badge-pop {
    0% {
        opacity: 0;
        transform: translateY(-50%) scale(0.6) rotate(-10deg);
    }

    18% {
        opacity: 1;
        transform: translateY(-50%) scale(1.15) rotate(6deg);
    }

    40% {
        transform: translateY(-50%) scale(1) rotate(-4deg);
    }

    70% {
        opacity: 1;
        transform: translateY(-50%) scale(1.04) rotate(3deg);
    }

    100% {
        opacity: 0;
        transform: translateY(-70%) scale(0.85) rotate(0deg);
    }
}

.rank-number,
.player-info,
.vote-btn {
    position: relative;
    z-index: 1;
}

/* =========================
Vote Button
========================= */
.vote-btn {
    background: linear-gradient(180deg, #2f3744, #1f2630);
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.10);
    padding: 8px 16px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 800;
    width: 105px;
    height: 38px;
    line-height: 1;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition:
        transform 0.18s ease,
        background-color 0.18s ease,
        box-shadow 0.18s ease;
    flex-shrink: 0;
}

.vote-btn:hover {
    background: linear-gradient(180deg, #3b4554, #28313d);
    transform: translateY(-1px) scale(1.03);
    box-shadow:
        0 8px 22px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

.vote-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.vote-count-wrap {
    position: relative;
    display: inline-block;
    min-width: 52px;
    height: 1em;
    overflow: hidden;
    vertical-align: middle;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.vote-count {
    display: block;
    line-height: 1;
    transition:
        transform 1s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 1s ease;
}

.vote-count.old {
    position: absolute;
    left: 0;
    top: 0;
    transform: translateY(0);
    opacity: 1;
}

.vote-count.new {
    transform: translateY(100%);
    opacity: 0;
}

.vote-btn.is-changing .vote-count.old {
    transform: translateY(-100%);
    opacity: 0;
}

.vote-btn.is-changing .vote-count.new {
    transform: translateY(0);
    opacity: 1;
}

/* =========================
Display Options 
========================= */
body.hide-profiles .profile-img {
    display: none;
}

body.hide-profiles .player-info {
    margin-left: 4px;
}

/* =========================
Notice Popup 
========================= */
.notice-popup {
    position: fixed;
    top: 15px;
    left: 15px;
    max-width: 400px;
    background-color: #181e25;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 12px 15px;
    font-size: 13px;
    color: #ccc;
    z-index: var(--z-notice);
    line-height: 1.6;
}

.notice-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.notice-point {
    color: #6366f1;
}

.notice-close-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    margin-left: 20px;
}

.notice-actions {
    margin-top: 10px;
    text-align: right;
}

.notice-hide-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 11px;
    text-decoration: underline;
}

/* =========================
Offline Banner
========================= */
#offline-banner {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: #7f1d1d;
    color: #fca5a5;
    text-align: center;
    font-size: 13px;
    padding: 8px 16px;
    z-index: var(--z-offline);
    letter-spacing: 0.02em;
}

/* =========================
Floating Buttons
========================= */
.theme-toggle,
#top-btn {
    width: 45px;
    height: 45px;
    background-color: #21262d;
    color: white;
    border: 1px solid #30363d;
    padding: 8px 10px;
    border-radius: 50%;
    cursor: pointer;
    z-index: var(--z-floating);

    display: flex;
    align-items: center;
    justify-content: center;

    box-shadow:
        0 10px 24px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);

    transition:
        background-color 0.18s ease,
        border-color 0.18s ease,
        transform 0.18s ease,
        box-shadow 0.18s ease;
}

.theme-toggle {
    position: fixed;
    bottom: 70px;
    right: 15px;
    font-weight: bold;
}

#top-btn {
    position: fixed;
    bottom: 15px;
    right: 15px;
    font-size: 18px;
}

.theme-toggle:hover,
#top-btn:hover {
    background-color: #30363d;
    transform: translateY(-1px) scale(1.04);

    box-shadow:
        0 14px 30px rgba(0, 0, 0, 0.34),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* =========================
Light Mode
========================= */
body.light-mode {
    background-color: #ffffff;
    color: #111827;
}

body.light-mode .search-box {
    background-color: #f6f7f9;
    border: 1px solid #edf0f3;
    box-shadow: none;
}

body.light-mode .search-box:focus-within {
    background-color: #ffffff;
    border-color: #c7d2fe;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.14);
}

body.light-mode .search-box input {
    color: #111827;
}

body.light-mode .search-box input::placeholder {
    color: #8a94a3;
}

body.light-mode .ranking-wrapper {
    background: #ffffff;
    border: 1px solid #e8ebef;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

body.light-mode .list-header {
    color: #667085;
    background-color: #ffffff;
    border-bottom: 1px solid #eef0f3;
}

body.light-mode .list-item {
    background: #ffffff;
    color: #111827;
    border: 1px solid #e6e9ee;
    box-shadow:
        0 8px 24px rgba(15, 23, 42, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

body.light-mode .rank-number {
    color: #111827;
}

body.light-mode .player-name {
    color: #111827;
}

body.light-mode .vote-btn {
    background: #ffffff;
    color: #1f2937;
    border: 1px solid #cfd6df;
    box-shadow:
        0 4px 12px rgba(15, 23, 42, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

body.light-mode .vote-btn:hover {
    background: #f8fafc;
    border-color: #aeb8c5;
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.10);
}

body.light-mode .theme-toggle,
body.light-mode #top-btn {
    background-color: #ffffff;
    color: #111827;
    border-color: #d8dee6;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.10);
}

body.light-mode .theme-toggle:hover,
body.light-mode #top-btn:hover {
    background-color: #f8fafc;
    border-color: #aeb8c5;
    transform: translateY(-1px) scale(1.04);
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.14);
}

body.light-mode .loading-msg,
body.light-mode .top-info {
    color: #6b7280;
}

body.light-mode .notice-popup {
    background-color: #ffffff;
    border-color: #e1e5ea;
    color: #667085;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.10);
}

body.light-mode .list-item.rank-up::before {
    background:
        linear-gradient(90deg, rgba(22, 163, 74, 0.12), transparent 42%);
}

body.light-mode .list-item.rank-down::before {
    background:
        linear-gradient(90deg, rgba(220, 38, 38, 0.10), transparent 42%);
}

body.light-mode .list-item.search-focus::before {
    background:
        linear-gradient(90deg, rgba(79, 70, 229, 0.14), transparent 42%);
}

body.light-mode .command-menu {
    background-color: #ffffff;
    border-color: #e8ebef;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.10);
}

body.light-mode .command-menu::-webkit-scrollbar-thumb {
    background-color: rgba(15, 23, 42, 0.18);
}

body.light-mode .command-item {
    color: #111827;
}

body.light-mode .command-item:hover {
    background-color: #f3f4f6;
}

body.light-mode .command-item.is-active {
    background-color: #f3f4f6;
}

body.light-mode .suggestion-name {
    color: #111827;
}

body.light-mode .suggestion-desc {
    color: #667085;
}

body.light-mode .command-name {
    color: #111827;
}

body.light-mode .command-desc {
    color: #667085;
}

body.light-mode .list-item.special-shine::after {
    background:
        linear-gradient(
            120deg,
            transparent 35%,
            rgba(255, 255, 255, 0.65) 48%,
            rgba(99, 102, 241, 0.16) 52%,
            transparent 65%
        );
}

body.light-mode .list-item.heat-focus::before {
    background:
        linear-gradient(90deg, rgba(249, 115, 22, 0.18), rgba(239, 68, 68, 0.10), transparent 48%);
}

/* =========================
Responsive
========================= */
@media (max-width: 1250px) {
    .top-info {
        position: static;
        text-align: right;
        margin-bottom: 10px;
        display: block;
    }

    .ranking-board {
        margin-top: 10px;
    }
}

@media (max-width: 1200px) {
    .top-bar {
        top: 10px;
        right: 15px;
    }
}

@media (max-width: 480px) {
    .vote-btn {
        min-width: 72px;
        padding: 8px 10px;
        font-size: 13px;
    }
    .player-name {
        font-size: 14px;
    }
}

@media (max-width: 1024px) {
    .ranking-board {
        max-width: 760px;
    }

    .rank-number {
        width: 58px;
        margin-left: -16px;
        font-size: 23px;
    }

    .player-info {
        margin-left: 8px;
    }

    .vote-btn {
        width: 100px;
        padding: 8px 14px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 14px;
    }

    .ranking-board {
        max-width: 100%;
    }

    .list-item {
        padding: 14px 16px;
    }

    .rank-number {
        width: 52px;
        margin-left: -14px;
        font-size: 22px;
    }

    img.profile-img {
        width: 36px;
        height: 36px;
        margin-right: 12px;
    }

    .player-name {
        font-size: 15px;
    }

    .vote-btn {
        width: 96px;
        padding: 8px 12px;
        font-size: 13px;
    }

    .vote-count-wrap {
        min-width: 48px;
    }
}
