body {
    font-family: "Plus Jakarta Sans", sans-serif;
    background-color: #f0f0f0; /* Fallback background, canvas will cover */
    color: #333;
}

#game-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#ui-container {
    /* Styles for ui-container are in index.html for higher specificity */
    /* This ensures they override default body/flex behaviors if any */
}

.hud-score-display {
    display:flex;
    flex-direction: row;
}


#hud-top {
    padding-top: 15px;
    display:flex;
    justify-content: row;
}

#score-display, #player-score-hud, #ai-score-hud, #vs-text-hud {
    vertical-align: middle;
    align-self: center;
    font-size: 1.2em;
    /* font-weight: bold; */
    color: #333;
    /* background-color: rgba(255, 255, 255, 0.7); */
    padding: 3px 10px;
    border-radius: 5px;
}

#money-display {
    font-size: 1.5em;
    font-weight: bold;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 5px 15px;
    border-radius: 8px;
}

#stage-display {
    font-size: 0.8em; /* Smaller font for inside the bar */
    font-weight: bold;
    color: rgba(0, 0, 0, 0.7); /* Dark text for contrast */
    text-shadow: 1px 1px 1px rgba(255,255,255,0.5); /* Light shadow for readability */
    position: absolute; /* Position absolutely inside container */
    left: 50%; /* Center horizontally */
    top: 50%;  /* Center vertically */
    transform: translate(-50%, -50%); /* Exact centering */
    z-index: 2; /* Ensure it's above the progress bar fill */
    pointer-events: none; /* Prevent text from interfering with clicks if any */
}

#hud-bottom {
    padding-bottom: 20px;
    max-width: 500px; /* Limit width of buttons on wider screens */
    margin-left: auto;
    margin-right: auto;
}

#hud-bottom button {
    font-family: "Plus Jakarta Sans", sans-serif; /* Explicitly set font */

    padding: 12px 8px;
    font-size: 0.9em;
    font-weight: bold;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    flex-grow: 1;
    margin: 0 5px;
    text-align: center;
    line-height: 1.3;
    box-shadow: 0 3px 5px rgba(0,0,0,0.2);
    transition: background-color 0.2s ease, transform 0.1s ease;
    min-width: 110px; /* Ensure buttons don't get too squeezed */
}

#hud-bottom button span {
    font-size: 1.1em;
    display: block;
    margin-top: 4px;
}

#hud-bottom button:hover {
    transform: translateY(-2px);
}

#hud-bottom button:active {
    transform: translateY(0px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

#upgrade-speed {
    background-color: #f39c12; /* Yellow/Orange */
}
#upgrade-speed:hover:not(:disabled) {
    background-color: #e68a00;
}

#upgrade-knives {
    background-color: #e74c3c; /* Red/Orange */
}
#upgrade-knives:hover:not(:disabled) {
    background-color: #c0392b;
}

#upgrade-multiplier, #upgrade-blitz {
    background-color: #2ecc71; /* Green */
}
#upgrade-multiplier:hover:not(:disabled), #upgrade-blitz:hover:not(:disabled) {
    background-color: #27ae60;
}

/* Style for disabled buttons */
#hud-bottom button:disabled {
    background-color: #95a5a6; /* Grey */
    color: #e0e0e0;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

#progress-bar-container {
    width: 80%;
    max-width: 300px;
    height: 18px; /* Slightly taller to accommodate text */
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 9px; /* Match height */
    margin: 8px auto 0;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.1);
    position: relative; /* Needed for absolute positioning of children */
}

#progress-bar-fill {
    width: 0%; 
    height: 100%;
    background-color: #4CAF50; 
    border-radius: 8px; /* Slightly smaller */
    transition: width 0.3s ease-in-out;
    position: relative; /* To potentially place things relative to the fill if needed */
    z-index: 1; /* Below the stage text */
}

/* Start Screen Styles */
#top-left-reset-area {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1001; /* Ensure it's above other start screen elements */
}

#top-right-profile-area {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    z-index: 1001; /* Ensure it's above other start screen elements but potentially below popups */
}

#welcome-message-span {
    color: #ffffff;
    margin-right: 10px;
    font-size: 0.9em; /* Adjust as needed */
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

#add-to-homescreen-button {
    position: absolute;
    bottom: 20px; /* Adjust as needed for padding from the bottom */
    padding: 12px 25px;
    font-size: 0.7em;
    background-color: #dadada; /* Example color, adjust to your theme */
    color: #333;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    width:300px;
    left:0;
    right:0;
    margin:auto;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 100; /* Ensure it's above other start screen elements if necessary */
    line-height: 1.5;
}

#add-to-homescreen-button:hover {
    background: linear-gradient(145deg, #42A5F5, #1E88E5);
}

#add-to-homescreen-button:active {
    background: linear-gradient(145deg, #1976D2, #1565C0);
}

#add-to-homescreen-button .material-icons {
    font-size: 1.4em;
    margin-right: 8px;
    vertical-align: middle;
}

#start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Subtle gradient background */
    background: linear-gradient(rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0.85));
    display: flex;
    flex-direction: column; /* Stack title and button vertically */
    justify-content: center;
    align-items: center;
    z-index: 1000; 
    color: white; /* Default text color for start screen */
    text-align: center; /* Ensure text within elements is centered */
    padding-bottom: 100px; /* Added padding to prevent overlap with bottom button */
    box-sizing: border-box; /* Ensure padding is included in height calculation */
}

#game-title {
    font-size: 4.5em; /* Much larger title */
    font-weight: 700; /* Bold weight */
    color: #FFC107; /* Amber color, like Game Over title */
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5); /* Add shadow */
    margin-bottom: 40px; /* Space between title and button */
    letter-spacing: 2px; /* Add some letter spacing */
    text-transform: uppercase; /* Make title uppercase */
}

#start-game-button, #start-vs-ai-button {
    padding: 20px 45px; /* Slightly adjusted padding */
    font-size: 1.9em;
    font-weight: 700; /* Bold button text */
    color: white;
    background: linear-gradient(145deg, #5cb85c, #4CAF50); /* Green gradient */
    border: none;
    border-radius: 12px; /* Slightly more rounded */
    cursor: pointer;
    width: 300px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.4); /* Stronger shadow */
    transition: background 0.3s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

#start-vs-ai-button {
    background: linear-gradient(145deg, #eb1845, #eb1845); /* Green gradient */
    font-size: 1.9em;
}

#start-game-button:hover {
    background: linear-gradient(145deg, #66cc66, #5cb85c);
    transform: scale(1.05) translateY(-2px); /* Lift and scale */
    box-shadow: 0 8px 22px rgba(0,0,0,0.45);
}

#start-game-button:active {
    transform: scale(1.0) translateY(0px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* Top Right Controls */
#top-right-controls {
    position: absolute;
    top: 120px; /* Further increased top margin based on user feedback (60px + 100px) */
    right: 10px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: auto;
}

#top-right-controls button {
    background-color: rgba(0,0,0,0.4);
    color: white;
    /* border: 1px solid rgba(255,255,255,0.3); */
    padding: 6px 10px;
    border-radius:100%;
    cursor: pointer;
    margin-bottom: 5px;
    font-size: 0.8em;
    width: 50; /* Ensure text fits */
    height:50px;
    text-align: center;
}

#top-right-controls button:hover {
    background-color: rgba(0,0,0,0.6);
}

/* Timer Display */
#timer-display {
    font-size: 1.8em; /* Or your preferred size */
    color: black;   /* --- ADD THIS LINE or change to your default HUD text color --- */
    margin-top: 8px;
    width: 100px;
    background-color: rgba(255, 255, 255, 0.6);
    padding: 10px 0px;
    border-radius: 5px;
    display: inline-block;
    transition: color 0.3s ease, transform 0.3s ease; /* Smooth transition for color/scale if needed */
}

@keyframes pulsate {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.12);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.timer-pulsate {
    animation: pulsate 0.6s infinite ease-in-out;
    color: #E53935 !important; /* Pulsates to red. !important can help override other styles */
    font-weight: bold;
}

/* Game Over Screen Styles */
#game-over-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000; 
    color: white;
    text-align: center;
    padding: 15px; /* Slightly reduced padding */
    box-sizing: border-box;
    overflow-y: auto; /* Allow scrolling if content still overflows */
}

#game-over-screen h2 {
    font-size: 2.0em; /* Reduced from 2.5em */
    margin-bottom: 10px; /* Reduced margin */
    color: #FFC107; /* Amber */
    margin-top:0px;
}

#game-over-screen p#final-score-message {
    font-size: 1.2em; /* Reduced from 1.4em */
    margin: 10px 0px 0px 0px
}

#game-over-screen h3 {
    font-size: 1.1em; /* Reduced from 1.2em */
    margin-bottom: 8px; /* Reduced margin */
    color: #FF9800; /* Orange */
}

#high-scores-tabs {
    margin-bottom: 0px; /* Reduced margin */
}

.score-tab {
    padding: 8px 15px; /* Reduced padding */
    font-size: 1.0em; /* Reduced font size */
}

#global-scores-container,
#local-scores-container {
    margin-bottom: 20px; /* Reduced margin */
}

/* --- Leaderboard Table Styles --- */
#high-scores-table,
#local-scores-table {
    width: 95%; /* Slightly wider to use space */
    max-width: 400px; /* Increased max-width slightly */
    margin: 0 auto 20px auto; /* Reduced bottom margin */
    border-collapse: collapse;
    color: white;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    overflow: hidden; /* Ensures border-radius clips content */
}

#high-scores-table th,
#local-scores-table th {
    padding: 10px 8px; /* Reduced padding */
    text-align: left;
    font-weight: bold;
    font-size: 1.0em; /* Reduced font size */
}

#high-scores-table td,
#local-scores-table td {
    padding: 8px 8px; /* Reduced padding */
    font-size: 0.9em; /* Reduced font size */
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#high-scores-table tbody tr:first-child td,
#local-scores-table tbody tr:first-child td {
    border-top: none; /* Remove top border for the first row in tbody */
}

/* Vibrant Rank Colors (Inspired by Game Over Text) */
.rank-1 td { background-color: rgba(255, 193, 7, 0.8); color: #333; } /* Vibrant Gold/Amber (From Game Over Title) */
.rank-2 td { background-color: rgba(192, 192, 192, 0.8); color: #333; } /* Vibrant Silver (Standard Silver, brighter) */
.rank-3 td { background-color: rgba(205, 127, 50, 0.8); color: #eee; } /* Vibrant Bronze (More saturated) */
.rank-other td { background-color: rgba(117, 117, 117, 0.3); } /* Slightly darker transparent Grey for contrast */

/* Highlight current player's score row */
.current-high-score td {
    font-weight: bold;
    /* Keep the rank background color, but maybe add a border or change text color slightly? */
    /* Example: Add a subtle left border */
    border: 3px solid #FFEB3B !important; /* Yellow border - Added !important */
    padding-left: 7px; /* Adjust padding to account for border */
}

.game-over-buttons {
    display: flex;
    justify-content: center; /* Center buttons horizontally */
    align-items: center; /* Align items vertically */
    gap: 15px; /* Add space between buttons */
    /* margin-top: 20px; Add some space above the button group */
}

#restart-game-button {
    padding: 12px 25px; /* Reduced padding */
    font-size: 1.3em; /* Reduced font size */
    color: white;
    background-color: #4CAF50;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}
#restart-game-button:hover {
    background-color: #45a049;
}

/* Icon Button Specific Styles */
.icon-button {
    font-size: 1.2em;
    padding: 8px;
    min-width: 48px;
    max-width: 48px;
    height: 48px;
    line-height: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: none; /* Transparent background */
    border: none; /* No border */
    color: #555; /* Darker icon color for visibility without background */
    cursor: pointer; /* Ensure cursor indicates clickability */
    transition: color 0.2s ease, transform 0.1s ease;
}

.icon-button1 {
    min-width: 48px;
    max-width: 100%;
}

.icon-button:hover {
    color: #000; /* Darken icon on hover */
    transform: scale(1.1);
}

.icon-button .material-icons {
    font-size: 30px; /* Slightly larger icon size */
    vertical-align: middle;
}

/* Specific margin for share button icon */
#share-score-button {
    /* margin-top: 10px; */ /* Removed margin-top as gap handles spacing */
    font-size: 0.9em; /* Reduced font size */
    /* color: white; */ /* Removed default white color */
    background-color: #FF9800; /* Orange color like h3 */
    color: white; /* Set text color to white for contrast */
    padding: 10px 15px; /* Adjust padding for better appearance */
    border-radius: 8px; /* Add border-radius */
    border: none; /* Ensure no default border */
    box-shadow: 0 3px 5px rgba(0,0,0,0.2); /* Add subtle shadow */
    display: inline-flex; /* Use inline-flex for icon alignment */
    align-items: center; /* Align icon and text */
    gap: 5px; /* Space between icon and text */
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#share-score-button:hover {
    background-color: #FB8C00; /* Darker orange on hover */
}

#share-score-button .material-icons {
    font-size: 1.2em; /* Adjust icon size if needed */
}

/* Remove specific background colors for icon buttons */
#pause-button {
    /* background-color: #FF9800; */
}
#pause-button:hover {
    /* background-color: #FB8C00; */
}

#menu-button {
    /* background-color: #2196F3; */
}
#menu-button:hover {
    /* background-color: #1E88E5; */
}

#sound-toggle-button {
    /* background-color: #4CAF50; */
}
#sound-toggle-button:hover {
    /* background-color: #43A047; */
} 

.floating-money{position:absolute;}

/* Toggle Switch Styles */
.setting-toggle {
    /* Add any container styling if needed */
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;  /* Width of the switch */
    height: 24px; /* Height of the switch */
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #777; /* Default OFF color */
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px; /* Size of the knob */
    width: 18px;
    left: 3px;   /* Padding from left */
    bottom: 3px; /* Padding from bottom */
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: #4CAF50; /* ON color (e.g., Green) */
}

input:focus + .slider {
    box-shadow: 0 0 1px #4CAF50;
}

input:checked + .slider:before {
    transform: translateX(26px); /* How far the knob moves */
}

/* Rounded sliders */
.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

#chop-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

#object-type-selector button {
    background-color: white;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 50%; /* Makes the button round */
    width: 50px; /* Fixed width */
    height: 50px; /* Fixed height */
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 5px; /* Spacing between buttons and display */
    padding: 0; /* Remove default padding */
    line-height: 1; /* Adjust for better vertical centering of text */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

#object-type-selector button:hover {
    background-color: #f0f0f0;
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

#object-type-selector button:active {
    background-color: #e0e0e0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Specific styles if needed, but the common one above should cover it */
/*
#prev-object-type-button {
}

#next-object-type-button {
}
*/

#high-scores-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.score-tab {
    padding: 10px 20px;
    background-color: rgba(255,255,255,0.1);
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-size: 1.1em;
    transition: background-color 0.3s ease;
}

.score-tab:hover {
    background-color: rgba(255,255,255,0.2);
}

.score-tab.active {
    background-color: rgba(255,255,255,0.3);
    font-weight: bold;
}

#global-scores-container,
#local-scores-container {
    margin-bottom: 30px;
}

#high-scores-list,
#local-scores-list {
    list-style-type: none;
    padding: 0;
    margin-bottom: 30px;
    max-width: 300px;
    width: 100%;
}

/* --- Leaderboard Table Styles --- */
#high-scores-table,
#local-scores-table {
    width: 90%;
    max-width: 350px;
    margin: 0 auto 0px auto;
    border-collapse: collapse;
    color: white;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    overflow: hidden; /* Ensures border-radius clips content */
    margin-top:20px;
}

#high-scores-table thead,
#local-scores-table thead {
    background-color: rgba(255, 255, 255, 0.2);
}

#high-scores-table th,
#local-scores-table th {
    padding: 12px 10px;
    text-align: left;
    font-weight: bold;
    font-size: 1.1em;
}

#high-scores-table td,
#local-scores-table td {
    padding: 10px 10px;
    font-size: 1em;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#high-scores-table tbody tr:first-child td,
#local-scores-table tbody tr:first-child td {
    border-top: none; /* Remove top border for the first row in tbody */
}

/* Remove old list styles */
/*
#high-scores-list,
#local-scores-list {
    list-style-type: none;
    padding: 0;
    margin-bottom: 30px;
    max-width: 300px;
    width: 100%;
}

#high-scores-list li,
#local-scores-list li {
    background-color: rgba(255,255,255,0.1);
    padding: 8px;
    margin-bottom: 5px;
    border-radius: 4px;
    font-size: 1.1em;
    text-align: left;
}

#high-scores-list li.current-high-score,
#local-scores-list li.current-high-score {
    font-weight: bold;
    color: #FFEB3B; 
    background-color: rgba(255, 235, 59, 0.2);
}
*/

/* Style for the new reset button (can be same as profile button for consistency) */
#reset-cache-button {
    font-size: 28px; /* Material icon size */
    padding: 8px;
    background-color: rgba(255,255,255,0.1);
    border-radius: 50%;
    color: #fff;
    border: none;
    cursor: pointer;
    display: inline-flex; /* Helps center the icon */
    align-items: center;
    justify-content: center;
}

#reset-cache-button .material-icons {
    font-size: inherit; /* Make icon size same as button font-size */
}