/* Tempo Keeper Game Styles */

:root {
    --color-idle: #FFD93D;
    --color-demo: #6C5CE7;
    --color-transition: #00CEC9;
    --color-playing: #2D3436;
    --color-result: #FFD93D;
    --color-perfect: #00B894;
    --color-early: #FDCB6E;
    --color-late: #FDCB6E;
    --color-miss: #FF7675;
    --color-text: #2D3436;
    --color-text-light: rgba(0, 0, 0, 0.5);
    --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.3s ease;
    user-select: none;
    -webkit-user-select: none;
}

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

.title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
    transition: transform 0.3s ease, color 0.3s ease;
}

/* Beat indicator container */
.beat-container {
    position: relative;
    width: 160px;
    height: 160px;
    margin: 2rem auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Beat indicator circle */
.beat-indicator {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    border: 4px solid rgba(255, 255, 255, 0.4);
    transition: transform 0.1s ease, background 0.1s ease, border-color 0.1s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.beat-indicator.pulse {
    animation: beat-pulse 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes beat-pulse {
    0% {
        transform: scale(1.2);
        background: rgba(255, 255, 255, 0.9);
        border-color: rgba(255, 255, 255, 0.9);
        box-shadow: 0 0 40px rgba(255, 255, 255, 0.6);
    }
    100% {
        transform: scale(1);
        background: rgba(255, 255, 255, 0.25);
        border-color: rgba(255, 255, 255, 0.4);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    }
}

/* Beat count number */
.beat-count {
    position: absolute;
    font-size: 3.5rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
}

.beat-count.pop {
    animation: count-pop 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

.instruction {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    opacity: 0.8;
    font-weight: 500;
}

.feedback {
    font-size: 2.5rem;
    font-weight: 800;
    min-height: 3rem;
    margin: 0.5rem 0;
    transition: color 0.1s ease;
    letter-spacing: -0.02em;
}

.feedback-perfect {
    color: var(--color-perfect);
    text-shadow: 0 0 20px rgba(0, 184, 148, 0.5);
}

.feedback-early,
.feedback-late {
    color: var(--color-early);
}

.feedback-miss {
    color: var(--color-miss);
    animation: shake 0.3s ease;
}

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

.score {
    font-size: 3.5rem;
    font-weight: 800;
    margin: 1rem 0;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.best-score {
    font-size: 1.1rem;
    color: var(--color-text-light);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

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

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

.home-link {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.6rem 1.2rem;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 25px;
    transition: background 0.2s, transform 0.2s;
    z-index: 10;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

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

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

/* ============ STATE: IDLE ============ */
.state-idle {
    background: linear-gradient(135deg, #FFD93D 0%, #FFE066 100%);
}

.state-idle .title {
    color: var(--color-text);
}

/* ============ STATE: DEMO ============ */
.state-demo {
    background: linear-gradient(135deg, #6C5CE7 0%, #A29BFE 100%);
}

.state-demo .title,
.state-demo .instruction {
    color: white;
}

.state-demo .beat-indicator {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.state-demo .beat-indicator.pulse {
    animation: demo-pulse 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes demo-pulse {
    0% {
        transform: scale(1.25);
        background: rgba(255, 255, 255, 0.95);
        border-color: white;
        box-shadow: 0 0 60px rgba(255, 255, 255, 0.7);
    }
    100% {
        transform: scale(1);
        background: rgba(255, 255, 255, 0.15);
        border-color: rgba(255, 255, 255, 0.3);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    }
}

.state-demo .home-link {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

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

/* ============ STATE: TRANSITION ============ */
.state-transition {
    background: linear-gradient(135deg, #00CEC9 0%, #81ECEC 100%);
    animation: transition-flash 0.6s ease;
}

@keyframes transition-flash {
    0% {
        background: linear-gradient(135deg, #6C5CE7 0%, #A29BFE 100%);
    }
    100% {
        background: linear-gradient(135deg, #00CEC9 0%, #81ECEC 100%);
    }
}

.state-transition .title {
    color: white;
    font-size: 3rem;
    animation: title-bounce 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes title-bounce {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    60% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.state-transition .beat-indicator {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    animation: indicator-ready 0.6s ease infinite;
}

@keyframes indicator-ready {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 40px rgba(255, 255, 255, 0.5);
    }
}

.state-transition .home-link {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* ============ STATE: PLAYING ============ */
.state-playing {
    background: linear-gradient(135deg, #2D3436 0%, #636E72 100%);
}

.state-playing .title,
.state-playing .instruction,
.state-playing .score {
    color: white;
}

.state-playing .beat-indicator {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.state-playing .beat-indicator.pulse {
    animation: play-pulse 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes play-pulse {
    0% {
        transform: scale(1.3);
        background: rgba(255, 255, 255, 0.9);
        border-color: white;
        box-shadow: 0 0 80px rgba(255, 255, 255, 0.6);
    }
    100% {
        transform: scale(1);
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.2);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    }
}

.state-playing .home-link {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

.state-playing .home-link:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============ STATE: RESULT ============ */
.state-result {
    background: linear-gradient(135deg, #FFD93D 0%, #FFE066 100%);
}

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

.state-result.new-best .score {
    animation: score-pop 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    color: #E17055;
}

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

@keyframes celebrate {
    0% {
        background: linear-gradient(135deg, #FFEAA7 0%, #FFF3B0 100%);
        box-shadow: inset 0 0 100px rgba(255, 215, 0, 0.5);
    }
    50% {
        background: linear-gradient(135deg, #FFF5CC 0%, #FFFDE7 100%);
        box-shadow: inset 0 0 150px rgba(255, 215, 0, 0.3);
    }
    100% {
        background: linear-gradient(135deg, #FFD93D 0%, #FFE066 100%);
        box-shadow: none;
    }
}

@keyframes score-pop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    60% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

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

    .beat-container {
        width: 140px;
        height: 140px;
        margin: 1.5rem auto;
    }

    .beat-indicator {
        width: 100px;
        height: 100px;
    }

    .beat-count {
        font-size: 2.5rem;
    }

    .instruction {
        font-size: 1.1rem;
    }

    .feedback {
        font-size: 2rem;
    }

    .score {
        font-size: 2.5rem;
    }

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

@media (max-height: 500px) {
    .content {
        padding: 1rem;
    }

    .beat-container {
        width: 100px;
        height: 100px;
        margin: 1rem auto;
    }

    .beat-indicator {
        width: 80px;
        height: 80px;
    }

    .beat-count {
        font-size: 2rem;
    }

    .title {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }
}

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