/* ===== BASE STYLES ===== */

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

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-main, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    background: var(--color-bg-secondary, #1a1a2e);
    color: var(--color-text, #fff);
    overflow: hidden;
}

.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: 20px;
    max-width: 400px;
    width: 100%;
}

/* ===== HEADER ===== */

.title {
    font-size: 2.5rem;
    margin: 0 0 5px;
    color: var(--color-primary, #FFD93D);
}

.tagline {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 20px;
}

.controls-inline {
    margin-bottom: 20px;
}

.control-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
}

.control-pill .touch::before {
    content: '👆';
}

/* ===== STATS ===== */
.stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.level-value, .moves-value {
    color: var(--color-primary, #FFD93D);
    font-weight: 700;
}

/* ===== GAME GRID ===== */
.grid-container {
    display: flex;
    justify-content: center;
    margin: 15px auto;
}

.grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    width: min(85vw, 320px);
    aspect-ratio: 1;
}

.tile {
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.1s, background 0.15s, box-shadow 0.15s;
    aspect-ratio: 1;
    border: none;
    padding: 0;
}

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

/* Tile on state - lit up with glow */
.tile.on {
    background: var(--color-primary, #FFD93D);
    box-shadow: 0 0 15px rgba(255, 217, 61, 0.5);
}

/* Tile off state - dark background */
.tile.off {
    background: var(--color-border-light, #2a2a4a);
}

.tile.toggling {
    animation: toggle-pulse 0.2s ease-out;
}

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

/* ===== HINT TEXT ===== */
.hint-text {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
    margin: 15px 0 0;
}

/* ===== RESULT SCREEN ===== */
.result {
    display: none;
}

.result-text {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0 0 10px;
    color: var(--color-success, #4CAF50);
}

.best-score {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 15px;
}

.share-container {
    margin: 15px 0;
}

.continue-hint {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
    margin: 15px 0 0;
}

/* ===== NAVIGATION ===== */
.home-link {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 10px 20px;
    z-index: 100;
}

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

/* ===== STATE MANAGEMENT ===== */
.state-idle .stats,
.state-idle .grid-container,
.state-idle .hint-text,
.state-idle .result {
    display: none;
}

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

.state-playing .grid-container {
    display: flex;
}

.state-solved .controls-inline,
.state-solved .tagline,
.state-solved .hint-text {
    display: none;
}

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

.state-solved .grid-container {
    display: flex;
    opacity: 0.5;
    pointer-events: none;
}

/* ===== ANIMATIONS ===== */
.state-solved .result-text {
    animation: celebrate 0.5s ease-out;
}

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