/* Besedle Tracker — Ardian vs Miha
   Wordle tiles are the fixed anchor; the surrounding system stays quiet and
   numeric so the tiles and the head-to-head numbers carry the page. */

:root {
    /* Canonical Wordle tile palette — do not restyle */
    --tile-green:  #6aaa64;
    --tile-yellow: #c9b458;
    --tile-grey:   #787c7e;
    --tile-fail:   #3a3a3c;

    /* Player identity — deliberately outside tile semantics */
    --ardian: #4a8db0;
    --miha:   #c67b4a;

    /* Dark-first surface */
    --bg:        #121213;
    --surface:   #1b1b1d;
    --surface-2: #242426;
    --line:      #35353a;
    --ink:       #e9e9ec;
    --ink-dim:   #a0a0a8;
    --ink-faint: #6f6f78;

    --radius: 10px;
    --gap: 24px;
    --maxw: 1040px;

    --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --num: "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg:        #fbfbf9;
        --surface:   #ffffff;
        --surface-2: #f3f3ee;
        --line:      #dcdcd4;
        --ink:       #1a1a1b;
        --ink-dim:   #575759;
        --ink-faint: #8a8a8f;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    line-height: 1.5;
    font-feature-settings: "tnum" 1, "cv01" 1;
    -webkit-font-smoothing: antialiased;
}

.wrap {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 40px 20px 80px;
}

/* ---- Masthead ---- */
.masthead {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding-bottom: 28px;
    border-bottom: 2px solid var(--line);
}
.wordmark {
    font-size: clamp(28px, 5vw, 44px);
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 0;
}
.wordmark .vs { color: var(--ink-faint); font-weight: 500; }
.a { color: var(--ardian); }
.m { color: var(--miha); }
.masthead .tagline {
    color: var(--ink-dim);
    font-size: 14px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* ---- Section rhythm ---- */
section { margin-top: 56px; }
.section-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin: 0 0 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.section-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}

/* ---- Scoreboard (headline) ---- */
.scoreboard {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: clamp(16px, 5vw, 56px);
    margin-top: 32px;
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.score-side { text-align: center; }
.score-side .name {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    min-height: 1.3em;
}
.score-side.ardian .name { color: var(--ardian); }
.score-side.miha .name { color: var(--miha); }
/* Hero Wordle-tile triptych: leader green, draws yellow, loser grey */
.score-tile {
    width: clamp(92px, 16vw, 140px);
    height: clamp(92px, 16vw, 140px);
    margin: 12px auto 10px;
    display: grid; place-items: center;
    border-radius: 8px;
    font-weight: 800;
    font-size: clamp(44px, 9vw, 72px);
    letter-spacing: -0.03em;
    line-height: 1;
    color: #fff;
    font-variant-numeric: tabular-nums;
}
.score-tile.win  { background: var(--tile-green); }
.score-tile.draw { background: var(--tile-yellow); color: #1a1a1b; }
.score-tile.loss { background: var(--tile-grey); }
.score-side .pts-label { font-size: 12px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.1em; }

/* ---- Player stat cards ---- */
.cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap);
}
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    border-top: 3px solid var(--line);
}
.card.ardian { border-top-color: var(--ardian); }
.card.miha   { border-top-color: var(--miha); }
.card h3 {
    margin: 0 0 18px;
    font-size: 18px;
    letter-spacing: -0.01em;
}
.card.ardian h3 { color: var(--ardian); }
.card.miha h3   { color: var(--miha); }

.statgrid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}
.stat {
    background: var(--surface);
    padding: 12px 14px;
}
.stat .k { font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.07em; }
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.stat .sub { font-size: 12px; color: var(--ink-dim); }
.stat.wide { grid-column: 1 / -1; }

/* Streak records mini-table */
.streaks {
    margin-top: 16px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    font-size: 13px;
}
.streaks .lbl { color: var(--ink-dim); }
.streaks .num { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Form strip */
.form-row { margin-top: 16px; }
.form-row .k { font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 6px; }
.form-strip { display: flex; gap: 4px; flex-wrap: wrap; }
.pip {
    width: 22px; height: 22px;
    border-radius: 5px;
    display: grid; place-items: center;
    font-size: 11px; font-weight: 800; color: #fff;
}
.pip.W { background: var(--tile-green); }
.pip.D { background: var(--tile-yellow); color: #1a1a1b; }
.pip.L { background: var(--tile-grey); }
.form-row .avg { font-size: 12px; color: var(--ink-dim); margin-top: 6px; }

/* ---- Tiles (the anchor) ---- */
.tiles { display: inline-flex; gap: 4px; vertical-align: middle; }
.tile {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    font-weight: 800; font-size: 17px;
    color: #fff; text-transform: uppercase;
    border-radius: 4px;
    user-select: none;
}
.tile.letter { background: var(--tile-green); }                 /* answer = solved solution */
.tile.t-win  { background: var(--tile-green); }                 /* daily winner */
.tile.t-draw { background: var(--tile-yellow); color: #1a1a1b; }/* tie */
.tile.t-loss { background: var(--tile-grey); }                  /* daily loser (incl. fails, shown as ✗) */

/* ---- History ---- */
.history-list { display: flex; flex-direction: column; gap: 2px; }
.hrow {
    display: grid;
    grid-template-columns: 92px 1fr auto;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}
.hrow .date { font-size: 12px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.hrow .players { display: flex; gap: 22px; justify-self: end; align-items: center; }
.result { display: flex; align-items: center; gap: 8px; }
.result .who { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; width: 54px; text-align: right; }
.result.ardian .who { color: var(--ardian); }
.result.miha .who   { color: var(--miha); }
.hrow.hidden-row { display: none; }

.showall {
    margin: 18px auto 0;
    display: block;
    background: var(--surface-2);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 22px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.showall:hover { border-color: var(--ink-faint); }
.history-list.expanded .hrow.hidden-row { display: grid; }

/* ---- Data tables (difficulty / splits / monthly) ---- */
.grid-3 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
}
.panel h3 { margin: 0 0 4px; font-size: 16px; }
.panel .hint { font-size: 12px; color: var(--ink-faint); margin: 0 0 16px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 8px 6px; text-align: right; font-variant-numeric: tabular-nums; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { color: var(--ink-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; border-bottom: 1px solid var(--line); }
table.data tbody tr + tr td { border-top: 1px solid var(--line); }
table.data td.word { font-weight: 700; letter-spacing: 0.02em; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.chip.ardian { background: color-mix(in srgb, var(--ardian) 22%, transparent); color: var(--ardian); }
.chip.miha   { background: color-mix(in srgb, var(--miha) 22%, transparent); color: var(--miha); }
.chip.draw   { background: var(--surface-2); color: var(--ink-dim); }

/* ---- Charts ---- */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.chart-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
}
.chart-card.full { grid-column: 1 / -1; }
.chart-card h3 { margin: 0 0 2px; font-size: 16px; }
.chart-card .hint { margin: 0 0 14px; font-size: 12px; color: var(--ink-faint); }
.chart { width: 100%; height: auto; display: block; }

/* svg primitives */
.c-grid { stroke: var(--line); stroke-width: 1; }
.c-axis { stroke: var(--ink-faint); stroke-width: 1; }
.c-zero { stroke: var(--ink-dim); stroke-width: 1.5; stroke-dasharray: 4 4; }
.c-tick, .c-count, .c-xlabel { fill: var(--ink-faint); font-size: 12px; font-family: var(--font); }
.c-count { font-weight: 700; fill: var(--ink-dim); }
.c-xlabel { font-size: 14px; font-weight: 600; }
.c-xlabel.fail { fill: var(--miha); font-weight: 800; }
.c-note { fill: var(--ink-dim); font-size: 12px; font-family: var(--font); }

.c-line-diff { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; }
.c-fill-ardian { fill: color-mix(in srgb, var(--ardian) 26%, transparent); stroke: none; }
.c-fill-miha   { fill: color-mix(in srgb, var(--miha) 26%, transparent); stroke: none; }

.c-line-ardian { fill: none; stroke: var(--ardian); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.c-line-miha   { fill: none; stroke: var(--miha);   stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }

.c-bar-ardian { fill: var(--ardian); }
.c-bar-miha   { fill: var(--miha); }
.c-bar-ardian.fail-bucket, .c-bar-miha.fail-bucket { stroke: var(--tile-fail); stroke-width: 1; }
.c-seg-draw { fill: var(--tile-yellow); }
.c-seg-label { fill: #fff; font-size: 15px; font-weight: 800; font-family: var(--font); }
.c-seg-label.dark { fill: #1a1a1b; }
.c-out-a { fill: var(--ardian); font-size: 13px; font-weight: 700; font-family: var(--font); }
.c-out-m { fill: var(--miha);   font-size: 13px; font-weight: 700; font-family: var(--font); }
.c-out-d { fill: var(--ink-dim); font-size: 13px; font-weight: 600; font-family: var(--font); }


/* ---- Admin ---- */
.admin-wrap { max-width: 640px; }
.masthead .tagline a { color: var(--ink-dim); text-decoration: none; }
.masthead .tagline a:hover { color: var(--ink); }
.admin-panel {
    margin-top: 28px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
}
.admin-form { display: flex; flex-direction: column; gap: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-k { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); }
.field-k.ardian { color: var(--ardian); }
.field-k.miha { color: var(--miha); }
.admin-form input, .admin-form select {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    color: var(--ink);
    font: inherit;
    font-size: 15px;
}
.admin-form input:focus, .admin-form select:focus {
    outline: none;
    border-color: var(--ardian);
}
.word-input { text-transform: uppercase; letter-spacing: 0.14em; font-weight: 700; }
.admin-hint { font-size: 12px; color: var(--ink-faint); margin: -2px 0 0; }
.btn {
    align-self: flex-start;
    background: var(--tile-green);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.btn:hover { filter: brightness(1.06); }
.form-actions { display: flex; align-items: center; gap: 16px; }
.cancel { color: var(--ink-dim); text-decoration: none; font-size: 14px; }
.cancel:hover { color: var(--ink); }

/* Admin link in the public masthead */
.admin-link { color: var(--ink-dim); text-decoration: none; border-bottom: 1px dotted var(--ink-faint); }
.admin-link:hover { color: var(--ink); }

/* Manage table */
.manage-scroll { max-height: 460px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.manage-scroll table.data { margin: 0; }
.manage-scroll thead th { position: sticky; top: 0; background: var(--surface); padding: 12px 10px; }
.manage.data td, .manage.data th { padding: 10px; }
.manage.data td.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
tr.editing { background: color-mix(in srgb, var(--ardian) 12%, transparent); }
.mini {
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 11px;
    border-radius: 6px;
    text-decoration: none;
    border: 1px solid var(--line);
    color: var(--ink-dim);
    background: var(--surface-2);
    cursor: pointer;
}
.mini:hover { color: var(--ink); border-color: var(--ink-faint); }
.mini.danger { color: #e07a6f; background: transparent; }
.mini.danger:hover { border-color: #e07a6f; }
.alert { padding: 12px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 18px; }
.alert.ok { background: color-mix(in srgb, var(--tile-green) 20%, transparent); color: var(--tile-green); }
.alert.error { background: color-mix(in srgb, #c0392b 22%, transparent); color: #e07a6f; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

footer { margin-top: 72px; padding-top: 24px; border-top: 1px solid var(--line); color: var(--ink-faint); font-size: 12px; text-align: center; }
footer a { color: var(--ink-dim); }

/* Wide tables scroll within their own box instead of overflowing the page. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* Guard against any element forcing a sideways scroll of the whole page. */
html, body { overflow-x: hidden; }

/* ---- Responsive (mobile only) ---- */
@media (max-width: 720px) {
    /* every chart on its own full-width line, bigger */
    .cards, .grid-3, .charts { grid-template-columns: 1fr; }
    .chart-card { padding: 16px; }
    .scoreboard { grid-template-columns: 1fr auto 1fr; padding: 18px 10px; gap: 8px; }
    .score-side .name { font-size: 13px; }
    .score-tile {
        width: clamp(64px, 21vw, 110px);
        height: clamp(64px, 21vw, 110px);
        font-size: clamp(30px, 10vw, 56px);
    }
    .score-side .pts-label { font-size: 10px; letter-spacing: 0.06em; }

    /* history: word on the left, both results stacked on the right (Miha top, Ardian bottom) */
    .hrow {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "date   date"
            "answer players";
        gap: 10px 14px;
        align-items: center;
    }
    .hrow .date { grid-area: date; }
    .hrow .answer { grid-area: answer; }
    .hrow .players {
        grid-area: players;
        flex-direction: column;
        align-items: flex-end;
        gap: 8px;
        justify-self: end;
    }

    /* keep table headers/cells on one line so they scroll rather than wrap */
    .table-scroll table.data th, .table-scroll table.data td { white-space: nowrap; }

    .tile { width: 30px; height: 30px; font-size: 15px; }
}

/* Accessibility floor */
a:focus-visible, button:focus-visible {
    outline: 2px solid var(--ardian);
    outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
