:root {
    --bg: #f6f5f2;
    --surface: #ffffff;
    --text: #1f2328;
    --muted: #656d76;
    --border: #d8dee4;
    --accent: #1f6feb;
    --accent-text: #ffffff;
    --ok-bg: #e6f4ea;
    --ok-text: #1a7f37;
    --error-bg: #fdecea;
    --error-text: #c62828;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1117;
        --surface: #161b22;
        --text: #e6edf3;
        --muted: #8d96a0;
        --border: #30363d;
        --accent: #4493f8;
        --accent-text: #0d1117;
        --ok-bg: #12261e;
        --ok-text: #56d364;
        --error-bg: #2d1416;
        --error-text: #f85149;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

main {
    max-width: 52rem;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

h1 {
    font-size: 1.6rem;
    margin: 0 0 0.25rem;
}

h2 {
    font-size: 1.1rem;
    margin: 0 0 0.75rem;
}

a {
    color: var(--accent);
}

.muted {
    color: var(--muted);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 0.4rem 0.5rem 0.4rem 0;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

th {
    font-weight: 600;
    color: var(--muted);
    font-size: 0.85rem;
}

tr:last-child td {
    border-bottom: none;
}

.num {
    text-align: right;
    white-space: nowrap;
}

.table-wrap {
    overflow-x: auto;
}

form.inline {
    display: inline;
}

.row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: end;
}

label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

input, select, textarea, button {
    font: inherit;
    color: var(--text);
}

input[type=date], select, textarea, input[type=file] {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.5rem;
    max-width: 100%;
}

textarea {
    width: 100%;
    min-height: 8rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9rem;
}

button {
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: 6px;
    padding: 0.45rem 0.9rem;
    cursor: pointer;
    font-weight: 600;
}

button.link {
    background: none;
    color: var(--error-text);
    padding: 0;
    font-weight: normal;
}

.tag {
    display: inline-block;
    font-size: 0.8rem;
    padding: 0 0.45rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--muted);
}

.tag.ok {
    border-color: transparent;
    background: var(--ok-bg);
    color: var(--ok-text);
}

.message {
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin: 0.5rem 0;
}

.message.ok {
    background: var(--ok-bg);
    color: var(--ok-text);
}

.message.error {
    background: var(--error-bg);
    color: var(--error-text);
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9em;
}

/* Analysis page */

:root {
    --safe: #1a7f37;
    --safe-text: #ffffff;
    --balanced: #0969da;
    --balanced-text: #ffffff;
    --value: #9a6700;
    --value-text: #ffffff;
    --played: #8250df;
    --played-text: #ffffff;
    --result: #ffffff;
    --result-text: #1f2328;
    --tip-bg: #ddf4ff;
    --tip-text: #0550ae;
    --good: #1a7f37;
    --bad: #b35900;
    --note-bg: #fff8c5;
    --note-text: #4d3800;
}

@media (prefers-color-scheme: dark) {
    :root {
        --safe: #3fb950;
        --safe-text: #0d1117;
        --balanced: #58a6ff;
        --balanced-text: #0d1117;
        --value: #d29922;
        --value-text: #0d1117;
        --played: #a371f7;
        --played-text: #0d1117;
        --result: #ffffff;
        --result-text: #0d1117;
        --tip-bg: #12253a;
        --tip-text: #79c0ff;
        --good: #56d364;
        --bad: #f0883e;
        --note-bg: #2e2a12;
        --note-text: #e3b341;
    }
}

main.wide {
    max-width: 64rem;
}

.small {
    font-size: 0.85rem;
}

form.card {
    margin-top: 0.5rem;
}

form.row p {
    margin: 0;
    align-self: center;
}

input[type=text] {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.5rem;
}

.legend {
    display: inline-block;
    font-weight: 600;
    padding: 0 0.5rem;
    border-radius: 999px;
    font-size: 0.85rem;
}

.legend.s0 {
    background: var(--safe);
    color: var(--safe-text);
}

.legend.s1 {
    background: var(--balanced);
    color: var(--balanced-text);
}

.legend.s2 {
    background: var(--value);
    color: var(--value-text);
}

.legend.played {
    background: var(--played);
    color: var(--played-text);
}

.legend.actual {
    background: var(--result);
    color: var(--result-text);
    box-shadow: inset 0 0 0 1px var(--border);
}

.signs {
    display: inline-flex;
    gap: 3px;
    margin-right: 0.4rem;
}

.sign {
    display: inline-block;
    width: 1.6rem;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--muted);
}

.sign.off {
    visibility: hidden;
}

.sign.on.s0 {
    background: var(--safe);
    border-color: var(--safe);
    color: var(--safe-text);
}

.sign.on.s1 {
    background: var(--balanced);
    border-color: var(--balanced);
    color: var(--balanced-text);
}

.sign.on.s2 {
    background: var(--value);
    border-color: var(--value);
    color: var(--value-text);
}

.sign.on.played {
    background: var(--played);
    border-color: var(--played);
    color: var(--played-text);
}

td.pick {
    white-space: nowrap;
    min-width: 9rem;
}

a.match-link,
a.match-link:visited {
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
}

a.match-link:hover {
    color: var(--text);
}

table.systems td:first-child,
table.stats td:first-child {
    color: var(--muted);
    white-space: nowrap;
}

table.stats {
    width: auto;
    min-width: 18rem;
}

table.stats th.num,
table.stats td.num {
    padding-left: 1rem;
}

table.stats tr.strong td {
    font-weight: 700;
}

table.stats tr.pick-row td {
    border-bottom: none;
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
}

td.good {
    color: var(--good);
    font-weight: 700;
}

td.bad {
    color: var(--bad);
}

.match h2 {
    margin-bottom: 0;
}

.match-body {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2rem;
    align-items: flex-start;
}

.match-body > .table-wrap {
    flex: 0 1 auto;
    max-width: 100%;
}

dl.facts {
    flex: 1 1 18rem;
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.3rem 0.75rem;
    margin: 0;
}

dl.facts dt {
    color: var(--muted);
}

dl.facts dd {
    margin: 0;
}

dl.match-facts {
    flex: 1 1 24rem;
    font-size: 0.95rem;
    gap: 0.4rem 0.9rem;
}

dl.facts .highlight {
    background: var(--tip-bg);
    padding: 0.3rem 0.5rem;
}

dl.facts dt.highlight {
    color: var(--tip-text);
    font-weight: 600;
    border-radius: 6px 0 0 6px;
}

dl.facts dd.highlight {
    border-radius: 0 6px 6px 0;
}

.tip {
    display: inline-block;
    margin-right: 0.75rem;
    white-space: nowrap;
}

.form {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-right: 0.4rem;
}

.result {
    display: inline-block;
    width: 1.2rem;
    text-align: center;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #ffffff;
    background: var(--muted);
}

.result.W {
    background: #2da44e;
}

.result.L {
    background: #cf222e;
}

.result.latest {
    outline: 2px solid var(--text);
    outline-offset: 1px;
}

.latest-label {
    margin-left: 0.3rem;
    font-size: 0.75rem;
    color: var(--muted);
    white-space: nowrap;
}

.note {
    background: var(--note-bg);
    color: var(--note-text);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    margin: 0.75rem 0 0;
}

/* Start page */

.coupon-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem 1rem;
}

.coupon-head h2 {
    margin: 0;
}

.coupon-head p {
    margin: 0.1rem 0 0;
}

.closes {
    text-align: right;
}

.time-left {
    font-size: 1.25rem;
    font-weight: 700;
}

.coupon-card > p {
    margin: 0.6rem 0 0;
}

a.button {
    display: inline-block;
    background: var(--accent);
    color: var(--accent-text);
    border-radius: 6px;
    padding: 0.4rem 0.9rem;
    font-weight: 600;
    text-decoration: none;
    margin-right: 0.4rem;
}

a.button.secondary {
    background: none;
    color: var(--accent);
    border: 1px solid var(--border);
}

/* Results */

h3 {
    font-size: 0.95rem;
    margin: 1rem 0 0.5rem;
}

.sign.on.actual {
    background: var(--result);
    border-color: var(--border);
    color: var(--result-text);
}

.mark {
    font-weight: 700;
    margin-left: 0.2rem;
}

.mark.good,
td.good {
    color: var(--good);
}

.mark.bad,
td.bad {
    color: var(--bad);
}

table.systems tr.section td {
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding-top: 0.8rem;
}

table.systems tr.strong td {
    font-weight: 700;
}
