/*
 * Tiles - Collaborative Painting Board
 * Stario light theme with warm yellows
 */

:root {
    --bg: #fafaf9;
    --fg: #1c1917;
    --surface: #ffffff;
    --surface-hover: #fef3c7;
    --border: #e7e5e4;
    --border-strong: #d6d3d1;
    --accent: #f59e0b;
    --accent-light: #fbbf24;
    --accent-glow: rgba(245, 158, 11, 0.25);
    --accent-soft: #fef3c7;
    --muted: #78716c;
    --radius: 10px;
    --cell-size: clamp(36px, 6vw, 48px);
    --gap: 4px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    background: var(--bg);
    color: var(--fg);
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 1rem;
    
    /* Dotted pattern background like Stario */
    background-image: radial-gradient(circle, #d6d3d1 1px, transparent 1px);
    background-size: 24px 24px;
}

.container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

h1 {
    font-size: clamp(1.5rem, 5vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 50%, #fcd34d 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
}

.subtitle {
    color: var(--muted);
    font-size: 0.875rem;
    text-align: center;
    max-width: 400px;
    line-height: 1.5;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Color swatch (player indicator) */
.swatch {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    vertical-align: middle;
}

.users-list .swatch {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Info Panel (combined stats + players) */
.info-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    min-width: 240px;
}

.info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.info-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.info-stats {
    font-size: 0.9rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.info-stats .count {
    color: var(--accent);
    font-weight: 700;
    font-size: 1.1rem;
}

/* Game Board */
.board {
    background: var(--surface);
    border: 4px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    padding: calc(var(--gap) * 2);
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    
    box-shadow: 
        0 1px 3px rgba(0, 0, 0, 0.05),
        0 4px 24px rgba(0, 0, 0, 0.08),
        0 0 0 1px var(--border);
    
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Celebration effect when all cells are filled */
.board.complete {
    border-color: transparent;
    background: 
        linear-gradient(var(--surface), var(--surface)) padding-box,
        linear-gradient(90deg, #ef4444, #f97316, #eab308, #22c55e, #3b82f6, #8b5cf6, #ec4899, #ef4444) border-box;
    background-size: 100% 100%, 200% 100%;
    animation: rainbow 2s linear infinite;
}

.row {
    display: flex;
    gap: var(--gap);
}

/* Individual Cells */
.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    
    display: flex;
    align-items: center;
    justify-content: center;
    
    user-select: none;
    
    transition: 
        background-color 0.15s ease,
        border-color 0.15s ease,
        transform 0.1s ease,
        box-shadow 0.15s ease;
}

.cell:hover {
    background: var(--accent-soft);
    border-color: var(--accent-light);
    transform: scale(1.05);
    box-shadow: 0 0 12px var(--accent-glow);
}

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

/* Painted State - color applied via inline style */
.cell.painted {
    border-color: rgba(0, 0, 0, 0.15);
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.1),
        inset 0 1px 2px rgba(255, 255, 255, 0.3);
    animation: pop 0.2s ease-out;
}

.cell.painted:hover {
    transform: scale(1.05);
    filter: brightness(1.05);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.12),
        inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

/* Users List (inside info panel) */
.users-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    justify-content: flex-end;
}

.users-list .swatch {
    width: 20px;
    height: 20px;
    border-radius: 5px;
}

.users-list li {
    animation: slideIn 0.2s ease-out;
}

.empty {
    color: var(--muted);
    font-size: 0.75rem;
    font-style: italic;
}

/* Error Page */
.error h1 {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.error p {
    color: var(--muted);
    margin-top: 0.5rem;
}

.back-link a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease;
}

.back-link a:hover {
    color: #d97706;
    text-decoration: underline;
}

/* Animations */
@keyframes pop {
    0% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes rainbow {
    to { background-position: 100% 100%, -200% 0; }
}

/* Install Button */
#install-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}

#install-btn:hover {
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

#install-btn:active {
    transform: translateX(-50%) scale(0.98);
}

/* Responsive */
@media (max-width: 640px) {
    .info-panel {
        min-width: unset;
        width: 100%;
        max-width: 400px;
    }
    
    .info-row {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

@media (max-width: 400px) {
    body {
        padding: 1rem 0.5rem;
    }
    
    .board {
        padding: var(--gap);
    }
    
    .info-panel {
        padding: 0.5rem 0.75rem;
    }
}
