/* Color IQ Game Styles */

:root {
    --color-bg: #1a1a2e;
    --color-surface: #16213e;
    --color-text: #eee;
    --color-text-muted: rgba(255, 255, 255, 0.6);
    --color-accent: #FFD93D;
    --color-success: #4CAF50;
    --color-error: #FF6B6B;
    --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;
    user-select: none;
    -webkit-user-select: none;
}

.content {
    text-align: center;
    padding: 1rem;
    max-width: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--color-accent);
}

.subtitle {
    font-size: 1rem;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

.controls-inline {
    margin-bottom: 1rem;
}

.stats {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    min-height: 1.5rem;
}

.level {
    color: var(--color-accent);
    font-weight: 600;
}

.lives {
    letter-spacing: 0.1em;
}

/* Grid container */
.grid {
    display: grid;
    gap: 4px;
    padding: 4px;
    background: var(--color-surface);
    border-radius: 8px;
    width: min(90vw, 400px);
    height: min(90vw, 400px);
    margin: 0 auto;
}

/* Individual tiles */
.tile {
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.1s ease, opacity 0.2s ease;
    aspect-ratio: 1;
    width: 100%;
    height: 100%;
}

.tile:active {
    transform: scale(0.95);
}

.tile.correct {
    animation: correct-pulse 0.4s ease-out;
}

.tile.wrong {
    animation: wrong-shake 0.4s ease-out;
}

@keyframes correct-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

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

/* Result text */
.result-text {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 1rem 0 0.5rem;
    min-height: 2rem;
}

.result-text.success {
    color: var(--color-success);
}

.result-text.error {
    color: var(--color-error);
}

.best-score {
    font-size: 1rem;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
    min-height: 1.5rem;
}

.hint {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-top: 0.75rem;
    min-height: 1.25rem;
}

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

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

/* State: Idle (start screen) */
.state-idle .grid {
    display: none;
}

.state-idle .stats {
    display: none;
}

.state-idle .subtitle {
    display: block;
}

/* State: Playing */
.state-playing .controls-inline {
    display: none;
}

.state-playing .subtitle {
    display: none;
}

.state-playing .result-text,
.state-playing .best-score,
.state-playing .hint {
    display: none;
}

/* State: Result */
.state-result .controls-inline {
    display: none;
}

.state-result .subtitle {
    display: none;
}

.state-result .stats {
    display: none;
}

.state-result .grid {
    display: none;
}

.state-result.new-best .result-text {
    animation: new-best-pop 0.5s ease-out;
}

@keyframes new-best-pop {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

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

    .grid {
        gap: 3px;
        padding: 3px;
    }

    .tile {
        border-radius: 3px;
    }

    .stats {
        gap: 1.5rem;
        font-size: 1rem;
    }
}

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

/* Context menu prevention */
.game-container {
    -webkit-touch-callout: none;
}
