/* Reaction Time Game Styles */

:root {
    --color-idle: #FFD93D;
    --color-waiting: #FF6B6B;
    --color-ready: #4CAF50;
    --color-result: #FFD93D;
    --color-too-early: #FF6B6B;
    --color-text: #333;
    --color-text-light: rgba(0, 0, 0, 0.6);
    --font-main: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-main);
    background: var(--color-idle);
    color: var(--color-text);
}

.game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
}

.content {
    text-align: center;
    padding: 2rem;
    max-width: 90%;
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.3);
}

.instruction {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

/* Controls shown only in idle state */
.controls-inline {
    margin-bottom: 1rem;
}

.state-waiting .controls-inline,
.state-ready .controls-inline,
.state-result .controls-inline,
.state-too-early .controls-inline {
    display: none;
}

.result-time {
    font-size: 4rem;
    font-weight: 700;
    margin: 1rem 0;
    line-height: 1.2;
}

.best-time {
    font-size: 1.25rem;
    color: var(--color-text-light);
    margin-bottom: 0.5rem;
}

.hint {
    font-size: 1rem;
    color: var(--color-text-light);
    margin-top: 1.5rem;
}

.home-link {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    transition: background 0.2s;
}

.home-link:hover {
    background: rgba(255, 255, 255, 0.8);
}

.home-link:active {
    transform: translateX(-50%) scale(0.95);
}

/* State: Idle (start screen) */
.state-idle {
    background-color: var(--color-idle);
}

/* State: Waiting (red, wait for green) */
.state-waiting {
    background-color: var(--color-waiting);
}

.state-waiting .title,
.state-waiting .instruction,
.state-waiting .home-link {
    color: white;
}

.state-waiting .home-link {
    background: rgba(0, 0, 0, 0.2);
}

.state-waiting .home-link:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* State: Ready (green, tap now!) */
.state-ready {
    background-color: var(--color-ready);
}

.state-ready .title,
.state-ready .instruction,
.state-ready .home-link {
    color: white;
}

.state-ready .home-link {
    background: rgba(0, 0, 0, 0.2);
}

.state-ready .home-link:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* State: Result */
.state-result {
    background-color: var(--color-result);
}

/* New Best celebration */
.state-result.new-best {
    animation: celebrate 0.6s ease-out;
}

.state-result.new-best .result-time {
    animation: score-pop 0.4s ease-out;
}

.state-result.new-best .title {
    color: #E6A700;
}

@keyframes celebrate {
    0% {
        background-color: #FFE566;
        box-shadow: inset 0 0 100px rgba(255, 215, 0, 0.5);
    }
    50% {
        background-color: #FFF0A0;
        box-shadow: inset 0 0 150px rgba(255, 215, 0, 0.3);
    }
    100% {
        background-color: var(--color-result);
        box-shadow: none;
    }
}

@keyframes score-pop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* State: Too Early */
.state-too-early {
    background-color: var(--color-too-early);
}

.state-too-early .title,
.state-too-early .instruction,
.state-too-early .hint,
.state-too-early .home-link {
    color: white;
}

.state-too-early .home-link {
    background: rgba(0, 0, 0, 0.2);
}

.state-too-early .home-link:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Responsive */
@media (max-width: 600px) {
    .title {
        font-size: 1.75rem;
    }

    .instruction {
        font-size: 1.25rem;
    }

    .result-time {
        font-size: 3rem;
    }

    .best-time {
        font-size: 1rem;
    }
}

/* Prevent text selection during gameplay */
.game-container * {
    user-select: none;
    -webkit-user-select: none;
}
