* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* Dark Mode (default) */
body.dark-mode {
    background-color: #1e1e1e;
    color: #f0f0f0;
}

/* Light Mode */
body.light-mode {
    background-color: #f5f5f5;
    color: #333;
}

.container {
    width: 90%;
    max-width: 600px;
    text-align: center;
}

h1 {
    margin-bottom: 20px;
}

.theme-toggle-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.theme-toggle {
    display: flex;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: inherit;
}

.theme-toggle-track {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
    background-color: #444;
    border-radius: 12px;
    margin-right: 8px;
    transition: background-color 0.3s ease;
}

.light-mode .theme-toggle-track {
    background-color: #ccc;
}

.theme-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #fff;
    transition: left 0.3s ease;
}

.light-mode .theme-toggle-thumb {
    left: 28px;
}

.instructions {
    margin-bottom: 30px;
    line-height: 1.6;
}

.dark-mode .instructions {
    color: #cccccc;
}

.game-area {
    position: relative;
    width: 100%;
    height: 300px;
    border-radius: 10px;
    overflow: hidden;
    user-select: none;
    cursor: pointer;
    transform: translateZ(0); /* Force hardware acceleration */
    backface-visibility: hidden; /* Reduce visual artifacts */
    perspective: 1000; /* Improve performance */
    will-change: background-color;
}

/* Game area states - Dark Mode */
.dark-mode .ready {
    background-color: #2b87d1;
}

.dark-mode .waiting {
    background-color: #c42b2b;
}

.dark-mode .click-now {
    background-color: #4daf4a;
}

.dark-mode .too-soon {
    background-color: #e67e22;
}

/* Game area states - Light Mode */
.light-mode .ready {
    background-color: #3498db;
}

.light-mode .waiting {
    background-color: #e74c3c;
}

.light-mode .click-now {
    background-color: #2ecc71;
}

.light-mode .too-soon {
    background-color: #f39c12;
}

.game-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
    width: 90%;
    will-change: contents;
}

.start-btn {
    margin-top: 20px;
    padding: 12px 24px;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.dark-mode .start-btn {
    background-color: #2b87d1;
}

.dark-mode .start-btn:hover {
    background-color: #1a5a8a;
}

.light-mode .start-btn {
    background-color: #3498db;
}

.light-mode .start-btn:hover {
    background-color: #2980b9;
}

.results {
    margin-top: 30px;
    padding: 20px;
    border-radius: 10px;
}

.dark-mode .results {
    background-color: #2a2a2a;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.light-mode .results {
    background-color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.current-time {
    font-size: 32px;
    font-weight: bold;
    margin: 10px 0;
}

.time-stats {
    display: flex;
    justify-content: space-around;
    margin-top: 15px;
}

.stat {
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
}

.dark-mode .stat-value {
    color: #2b87d1;
}

.light-mode .stat-value {
    color: #3498db;
}

.dark-mode .stat-label {
    color: #cccccc;
}

.light-mode .stat-label {
    color: #7f8c8d;
}

.hidden {
    display: none;
}

.calibration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.dark-mode .calibration-overlay {
    background-color: rgba(0, 0, 0, 0.8);
}

.light-mode .calibration-overlay {
    background-color: rgba(0, 0, 0, 0.5);
}

.calibration-content {
    padding: 30px;
    border-radius: 10px;
    max-width: 80%;
    text-align: center;
}

.dark-mode .calibration-content {
    background-color: #2a2a2a;
}

.light-mode .calibration-content {
    background-color: white;
    color: #333;
}

.calibration-progress {
    width: 100%;
    height: 20px;
    border-radius: 10px;
    margin: 20px 0;
    overflow: hidden;
}

.dark-mode .calibration-progress {
    background-color: #444;
}

.light-mode .calibration-progress {
    background-color: #ddd;
}

.calibration-bar {
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
}

.dark-mode .calibration-bar {
    background-color: #2b87d1;
}

.light-mode .calibration-bar {
    background-color: #3498db;
}

.reaction-history {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
}

.reaction-point {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    opacity: 0.5;
}

.dark-mode .reaction-point {
    background-color: #2b87d1;
}

.light-mode .reaction-point {
    background-color: #3498db;
}

.reaction-point.active {
    opacity: 1;
}

@media (max-width: 480px) {
    .time-stats {
        flex-direction: column;
        gap: 15px;
    }
}