﻿:root {
    --bg: #f5f3ee;
    --surface: #ffffff;
    --ink: #1f2430;
    --muted: #6b7280;
    --accent: #2f6fed;
    --accent-ink: #ffffff;
    --tile: #fbf3dc;
    --tile-edge: #d9c89a;
    --good: #1a7f4b;
    --bad: #b3261e;
    --border: #e2ded3;
    --invalid-bg: #f9c5c5;
    --invalid-edge: #e08a8a;
    --new-bg: #62c684;
    --new-edge: #449e63;
    --found-bg: #bcd9f7;
    --found-edge: #7aaee6;
    --tint-ink: #1f2430;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14161b;
        --surface: #1d2027;
        --ink: #eceef2;
        --muted: #9aa3b2;
        --accent: #6c9bff;
        --accent-ink: #0d1117;
        --tile: #3a3524;
        --tile-edge: #5b5233;
        --good: #5cd18f;
        --bad: #ff8a80;
        --border: #2d313b;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.4;
}

h1, h2 { margin: 0.4em 0; }
h1:focus { outline: none; }
a { color: var(--accent); }
.muted { color: var(--muted); }

.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding: 0.75rem 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar nav { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

.page { max-width: 560px; margin: 0 auto; padding: 16px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    margin: 16px 0;
}
.card.narrow { margin-top: 10vh; }

.key-input {
    width: 100%;
    font: inherit;
    padding: 0.7rem;
    margin: 0.5rem 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--ink);
}
.btn {
    font: inherit;
    padding: 0.7rem 1.4rem;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-ink);
    cursor: pointer;
}
.btn:disabled { opacity: 0.5; cursor: default; }

.error { color: var(--bad); }
.notice { background: var(--surface); border: 1px solid var(--accent); border-radius: 8px; padding: 0.6rem 0.9rem; }

.status { display: flex; justify-content: space-between; gap: 8px; }
.status div { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; text-align: center; }
.status .label { display: block; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.status strong { font-size: 1.2rem; }

.board-wrap { margin-top: 16px; }
.live-word {
    min-height: 2.2rem;
    text-align: center;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}
.board {
    position: relative;
    display: grid;
    grid-template-columns: repeat(var(--size, 5), 1fr);
    gap: 6px;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    aspect-ratio: 1;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
.tile {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tile);
    border: 2px solid var(--tile-edge);
    border-radius: 14px;
    font-size: clamp(1.3rem, 7.5vw, 2.3rem);
    font-weight: 700;
    text-transform: uppercase;
    transition: background 0.08s, transform 0.08s;
}
.tile.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tile.head { transform: scale(1.06); }
.board-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.board-lines polyline {
    fill: none;
    stroke: var(--ink);
    stroke-opacity: 0.55;
    stroke-width: 12;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.feedback { min-height: 1.6rem; text-align: center; font-weight: 600; margin: 12px 0 0; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }

.words { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 16px; }
.words li { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--border); padding: 2px 0; }
.pts { color: var(--muted); font-variant-numeric: tabular-nums; }

.day-list { list-style: none; padding: 0; }
.day-list li { padding: 0.6rem 0; border-bottom: 1px solid var(--border); }

.standings { padding-left: 1.4rem; margin: 0; }
.standings li { padding: 4px 0; }
.standings li .name { font-weight: 600; margin-right: 0.6rem; }
.standings li strong { float: right; }

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    padding: 0.6rem 1.25rem;
    background: #ffffe0;
    color: #222;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* Play page: board on the left, found words on the right (stacked on narrow screens). */
.page:has(.play-layout) { max-width: 1160px; }
.play-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 24px; align-items: start; }
.play-words { margin-top: 16px; }
.play-words .words { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 4px 12px; max-height: 70vh; overflow-y: auto; }
@media (min-width: 820px) {
    .play-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
}

/* Live word shading while tracing: light red = invalid, light green = new word, light blue = already found. */
.live-word { border-radius: 10px; transition: background 0.1s; }
.board-wrap[data-state="invalid"] .live-word,
.board-wrap[data-state="invalid"] .tile.active { background: var(--invalid-bg); color: var(--tint-ink); border-color: var(--invalid-edge); }
.board-wrap[data-state="found"] .live-word,
.board-wrap[data-state="found"] .tile.active { background: var(--found-bg); color: var(--tint-ink); border-color: var(--found-edge); }
.board-wrap[data-state="new"] .live-word,
.board-wrap[data-state="new"] .tile.active { background: var(--new-bg); color: var(--tint-ink); border-color: var(--new-edge); }

/* Latest found words, shown beside the "Your words" heading. */
.words-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.recent { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; font-size: 0.85rem; }
.chip { background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; }
