:root {
    --sky: #4ec0ca;
    --ground: #ded895;
    --pipe: #74bf2e;
    --pipe-dark: #558022;
    --bird: #f7d308;
    --white: #ffffff;
    --black: #000000;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: #1a1a2e;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

/* ── Layout ───────────────────────────────────────────── */

#app {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 20px;
}

#game-wrapper {
    flex-shrink: 0;
    /* width/height set by JS to match scaled game */
}

#game-container {
    position: relative;
    width: 320px;
    height: 480px;
    background-color: var(--sky);
    border: 4px solid #000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    transform-origin: top left;
}

canvas {
    display: block;
}

/* ── UI Overlay ───────────────────────────────────────── */

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.overlay-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 82%;
    text-align: center;
    padding: 18px 16px;
    pointer-events: auto;
    transition: opacity 0.3s;
    max-height: 94%;
    display: flex;
    flex-direction: column;
}

.overlay-panel.hidden {
    opacity: 0;
    pointer-events: none;
}

.logo {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--white);
    -webkit-text-stroke: 1.5px #543847;
    text-shadow: 2px 2px 0 #543847;
    margin-bottom: 24px;
}

.game-over-text {
    font-size: 1.9rem;
    font-weight: 900;
    color: #e86101;
    -webkit-text-stroke: 1px #fff;
    text-shadow: 2px 2px 0 #543847;
    margin-bottom: 14px;
}

.stats-box {
    background-color: #ded895;
    border: 3px solid #543847;
    border-radius: 5px;
    padding: 12px;
    margin-bottom: 12px;
}

.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    font-weight: 700;
    color: #543847;
    font-size: 0.85rem;
}

.score-row span:last-child {
    font-size: 1.1rem;
    color: #fff;
    -webkit-text-stroke: 1px #543847;
}

input[type="text"] {
    width: 100%;
    border: 3px solid #543847;
    padding: 10px;
    border-radius: 5px;
    text-align: center;
    font-weight: 700;
    margin-bottom: 14px;
    outline: none;
    font-size: 0.95rem;
}

input[type="text"].input-error {
    border-color: #e86101;
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%       { transform: translateX(-6px); }
    75%       { transform: translateX(6px); }
}

button {
    background-color: #e86101;
    border: 3px solid #fff;
    box-shadow: 0 4px 0 #543847;
    color: white;
    font-weight: 900;
    padding: 10px 24px;
    cursor: pointer;
    font-size: 1rem;
    white-space: nowrap;
    border-radius: 5px;
    transition: transform 0.1s;
}

button:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #543847;
}

#heads-up-display {
    position: absolute;
    top: 20px;
    width: 100%;
    text-align: center;
}

#current-score {
    font-size: 3.5rem;
    font-weight: 900;
    color: white;
    -webkit-text-stroke: 2px #000;
    text-shadow: 2px 2px 0 #000;
}

/* ── Leaderboard (shared styles) ──────────────────────── */

.lb-title {
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #f7d308;
    margin-bottom: 8px;
    -webkit-text-stroke: 0.5px #543847;
}

.lb-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.lb-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.07);
    border-left: 3px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 0.72rem;
    transition: background 0.15s;
}

.lb-entry:nth-child(1) { border-left-color: #f7d308; background: rgba(247,211,8,0.12); }
.lb-entry:nth-child(2) { border-left-color: #c0c0c0; background: rgba(192,192,192,0.10); }
.lb-entry:nth-child(3) { border-left-color: #cd7f32; background: rgba(205,127,50,0.10); }

.lb-rank {
    font-weight: 900;
    color: rgba(255,255,255,0.5);
    min-width: 22px;
    font-size: 0.7rem;
    text-align: center;
}

.lb-entry:nth-child(1) .lb-rank { color: #f7d308; font-size: 0.9rem; }
.lb-entry:nth-child(2) .lb-rank { color: #c0c0c0; font-size: 0.85rem; }
.lb-entry:nth-child(3) .lb-rank { color: #cd7f32; font-size: 0.82rem; }

.lb-name {
    flex: 1;
    color: #fff;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
    font-size: 0.73rem;
}

.lb-score {
    font-weight: 900;
    color: #fff;
    font-size: 0.75rem;
    background: rgba(255,255,255,0.12);
    padding: 2px 7px;
    border-radius: 10px;
    letter-spacing: 0.03em;
}

.lb-empty {
    color: rgba(255,255,255,0.35);
    font-size: 0.7rem;
    padding: 14px 0;
    font-style: italic;
}

/* ── Rank position card (game over) ──────────────────── */

#rank-display {
    margin: 8px 0 6px;
    border-radius: 8px;
    overflow: hidden;
    font-size: 0.7rem;
    font-family: inherit;
}

#rank-display.hidden { display: none; }

.rank-badge {
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-weight: 900;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    padding: 5px 10px;
    text-align: center;
}

.rank-neighbor {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 10px;
    color: rgba(255,255,255,0.6);
    background: rgba(0,0,0,0.15);
}

.rank-neighbor span { font-weight: 700; color: rgba(255,255,255,0.75); }

.rank-self {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 10px;
    background: rgba(255,200,0,0.25);
    color: #ffe066;
    font-weight: 900;
    border-left: 3px solid #ffe066;
}

.rank-self span { color: #ffe066; font-weight: 900; }

/* ── Start screen button row ──────────────────────────── */

.start-btns {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

#hof-link {
    display: block;
    margin-top: 10px;
    font-size: 0.68rem;
    font-weight: 900;
    color: var(--yellow);
    text-decoration: none;
    letter-spacing: 0.06em;
    opacity: 0.75;
    transition: opacity 0.15s;
}
#hof-link:hover { opacity: 1; }

#hof-view-btn {
    display: block;
    background: var(--orange);
    color: #fff;
    font-weight: 900;
    font-size: 0.9rem;
    padding: 10px 24px;
    border-radius: 5px;
    border: 2px solid var(--dark);
    box-shadow: 0 3px 0 var(--dark);
    text-decoration: none;
    cursor: pointer;
    margin-top: 4px;
    transition: transform 0.1s, box-shadow 0.1s;
}
#hof-view-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--dark); }

/* ── Game-themed alert/modal ──────────────────────────── */

.game-alert {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
    pointer-events: auto;
}

.game-alert-inner {
    background: #ded895;
    border: 3px solid #543847;
    border-radius: 8px;
    padding: 20px 16px;
    text-align: center;
    width: 88%;
    max-height: 88%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 6px 0 #543847;
    overflow: hidden;
}

.game-alert-title {
    font-size: 1.4rem;
    font-weight: 900;
    color: #e86101;
    -webkit-text-stroke: 1px #543847;
    text-shadow: 1px 1px 0 #543847;
    margin-bottom: 10px;
}

.game-alert-msg {
    font-size: 0.82rem;
    font-weight: 700;
    color: #543847;
    line-height: 1.5;
    margin-bottom: 16px;
}

.modal-lb-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

.modal-lb-list .lb-entry {
    background: rgba(84, 56, 71, 0.1);
    border-left-color: rgba(84,56,71,0.25);
}
.modal-lb-list .lb-entry:nth-child(1) { background: rgba(247,211,8,0.2); border-left-color: #c9a800; }
.modal-lb-list .lb-entry:nth-child(2) { background: rgba(140,140,140,0.18); border-left-color: #888; }
.modal-lb-list .lb-entry:nth-child(3) { background: rgba(160,100,40,0.15); border-left-color: #a0622a; }
.modal-lb-list .lb-name { color: #3a2530; }
.modal-lb-list .lb-rank { color: rgba(84,56,71,0.5); }
.modal-lb-list .lb-entry:nth-child(1) .lb-rank { color: #b8920a; }
.modal-lb-list .lb-entry:nth-child(2) .lb-rank { color: #777; }
.modal-lb-list .lb-entry:nth-child(3) .lb-rank { color: #8a5522; }
.modal-lb-list .lb-score { color: #3a2530; background: rgba(84,56,71,0.12); }

/* ── Sidebar leaderboard (PC only) ────────────────────── */

#leaderboard-panel {
    width: 200px;
    background: rgba(0, 0, 0, 0.45);
    border: 2px solid rgba(247, 211, 8, 0.3);
    border-radius: 10px;
    padding: 14px 12px;
    align-self: flex-start;
    backdrop-filter: blur(6px);
    flex-shrink: 0;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

#leaderboard-panel .lb-title {
    text-align: center;
    margin-bottom: 10px;
    font-size: 0.75rem;
}

.lb-status {
    font-size: 0.6rem;
    color: rgba(255,255,255,0.35);
    text-align: center;
    margin-top: 10px;
}

.lb-status.live::before {
    content: '● ';
    color: #74bf2e;
}

/* ── Mobile leaderboard (inside game-over overlay) ────── */

#mobile-lb {
    margin-bottom: 10px;
    display: none;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#mobile-lb .lb-title {
    font-size: 0.65rem;
    margin-bottom: 5px;
}

#mobile-lb-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#mobile-lb-list .lb-entry {
    padding: 3px 6px;
    font-size: 0.63rem;
}

/* ── Mobile: full-screen game, hide sidebar ───────────── */

@media (max-width: 699px) {
    body {
        background: #000;
        overflow: hidden;
    }

    #app {
        flex-direction: column;
        gap: 0;
        justify-content: center;
        align-items: center;
        width: 100vw;
        height: 100vh;
    }

    #game-container {
        border: none;
        box-shadow: none;
    }

    #leaderboard-panel {
        display: none;
    }

    #mobile-lb {
        display: flex;
    }

    .overlay-panel {
        padding: 12px 14px;
    }

    .game-over-text {
        font-size: 1.6rem;
        margin-bottom: 10px;
    }

    .stats-box {
        padding: 8px 10px;
        margin-bottom: 8px;
    }
}
