/* Inverse Game Styles */

:root {
    --color-bg: #1a1a2e;
    --color-primary: #FFD93D;
    --color-correct: #4CAF50;
    --color-wrong: #e74c3c;
    --color-text: #fff;
    --color-text-dim: rgba(255, 255, 255, 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;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

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

.title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--color-primary);
}

.tagline {
    font-size: 1.25rem;
    color: var(--color-text-dim);
    margin-bottom: 1.5rem;
}

/* Controls */
.controls-inline {
    margin-bottom: 2rem;
}

.state-playing .controls-inline,
.state-result .controls-inline {
    display: none;
}

.state-playing .tagline,
.state-result .tagline {
    display: none;
}

/* Lives Display */
.lives-display {
    display: none;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.state-playing .lives-display {
    display: flex;
}

.heart {
    width: 24px;
    height: 24px;
    background: var(--color-wrong);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3C/svg%3E") center / contain no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3C/svg%3E") center / contain no-repeat;
    transition: opacity 0.3s, transform 0.3s;
}

.heart.lost {
    opacity: 0.2;
    transform: scale(0.8);
}

/* Instruction Display */
.instruction-display {
    display: none;
    min-height: 60px;
    margin-bottom: 1rem;
}

.state-playing .instruction-display {
    display: block;
}

.instruction-text {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--color-primary);
    animation: pulse-instruction 0.3s ease-out;
}

@keyframes pulse-instruction {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Timer Bar */
.timer-bar {
    display: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.state-playing .timer-bar {
    display: block;
}

.timer-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 3px;
    width: 100%;
}

/* Challenge Area */
.challenge-area {
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.state-idle .challenge-area,
.state-result .challenge-area {
    display: none;
}

/* Color Options */
.color-options {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
}

.color-btn {
    width: 100px;
    height: 100px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

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

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

/* Position Options */
.position-options {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 200px;
}

.position-btn {
    padding: 1.25rem 2rem;
    font-size: 1.25rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.15);
    color: var(--color-text);
    transition: transform 0.15s, background 0.15s;
}

.position-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

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

/* Direction Challenge */
.direction-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* Arrow Keys (desktop only) */
.arrow-keys {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.arrow-row {
    display: flex;
    gap: 0.25rem;
}

.arrow-key {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    font-size: 1.5rem;
    color: var(--color-text);
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.arrow-key:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.arrow-key:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.3);
}

/* Swipe Hint (mobile only) */
.swipe-hint {
    font-size: 1rem;
    color: var(--color-text-dim);
    display: none;
}

/* Show arrow keys on desktop, swipe hint on mobile */
@media (hover: hover) and (pointer: fine) {
    .arrow-keys {
        display: flex;
    }
    .swipe-hint {
        display: none;
    }
}

@media (hover: none) or (pointer: coarse) {
    .arrow-keys {
        display: none;
    }
    .swipe-hint {
        display: block;
    }
}

/* Feedback */
.feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: 700;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.feedback.correct {
    color: var(--color-correct);
    opacity: 1;
    animation: pop-correct 0.4s ease-out;
}

.feedback.wrong {
    color: var(--color-wrong);
    opacity: 1;
    animation: shake 0.4s ease-out;
}

@keyframes pop-correct {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

@keyframes shake {
    0%, 100% { transform: translate(-50%, -50%); }
    20% { transform: translate(-60%, -50%); }
    40% { transform: translate(-40%, -50%); }
    60% { transform: translate(-55%, -50%); }
    80% { transform: translate(-45%, -50%); }
}

/* Score Display */
.score-display {
    display: none;
    position: fixed;
    top: 2rem;
    right: 2rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-primary);
}

.state-playing .score-display {
    display: block;
}

.current-score {
    display: inline-block;
    min-width: 2ch;
}

/* Result */
.result {
    display: none;
}

.state-result .result {
    display: block;
}

.final-score {
    font-size: 3rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

.best-score {
    font-size: 1.25rem;
    color: var(--color-text-dim);
    margin-bottom: 1.5rem;
}

/* 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.1);
    border-radius: 20px;
    transition: background 0.2s;
}

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

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

/* Hide title during gameplay */
.state-playing .title {
    display: none;
}

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

    .tagline {
        font-size: 1rem;
    }

    .instruction-text {
        font-size: 1.5rem;
    }

    .color-btn {
        width: 80px;
        height: 80px;
    }

    .color-options {
        gap: 1rem;
    }

    .position-btn {
        padding: 1rem 1.5rem;
        font-size: 1rem;
    }

    .score-display {
        top: 1rem;
        right: 1rem;
        font-size: 1.25rem;
    }

    .final-score {
        font-size: 2.5rem;
    }
}

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