/* YardCoach — mobile-first styles. Big targets, high contrast, readable in sun and darkness. */

:root {
  --bg: #f4f5f3;
  --card: #ffffff;
  --text: #17211a;
  --muted: #5b6660;
  --line: #d7ddd8;
  --accent: #166534;
  --accent-text: #ffffff;
  --chip: #e8ece8;
  --chip-selected: #166534;
  --chip-selected-text: #ffffff;
  --red: #c92a2a;
  --orange: #d9480f;
  --green: #2b8a3e;
  --blue: #1864ab;
  --radius: 14px;
}

html[data-theme='dark'] {
  --bg: #101512;
  --card: #1a211c;
  --text: #eef2ee;
  --muted: #9fb0a5;
  --line: #2e3831;
  --accent: #4ade80;
  --accent-text: #0c130e;
  --chip: #242e27;
  --chip-selected: #4ade80;
  --chip-selected-text: #0c130e;
  --red: #ff6b6b;
  --orange: #ffa94d;
  --green: #51cf66;
  --blue: #74c0fc;
}

@media (prefers-color-scheme: dark) {
  html[data-theme='auto'] {
    --bg: #101512;
    --card: #1a211c;
    --text: #eef2ee;
    --muted: #9fb0a5;
    --line: #2e3831;
    --accent: #4ade80;
    --accent-text: #0c130e;
    --chip: #242e27;
    --chip-selected: #4ade80;
    --chip-selected-text: #0c130e;
    --red: #ff6b6b;
    --orange: #ffa94d;
    --green: #51cf66;
    --blue: #74c0fc;
  }
}

html[data-contrast='on'] {
  --muted: var(--text);
  --line: currentColor;
}

html[data-scale='115'] { font-size: 115%; }
html[data-scale='130'] { font-size: 130%; }

[x-cloak] { display: none !important; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }
p { margin: 0 0 0.75rem; }

button {
  font: inherit;
  color: inherit;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius);
  min-height: 48px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  touch-action: manipulation;
}

button:active { transform: scale(0.98); }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 48px;
  padding: 0.5rem 0.75rem;
  width: 100%;
}

textarea { min-height: 72px; resize: vertical; }
label { display: block; font-size: 0.85rem; color: var(--muted); margin: 0.75rem 0 0.25rem; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  font-weight: 700;
  width: 100%;
}

.btn-danger { border-color: var(--red); color: var(--red); font-weight: 600; }
.btn-ghost { background: transparent; }
.btn-row { display: flex; gap: 0.5rem; }
.btn-row > button { flex: 1; }

/* ---- layout ---- */

.boot { padding: 3rem 1rem; text-align: center; color: var(--muted); }

.welcome {
  max-width: 480px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

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

.shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 0.75rem calc(6rem + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.25rem 0.5rem;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

.topbar .title { font-weight: 800; }
.topbar .round { color: var(--muted); font-size: 0.9rem; }

.sync {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
  border: none;
  background: none;
  min-height: 44px;
}

.sync .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); }
.sync.offline .dot { background: var(--orange); }

.offline-banner {
  background: var(--orange);
  color: #fff;
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.gone-banner { background: var(--red); }
.gone-banner button { background: #fff; color: var(--red); border-color: #fff; width: 100%; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
  margin-bottom: 0.9rem;
}

.card + h2, section > h2 { margin-top: 1.25rem; }

/* ---- countdown ---- */

.countdown-card { text-align: center; }
.countdown-card .label { color: var(--muted); font-size: 0.9rem; }
.countdown-card .time {
  font-size: 3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.countdown-card .sub { color: var(--muted); font-size: 0.9rem; }
.cd-warn .time { color: var(--orange); }
.cd-danger .time { color: var(--red); }

@media (prefers-reduced-motion: no-preference) {
  .cd-danger .time { animation: yc-pulse 1s ease-in-out infinite; }
}

@keyframes yc-pulse {
  50% { opacity: 0.55; }
}

/* ---- status banner (crew) ---- */

.status-banner {
  border-radius: var(--radius);
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  text-align: center;
  padding: 0.9rem;
  margin-bottom: 0.9rem;
}
.status-red { background: var(--red); }
.status-orange { background: var(--orange); }
.status-green { background: var(--green); }
.status-self { background: var(--blue); }
html[data-theme='dark'] .status-banner,
html[data-contrast='on'] .status-banner { color: #10130f; }
html[data-theme='auto'] .status-banner { color: #fff; }
@media (prefers-color-scheme: dark) {
  html[data-theme='auto'] .status-banner { color: #10130f; }
}

/* ---- quick-pick chips ---- */

.prio-switch { display: flex; gap: 0.4rem; margin-bottom: 0.4rem; }
.prio-switch button { flex: 1; font-size: 0.85rem; padding: 0.4rem 0.25rem; }
.prio-switch button.active { font-weight: 800; }

/* Priority colors, shared by the mode buttons and selected quick-pick chips. */
.pcol-must { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
.pcol-nice { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 700; }
.pcol-if_time { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 700; }

html[data-theme='dark'] .pcol-must,
html[data-theme='dark'] .pcol-nice,
html[data-theme='dark'] .pcol-if_time { color: #10130f; }

@media (prefers-color-scheme: dark) {
  html[data-theme='auto'] .pcol-must,
  html[data-theme='auto'] .pcol-nice,
  html[data-theme='auto'] .pcol-if_time { color: #10130f; }
}

/* Inline text colors for the "new taps become X" hint. */
.txt-must { color: var(--red); }
.txt-nice { color: var(--orange); }
.txt-if_time { color: var(--blue); }
.prio-hint { margin: 0 0 0.75rem; }

.chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.chips button {
  min-height: 56px;
  font-weight: 600;
  text-align: center;
  padding: 0.4rem 0.5rem;
}

.chips button.selected::before { content: '✓ '; }

.custom-row { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.custom-row input { flex: 1; }
.custom-row button { flex: 0 0 auto; }

/* ---- task lists ---- */

.task {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}
.task:last-child { border-bottom: none; }

.task .check {
  flex: 0 0 48px;
  height: 48px;
  border-radius: 12px;
  font-size: 1.3rem;
  font-weight: 800;
  color: transparent;
}
.task .check.checked {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.task .body { flex: 1; min-width: 0; }
.task .label { font-weight: 700; font-size: 1.05rem; }
.task.done .label { text-decoration: line-through; opacity: 0.55; }
.task .meta { font-size: 0.8rem; color: var(--muted); }
.task .note { font-size: 0.9rem; color: var(--text); background: var(--chip); border-radius: 8px; padding: 0.25rem 0.5rem; margin-top: 0.25rem; display: inline-block; }

.task .actions { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.35rem; }
.task .actions button { min-height: 40px; padding: 0.25rem 0.7rem; font-size: 0.8rem; border-radius: 10px; }

.pri {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  color: #fff;
  vertical-align: middle;
}
.pri-must { background: var(--red); }
.pri-nice { background: var(--orange); }
.pri-if_time { background: var(--blue); }
html[data-theme='dark'] .pri { color: #10130f; }

.tag { font-size: 0.72rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0.1rem 0.5rem; }

.empty { color: var(--muted); text-align: center; padding: 1.5rem 0.5rem; }

/* ---- crew header facts ---- */

.facts { display: flex; flex-wrap: wrap; gap: 0.9rem; justify-content: center; }
.facts .fact { text-align: center; min-width: 80px; }
.facts .fact .v { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.facts .fact .k { font-size: 0.75rem; color: var(--muted); }

.runner-note {
  background: var(--chip);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  margin-top: 0.75rem;
  font-size: 1rem;
}

/* ---- confirm panel ---- */

.confirm {
  border: 2px solid var(--red);
  border-radius: var(--radius);
  padding: 0.9rem;
  margin-top: 0.75rem;
}

/* ---- race code ---- */

.race-code {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.25em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  background: var(--chip);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin: 0.5rem 0;
  user-select: all;
}

/* ---- history ---- */

.round-card .head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.round-card .head .when { color: var(--muted); font-size: 0.85rem; }
.round-card ul { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.round-card li { padding: 0.2rem 0; font-size: 0.95rem; }
.round-card li.notdone { color: var(--muted); }

/* ---- toast ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(5.5rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  font-weight: 600;
  max-width: 90vw;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

/* ---- bottom navigation ---- */

.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}

.nav button {
  flex: 1;
  min-height: 56px;
  border: none;
  border-radius: 0;
  background: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.nav button.active {
  color: var(--accent);
  font-weight: 800;
  box-shadow: inset 0 3px 0 var(--accent);
}

/* ---- role picker ---- */

.role-buttons { display: grid; gap: 0.75rem; margin-top: 1rem; }
.role-buttons button { min-height: 76px; font-size: 1.15rem; font-weight: 700; }

.hint { font-size: 0.85rem; color: var(--muted); }
.error { color: var(--red); font-weight: 600; margin-top: 0.5rem; }
.divider { border: none; border-top: 1px solid var(--line); margin: 1.5rem 0; }

/* ---- form extras ---- */

.check-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 48px;
  margin-top: 0.5rem;
}

.check-row input[type='checkbox'] {
  width: 1.5rem;
  height: 1.5rem;
  min-height: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.check-row span { font-size: 0.95rem; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.75rem; }
.form-grid .full { grid-column: 1 / -1; }
