/* =============================================================
   Bingo — dark mode stylesheet
   Base palette is shared; only --accent* vars change per variant
   (injected at mount by inject_theme() in theme.rs).
   ============================================================= */

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Design tokens ──────────────────────────────────────────── */
:root {
    --bg-app:             #0f0f0f;
    --bg-board:           #181818;
    --bg-cell:            #242424;
    --bg-cell-hover:      #2c2c2c;
    --text-primary:       #f0f0f0;
    --text-muted:         #555555;
    --border-cell:        #333333;
    --radius:             6px;

    /* Accent tokens — overwritten at mount by inject_theme().
       Fallback values ensure the board is usable before WASM loads. */
    --accent:             #888888;
    --accent-subtle:      #88888833;
    --accent-glow:        #88888899;
}

/* ── Base ───────────────────────────────────────────────────── */
html, body {
    height: 100%;
    background: var(--bg-app);
    color: var(--text-primary);
    font-family: system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ── Layout ─────────────────────────────────────────────────── */
#container {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 1.5rem 1rem;
    gap: 1rem;
}

/* ── Header ─────────────────────────────────────────────────── */
#header {
    font-size: clamp(1.1rem, 4vw, 1.7rem);
    font-weight: 700;
    letter-spacing: 0.03em;
    text-align: center;
    color: var(--text-primary);
    border-bottom: 2px solid var(--accent);
    padding-bottom: 0.5rem;
    width: 100%;
    max-width: 600px;
    transition: color 0.3s ease, border-color 0.3s ease;
}

#header.win {
    color: var(--accent);
    border-color: var(--accent);
    text-shadow: 0 0 24px var(--accent-glow);
    animation: pulse 1.2s ease-in-out infinite alternate;
}

@keyframes pulse {
    from { text-shadow: 0 0 10px var(--accent-glow); }
    to   { text-shadow: 0 0 32px var(--accent-glow); }
}

/* ── Board grid ─────────────────────────────────────────────── */
#board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    width: 100%;
    max-width: 600px;
    background: var(--bg-board);
    border-radius: calc(var(--radius) + 4px);
    padding: 4px;
}

/* ── Cells ──────────────────────────────────────────────────── */
.square {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-cell);
    border: 1px solid var(--border-cell);
    border-radius: var(--radius);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
    min-height: 48px; /* minimum touch target */
}

.square:hover {
    background: var(--bg-cell-hover);
}

.square:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.square.selected {
    background: var(--accent-subtle);
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.square.freesquare {
    background: var(--accent-subtle);
    border-color: var(--accent);
    opacity: 0.5;
    cursor: default;
}

.square.freesquare:hover {
    background: var(--accent-subtle);
}

/* ── Cell text ──────────────────────────────────────────────── */
.text {
    font-size: clamp(0.55rem, 1.6vw, 0.8rem);
    line-height: 1.25;
    text-align: center;
    padding: 4px;
    pointer-events: none;
    word-break: break-word;
    hyphens: auto;
}

/* ── Footer ─────────────────────────────────────────────────── */
#footer {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    padding-bottom: 1rem;
}

#footer a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s ease;
}

#footer a:hover {
    color: var(--accent);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 400px) {
    #container {
        padding: 1rem 0.5rem;
    }

    #board {
        gap: 3px;
        padding: 3px;
    }
}
