:root {
    --wheat-light: #fef3c7;
    --wheat-glow: #f59e0b;
    --crust-dark: #452906;
    --crust-glow: #d97706;
    --white: #ffffff;
    --overlay-bg: rgba(45, 27, 4, 0.5); /* Much more transparent */
    --font-main: 'Outfit', 'Montserrat', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-main);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: radial-gradient(circle at center, #2d1b04 0%, #0c0802 100%);
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #1a0f02; /* Deep dark oven-like background */
    display: flex;
    justify-content: center;
    align-items: center;
}

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

#score-container {
    position: absolute;
    top: 3rem;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--white);
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

#score-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: opacity 0.6s ease, transform 0.6s ease;
    z-index: 50;
}

#score-container.faded {
    opacity: 0;
    transform: translateY(-30px);
    pointer-events: none;
}

#score-label {
    font-size: 0.8rem;
    font-weight: 900;
    letter-spacing: 0.4rem;
    color: #fbbf24; 
    opacity: 0.8;
    margin-bottom: -0.5rem;
}

#score-value {
    font-size: 5rem;
    font-weight: 900;
    color: var(--white); 
    text-shadow: 
        0 4px 0 #b45309, 
        0 8px 30px rgba(251, 191, 36, 0.3); 
    letter-spacing: -2px;
}

#combo-container {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    z-index: 1500;
    opacity: 0;
}

#combo-text {
    font-size: 2.2rem; /* Subtler, more premium scale */
    font-weight: 900;
    color: #fef3c7;
    text-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.4),
        0 0 30px #d97706,
        0 4px 0 #78350f;
    letter-spacing: -1.5px;
    transform: rotate(-8deg);
    text-transform: uppercase;
    font-family: 'Outfit', sans-serif;
}

.overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(circle at center, rgba(30, 20, 10, 0.2) 0%, rgba(15, 10, 5, 0.4) 100%);
    display: flex;
    flex-direction: column; 
    justify-content: center; /* Default: centered for start screen */
    align-items: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

#start-screen {
    gap: 4rem; /* Increased gap between major blocks */
    text-align: center;
    justify-content: center;
}

#start-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem; /* Tight header block */
}

#start-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem; /* Grouped game buttons */
    width: 100%;
}

#start-actions button {
    width: 85vw;
    max-width: 340px;
    min-width: 220px;
}

#game-over-screen {
    justify-content: space-between; /* Important for camera logic to fit tower in gap */
    padding: 10vh 0;
    background: none;
    backdrop-filter: none;
}

#score-container {
    position: absolute;
    top: 5vh;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    text-align: center;
    z-index: 2000;
    opacity: 0; /* Hidden by default for start screen */
    pointer-events: none;
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.8s ease;
}

#score-container.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.score-label {
    font-size: 0.7rem;
    font-weight: 800;
    color: #f59e0b;
    opacity: 0.6;
    letter-spacing: 4px;
    margin-bottom: 5px;
    display: none; /* Hide label during play, maybe show on GO */
}

#game-over-screen.active .score-label {
    display: block;
}

#score-value {
    font-size: 6.5rem;
    font-weight: 900;
    color: #fef3c7;
    text-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

#game-over-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
    width: 100%;
    transform: translateY(8vh);
    opacity: 0;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

#game-over-screen.active #game-over-actions {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
}

#restart-button {
    width: auto;
    min-width: 280px;
    padding: 22px 60px;
    font-weight: 900;
    font-size: 1.1rem;
    letter-spacing: 3px;
    color: #1a0f02;
    background: #fbbf24;
    border: none;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
}

#show-leaderboard-btn {
    background: transparent;
    border: 2px solid rgba(254, 243, 199, 0.4);
    color: #fef3c7;
    margin-top: 5px;
    padding: 12px 30px;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 3px;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.3s ease;
    pointer-events: all;
}

#show-leaderboard-btn:hover {
    background: rgba(254, 243, 199, 0.1);
    border-color: #fef3c7;
    transform: scale(1.05);
}

#back-to-menu-button {
    background: transparent;
    border: 2px solid rgba(254, 243, 199, 0.2);
    color: #fef3c7;
    padding: 14px 40px;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 3px;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.7;
}

#back-to-menu-button:hover {
    background: rgba(254, 243, 199, 0.05);
    border-color: rgba(254, 243, 199, 0.6);
    opacity: 1;
    transform: scale(1.05);
}

#restart-button:hover {
    background: #fef3c7;
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

/* Cleanup: Removed sidebar/receipt styles */

h1 { /* Corrected style for start screen only */
    font-size: clamp(3rem, 15vw, 5.5rem); /* Slightly larger now that it's stacked */
    font-weight: 900;
    color: #fef3c7;
    text-shadow: 0 10px 40px rgba(0, 0, 0, 0.4), 0 5px 0 #b45309;
    line-height: 0.85; /* Tighter stack */
    margin-bottom: 0.5rem;
    text-align: center;
}

h2 {
    font-size: clamp(0.7rem, 3.5vw, 1.2rem);
    font-weight: 700;
    color: #fbbf24;
    letter-spacing: clamp(0.3rem, 2vw, 0.8rem);
    margin-bottom: 0.5rem; /* Reduced to bring instructions closer */
    text-transform: uppercase;
}

p {
    font-size: clamp(0.9rem, 3vw, 1.1rem);
    color: var(--white);
    opacity: 0.7;
    margin-bottom: 0; /* Let flex gap handle it */
    max-width: 80%;
}

button {
    background: linear-gradient(135deg, #fbbf24, #d97706);
    border: none;
    padding: clamp(1rem, 4vw, 1.5rem) clamp(2rem, 8vw, 4rem);
    font-size: clamp(1.1rem, 4vw, 1.4rem);
    font-weight: 900;
    color: #452906;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4), inset 0 -4px 0 rgba(0,0,0,0.2);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease;
}

.secondary-btn {
    background: rgba(251, 191, 15, 0.1);
    color: #fbbf24;
    border: 2px solid #fbbf24;
    padding: 16px 40px;
    font-size: 1rem;
    font-weight: 900;
    margin-top: 15px;
    border-radius: 12px;
    cursor: pointer;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.btn-emoji {
    font-size: 1.4rem;
    transition: transform 0.3s ease;
}

.secondary-btn:hover {
    background: rgba(251, 191, 15, 0.25);
    border-color: #fef3c7;
    color: #fef3c7;
    transform: translateY(-4px) scale(1.02);
    box-shadow: 
        0 15px 40px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(251, 191, 36, 0.3);
}

.secondary-btn:hover .btn-emoji {
    transform: scale(1.3) rotate(15deg);
}

/* BMC BUTTON & FOOTER */
#start-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 2rem; /* Additional separation from buttons */
    padding-bottom: 30px;
    width: 100%;
}

#footer-links {
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

.bmc-button {
    background: #FFDD00;
    border: 1px solid transparent;
    padding: 10px 20px;
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 900;
    color: #000000;
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.bmc-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.developer-credit {
    font-size: 0.8rem;
    font-weight: 700;
    opacity: 0.5;
    margin-top: 15px;
    letter-spacing: 1px;
    color: #fef3c7;
}

.developer-credit a {
    text-decoration: none;
}

button:hover {
    transform: scale(1.05) translateY(-5px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

button:active {
    transform: scale(0.95) translateY(0);
}

#game-over-info {
    margin-bottom: 3rem;
    animation: float 3s ease-in-out infinite;
}

#final-stats-label {
    font-size: 1rem;
    font-weight: 900;
    color: #d97706;
    letter-spacing: 0.3rem;
}

#final-stats-value {
    font-size: 6rem;
    font-weight: 900;
    color: #fef3c7;
    text-shadow: 0 10px 0 #b45309;
    margin-bottom: 1rem;
}

#fun-comparison {
    font-style: italic;
    color: #fbbf24;
    opacity: 1;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

#game-canvas, #top-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent !important;
}

#top-canvas {
    pointer-events: none;
    z-index: 10005;
}

canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
}


#start-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    pointer-events: all;
    width: 90%;
}

.bmc-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(0.6rem, 2vw, 0.8rem) clamp(1.5rem, 5vw, 2.5rem);
    border: 2px solid #d97706;
    background: rgba(0, 0, 0, 0.4);
    color: #fbbf24;
    text-decoration: none;
    font-size: clamp(0.7rem, 2.5vw, 0.9rem);
    font-weight: 700;
    letter-spacing: clamp(0.1rem, 1vw, 0.3rem);
    text-transform: uppercase;
    transition: all 0.3s ease;
    cursor: pointer;
    width: auto;
}

.bmc-button:hover {
    background: #d97706;
    color: #1a0f02;
    box-shadow: 0 0 20px rgba(217, 119, 6, 0.4);
    transform: translateY(-2px);
}

.developer-credit {
    font-size: clamp(0.5rem, 2vw, 0.65rem);
    color: var(--white);
    opacity: 0.4;
    letter-spacing: clamp(0.2rem, 2.5vw, 0.5rem);
    text-transform: uppercase;
    font-weight: 700;
    text-align: center;
}

/* Mobile specific tweaks */
@media (max-height: 700px) {
    #start-screen {
        gap: 0.8rem;
    }
    h2, p {
        margin-bottom: 1.5rem;
    }
    #start-footer {
        gap: 0.8rem;
    }
}

.developer-credit a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 4px;
    transition: opacity 0.3s ease;
}

.developer-credit a:hover {
    opacity: 1;
}

#name-entry-overlay {
    background: rgba(15, 10, 5, 0.4);
    backdrop-filter: blur(25px) saturate(220%);
    z-index: 9999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#name-entry-overlay.active {
    display: flex;
    opacity: 1;
}

#name-input-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    width: 90%;
    max-width: 400px;
    background: rgba(15, 10, 5, 0.8);
    padding: 3rem 2rem;
    border-radius: 30px;
    border: 2px solid rgba(251, 191, 36, 0.3);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
}

#name-input-container h2 {
    margin-bottom: 0.5rem;
    font-size: 2.8rem;
    line-height: 1.0;
    letter-spacing: -2px;
    color: #fef3c7;
    text-shadow: 
        0 0 30px rgba(251, 191, 36, 0.6),
        0 4px 0 #b45309;
    text-align: center;
}

#player-name {
    width: 100%;
    padding: 18px 25px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(251, 191, 36, 0.2);
    border-radius: 18px;
    color: #fef3c7;
    font-size: 1.2rem;
    font-weight: 800;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 3px;
    outline: none;
    transition: all 0.3s ease;
}

#player-name::placeholder {
    color: rgba(254, 243, 199, 0.3);
    font-size: 0.9rem;
    letter-spacing: 1px;
}

#player-name:focus {
    border-color: #fbbf24;
    background: rgba(0, 0, 0, 0.7);
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.2);
}

#submit-score-btn {
    width: auto;
    min-width: 200px;
    padding: 12px 30px;
    font-size: 0.9rem;
    border-radius: 100px;
    background: #f59e0b;
    color: #1a0f02;
    font-weight: 900;
    letter-spacing: 2px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

#leaderboard-overlay {
    background: radial-gradient(circle at center, rgba(30, 20, 10, 0.95) 0%, #0c0802 100%);
    backdrop-filter: blur(10px);
}

#leaderboard-container {
    width: 90%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.leaderboard-title {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 2rem;
    width: 100%;
}

.title-light {
    font-weight: 300;
    letter-spacing: 8px;
    color: rgba(254, 243, 199, 0.7);
    font-size: 1.8rem;
}

.title-bold {
    font-weight: 900;
    letter-spacing: 2px;
    color: #fbbf24;
    font-size: 2.2rem;
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.4);
}

#leaderboard-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    max-height: 50vh;
    overflow-y: auto;
    padding: 10px;
}

/* Custom Scrollbar */
#leaderboard-list::-webkit-scrollbar {
    width: 6px;
}
#leaderboard-list::-webkit-scrollbar-thumb {
    background: rgba(251, 191, 36, 0.3);
    border-radius: 10px;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 25px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    width: 98%;
    margin: 0 auto;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Prestige Tiers */
.rank-1 { 
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.12), rgba(217, 119, 6, 0.12));
    border-color: rgba(251, 191, 36, 0.6);
    transform: scale(1.03);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
}
.rank-1 .entry-rank { color: #fbbf24; font-size: 1.6rem; text-shadow: 0 0 15px rgba(251, 191, 36, 0.4); }

.rank-2 { 
    background: linear-gradient(90deg, rgba(229, 231, 235, 0.08), rgba(156, 163, 175, 0.08));
    border-color: rgba(209, 213, 219, 0.3);
}
.rank-2 .entry-rank { color: #e5e7eb; }

.rank-3 { 
    background: linear-gradient(90deg, rgba(217, 119, 6, 0.08), rgba(120, 53, 15, 0.08));
    border-color: rgba(217, 119, 6, 0.3);
}
.rank-3 .entry-rank { color: #d97706; }

/* Submission Highlight */
.newly-submitted {
    animation: pulse-gold 2s infinite ease-in-out;
    border-color: #fbbf24 !important;
}

@keyframes pulse-gold {
    0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); transform: scale(1); }
    50% { box-shadow: 0 0 30px 5px rgba(251, 191, 36, 0.2); transform: scale(1.02); }
    100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); transform: scale(1); }
}

.entry-rank {
    font-weight: 900;
    color: #fbbf24;
    font-size: 1.2rem;
    width: 30px;
}

.entry-info {
    flex-grow: 1;
    margin-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.entry-name {
    font-weight: 800;
    color: #fef3c7;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 1.1rem;
}

.entry-time {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(254, 243, 199, 0.4);
    letter-spacing: 1px;
}

.entry-score {
    font-weight: 900;
    color: #fbbf24;
    font-size: 1.6rem;
    text-shadow: 0 0 15px rgba(251, 191, 36, 0.3);
}

#close-leaderboard-btn {
    margin-top: 1rem;
    background: transparent;
    border: 2px solid rgba(254, 243, 199, 0.4);
    color: #fef3c7;
    padding: 12px 40px;
    font-size: 0.9rem;
    border-radius: 100px;
}

#close-leaderboard-btn:hover {
    background: rgba(254, 243, 199, 0.1);
    border-color: #fef3c7;
}

#save-score-btn {
    background: #f59e0b;
    color: #1a0f02;
}

.text-btn {
    background: transparent !important;
    border: none !important;
    color: #fbbf24 !important;
    font-size: 0.8rem !important;
    padding: 0 !important;
    opacity: 0.6;
    box-shadow: none !important;
}

.text-btn:hover {
    opacity: 1;
    text-decoration: underline;
}
