:root {
    --bg: #0f1420;
    --card: #171e2e;
    --card-2: #1d2537;
    --text: #e8ecf4;
    --muted: #8b93a7;
    --accent: #4f8cff;
    --ok: #35c98f;
    --bad: #ff5d6c;
    --warn: #ffb545;
    --border: #2a3345;
    --ink: #0c1220;          /* dark text for colored fills — passes AA where white fails */
    --p1: #4f8cff;           /* player 1 (Marcus) */
    --p2: #ffb545;           /* player 2 (Alex) */
    --heading: 'Barlow Condensed', 'Inter', -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
button:focus-visible { outline-color: var(--text); }

.p1 { --player: var(--p1); }
.p2 { --player: var(--p2); }

.wrap {
    max-width: 760px;
    margin: 0 auto;
    padding: 16px 16px 64px;
}

/* ---- nav ---- */
.topnav {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 10px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.brand { font-family: var(--heading); font-weight: 700; font-size: 1.25rem; color: var(--text); letter-spacing: 0.01em; }
.navlinks { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.navlinks a { color: var(--muted); font-size: 0.95rem; padding: 8px 8px; border-radius: 6px; }
.navlinks a:hover { color: var(--text); text-decoration: none; }
.navlinks a.active { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.navuser { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.9rem; }

.commit-banner {
    background: rgba(255, 181, 69, 0.14);
    border-bottom: 1px solid rgba(255, 181, 69, 0.35);
    color: var(--warn);
    text-align: center;
    padding: 10px 16px;
    font-size: 0.95rem;
}
.commit-banner a { color: var(--warn); font-weight: 600; text-decoration: underline; }

/* ---- type scale ---- */
h1 { font-family: var(--heading); font-size: 2.2rem; font-weight: 700; margin: 12px 0 4px; line-height: 1.1; }
h2 { font-family: var(--heading); font-size: 1.35rem; font-weight: 600; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.page-header { margin-bottom: 20px; }

/* ---- hero ---- */
.hero { text-align: center; padding: 36px 20px; }
.hero-kicker { color: var(--muted); text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.8rem; }
.hero-title { font-family: var(--heading); font-size: 3.2rem; font-weight: 700; margin: 6px 0; line-height: 1; }
.hero-sub { color: var(--muted); font-size: 1.05rem; margin: 0; }
.hero-sub strong { color: var(--text); }

/* ---- flashes ---- */
.flashes { margin: 12px 0; }
.flash {
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--card-2);
    border: 1px solid var(--border);
    margin-bottom: 8px;
}
.flash-badge {
    background: #2a2340;
    border-color: #4b3d8a;
    font-weight: 600;
    animation: pop 0.35s ease-out;
}
.flash-error { border-color: var(--bad); background: rgba(255, 93, 108, 0.12); }
.flash-success { border-color: rgba(53, 201, 143, 0.5); background: rgba(53, 201, 143, 0.1); }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .flash-badge { animation: none; } }

/* ---- cards ---- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 20px;
}

/* ---- race strip ---- */
.race { padding: 16px 18px; }
.race-heads { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.race-name { font-family: var(--heading); font-weight: 700; font-size: 1.3rem; color: var(--player); }
.race-verdict { color: var(--muted); font-size: 0.9rem; text-align: center; }
.race-track { height: 14px; border-radius: 999px; background: var(--p2); overflow: hidden; }
.race-fill { height: 100%; background: var(--player); border-right: 2px solid var(--bg); }
.race-money { display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; }
.race-amount { font-family: var(--heading); font-weight: 700; font-size: 1.7rem; color: var(--player); font-variant-numeric: tabular-nums; }

/* ---- player cards ---- */
.leaderboard { display: flex; flex-direction: column; gap: 16px; }
.player-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--player, var(--border));
    border-radius: 14px;
    padding: 18px;
}
.player-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.player-head h2 { margin: 0; font-size: 1.6rem; }
.player-link { color: var(--text); }
.player-link:hover { color: var(--player); text-decoration: none; }
.you-tag { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; vertical-align: middle; }

.score { text-align: right; }
.score-num { font-family: var(--heading); font-size: 2.8rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.score-label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }

.pill {
    display: inline-block;
    font-size: 0.78rem;
    padding: 2px 9px;
    border-radius: 999px;
    margin-top: 6px;
}
.pill-ok { background: rgba(53, 201, 143, 0.15); color: var(--ok); }
.pill-warn { background: rgba(255, 181, 69, 0.15); color: var(--warn); }
a.pill-warn { text-decoration: underline; }

.goal-list { margin: 12px 0 0; padding-left: 18px; }
.goal-list li { margin-bottom: 6px; }

/* ---- week box ---- */
.week-box { margin: 14px 0 10px; }
.week-box-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.88rem; margin-bottom: 4px; gap: 8px; }
.at-risk { color: var(--warn); font-weight: 600; font-size: 0.88rem; }

.bar {
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: repeating-linear-gradient(
        -45deg,
        rgba(255, 93, 108, 0.28) 0 6px,
        rgba(255, 93, 108, 0.1) 6px 12px
    );
}
.bar-secured { height: 100%; background: var(--player, var(--accent)); border-radius: 999px; }

/* ---- components (3-state) ---- */
.components { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.component { display: flex; align-items: center; gap: 8px; font-size: 0.92rem; }
.c-mark { width: 16px; text-align: center; font-weight: 700; flex-shrink: 0; }
.c-met .c-mark { color: var(--ok); }
.c-open .c-mark { color: var(--warn); }
.c-missed .c-mark { color: var(--bad); }
.c-missed .component-label { color: var(--muted); text-decoration: line-through; }
.component-label { flex: 1; }
.component-count { color: var(--muted); font-size: 0.85rem; }

/* ---- quick check-in ---- */
.quick-checkin {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--card-2);
    border-radius: 10px;
    flex-wrap: wrap;
}
.quick-checkin span { font-size: 0.92rem; font-weight: 600; }

/* ---- week dots ---- */
.week-dots { display: flex; gap: 6px; margin-top: 12px; }
.wd {
    width: 30px; height: 30px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.72rem; font-weight: 700;
    background: var(--card-2);
    color: var(--muted);
    border: 1px solid var(--border);
}
.wd-clean { background: var(--ok); color: var(--ink); border-color: var(--ok); }
.wd-slipped { background: var(--bad); color: var(--ink); border-color: var(--bad); }
.wd-future { opacity: 0.35; }
.wd-today { box-shadow: 0 0 0 2px var(--accent); }
a.wd:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }

/* ---- todos ---- */
.todos { margin-top: 12px; }
.todos-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 6px; }
.todo {
    display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
    padding: 8px 12px; margin-bottom: 6px;
    background: var(--card-2); border-radius: 8px;
    color: var(--text); font-size: 0.92rem;
}
.todo:hover { text-decoration: none; background: #232d44; }
.todo-pts { color: var(--warn); font-weight: 700; font-size: 0.85rem; white-space: nowrap; }
.todo-urgent { border: 1px solid var(--bad); color: var(--bad); font-weight: 700; }

.prospect { margin-top: 10px; font-size: 0.92rem; color: var(--warn); }

/* ---- streaks & badges strip ---- */
.streak-row { display: flex; align-items: center; gap: 14px; margin-top: 12px; flex-wrap: wrap; }
.streak { font-size: 0.88rem; color: var(--warn); }
.badge-strip { font-size: 1.05rem; letter-spacing: 2px; }

details.recent { margin-top: 12px; }
details.recent summary { cursor: pointer; color: var(--muted); font-size: 0.88rem; }

/* ---- tables ---- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 0.88rem; }
table th, table td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--border); }
table th { color: var(--muted); font-weight: 500; }
table td:first-child { white-space: nowrap; }

/* ---- forms ---- */
input, select, button {
    font-family: inherit;
    font-size: 0.95rem;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card-2);
    color: var(--text);
}
button {
    cursor: pointer;
    background: var(--accent);
    border: none;
    color: var(--ink);
    font-weight: 700;
}
button:hover { filter: brightness(1.1); }
button:active { transform: translateY(1px); }
.btn-clean { background: var(--ok); color: var(--ink); }
.btn-slip { background: var(--bad); color: var(--ink); }

.linklike {
    background: none;
    border: none;
    color: var(--muted);
    font-weight: 400;
    padding: 0;
    text-decoration: underline;
    font-size: 0.85rem;
    cursor: pointer;
}
.linklike.danger { color: var(--bad); }

.inline-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.inline-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.nutrition-form { padding: 12px; background: var(--card-2); border-radius: 10px; }
.button-row { display: flex; gap: 10px; }

.entry-actions { display: flex; gap: 10px; align-items: baseline; }
.edit-details summary { list-style: none; }
.edit-details summary::-webkit-details-marker { display: none; }
.edit-form { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.edit-form input[type="number"] { width: 70px; }
.edit-form input[type="text"] { width: 140px; }

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

/* ---- login ---- */
.login-card {
    max-width: 360px;
    margin: 60px auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    text-align: center;
}
.login-mark { font-size: 2.4rem; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; text-align: left; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); }

/* ---- feed ---- */
.feed { display: flex; flex-direction: column; gap: 10px; }
.feed-day { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 8px; }
.feed-item {
    display: flex; gap: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--player, var(--border));
    border-radius: 10px;
    padding: 12px;
}
.feed-own { opacity: 0.92; }
.feed-icon { font-size: 1.3rem; }

/* ---- badges page ---- */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.badge-tile {
    text-align: center;
    background: var(--card-2);
    border-radius: 10px;
    padding: 14px 10px;
    border: 1px solid var(--border);
}
.badge-tile.locked { opacity: 0.4; filter: grayscale(0.6); }
.badge-icon { font-size: 1.7rem; }
.badge-label { font-weight: 600; font-size: 0.85rem; margin-top: 4px; }
.badge-n { color: var(--warn); font-weight: 700; }
.badge-odds { margin-top: 4px; }

/* ---- calendar ---- */
.cal-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.cal-users { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pill-link { font-size: 0.88rem; color: var(--player, var(--muted)); }

.cal-legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.cal-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.cal-dot-clean { background: var(--ok); }
.cal-dot-slipped { background: var(--bad); }

/* the card is the calendar frame: zero padding so the lattice runs edge to edge */
.cal-card { padding: 0; overflow: hidden; }

.cal-month-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}
.cal-month-name { font-family: var(--heading); font-size: 1.6rem; font-weight: 700; }
.cal-nav-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    border-radius: 8px;
    background: var(--card-2);
    color: var(--text);
    font-size: 1.1rem;
}
.cal-nav-btn:hover { background: #232d44; text-decoration: none; }
.cal-nav-off { opacity: 0.3; pointer-events: none; }

/* one contiguous lattice: header cells are children 1-7, so :nth-child(7n)
   strips the right border on the header's last cell and every Sunday alike */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.calendar-grid > *:nth-child(7n) { border-right: none; }

.cal-head-cell {
    text-align: center;
    padding: 8px 0 6px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--card-2);
}

.cal-day {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 84px;
    padding: 6px 8px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--card);
    color: inherit;
}
a.cal-day:hover { background: #202a40; text-decoration: none; }
.cal-day.cal-outside { background: var(--bg); }
.cal-day.cal-outside .cal-day-num { color: #3a4356; font-weight: 400; }
.cal-day.cal-off-season { background: var(--bg); }
.cal-day.cal-off-season .cal-day-num { color: #3a4356; font-weight: 400; }
.cal-day.cal-today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day.cal-nut-clean { background: rgba(53, 201, 143, 0.14); }
.cal-day.cal-nut-slipped { background: rgba(255, 93, 108, 0.14); }
a.cal-day.cal-nut-clean:hover { background: rgba(53, 201, 143, 0.24); }
a.cal-day.cal-nut-slipped:hover { background: rgba(255, 93, 108, 0.24); }
.cal-day.cal-unlogged { outline: 1px dashed var(--border); outline-offset: -4px; }

/* corner status dot — survives color-vision deficiencies where the tint alone doesn't */
.cal-day.cal-nut-clean::after,
.cal-day.cal-nut-slipped::after {
    content: '';
    position: absolute; top: 6px; right: 6px;
    width: 7px; height: 7px; border-radius: 50%;
}
.cal-day.cal-nut-clean::after { background: var(--ok); }
.cal-day.cal-nut-slipped::after { background: var(--bad); }

.cal-day-num { font-size: 0.92rem; font-weight: 600; color: var(--text); line-height: 1.2; }
.cal-day.cal-today .cal-day-num { color: var(--accent); font-weight: 700; }

.cal-workouts { margin-top: auto; padding-top: 4px; display: flex; gap: 3px; flex-wrap: wrap; }
.cal-workout-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background: var(--accent);
    color: var(--ink);
    font-size: 0.7rem;
    font-weight: 700;
}

/* ---- responsive ---- */
@media (max-width: 480px) {
    .player-head { flex-direction: column; }
    .score { text-align: left; }
    .navuser span { display: none; }
    .cal-day { min-height: 58px; padding: 4px 5px; }
    .cal-day-num { font-size: 0.8rem; }
    .cal-head-cell { font-size: 0.6rem; letter-spacing: 0.04em; }
    .cal-month-name { font-size: 1.25rem; }
    .cal-workout-chip { width: 14px; height: 14px; font-size: 0.6rem; }
    .hero-title { font-size: 2.4rem; }
    .race-amount { font-size: 1.3rem; }
    .week-dots { justify-content: space-between; width: 100%; }
}
