* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;

    -webkit-text-size-adjust: 100%;
    overscroll-behavior: none;
}

body {
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif;

    background:
        linear-gradient(
            180deg,
            #75d8ff 0%,
            #b8edff 55%,
            #f5f5f5 100%
        );

    overflow-x: hidden;
    overflow-y: auto;

    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;

    touch-action: manipulation;
    overscroll-behavior: none;
}

button {
    font: inherit;
}

/* =========================
   LAYOUT
========================= */

.game-wrapper {
    width: 100%;
    min-height: 100vh;

    display: flex;
    flex-direction: column;
    align-items: center;
}

.topbar {
    width: min(100%, 1450px);

    min-height: 60px;
    padding: 10px 20px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.game-title {
    font-size: 20px;
    font-weight: 800;
    color: #ffffff;

    text-shadow:
        0 2px 3px rgba(0, 0, 0, 0.25);
}

.small-button {
    border: 0;
    border-radius: 12px;

    padding: 10px 14px;

    background: rgba(255, 255, 255, 0.9);
    color: #222;

    font-weight: 700;

    cursor: pointer;

    box-shadow:
        0 3px 8px rgba(0, 0, 0, 0.12);
}

.small-button:active {
    transform: scale(0.96);
}

.online-status {
    font-size: 12px;
    font-weight: 700;

    color: white;

    background: rgba(0, 0, 0, 0.18);

    padding: 7px 10px;
    border-radius: 999px;

    white-space: nowrap;
}

/* =========================
   DESKTOP 3 COLUMNS
========================= */

.flappy-layout {
    width: min(100% - 32px, 1380px);

    display: grid;
    grid-template-columns: 280px minmax(360px, 480px) 320px;

    justify-content: center;
    align-items: start;

    gap: 28px;

    padding: 10px 0 30px;
}

/* =========================
   SIDE PANELS
========================= */

.side-panel {
    width: 100%;

    background: rgba(255, 255, 255, 0.88);

    border: 1px solid rgba(255, 255, 255, 0.75);

    border-radius: 22px;

    padding: 20px;

    box-shadow:
        0 12px 35px rgba(0, 0, 0, 0.12);

    backdrop-filter: blur(8px);
}

.side-title {
    margin: 0 0 16px;

    font-size: 18px;
    font-weight: 900;

    color: #222;
}

.profile-user {
    display: flex;
    align-items: center;
    gap: 12px;

    margin-bottom: 18px;

    padding: 12px;

    border-radius: 16px;

    background: #f4f1ff;
}

.profile-avatar {
    width: 46px;
    height: 46px;
    min-width: 46px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: white;

    border: 2px solid #ddd6f0;

    font-size: 24px;
}

.profile-name {
    min-width: 0;
}

.profile-name strong {
    display: block;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 15px;
    color: #222;
}

.profile-status {
    margin-top: 3px;

    font-size: 12px;
    color: #777;
}

.profile-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 13px 0;

    border-bottom: 1px solid #eee;
}

.profile-stat:last-child {
    border-bottom: 0;
}

.profile-stat span {
    color: #777;
    font-size: 13px;
    font-weight: 600;
}

.profile-stat strong {
    color: #222;
    font-size: 17px;
}

/* =========================
   GAME
========================= */

.game-column {
    width: 100%;

    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-area {
    position: relative;

    width: min(94vw, 480px);

    aspect-ratio: 9 / 16;

    max-height: calc(100vh - 130px);

    overflow: hidden;

    border-radius: 20px;

    background: #73d8ff;

    box-shadow:
        0 12px 35px rgba(0, 0, 0, 0.22);

    touch-action: none;
    overscroll-behavior: none;

    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

#gameCanvas {
    display: block;

    width: 100%;
    height: 100%;

    touch-action: none;

    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.hud {
    position: absolute;

    top: 14px;
    left: 14px;
    right: 14px;

    display: flex;
    justify-content: center;
    gap: 14px;

    pointer-events: none;
}

.score,
.high-score {
    min-width: 95px;

    padding: 7px 15px;

    border-radius: 14px;

    text-align: center;

    color: white;

    background: rgba(0, 0, 0, 0.22);

    backdrop-filter: blur(4px);
}

.score span,
.high-score span {
    display: block;

    font-size: 11px;
    font-weight: 700;

    opacity: 0.9;
}

.score strong,
.high-score strong {
    display: block;

    margin-top: 1px;

    font-size: 25px;
    line-height: 1;

    text-shadow:
        0 2px 3px rgba(0, 0, 0, 0.3);
}

/* =========================
   OVERLAY
========================= */

.overlay {
    position: absolute;

    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;

    background: rgba(0, 0, 0, 0.18);

    z-index: 5;
}

.hidden {
    display: none !important;
}

.panel {
    width: min(90%, 330px);

    padding: 28px 24px;

    text-align: center;

    background: rgba(255, 255, 255, 0.96);

    border-radius: 24px;

    box-shadow:
        0 15px 45px rgba(0, 0, 0, 0.22);
}

.bird-icon {
    font-size: 60px;

    margin-bottom: 4px;
}

.panel h1,
.panel h2 {
    margin: 5px 0 10px;

    color: #222;
}

.panel p {
    margin: 0 0 22px;

    color: #666;
}

.main-button,
.secondary-button {
    width: 100%;

    min-height: 48px;

    border: 0;
    border-radius: 14px;

    font-weight: 800;

    cursor: pointer;
}

.main-button {
    color: white;

    background: #ffb000;

    box-shadow:
        0 4px 0 #d58f00;
}

.main-button:active {
    transform: translateY(2px);

    box-shadow:
        0 2px 0 #d58f00;
}

.secondary-button {
    margin-top: 10px;

    color: #555;

    background: #eeeeee;
}

.secondary-button:active {
    transform: scale(0.98);
}

.result {
    display: flex;
    justify-content: center;

    gap: 25px;

    margin: 20px 0;
}

.result div {
    min-width: 85px;
}

.result span {
    display: block;

    font-size: 13px;
    color: #777;
}

.result strong {
    display: block;

    margin-top: 4px;

    font-size: 30px;
    color: #222;
}

/* =========================
   LEADERBOARD
========================= */

.leaderboard-list {
    display: flex;
    flex-direction: column;

    gap: 8px;

    /* Hiện khoảng 10 người; từ hạng 11 đến 50 cuộn xuống */
    max-height: 440px;
    overflow-y: auto;
    overflow-x: hidden;

    padding-right: 4px;
    scrollbar-width: thin;
}
.leaderboard-list::-webkit-scrollbar {
    width: 6px;
}

.leaderboard-list::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.18);
}

.leaderboard-list::-webkit-scrollbar-track {
    background: transparent;
}


.leaderboard-row {
    display: flex;
    align-items: center;
    gap: 10px;

    padding: 10px 11px;

    border-radius: 13px;

    background: #f7f7f9;
}

.leaderboard-rank {
    width: 26px;
    min-width: 26px;

    text-align: center;

    font-size: 13px;
    font-weight: 900;

    color: #777;
}

.leaderboard-row:nth-child(1) .leaderboard-rank {
    color: #e5a400;
}

.leaderboard-row:nth-child(2) .leaderboard-rank {
    color: #777;
}

.leaderboard-row:nth-child(3) .leaderboard-rank {
    color: #a86632;
}

.leaderboard-avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: white;

    font-size: 15px;
}

.leaderboard-name {
    min-width: 0;
    flex: 1;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 13px;
    font-weight: 800;

    color: #333;
}

.leaderboard-score {
    font-size: 14px;
    font-weight: 900;

    color: #222;
}

.leaderboard-empty {
    padding: 25px 10px;

    text-align: center;

    color: #888;

    font-size: 13px;
}

.leaderboard-loading {
    padding: 25px 10px;

    text-align: center;

    color: #888;

    font-size: 13px;
}

/* =========================
   HINT
========================= */

.hint {
    display: flex;

    justify-content: center;
    gap: 8px;

    padding: 10px;

    color: #555;

    font-size: 13px;
    font-weight: 600;
}

/* =========================
   MOBILE
========================= */

@media (max-width: 1050px) {
    .flappy-layout {
        grid-template-columns: 240px minmax(340px, 440px) 280px;
        gap: 18px;
    }

    .side-panel {
        padding: 16px;
    }
}

@media (max-width: 850px) {
    body {
        overflow-y: auto;
    }

    .topbar {
        width: 100%;
    }

    .flappy-layout {
        width: 100%;

        display: flex;
        flex-direction: column;

        align-items: center;

        gap: 20px;

        padding: 4px 0 30px;
    }

    /* Game luôn nằm trên cùng */
    .game-column {
        order: 1;
    }

    /* Hồ sơ nằm sau game */
    .profile-panel {
        order: 2;
    }

    /* BXH nằm cuối */
    .leaderboard-panel {
        order: 3;
    }

    .side-panel {
        width: min(94vw, 480px);
    }

    .game-area {
        width: min(94vw, 480px);
        max-height: calc(100vh - 120px);
    }

    .hint {
        padding-bottom: 0;
    }
}

@media (max-height: 700px) and (min-width: 851px) {
    .topbar {
        min-height: 48px;
        padding: 6px 10px;
    }

    .game-area {
        max-height: calc(100vh - 90px);
    }

    .hint {
        display: none;
    }
}

@media (max-width: 380px) {
    .game-area {
        width: 96vw;
    }

    .topbar {
        padding-left: 8px;
        padding-right: 8px;
    }

    .game-title {
        font-size: 17px;
    }

    .online-status {
        font-size: 10px;
        padding: 6px 8px;
    }

    .side-panel {
        width: 94vw;
        padding: 15px;
    }
}
.game-credit {
    position: absolute;
    right: 18px;
    bottom: 10px;

    font-size: 13px;
    font-weight: 800;
    color: #222;

    pointer-events: none;
    user-select: none;

    text-shadow:
        0 1px 2px rgba(255, 255, 255, 0.7);

    z-index: 20;
}
.leaderboard-more {
    width: 100%;
    margin-top: 10px;
    padding: 9px 12px;
    border: 1px solid #ddd7ea;
    border-radius: 10px;
    background: #f7f4fc;
    color: #66558a;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition: 0.2s;
}

.leaderboard-more:hover {
    background: #eee9f8;
    transform: translateY(-1px);
}

.leaderboard-me {
    background: #f4efff;
}