:root {
  --bg: #0b1220;
  --bg-elev: #131c2e;
  --bg-elev-2: #1a2438;
  --border: #263149;
  --text: #e7edf7;
  --text-dim: #93a1bd;
  --skill: #34d0a0;
  --phys: #4ea1ff;
  --nutrition: #ffcc4d;
  --rest: #b892ff;
  --composure: #ff6b6b;
  --work: #ff9f43;
  --accent: #34d0a0;
  --danger: #ff5d5d;
  --warn: #ffb020;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: contain;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: calc(24px + var(--safe-bottom));
  min-height: 100vh;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: calc(8px + var(--safe-top)) 16px 8px;
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, var(--bg) 80%, transparent);
  z-index: 10;
}
.topbar-top { display: flex; justify-content: space-between; align-items: center; }
.topbar-info { display: flex; flex-direction: column; gap: 2px; }
.brand { font-weight: 800; font-size: 18px; letter-spacing: 0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; margin-right: 8px; }
/* Narrower phones: give the cash / rating / table-position chips room. */
@media (max-width: 400px) { .brand { font-size: 16px; } }
.match-counter {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.match-counter-sub { font-size: 11px; opacity: 0.8; }
/* Wraps rather than ellipsizing: on a narrow screen the hours pill drops
   to its own line instead of cutting off the match info beside it. */
.topbar-sub-row { display: flex; flex-wrap: wrap; align-items: center; column-gap: 8px; row-gap: 2px; }
.topbar-sub-row .match-counter-sub { min-width: 0; }
.topbar-hours {
  margin-left: auto;
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 11px;
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev);
}
.match-counter:empty { display: none; }
.topbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.chip {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.icon-btn {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  width: 34px;
  height: 34px;
  font-size: 16px;
}

/* ---------- Stats ---------- */
.stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 2px 16px 8px;
}
.bar {
  position: relative;
  height: 7px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  overflow: hidden;
  border: 1px solid var(--border);
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s ease;
}
/* Tomorrow's projected value, layered over the current bar: always green
   for a gain and always red for a decay, regardless of the bar's own
   color, so direction reads at a glance without checking the number. */
.bar-preview {
  position: absolute;
  top: 0;
  transition: left 0.2s ease, width 0.2s ease;
}
/* Above the current cap: hatched and dimmed, with a light edge at the cap. */
.bar-locked {
  position: absolute;
  top: 0;
  height: 100%;
  border-left: 1px solid rgba(255, 255, 255, 0.45);
  background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.13) 0 2px, transparent 2px 5px);
}
.bar-preview-gain { background: var(--skill) !important; opacity: 0.55; }
/* Calm's reserve above 100: a bright strip along the top of the (full) bar,
   its width the reserve's share of what it can hold. */
.bar-bank { position: absolute; top: 0; left: 0; height: 3px; background: #ffe08a; border-radius: 999px; box-shadow: 0 0 4px rgba(255, 224, 138, 0.7); }
.bar-bank-gain { background: #ffe08a; opacity: 0.45; box-shadow: none; }
/* A darker, more saturated red than the Composure bar's own (lighter)
   red — same hue family would otherwise nearly vanish on that bar, so
   the loss overlay leans darker to stay legible there too. */
.bar-preview-loss { background: #e03131 !important; opacity: 0.6; }
.bar-fill.skill { background: var(--skill); }
.bar-fill.phys { background: var(--phys); }
.bar-fill.nutrition { background: var(--nutrition); }
.bar-fill.work { background: var(--work); }
.bar-fill.rest { background: var(--rest); }
.bar-fill.composure { background: var(--composure); }

.warning-banner {
  margin: 0 16px 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: rgba(255, 93, 93, 0.12);
  border: 1px solid rgba(255, 93, 93, 0.4);
  color: #ffb3b3;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}
.warning-banner.hidden { display: none; }

/* ---------- Planner ---------- */
.planner {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 16px 12px;
  padding: 12px 12px 12px;
}
.planner-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.planner-header h2 { font-size: 15px; margin: 0; }
.hours-left { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
#hoursLeft.over { color: var(--danger); font-weight: 700; }
#hoursLeft.unassigned { color: var(--warn); font-weight: 700; }
.hours-cap-note { color: var(--warn); }

.activity { padding: 6px 0; border-top: 1px solid var(--border); }
.activity:first-of-type { border-top: none; }
.activity-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 4px;
}
.activity-icon { font-size: 16px; flex-shrink: 0; }
.activity-name { font-weight: 600; flex-shrink: 0; }
.combo-outcome {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex-shrink: 1;
}
.combo-bar { margin: 5px 0 8px; }
.activity-hours {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  font-weight: 600;
  min-width: 28px;
  text-align: right;
}
.stepper { display: flex; align-items: center; gap: 10px; }
.slider-wrap { position: relative; flex: 1; display: flex; align-items: center; }
.slider-wrap input[type="range"] { flex: 1; }
.slider-marker {
  position: absolute;
  top: 50%;
  left: 0;
  width: 2px;
  height: 14px;
  transform: translate(-50%, -50%);
  background: var(--text-dim);
  opacity: 0.6;
  pointer-events: none;
  border-radius: 1px;
}
.skill-shop-tag {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  white-space: nowrap;
}
.skill-shop-tag-none { opacity: 0.6; font-weight: 600; }
/* A skill row's coach tag opens that coach in Staff. */
button.coach-link { font-family: inherit; line-height: inherit; cursor: pointer; margin: 0; }
.skill-shop-tag-negative { color: var(--danger); }
.step-btn {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}
.step-btn:active { background: #24314d; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  outline: none;
  transition: background-color 0.2s ease;
}
/* A light tint on the track itself shows at a glance whether today's hours
   clear the stat's decay/requirement threshold, independent of bar color. */
input[type="range"].slider-meets { background: rgba(52, 208, 160, 0.3); }
input[type="range"].slider-under { background: rgba(255, 93, 93, 0.3); }
input[type="range"].slider-held { background: rgba(120, 150, 200, 0.3); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #0b1220;
  box-shadow: 0 0 0 1px var(--accent);
}
.skill-row input[type="range"]::-webkit-slider-thumb { background: var(--skill); box-shadow: 0 0 0 1px var(--skill); }
.activity[data-act="exercise"] input[type="range"]::-webkit-slider-thumb { background: var(--phys); box-shadow: 0 0 0 1px var(--phys); }
.activity[data-act="sleep"] input[type="range"]::-webkit-slider-thumb { background: var(--rest); box-shadow: 0 0 0 1px var(--rest); }
.activity[data-act="relax"] input[type="range"]::-webkit-slider-thumb { background: var(--composure); box-shadow: 0 0 0 1px var(--composure); }
.activity[data-act="work"] input[type="range"]::-webkit-slider-thumb { background: var(--work); box-shadow: 0 0 0 1px var(--work); }
.activity[data-act="nutrition"] input[type="range"]::-webkit-slider-thumb { background: var(--nutrition); box-shadow: 0 0 0 1px var(--nutrition); }

.end-day-btn {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #04241a;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.2px;
}
.end-day-btn:disabled {
  background: var(--bg-elev-2);
  color: var(--text-dim);
}
.end-day-btn:active:not(:disabled) { transform: scale(0.98); }

/* ---------- Log ---------- */
.log-section { padding: 0 16px; }
.log-section h2 { font-size: 15px; margin: 0 0 8px; color: var(--text-dim); }
.log {
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding-bottom: 8px;
}
.log-entry {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
}
.log-entry.day-header { font-weight: 800; background: var(--bg-elev-2); }
.log-entry.event-good { border-color: rgba(52, 208, 160, 0.4); }
.log-entry.event-bad { border-color: rgba(255, 93, 93, 0.4); }
.log-entry.event-match { border-color: rgba(255, 176, 32, 0.5); background: rgba(255, 176, 32, 0.06); }
.log-entry.event-season { border-color: rgba(184, 146, 255, 0.5); background: rgba(184, 146, 255, 0.08); font-weight: 600; }

/* ---------- Save toast ---------- */
.save-toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  transform: translate(-50%, 12px);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: calc(100% - 32px);
  text-align: center;
}
.save-toast.hidden { display: none; }
.save-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.save-toast.toast-warn {
  background: rgba(255, 93, 93, 0.15);
  border-color: rgba(255, 93, 93, 0.5);
  color: #ffb3b3;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  width: 100%;
  max-width: 560px;
  max-height: 82vh;
  overflow-y: auto;
  padding: 20px 18px calc(24px + var(--safe-bottom));
  position: relative;
  animation: slideUp 0.22s ease;
}
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
}
.modal h2 { margin-top: 4px; }
.modal.modal-own-close > .modal-close { display: none; }
/* Pinned to the top of the scrolling sheet. Negative margins + matching
   padding stretch its background edge to edge so content scrolls under it;
   top matches the sheet's own top padding. Cash and ✕ never shrink — the
   title truncates first if the row runs out of room. */
.modal-sticky-head {
  position: sticky;
  top: -20px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -20px -18px 14px;
  padding: 16px 18px 12px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}
.modal-sticky-head h2 {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.modal-sticky-head .sticky-cash {
  flex-shrink: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 14px;
}
.modal-close.modal-close-inline { position: static; flex-shrink: 0; }
/* Segmented tab switch used as a sticky header's title (Staff & Items). */
.tab-switch { display: inline-flex; background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; vertical-align: middle; }
.tab-btn { background: transparent; color: var(--text-dim); border: none; border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 700; white-space: nowrap; }
.tab-btn.active { background: var(--accent); color: #04241a; }
.modal-section { margin-bottom: 18px; }
.modal-section h3 { font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin: 0 0 8px; }

.callout {
  background: rgba(52, 208, 160, 0.08);
  border: 1px solid rgba(52, 208, 160, 0.35);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0;
  font-size: 14px;
}
.callout-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--skill);
  font-weight: 700;
  margin-bottom: 4px;
}

.skill-row-detail { margin-bottom: 10px; }
.skill-row-detail:last-child { margin-bottom: 0; }
.skill-row-detail-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}
.skill-row-detail-active .skill-row-detail-label { font-weight: 700; color: var(--text); }

.match-card {
  text-align: center;
  padding: 10px 0 4px;
}
.match-result {
  font-size: 26px;
  font-weight: 800;
  margin: 6px 0;
}
.match-result.win { color: var(--accent); }
.match-result.loss { color: var(--danger); }
.match-result.neutral { color: var(--work); }
.match-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 14px; }

.shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  background: var(--bg-elev-2);
}
.shop-item-match { border-color: var(--warn); background: rgba(255, 176, 32, 0.08); }
.shop-item-match-tag {
  display: inline-block;
  background: rgba(255, 176, 32, 0.18);
  color: var(--warn);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 800;
  vertical-align: middle;
}
.shop-item-icon { font-size: 22px; }
.shop-item-info { flex: 1; }
.shop-item-name { font-weight: 700; font-size: 14px; }

.primary-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #04241a;
  font-size: 15px;
  font-weight: 800;
  margin-top: 6px;
}

.name-input {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 15px;
  margin-bottom: 10px;
  -webkit-user-select: text;
  user-select: text;
}

.standings-list {
  margin: 0;
  padding-left: 22px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.7;
}
.standings-list li.standings-you { color: var(--accent); font-weight: 700; }

.modal-sub { font-size: 12px; color: var(--text-dim); margin: 6px 0 0; }

.league-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
}
.league-tab {
  flex-shrink: 0;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
}
.league-tab.active { background: var(--accent); color: #04241a; border-color: var(--accent); }

.league-table-header,
.league-row {
  display: grid;
  grid-template-columns: 26px 1fr 46px 24px 24px 30px;
  gap: 6px;
  align-items: center;
  padding: 7px 8px;
  font-size: 13px;
}
.league-table-header {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.league-table {
  max-height: 50vh;
  overflow-y: auto;
}
.league-row { border-bottom: 1px solid var(--border); }
.league-row:last-child { border-bottom: none; }
.league-pos { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.league-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.league-rating, .league-points, .league-wl { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-dim); }
.league-row.zone-promo { background: rgba(52, 208, 160, 0.07); }
.league-row.zone-releg { background: rgba(255, 93, 93, 0.07); }
.league-row.league-row-you { background: rgba(255, 176, 32, 0.12); }
.league-row.league-row-you .league-name { color: var(--text); font-weight: 700; }

.league-legend { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 2px; }
.legend-dot.legend-promo { background: rgba(52, 208, 160, 0.5); }
.legend-dot.legend-releg { background: rgba(255, 93, 93, 0.5); }
/* Playoff qualifiers: a left edge bar, independent of the promo/releg
   background tint, plus a dashed divider under the last qualifying place. */
.league-row.zone-playoff { box-shadow: inset 3px 0 0 rgba(78, 161, 255, 0.85); }
.legend-dot.legend-playoff { background: rgba(78, 161, 255, 0.85); }
.league-cutline {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--phys);
  border-top: 1px dashed rgba(78, 161, 255, 0.6);
  padding: 3px 0 3px 36px;
}
.ghost-btn {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  margin-top: 8px;
}

.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px;
  border-top: 1px solid var(--border);
  font-size: 15px;
  font-weight: 600;
}
.menu-row:first-of-type { border-top: none; }
.menu-row span.arrow { color: var(--text-dim); }

.version-tag {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 14px;
}

@media (min-width: 560px) {
  #app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

/* Export / import save */
.save-transfer-note { font-size: 13px; color: var(--text-dim); margin: 0 0 8px; }
.save-transfer-status { font-size: 13px; color: var(--accent); margin-top: 8px; min-height: 0; }
.save-transfer-status:empty { display: none; }
.save-transfer-status.bad { color: var(--danger, #f87171); }
.save-code-input { font-family: ui-monospace, Menlo, monospace; font-size: 12px; resize: vertical; word-break: break-all; }
.save-file-btn { display: block; text-align: center; cursor: pointer; box-sizing: border-box; }

/* Match result: performance breakdown table */
.perf-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.perf-table th { font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.4px; padding: 0 4px 6px; border-bottom: 1px solid var(--border); }
.perf-table td { padding: 5px 4px; }
.perf-table th, .perf-table td { text-align: right; white-space: nowrap; }
.perf-table th:first-child, .perf-table td:first-child { text-align: left; white-space: normal; }
.perf-table .perf-main td { color: var(--text); border-top: 1px solid var(--border); }
.perf-table tbody .perf-main:first-child td { border-top: none; }
.perf-table .perf-sub td { color: var(--text-dim); font-size: 12px; padding-top: 2px; padding-bottom: 2px; }
.perf-table .perf-sub td:first-child { padding-left: 22px; }
.perf-table .perf-warn td { color: var(--danger); }
.perf-table tfoot td { font-weight: 800; color: var(--text); border-top: 2px solid var(--border); padding-top: 7px; }
.perf-table .perf-of { font-weight: 600; color: var(--text-dim); }
.perf-note { font-size: 12px; }

/* End Day / End Week pair — End Week is the quieter, secondary action */
.end-day-row { display: flex; gap: 8px; margin-top: 10px; }
.end-day-row .end-day-btn { flex: 1 1 0; min-width: 0; margin-top: 0; white-space: nowrap; padding: 12px 4px; font-size: 15px; }
.end-week-btn { background: transparent; color: var(--text); border: 1px solid var(--border); font-weight: 700; font-size: 14px !important; }
.end-week-btn:disabled { background: transparent; }
.end-week-days { color: var(--text-dim); font-weight: 600; }

/* Week summary (End Week) */
.week-summary { text-align: left; margin: 14px 0 4px; }
.week-summary h3 { font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin: 0 0 8px; }
.week-stop { font-size: 13px; color: var(--warn); background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; }
.week-table td { border-top: 1px solid var(--border); }
.week-table .wk-up { color: var(--accent); }
.week-table .wk-down { color: var(--danger); }
@media (max-width: 350px) {
  .end-day-row .end-day-btn { font-size: 13px; }
  .end-week-btn { font-size: 12.5px !important; }
}

/* Match result: pinned VICTORY / DEFEAT header + win-chance table */
.modal-sticky-head .match-head { font-size: 22px; font-weight: 800; letter-spacing: 0.5px; }
.modal-sticky-head .match-head.win { color: var(--accent); }
.modal-sticky-head .match-head.loss { color: var(--danger); }
.match-card > .match-sub:first-child { margin-top: 2px; }
.win-ladder { margin-top: 2px; }
.win-ladder .ladder-you td { color: var(--text); font-weight: 800; background: var(--bg-elev-2); }

/* Leagues button: table position */
.icon-btn.has-pos { width: auto; padding: 0 6px; display: inline-flex; align-items: center; gap: 3px; font-size: 15px; }
.leagues-pos { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.leagues-pos.pos-promo { color: var(--accent); }
.leagues-pos.pos-releg { color: var(--danger); }
.leagues-pos.pos-out { color: var(--text-dim); }

/* Match result v2: header subline, Result + You vs Opponent tables, collapsibles */
.modal-sticky-head .match-head { display: block; }
.modal-sticky-head .match-head-sub { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-dim); letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.champion-line { color: var(--work); font-weight: 700; }
.result-table { margin-top: 2px; }
.result-table .wk-up, .h2h-table .wk-up { color: var(--accent); }
.result-table .wk-down { color: var(--danger); }
.h2h-table { margin-top: 14px; }
/* Table place sits above the rows that add up to the match-day rating. */
.h2h-table tr.h2h-context td { border-bottom: 1px dashed var(--border); }
.h2h-table th.h2h-opp { max-width: 120px; overflow: hidden; text-overflow: ellipsis; text-transform: none; letter-spacing: 0; }
.h2h-table thead th:nth-child(2) { text-transform: none; letter-spacing: 0; }
.h2h-table tfoot td { font-size: 15px; }
.h2h-icons { font-size: 12px; letter-spacing: -1px; }
.next-match { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.next-match-title { font-weight: 800; font-size: 14px; color: var(--text); }
.next-match .next-match-table { margin-top: 8px; }
.next-match .next-match-focus { margin-top: 12px; }
.match-verdict { text-align: center; font-size: 16px; font-weight: 800; margin: 10px 0 4px; }
.match-verdict.win { color: var(--accent); }
.match-verdict.loss { color: var(--danger); }
details.match-more { border: 1px solid var(--border); border-radius: 10px; padding: 0 10px; margin: 10px 0; text-align: left; }
details.match-more > summary { list-style: none; cursor: pointer; padding: 11px 0; font-size: 13.5px; font-weight: 700; color: var(--text); display: flex; justify-content: space-between; align-items: center; }
details.match-more > summary::-webkit-details-marker { display: none; }
details.match-more > summary::after { content: "▸"; color: var(--text-dim); transition: transform 0.15s; }
details.match-more[open] > summary::after { transform: rotate(90deg); }
details.match-more[open] { padding-bottom: 8px; }
.calc-table { margin-top: 2px; }
.calc-table + .perf-note { margin-bottom: 14px; }

/* Career & Season: label / value rows */
.kv-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--border); font-size: 14px; }
.kv-row:first-of-type { border-top: none; }
.kv-row > span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.kv-row > span:first-child { color: var(--text-dim); }
.callout .kv-row { border-top-color: rgba(52, 208, 160, 0.2); }
.callout .kv-row > span:first-child { color: var(--text); }
.emp-returns .kv-row > span:first-child { color: var(--text); }
.kv-row .kv-dim { color: var(--text-dim); font-size: 12.5px; align-self: center; }
.skills-legend { margin-bottom: 10px !important; }
.end-day-hint { font-size: 12.5px; color: var(--warn); text-align: center; margin-top: 8px; }
.end-day-hint:empty { display: none; }

/* Match History */
.log-head { display: flex; justify-content: space-between; align-items: baseline; }
.log-head h2 { margin-bottom: 8px; }
.link-btn { background: none; border: none; color: var(--accent); font-size: 13px; font-weight: 700; padding: 4px 0; cursor: pointer; }
.history-tabs { margin-bottom: 12px; }
.hist-list { display: flex; flex-direction: column; }
.hist-row { display: grid; grid-template-columns: 34px 22px 1fr auto 40px; align-items: center; gap: 8px; padding: 8px 2px; border-top: 1px solid var(--border); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.hist-row:first-child { border-top: none; }
.hist-row[data-mi] { cursor: pointer; }
.hist-row[data-mi]:active { background: var(--bg-elev-2); }
.hist-round { color: var(--text-dim); font-size: 12px; font-weight: 700; }
.hist-wl { font-weight: 800; text-align: center; }
.hist-wl.win { color: var(--accent); }
.hist-wl.loss { color: var(--danger); }
.hist-opp { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-score { color: var(--text-dim); text-align: right; }
.hist-delta { text-align: right; font-weight: 700; }
.hist-delta.wk-up { color: var(--accent); } .hist-delta.wk-down { color: var(--danger); }
.up-row { grid-template-columns: 34px 1fr auto 34px 38px; }
.res2-row { grid-template-columns: 30px 14px 1fr auto 30px 30px; gap: 6px; }
.res2-row.up-head span:nth-child(3) { text-align: left; }
.res2-row[data-mi] { cursor: pointer; }
.res2-you { background: rgba(255, 176, 32, 0.12); }
.up-row[data-rival] { cursor: pointer; }
.up-head { color: var(--text-dim); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.up-head span:nth-child(n+3) { text-align: right; }
.up-next { background: rgba(52, 208, 160, 0.08); }
.up-pos { color: var(--text-dim); text-align: right; }
.up-pct { text-align: right; font-weight: 700; }
.up-tbd { color: var(--text-dim); font-style: italic; }
.hist-legacy { opacity: 0.75; }
.round-stepper { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 10px; font-weight: 700; }
.round-stepper .icon-btn:disabled { opacity: 0.3; }
.res-list { display: flex; flex-direction: column; }
.res-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; padding: 7px 4px; border-top: 1px solid var(--border); font-size: 13px; }
.res-row:first-child { border-top: none; }
.res-row .res-side:last-child { text-align: right; color: var(--text-dim); }
.res-row .res-side { min-width: 0; display: flex; align-items: baseline; gap: 4px; white-space: nowrap; }
.res-row .res-side:last-child { justify-content: flex-end; }
/* Only the name gives way on a narrow screen; # and rating always show. */
.res-row .res-side > .link-name, .res-row .res-side > b { min-width: 0; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-row .res-side > .res-pos, .res-row .res-side > .res-rt { flex: none; }
.res-you { background: rgba(52, 208, 160, 0.08); border-radius: 8px; }
.res-beat { color: var(--text-dim); font-size: 11.5px; }
.res-rt { color: var(--text-dim); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.res-pos, .hist-pos { color: var(--text-dim); font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.link-name { background: none; border: none; padding: 0; color: inherit; font: inherit; text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer; }
.league-row[data-rival] { cursor: pointer; }
.league-tab:disabled { opacity: 0.35; }

/* Staff (weekly hiring) */
.staff-week { margin-bottom: 16px; }
.staff-card { align-items: flex-start; }
.staff-card-hired { border-color: rgba(52, 208, 160, 0.55); }
.staff-line { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; line-height: 1.35; }
.staff-line-locked { opacity: 0.55; }
.staff-stat { color: var(--text); }
.staff-prorate { font-style: italic; }
.staff-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.staff-chip { background: var(--accent); color: #04241a; border: none; border-radius: 999px; padding: 6px 11px; font-size: 12.5px; font-weight: 800; }
.staff-chip:disabled { background: var(--bg-elev-2); color: var(--text-dim); }
.staff-chip.staff-unlock { background: transparent; color: var(--text); border: 1px solid var(--border); }
.staff-chip.staff-unlock:disabled { color: var(--text-dim); }
.staff-sale { margin: 6px 0 10px; }
.staff-line s { opacity: 0.6; }
.staff-hired { color: var(--accent); font-weight: 800; font-size: 13px; }
.staff-locked { color: var(--text-dim); font-size: 12px; align-self: center; }
.staff-auto { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; font-weight: 700; color: var(--text); cursor: pointer; }
.staff-auto input { position: absolute; opacity: 0; width: 0; height: 0; }
.staff-auto-switch { position: relative; flex: 0 0 auto; width: 34px; height: 20px; border-radius: 999px; background: var(--bg-elev-2); border: 1px solid var(--border); transition: background 0.15s; }
.staff-auto-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-dim); transition: transform 0.15s, background 0.15s; }
.staff-auto input:checked + .staff-auto-switch { background: var(--accent); border-color: var(--accent); }
.staff-auto input:checked + .staff-auto-switch::after { transform: translateX(14px); background: #04241a; }
.staff-auto input:focus-visible + .staff-auto-switch { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Phase splash + tutorial */
.splash { text-align: center; padding-top: 4px; }
.splash-icon { font-size: 44px; line-height: 1.1; }
.splash-title { font-size: 24px; font-weight: 800; margin-top: 6px; }
.splash-sub { color: var(--text-dim); font-size: 14px; margin-top: 2px; }
.splash-section { text-align: left; margin-top: 18px; }
.splash-section .kv-row span:first-child { flex-shrink: 0; white-space: nowrap; }
.splash-section .kv-row span:last-child { text-align: right; }
.splash-note { text-align: left; font-size: 13.5px; margin: 6px 0 14px; }
.tutorial-body { font-size: 15px; line-height: 1.5; color: var(--text); text-align: left; margin: 16px 2px 18px; }
.tutorial-dots { display: flex; justify-content: center; gap: 7px; margin-bottom: 16px; }
.tutorial-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.tutorial-dots span.on { background: var(--accent); }
.tutorial-nav { display: flex; gap: 10px; }
.tutorial-nav .ghost-btn, .tutorial-nav .primary-btn { flex: 1; margin-top: 0; }
.tutorial-nav .ghost-btn:disabled { opacity: 0.35; }
.tutorial-skip { display: block; margin: 12px auto 0; color: var(--text-dim); }

/* Event screens (injury, job, burnout…) */
.event-card { text-align: left; border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 12px; padding: 10px 14px; margin-top: 14px; }
.event-card p { margin: 6px 0; font-size: 14.5px; line-height: 1.45; }
.event-card.event-bad { border-left-color: var(--danger); background: rgba(255, 93, 93, 0.06); }
.event-card.event-good { border-left-color: var(--accent); background: rgba(52, 208, 160, 0.07); }
.event-card.event-neutral { border-left-color: var(--warn); background: rgba(255, 176, 32, 0.06); }
.event-card-title { font-weight: 800; font-size: 15px; margin-top: 2px; }
.event-card .event-tip { color: var(--text-dim); font-size: 13.5px; }
.splash > .primary-btn { margin-top: 16px; }

/* How to Play */
.howto-nav { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 18px; }
.howto-chip { background: var(--bg-elev-2); color: var(--text); border: 1px solid var(--border); border-radius: 999px; padding: 5px 10px; font-size: 12.5px; font-weight: 600; }
.howto-section { padding-top: 14px; border-top: 1px solid var(--border); }
.howto-section h3 { font-size: 14px; color: var(--text); text-transform: none; letter-spacing: 0; margin-bottom: 6px; }
.howto-lead { font-size: 14.5px; line-height: 1.45; margin: 0 0 10px; }
.howto-list { margin: 6px 0 8px; padding-left: 18px; }
.howto-list li { font-size: 14px; line-height: 1.45; margin: 5px 0; color: var(--text); }
.howto-table { margin: 6px 0 10px; }
.howto-table td { white-space: normal; }

/* Playoff bracket */
.br-round { margin: 10px 0 4px; }
.br-round-name { font-size: 12px; font-weight: 800; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 6px; }
.br-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.br-grid-one { grid-template-columns: 1fr; }
.br-match { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg-elev); }
.br-team { display: flex; align-items: center; gap: 5px; padding: 5px 7px; font-size: 12.5px; min-width: 0; }
.br-team + .br-team { border-top: 1px solid var(--border); }
.br-team[data-rival] { cursor: pointer; }
.br-seed { color: var(--text-dim); font-size: 11px; font-weight: 700; flex: none; font-variant-numeric: tabular-nums; }
.br-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; }
.br-tick { color: var(--accent); font-weight: 800; flex: none; }
.br-win .br-name { font-weight: 800; }
.br-out { opacity: 0.45; }
.br-you { background: rgba(255, 176, 32, 0.14); }
.br-tbd { color: var(--text-dim); font-style: italic; font-size: 12px; }

/* Games screen / menu: the game length beside a label */
.menu-note { font-size: 12px; font-weight: 600; color: var(--text-dim); margin-left: 4px; }

/* Specialisation picker */
.spec-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.spec-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.spec-row.on { border-color: var(--accent); background: var(--bg-elev-2); }
.spec-star { font-size: 16px; width: 20px; text-align: center; }
.spec-name { flex: 1; font-weight: 700; }
.spec-val { font-size: 12px; color: var(--text-dim); text-align: right; }
.spec-loss { color: var(--danger); font-weight: 700; }
