body {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 100vh;
    font-family: sans-serif;
    background-color: #f0f0f0;
    user-select: none; /* Prevent text selection during rapid clicking */
    padding: 20px 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark mode styles */
body.dark-mode {
    background-color: #121212;
    color: #e0e0e0;
}

#game-container {
    background-color: #fff;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
    width: 90%;
    max-width: 400px; /* Added max-width for better control */
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

body.dark-mode #game-container {
    background-color: #1e1e1e;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

h1 {
    color: #333;
    margin-bottom: 10px;
    transition: color 0.3s ease;
}

body.dark-mode h1 {
    color: #e0e0e0;
}

#instructions {
    color: #666;
    margin-top: 10px;
    margin-bottom: 20px;
    transition: color 0.3s ease;
}

body.dark-mode #instructions {
    color: #aaa;
}

#status-display {
    display: flex;
    justify-content: center; /* Center the single status message */
    font-size: 1.2em;
    margin-bottom: 25px;
    color: #444;
    min-height: 1.5em; /* Ensure space for message */
    height: 1.5em; /* Fixed height to prevent movement */
    margin-top: 5px; /* Add top margin to separate from reaction time display */
    transition: color 0.3s ease;
}

body.dark-mode #status-display {
    color: #c0c0c0;
}

#click-target {
    display: block; /* Make it block to control width/margin easily */
    width: 200px; /* Increased from 150px */
    height: 200px; /* Increased from 150px */
    margin: 20px auto; /* Center the button */
    background-color: #cccccc; /* Default: Disabled/Waiting state color */
    color: white;
    font-size: 1.8em; /* Increased from 1.5em to match larger button */
    font-weight: bold;
    border: none;
    border-radius: 20px; /* Changed from 50% to 20px for rounded rectangle */
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease; /* Adjusted transition */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative; /* Add positioning context */
}

/* Style for the 'waiting' period before it turns ready */
#click-target.waiting {
    background-color: #ff4757; /* Red: Wait state */
    cursor: pointer; /* Allow clicks (for premature detection) */
}

/* Style for when the target is ready to be clicked */
#click-target.ready {
    background-color: #2ed573; /* Green: Ready state */
    cursor: pointer;
}

#click-target.ready:hover {
     background-color: #7bed9f; /* Lighter green on hover */
}

#click-target:active:not(:disabled) { /* Keep active effect for ready state */
    transform: scale(0.95); /* Click effect */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#click-target:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    box-shadow: none;
}

#start-button {
    padding: 10px 20px;
    font-size: 1.1em;
    background-color: #1e90ff; /* Blue start button */
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin-top: 10px; /* Add some space above */
}

#start-button:hover:not(:disabled) {
    background-color: #4faaff; /* Lighter blue */
}

#start-button:disabled {
     background-color: #a4ceff; /* Lighter blue disabled */
     cursor: not-allowed;
}

#reaction-time-display { 
    margin-top: 20px;
    font-size: 1.3em;
    font-weight: bold;
    color: #333; /* Changed color */
    min-height: 2em; /* Reserve space */
    height: 2em; /* Fixed height to prevent movement */
    transition: color 0.3s ease;
}

body.dark-mode #reaction-time-display {
    color: #c0c0c0;
}

#reference-times {
    margin-top: 20px;
    background-color: #f8f8f8;
    border-radius: 8px;
    padding: 12px;
    font-size: 0.9em;
    text-align: left;
    transition: background-color 0.3s ease;
}

body.dark-mode #reference-times {
    background-color: #2a2a2a;
}

#reference-times h3 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 1.1em;
    text-align: center;
    color: #333;
    transition: color 0.3s ease;
}

body.dark-mode #reference-times h3 {
    color: #e0e0e0;
}

#reference-times ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#reference-times li {
    padding: 4px 0;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed #eee;
    transition: border-color 0.3s ease;
}

body.dark-mode #reference-times li {
    border-bottom: 1px dashed #444;
}

#reference-times li:last-child {
    border-bottom: none;
}

.reference-category {
    font-weight: bold;
    color: #555;
    transition: color 0.3s ease;
}

body.dark-mode .reference-category {
    color: #c0c0c0;
}

.reference-time {
    color: #666;
    transition: color 0.3s ease;
}

body.dark-mode .reference-time {
    color: #aaa;
}

#results-container {
    background-color: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
    width: 90%;
    max-width: 400px; /* Added max-width */
    margin-top: 20px;
    margin-bottom: 20px;
    position: relative;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

body.dark-mode #results-container {
    background-color: #1e1e1e;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

#results-container h2 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2em;
    transition: color 0.3s ease;
}

body.dark-mode #results-container h2 {
    color: #e0e0e0;
}

#language-selector {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
}

#sound-toggle {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 100;
}

#sound-label {
    font-size: 1.5em;
    cursor: pointer;
}

#sound-checkbox {
    display: none; /* Hide the actual checkbox */
}

#language-select {
    padding: 5px;
    border-radius: 5px;
    border: 1px solid #ddd;
    background-color: white;
    font-size: 0.9em;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

body.dark-mode #language-select {
    background-color: #2a2a2a;
    border-color: #444;
    color: #e0e0e0;
}

#results-list {
    list-style: none;
    padding: 0;
    margin: 0 0 15px 0;
    max-height: 400px; /* Increased height to accommodate more entries */
    overflow-y: auto; /* Add scrollbar if needed */
    border: 1px solid #eee;
    border-radius: 5px;
    transition: border-color 0.3s ease;
}

body.dark-mode #results-list {
    border-color: #444;
}

#results-list li {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    color: #555;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    text-align: left;
    transition: border-color 0.3s ease, color 0.3s ease;
}

body.dark-mode #results-list li {
    border-color: #444;
    color: #c0c0c0;
}

#results-list li.rank-1 {
    background-color: #fff9c4; /* Gold background */
    font-weight: bold;
    transition: background-color 0.3s ease;
}

body.dark-mode #results-list li.rank-1 {
    background-color: #524800; /* Dark gold background */
}

#results-list li.rank-2 {
    background-color: #f5f5f5; /* Silver background */
    font-weight: bold;
    transition: background-color 0.3s ease;
}

body.dark-mode #results-list li.rank-2 {
    background-color: #3a3a3a; /* Dark silver background */
}

#results-list li.rank-3 {
    background-color: #ffccbc; /* Bronze background */
    font-weight: bold;
    transition: background-color 0.3s ease;
}

body.dark-mode #results-list li.rank-3 {
    background-color: #4a2e24; /* Dark bronze background */
}

#results-list li:last-child {
    border-bottom: none;
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-right: 10px;
    object-fit: cover;
    border: 1px solid #eee;
    transition: border-color 0.3s ease;
}

body.dark-mode .user-avatar {
    border-color: #444;
}

.ranking-info {
    flex: 1;
}

#clear-results-button {
    padding: 8px 15px;
    font-size: 0.9em;
    background-color: #ff6b6b; /* Red for clear */
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#clear-results-button:hover {
    background-color: #ff4757; /* Darker red */
}

/* Add theme toggle styles */
#theme-toggle {
    position: absolute;
    top: 10px;
    left: 60px;
    z-index: 100;
}

#theme-label {
    font-size: 1.5em;
    cursor: pointer;
}

#theme-checkbox {
    display: none; /* Hide the actual checkbox */
}