:root {
  color-scheme: light;
  --ink: #19251f;
  --muted: #65746c;
  --paper: #f3f6ef;
  --surface: #ffffff;
  --line: #dce4da;
  --green: #24684d;
  --green-dark: #174b37;
  --green-soft: #e2efe5;
  --coral: #bd503a;
  --coral-soft: #f8e8e1;
  --gold: #8a6413;
  --gold-soft: #f4edcf;
  --shadow: 0 12px 30px rgb(25 37 31 / 7%);
  font-family: "Aptos", "Microsoft YaHei UI", "Noto Sans CJK SC", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); }
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid #bd503a;
  outline-offset: 2px;
}
button:disabled { opacity: .48; cursor: not-allowed; }

.app-shell { min-height: 100dvh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 246px;
  display: flex;
  flex-direction: column;
  padding: 28px 18px 18px;
  background: #e6eee5;
  border-right: 1px solid var(--line);
  z-index: 5;
}
.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; padding: 4px 8px 34px; }
.brand strong { display: block; font-size: 17px; line-height: 1.25; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.brand-mark { width: 38px; height: 38px; display: flex; align-items: end; gap: 3px; padding: 8px; background: var(--green); border-radius: 12px 12px 12px 4px; }
.brand-mark span { width: 5px; border-radius: 3px 3px 1px 1px; background: #fff; }
.brand-mark span:nth-child(1) { height: 10px; }
.brand-mark span:nth-child(2) { height: 17px; }
.brand-mark span:nth-child(3) { height: 13px; }
.side-nav { display: grid; gap: 6px; }
.nav-button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  border: 0;
  border-radius: 7px;
  padding: 0 12px;
  background: transparent;
  color: #48574e;
  text-align: left;
  cursor: pointer;
}
.nav-button:hover { background: rgb(255 255 255 / 65%); }
.nav-button.active { background: var(--green); color: #fff; }
.nav-icon { width: 27px; font: 600 10px/1 "Aptos", sans-serif; opacity: .72; }
.sidebar-footer { display: flex; gap: 9px; align-items: center; margin-top: auto; padding: 12px 8px; color: var(--muted); font-size: 12px; }
.offline-dot { width: 8px; height: 8px; border-radius: 50%; background: #40865f; box-shadow: 0 0 0 3px #d2e6d6; }

#main-content { min-height: 100dvh; margin-left: 246px; }
.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: rgb(243 246 239 / 94%);
}
.topbar-meta { color: var(--muted); font-size: 13px; }
.mobile-brand { display: none; align-items: center; gap: 10px; }
.brand-mark.small { width: 30px; height: 30px; padding: 6px; border-radius: 9px 9px 9px 3px; gap: 2px; }
.brand-mark.small span { width: 4px; }
.brand-mark.small span:nth-child(1) { height: 8px; }
.brand-mark.small span:nth-child(2) { height: 14px; }
.brand-mark.small span:nth-child(3) { height: 10px; }
.text-button { min-height: 40px; border: 0; background: transparent; color: var(--coral); cursor: pointer; font-size: 13px; }
.text-button:hover { text-decoration: underline; }
.view-root { width: min(1100px, 100%); margin: 0 auto; padding: 36px clamp(20px, 4vw, 54px) 72px; }
.page-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: 12px; font-weight: 700; }
h1 { margin: 0; font-size: clamp(27px, 3vw, 36px); line-height: 1.2; letter-spacing: 0; }
h2 { margin: 0; font-size: 18px; line-height: 1.35; }
h3 { margin: 0; font-size: 15px; line-height: 1.4; }
p { line-height: 1.65; }
.subheading { max-width: 620px; margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.section-label { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 30px 0 12px; }
.section-label p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.surface { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.surface-pad { padding: 22px; }
.stack { display: grid; gap: 16px; }
.grid-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--green);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}
.button:hover { background: var(--green-dark); }
.button.secondary { background: #fff; border-color: var(--line); color: var(--ink); }
.button.secondary:hover { background: var(--paper); }
.button.subtle { background: var(--green-soft); color: var(--green-dark); }
.button.subtle:hover { background: #d5e7d9; }
.button.danger { background: var(--coral-soft); color: #923c2b; }
.button.danger:hover { background: #f2d6cb; }
.button.small { min-height: 38px; padding: 0 12px; font-size: 13px; }
.button.full { width: 100%; }
.text-link { padding: 8px 0; border: 0; background: transparent; color: var(--green); font-weight: 650; cursor: pointer; }
.field { display: grid; gap: 7px; }
.field label, .field-label { color: #4e5d54; font-size: 13px; font-weight: 650; }
.field input, .field select, .search-input {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cbd7cb;
  border-radius: 5px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}
.field input::placeholder { color: #87938b; }
.field-help { margin: 0; color: var(--muted); font-size: 12px; }
.segmented { display: flex; flex-wrap: wrap; gap: 8px; }
.segment { min-height: 42px; padding: 0 13px; border: 1px solid var(--line); border-radius: 5px; background: #fff; cursor: pointer; }
.segment[aria-pressed="true"] { border-color: var(--green); background: var(--green-soft); color: var(--green-dark); font-weight: 700; }
.player-fields { display: grid; gap: 10px; }
.player-field-row { display: grid; grid-template-columns: 36px 1fr; align-items: center; gap: 10px; }
.player-number { display: grid; width: 30px; aspect-ratio: 1; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green-dark); font-size: 12px; font-weight: 700; }
.setup-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr); gap: 18px; align-items: start; }
.rule-callout { padding: 16px; border-left: 3px solid #d5a93d; background: #faf6e6; color: #52451f; font-size: 13px; line-height: 1.65; }
.rule-callout strong { color: #392f16; }
.setup-art { position: relative; min-height: 184px; overflow: hidden; padding: 24px; background: #dcebe0; }
.track-lines { position: absolute; inset: 0; display: flex; justify-content: end; gap: 8px; padding-right: 25px; opacity: .85; }
.track-lines i { width: 18px; height: 100%; background: #bed8c6; transform: skewX(-18deg); }
.setup-art-copy { position: relative; z-index: 1; max-width: 310px; }
.setup-art-copy strong { display: block; font-size: 20px; line-height: 1.35; }
.setup-art-copy p { margin: 8px 0 0; color: #435f4c; font-size: 13px; }
.setup-roster-image { width: 100%; height: 188px; object-fit: cover; object-position: center 32%; border: 1px solid var(--line); border-radius: 7px; background: #fff; }

.status-strip { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; padding: 13px 16px; background: #e6eee5; border: 1px solid #d3dfd3; border-radius: 6px; font-size: 13px; }
.status-strip strong { color: var(--green-dark); }
.progress-track { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.race-step { display: grid; gap: 5px; min-height: 76px; align-content: center; padding: 11px 13px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--muted); text-align: left; cursor: pointer; }
.race-step strong { color: var(--ink); font-size: 13px; }
.race-step span { font-size: 11px; }
.race-step.current { border: 2px solid var(--green); background: var(--green-soft); }
.race-step.complete { border-color: #9bc4a5; background: #eef6ee; }
.race-step:disabled { cursor: default; opacity: 1; }
.race-main { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(250px, .65fr); gap: 16px; align-items: start; }
.race-panel-header { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 20px; }
.track-tag { display: inline-flex; align-items: center; min-height: 28px; padding: 0 9px; border-radius: 4px; background: var(--gold-soft); color: #6b5012; font-size: 11px; font-weight: 700; }
.selection-group { padding: 15px 0; border-top: 1px solid var(--line); }
.selection-group:first-child { border-top: 0; padding-top: 0; }
.selection-title { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 9px; font-size: 13px; font-weight: 700; }
.selection-options { display: flex; flex-wrap: wrap; gap: 7px; }
.pick-chip { min-height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 5px; background: #fff; cursor: pointer; font-size: 12px; }
.pick-chip[aria-pressed="true"] { border-color: var(--green); background: var(--green); color: #fff; }
.pick-chip:disabled { cursor: not-allowed; }
.pick-chip { display: inline-flex; align-items: center; gap: 7px; }
.pick-chip-image { display: inline-grid; width: 25px; height: 25px; overflow: hidden; border-radius: 4px; background: var(--green-soft); }
.pick-chip-image img { width: 100%; height: 100%; object-fit: cover; }
.lock-status { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.privacy-note { margin: 0; color: var(--muted); font-size: 12px; }
.turn-checklist { display: grid; gap: 9px; margin-top: 18px; }
.turn-item { display: flex; gap: 10px; align-items: start; padding: 11px; border: 1px solid var(--line); border-radius: 5px; background: #fff; font-size: 13px; line-height: 1.5; }
.turn-item b { display: grid; width: 22px; height: 22px; flex: 0 0 22px; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green-dark); font-size: 11px; }
.score-list { display: grid; gap: 0; }
.score-row { display: grid; grid-template-columns: 36px 1fr auto; gap: 11px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.score-row:first-child { border-top: 0; }
.score-rank { color: var(--muted); font: 700 12px/1 "Aptos", sans-serif; }
.score-name { font-size: 13px; font-weight: 700; }
.score-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.score-value { font-variant-numeric: tabular-nums; font-weight: 750; }
.roster-summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px; background: var(--paper); border-radius: 5px; }
.roster-summary span { color: var(--muted); font-size: 12px; }
.empty-state { padding: 28px 18px; border: 1px dashed #b9c9bb; border-radius: 6px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 6px; color: var(--ink); }
.podium-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.podium-fields .field { padding: 13px; border-radius: 5px; }
.podium-fields .first { background: #faf4dc; border: 1px solid #e8dba5; }
.podium-fields .second { background: #eff1ef; border: 1px solid #d9dfda; }
.points-adjust { display: grid; grid-template-columns: minmax(0, 1fr) 92px auto; gap: 8px; align-items: end; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.mini-table th, .mini-table td { padding: 11px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.mini-table th { color: var(--muted); font-weight: 600; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.hint { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.athlete-tools { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.search-wrap { position: relative; flex: 1 1 230px; }
.search-input { padding-left: 38px; }
.search-glyph { position: absolute; top: 12px; left: 13px; color: var(--muted); font-size: 17px; }
.filter-select { min-width: 150px; min-height: 46px; padding: 0 10px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.athlete-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.athlete-card { min-height: 184px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 6px; padding: 15px; background: #fff; cursor: pointer; text-align: left; }
.athlete-card:hover { border-color: #85ad91; box-shadow: var(--shadow); }
.athlete-card-top { display: flex; align-items: start; justify-content: space-between; gap: 8px; min-height: 83px; }
.athlete-thumb { width: 78px; height: 78px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: var(--green-soft); }
.athlete-title { color: var(--coral); font-size: 11px; }
.athlete-card h3 { margin-top: 13px; }
.athlete-card p { margin: 6px 0 12px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.athlete-card-foot { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-top: auto; color: var(--green); font-size: 11px; font-weight: 700; }
.mini-roster { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.mini-roster .athlete-image { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; }
.draft-picker { grid-template-columns: repeat(4, minmax(0, 1fr)); max-height: 520px; overflow: auto; padding-right: 4px; }
.athlete-dialog { width: min(510px, calc(100% - 24px)); max-height: min(760px, calc(100dvh - 30px)); overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 26px; background: #fff; color: var(--ink); box-shadow: 0 24px 75px rgb(20 30 24 / 24%); }
.athlete-dialog::backdrop { background: rgb(19 31 24 / 58%); }
.dialog-visual { display: flex; justify-content: center; margin: -3px 0 17px; }
.dialog-image { width: 168px; height: 168px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.dialog-close { position: absolute; top: 12px; right: 12px; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: #fff; font-size: 22px; cursor: pointer; }
.dialog-kicker { margin: 0 0 9px; color: var(--coral); font-size: 12px; font-weight: 700; }
.dialog-summary { margin: 16px 0; padding: 15px; border-left: 3px solid var(--green); background: var(--green-soft); line-height: 1.65; }
.dialog-detail { color: #4c5b51; font-size: 14px; line-height: 1.7; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }

.guide-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 20px; align-items: start; }
.guide-nav { position: sticky; top: 16px; display: grid; gap: 3px; padding: 10px; }
.guide-nav button { min-height: 40px; border: 0; border-radius: 4px; background: transparent; color: #4f5d54; text-align: left; cursor: pointer; font-size: 13px; }
.guide-nav button:hover { background: var(--paper); color: var(--green-dark); }
.guide-content { display: grid; gap: 14px; }
.guide-section { scroll-margin-top: 18px; padding: 21px; }
.guide-section h2 { margin-bottom: 13px; }
.guide-section p { margin: 7px 0; color: #4e5d54; font-size: 13px; }
.guide-section ol, .guide-section ul { display: grid; gap: 10px; margin: 0; padding-left: 20px; color: #4e5d54; font-size: 13px; line-height: 1.65; }
.race-score-table td:nth-child(n+2), .race-score-table th:nth-child(n+2) { text-align: center; }
.rule-term { display: grid; grid-template-columns: 100px 1fr; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.55; }
.rule-term:first-of-type { border-top: 0; }
.rule-term strong { color: var(--green-dark); }
.disclaimer { padding: 14px; background: #f4efe0; color: #5f512c; font-size: 12px; line-height: 1.6; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: min(380px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 5px; background: #1c3327; color: #fff; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity 180ms ease, transform 180ms ease; font-size: 13px; }
.toast.visible { opacity: 1; transform: translateY(0); }
.mobile-nav { display: none; }

@media (max-width: 980px) {
  .sidebar { width: 210px; }
  #main-content { margin-left: 210px; }
  .athlete-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .setup-layout, .race-main { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .sidebar { display: none; }
  #main-content { margin-left: 0; }
  .topbar { height: 58px; padding: 0 18px; }
  .mobile-brand { display: flex; }
  .mobile-brand strong { font-size: 14px; }
  .topbar-meta { display: none; }
  .view-root { padding: 25px 16px 98px; }
  .mobile-nav {
    position: fixed;
    inset: auto 0 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: #f8faf6;
    z-index: 10;
  }
  .mobile-nav .nav-button { min-height: 54px; display: grid; justify-items: center; align-content: center; gap: 3px; padding: 4px; font-size: 11px; }
  .mobile-nav .nav-icon { width: auto; font-size: 9px; }
  .page-heading { margin-bottom: 20px; }
  .grid-two, .grid-three { grid-template-columns: 1fr; }
  .progress-track { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .athlete-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .draft-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 620px; }
  .athlete-card { min-height: 196px; padding: 12px; }
  .athlete-thumb { width: 64px; height: 64px; }
  .athlete-card p { font-size: 11px; }
  .guide-layout { grid-template-columns: 1fr; gap: 12px; }
  .guide-nav { position: static; display: flex; gap: 5px; overflow-x: auto; }
  .guide-nav button { flex: 0 0 auto; padding: 0 9px; }
  .surface-pad { padding: 17px; }
  .rule-term { grid-template-columns: 82px 1fr; }
  .podium-fields { grid-template-columns: 1fr; }
  .points-adjust { grid-template-columns: 1fr 78px; }
  .points-adjust .button { grid-column: 1 / -1; }
}
@media (max-width: 390px) {
  .athlete-grid { grid-template-columns: 1fr; }
  .athlete-card { min-height: 0; }
  .status-strip { gap: 8px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
