:root {
    --grass: #1a2e1d; /* Darker, richer green */
    --dirt: #3d2c20;
    --fence: #241913;
}

body {
    margin: 0;
    padding: 0;
    background-color: #000;
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    color: white;
    touch-action: none;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 8a3 3 0 0 0-3-3H5a3 3 0 0 0-3 3v8a3 3 0 0 0 3 3h10a3 3 0 0 0 3-3V8Z'/%3E%3Cpath d='M10 8v8'/%3E%3Cpath d='M18 12h4'/%3E%3C/svg%3E") 12 12, auto;
}

canvas {
    display: block;
    background-color: var(--grass);
    width: 100%;
    height: 100%;
}

/* Glassmorphic Overlay */
#start-screen, #end-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    
    background: radial-gradient(circle at center, rgba(30, 41, 59, 0.4) 0%, rgba(2, 6, 23, 0.9) 100%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.5s ease;
}

#start-screen.hidden, #end-screen.hidden, .hidden {
    display: none !important;
}

/* Typography & Titles */
h1 {
    font-size: 4rem;
    font-weight: 300;
    letter-spacing: 0.5rem;
    margin-bottom: 3rem;
    text-transform: uppercase;
    background: linear-gradient(to right, #94a3b8, #f8fafc);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(255,255,255,0.1);
}

#loading-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(to right, #94a3b8, #f8fafc);
    border-radius: 5px;
    transition: width 0.1s ease;
}

/* Loading Bar */
#loading-modal {
    background: #0a0f18; /* Solid dark background to hide game */
    z-index: 200;       /* Above everything else */
}

.loading-bar-container {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
    margin-top: 1.5rem;
}

/* Sleek Play Button */
button {
    padding: 1rem 4rem;
    font-size: 1.2rem;
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    letter-spacing: 0.2rem;
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px rgba(255,255,255,0.2);
}

button:active {
    transform: translateY(1px);
}

.modal {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.7);
    z-index: 100;
    transition: opacity 0.3s;
}

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

.modal-content {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2.5rem;
    border-radius: 20px;
    min-width: 350px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    margin-top: 0;
    font-weight: 300;
    margin-bottom: 2rem;
    letter-spacing: 0.1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 1rem;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 300;
    font-size: 1.1rem;
}

.sm-btn {
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
    letter-spacing: 0.1rem;
}

select {
    background: rgba(0,0,0,0.5);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    padding: 0.5rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    max-height: 250px;
    overflow-y: auto;
    padding: 1rem;
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
}

.level-grid::-webkit-scrollbar {
    width: 6px;
}

.level-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.level-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.level-btn {
    text-align: left;
    padding: 0.8rem 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.level-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Post-Level Leaderboard */
#leaderboard-container {
    margin-top: 2rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    width: 300px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.leaderboard-title {
    font-size: 1rem;
    letter-spacing: 0.2rem;
    color: #94a3b8;
    margin-bottom: 1rem;
    text-align: center;
}

.record-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 1rem;
    font-weight: 300;
}

.record-item:last-child {
    border-bottom: none;
}

.record-rank {
    color: #94a3b8;
    margin-right: 1rem;
}

.record-name {
    flex-grow: 1;
    text-align: left;
}

.record-time {
    color: #f8fafc;
    font-family: monospace;
}

/* Initials Input */
.initials-input {
    background: transparent;
    border: none;
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    text-transform: uppercase;
    width: 3ch;
    padding: 0;
    outline: none;
    caret-color: transparent;
}

.cursor-flash {
    display: inline-block;
    width: 2px;
    height: 1.2rem;
    background: #fff;
    vertical-align: middle;
    margin-left: 2px;
    animation: flash 1s infinite step-end;
}

#end-time-display {
    font-family: monospace;
    font-size: 2rem;
    color: #f8fafc;
    margin-top: -1.5rem;
    margin-bottom: 1.5rem;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Mode Selection Buttons */
.mode-btns {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.mode-btn {
    padding: 1rem 2rem;
    min-width: 180px;
}

#timer-hud {
    position: absolute;
    top: 20px;
    left: 20px;
    font-family: monospace;
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.6);
    pointer-events: none;
}

