:root {
    /* Blue similar to Chrome's default range accent (approximation) */
    --range-blue: #1a73e8;
    /* Neutral button background (light chrome-like) */
    --btn-gray: #f3f3f3;
}

body {
    min-height: 100vh;
    margin: 0;
    padding: 0 2vw;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Base button appearance (neutral look like Chrome) */
button {
    background: var(--btn-gray);
    border: 1px solid #9e9e9e;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    width: 100%;
    margin: 0.16em 0;
}

/* Learning buttons: JS will set a precise gradient inline; this is a safe fallback */
.learning-btn {
    background: linear-gradient(90deg, var(--range-blue) 0%, var(--btn-gray) 100%);
    transition: background 180ms linear;
    color: #000;
}

/* Disabled look */
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Try to align range accents with the same blue */
input[type="range"] {
    accent-color: var(--range-blue);
}

#game {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    width: 100%;
    max-width: 1000px;
    margin: auto;
}

/* Row 1: Game Management - spans full width, 2 inner columns */
#game-management {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
}

.game-management-col {
    padding: 2px;
    display: flex;
    flex-direction: column;
}

/* Container for start and leaderboard buttons side by side */
.game-management-col>div {
    display: flex;
    gap: 8px;
}

.game-management-col button {
    flex: 1;
}

/* Row 2: Scoring Display - spans full width, 2 inner columns */
#display {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.display-col {
    padding: 2px;
}

/* Row 3: Work, Learning, Banking - 3 columns */
#work-zone {
    grid-column: 1;
}

#learn-zone {
    grid-column: 2;
}

#banking-zone {
    grid-column: 3;
}

/* Row 4: Graphic Zone - full width */
#graphic-zone {
    grid-column: 1 / -1;
    padding: 2px;
}

#game>* {
    padding: 2px;
}

body {
    font-size: 13px;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

h1 {
    font-size: 1.6em;
    margin: 0.3em 0;
}

h2 {
    font-size: 1.3em;
    margin: 0.25em 0;
}

h3 {
    font-size: 1.1em;
    margin: 0.1em 0;
}

h4 {
    font-size: 1.1em;
    margin: 0.1em 0;
}

/* #cash{
    font-size: 1.2em;
    font-weight: 600;
    color: #000000;
} */

p {
    margin: 0.24em 0;
}

label {
    font-size: 0.9em;
}

button {
    font-size: 0.9em;
    padding: 10px;
    width: 100%;
    margin: 0.16em 0;
}

#scoreChart {
    margin: auto;
    max-width: 100%;
    display: block;
}

/* Mobile styles with vw units */
@media (max-width: 500px) {
    body {
        font-size: 3vw;

    }

    h1 {
        font-size: 5vw;
        margin: 1vw 0;
    }

    h2 {
        font-size: 4vw;
        margin: 1vw 0;
    }

    h3 {
        font-size: 3.5vw;
        margin: 1vw 0;
    }

    #game {
        grid-template-columns: repeat(3, 1fr);
        gap: 1vw;
    }

    #game-management,
    #display {
        grid-column: 1 / -1;
        grid-template-columns: 1fr 1fr;
        gap: 1vw;
    }

    #work-zone {
        grid-column: 1;
    }

    #learn-zone {
        grid-column: 2;
    }

    #banking-zone {
        grid-column: 3;
    }

    #work-zone,
    #learn-zone,
    #banking-zone {
        padding: 1vw;
    }

    #game>* {
        padding: 1vw;
    }

    button {
        padding: 3vw;
        font-size: 3vw;
    }

    p {
        font-size: 3vw;
        margin: 1vw 0;
    }

    label {
        font-size: 3vw;
    }

    input[type="range"] {
        width: 100%;
    }

    #scoreChart {
        width: 100%;
        height: auto;
    }
}

/* (removed duplicate :root and learning-btn declarations to keep variables centralized) */

/* Modal / Leaderboard styles */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.modal-content {
    position: relative;
    background: #fff;
    padding: 16px;
    width: min(1000px, 95%);
    max-height: 85vh;
    overflow: auto;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.modal-close {
    position: absolute;
    right: 8px;
    top: 6px;
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
}

.leaderboard-columns {
    display: flex;
    gap: 12px;
}

.leaderboard-col {
    flex: 1;
    padding: 6px;
    border-radius: 6px;
    background: #fafafa;
    border: 1px solid #e6e6e6;
}

.leaderboard-col ol {
    padding-left: 1.2em;
    margin: 6px 0;
}

.world-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.world-filters {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
    padding: 8px;
    background: #f0f0f0;
    border-radius: 4px;
}

.filter-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

.filter-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 0.9em;
    white-space: nowrap;
}

.filter-group input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-controls input[type="range"] {
    flex: 1;
    min-width: 100px;
}

.filter-controls span {
    font-weight: bold;
    color: var(--range-blue);
    min-width: 25px;
    text-align: center;
}

.world-limit {
    padding: 6px 8px;
    font-size: 0.9em;
}

/* Leaderboard Tables */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.leaderboard-table thead {
    background: linear-gradient(135deg, var(--range-blue), #0d47a1);
    color: #fff;
    font-weight: 600;
}

.leaderboard-table th {
    padding: 8px 6px;
    text-align: left;
    font-size: 0.85em;
    border-bottom: 2px solid var(--range-blue);
}

.leaderboard-table td {
    padding: 8px 6px;
    border-bottom: 1px solid #e6e6e6;
    font-size: 0.9em;
}

.leaderboard-table tbody tr {
    transition: background-color 200ms ease;
}

.leaderboard-table tbody tr:hover {
    background-color: #f5f5f5;
}

.leaderboard-table tbody tr:nth-child(even) {
    background-color: #fafafa;
}

.leaderboard-table tbody tr:last-child td {
    border-bottom: none;
}

/* Delete button styling */
.delete-btn {
    background: #ff5252;
    color: #fff;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8em;
    transition: background 150ms ease;
}

.delete-btn:hover {
    background: #ff1744;
}

.delete-btn:active {
    background: #d32f2f;
}

.empty-message {
    text-align: center;
    color: #999;
    padding: 16px 0;
    font-style: italic;
}

/* Responsive table for mobile */
@media (max-width: 900px) {
    .leaderboard-columns {
        flex-direction: column;
    }

    .leaderboard-col {
        flex: 1;
    }

    .leaderboard-table {
        font-size: 0.8em;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 6px 4px;
    }

    .delete-btn {
        padding: 3px 6px;
        font-size: 0.75em;
    }

    .world-filters {
        flex-direction: column;
        align-items: flex-start;
    }

    .world-filters label {
        width: 100%;
    }

    .world-filters select,
    .world-filters input[type="range"] {
        width: 100%;
    }
}
}

@media (max-width: 500px) {
    .leaderboard-table {
        font-size: 2.5vw;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 1vw 0.5vw;
    }

    .delete-btn {
        padding: 1vw 2vw;
        font-size: 2vw;
    }
}