/* Number Chain Game Styles */

:root {
    --color-bg: #FFD93D;
    --color-btn: #4A90D9;
    --color-btn-hover: #357ABD;
    --color-correct: #4CAF50;
    --color-wrong: #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-bg);
    color: var(--color-text);
}

.game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    user-select: none;
    -webkit-user-select: none;
}

.header {
    text-align: center;
    padding: 1rem;
    flex-shrink: 0;
}

.title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.instruction {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.timer {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text);
}

.best-time {
    font-size: 1rem;
    color: var(--color-text-light);
}

.numbers-area {
    flex: 1;
    position: relative;
    margin: 0.5rem;
    margin-bottom: 4rem;
}

.number-btn {
    position: absolute;
    border: none;
    border-radius: 50%;
    background: var(--color-btn);
    color: white;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, background-color 0.1s, opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.number-btn:hover {
    background: var(--color-btn-hover);
    transform: scale(1.1);
}

.number-btn:active {
    transform: scale(0.95);
}

.number-btn.correct {
    background: var(--color-correct);
}

.number-btn.wrong {
    background: var(--color-wrong);
    animation: shake 0.2s ease-in-out;
}

.number-btn.hidden {
    opacity: 0;
    pointer-events: none;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Result overlay */
.result-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    text-align: center;
    padding: 2rem;
}

.state-result .result-overlay {
    display: flex;
}

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

.state-result.new-best .result-time {
    animation: score-pop 0.4s ease-out;
    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-bg);
        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-result .header,
.state-result .numbers-area {
    display: none;
}

.result-time {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.result-best {
    font-size: 1.5rem;
    color: var(--color-text-light);
    margin-bottom: 1rem;
}

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

/* Hide controls during gameplay */
.state-playing .controls-inline,
.state-result .controls-inline {
    display: none;
}

/* Idle state */
.state-idle .numbers-area {
    display: flex;
    align-items: center;
    justify-content: center;
}

.state-idle .game-container {
    cursor: pointer;
}

/* Home link */
.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;
    z-index: 10;
}

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

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

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

    .instruction {
        font-size: 1rem;
    }

    .timer {
        font-size: 1.5rem;
    }

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

    .result-best {
        font-size: 1.25rem;
    }
}

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