:root {
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --accent: #2563eb;
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

/* Header */
#resultTitle,
#redeemTitle {
    font-weight: 900;
    font-size: 28px;
    color: #555555;
}

.popup-desc,
#resultText {
    font-size: 15px;
    color: #555555;
}

.cardTitle {
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: 900;
    color: #555555;
}

.sub {
    color: var(--muted);
    font-size: 14px;
    text-align: center;
    margin-bottom: 16px;
}

/* Layout */
.layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    width: 100%;
    max-width: 1200px;
}

@media (min-width: 900px) {
    .layout {
        grid-template-columns: 1.1fr 1fr;
        align-items: start;
    }
}

/* Wheel */
.stage {
    background: var(--card);
    border: 1px solid rgba(2, 6, 23, 0.06);
    border-radius: var(--radius);
    box-shadow: 0 4px 18px rgba(2, 6, 23, 0.06);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.wheel-wrap {
    position: relative;
    width: 100%;
    /* max-width: 400px; */
    aspect-ratio: 1/1;
}

.hud {
    position: absolute;
    inset: 25% 25%;
    border-radius: 50%;
    background: #fff;
    border: 1px solid rgba(2, 6, 23, 0.06);
    display: grid;
    place-items: center;
    gap: 10px;
    box-shadow: 0 0px 20px rgba(2, 6, 23, 0.08);
    pointer-events: none;
}

.hud .target-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
}

.hud .target-title {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}

.hud .target-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 15px;
}

.swatch {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 1px solid rgba(2, 6, 23, 0.1);
}

.progress {
    font-weight: 600;
    font-size: 15px;
    background-color: #ffffff;
    height: 20px;
}

.btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 20px 22px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(37, 99, 235, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    width: fit-content;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 26px rgba(37, 99, 235, 0.3);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.gameControl {
    height: 60px;
    width: 180px;
}

.green {
    background: #32c671;
}

.btn-wrap {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* Right side */
.right-side {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
}

.card {
    background: var(--card);
    border: 1px solid rgba(2, 6, 23, 0.06);
    border-radius: var(--radius);
    box-shadow: 0 4px 18px rgba(2, 6, 23, 0.05);
    padding: 20px;
    width: 100%;
}

.card h2 {
    margin: 0 0 10px;
    font-size: 1.1rem;
    font-weight: 600;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    max-width: 100%;
}

th,
td {
    padding: 6px 8px;
    text-align: left;
}

tr:nth-child(even) {
    background: #f9fafb;
}

/* Leader board pagination */
#pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

#pagination button {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    color: #334155;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

#pagination button:hover {
    background: #f1f5f9;
}

#pagination button.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* Tabs for leaderboard and prize list */
.lb-tabs,
.prize-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
}

.lb-tab,
.prize-tab {
    background: #fff;
    border: 1px solid #d1d5db;
    padding: 6px 14px;
    border-radius: 8px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    transition: all 0.25s ease;
}

.lb-tab.active,
.prize-tab.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

#difficulty.locked,
#difficulty:disabled {
    opacity: 0.6;
    pointer-events: none;
    cursor: not-allowed;
}

/* popup */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.popup {
    width: min(380px, 92vw);
    background: #fff;
    border-radius: 16px;
    padding: 28px;
    text-align: center;
    transform: translateY(24px);
    opacity: 0;
    transition: transform 0.35s ease, opacity 0.35s ease;
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.25);
}

.overlay.active .popup {
    transform: translateY(0);
    opacity: 1;
}

.popup h2 {
    margin: 0 0 6px;
}

.popup p {
    margin: 0 0 18px;
    color: var(--muted);
}

/* Make long popups scrollable on small screens */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
    z-index: 1;
}

.popup {
    width: min(380px, 92vw);
    background: #fff;
    border-radius: 16px;
    padding: 28px;
    text-align: center;
    transform: translateY(24px);
    opacity: 0;
    transition: transform 0.35s ease, opacity 0.35s ease;
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.25);
    max-height: 90vh;
    /* 👈 prevents it from exceeding viewport height */
    overflow-y: auto;
    /* 👈 allows internal scrolling */
    -webkit-overflow-scrolling: touch;
}

/* Mobile tabs */
.mobile-nav {
    display: none;
}

@media (max-width: 899px) {
    .mobile-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: #fff;
        border-top: 1px solid rgba(0, 0, 0, 0.08);
        display: flex;
        justify-content: space-around;
        align-items: center;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.05);
        z-index: 50;
    }

    .mobile-nav button {
        flex: 1;
        height: 100%;
        border: none;
        background: none;
        font-weight: 600;
        color: var(--muted);
        font-size: 15px;
        cursor: pointer;
        padding: 10px 0;
        transition: all 0.25s ease;
    }

    .mobile-nav button.active {
        color: var(--accent);
        background: rgba(37, 99, 235, 0.08);
    }

    .tab-panel {
        display: none;
        animation: fadeIn 0.3s ease forwards;
    }

    .tab-panel.active {
        display: block;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
            transform: translateY(10px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    body {
        padding-bottom: 80px;
    }

    .layout {
        grid-template-columns: 1fr !important;
    }
	
	#tryAgain {
		margin-top: 10px;
	}
}

/* Leaderboard medals */
#leaderboardTable tr:first-child td {
    font-weight: 700;
}

#leaderboardTable tr:nth-child(2) td {
    font-weight: 600;
}

#leaderboardTable tr:nth-child(3) td {
    font-weight: 600;
}

/* --- Leaderboard form --- */
#leaderboardForm {
    width: 100%;
    max-width: 100%;
}

#leaderboardForm .form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

#leaderboardForm label {
    flex: 0 0 38%;
    text-align: left;
    font-size: 14px;
    color: var(--muted);
}

#leaderboardForm input {
    flex: 1;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 14px;
}

/* Responsive form layout for mobile */
@media (max-width: 600px) {
    #leaderboardForm {
        max-height: 70vh;
        overflow-y: auto;
        padding-right: 6px;
    }

    #leaderboardForm .form-row {
        flex-direction: column;
        align-items: flex-start;
    }

    #leaderboardForm label {
        text-align: left;
        width: 100%;
        margin-bottom: 4px;
    }

    #leaderboardForm input {
        width: 100%;
    }

    #leaderboardTable {
        font-size: 13px !important;
    }

    #leaderboardTable td,
    #leaderboardTable th {
        padding: 4px 6px !important;
    }

    #leaderboardTable td:first-child {
        width: 40px;
        /* keeps medal/rank column tidy */
        text-align: center;
    }

    #leaderboardTable td:nth-child(2) {
        word-break: break-word;
        max-width: 140px;
        /* prevent long aliases overflowing */
    }

    .cc-revoke {
        display: none !important
    }
}