:root {
  --bg: #0b0b0d;
  --surface: #16161a;
  --surface-2: #1e1e23;
  --border: rgba(255,255,255,0.08);
  --ink: #f5f5f0;
  --ink-2: #a8a8b0;
  --muted: #6f6f78;
  --accent: #ff6a3d;
  --accent-2: #ffb020;

  --mercedes: #00d2be;
  --ferrari: #e8002d;
  --redbull: #3671c6;
  --mclaren: #ff8000;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 76px;
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  background: rgba(11,11,13,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.brand span { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-2); font-size: 16px; cursor: pointer;
}

main { max-width: 560px; margin: 0 auto; padding: 16px; }

.countdown-card {
  background: radial-gradient(120% 140% at 0% 0%, rgba(255,106,61,0.22), transparent 60%), var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 22px 20px;
  text-align: center;
  margin-bottom: 18px;
}
.countdown-label { color: var(--ink-2); font-size: 13px; font-weight: 600; }
.countdown-timer {
  font-size: 40px; font-weight: 800; letter-spacing: -0.02em; margin: 8px 0 10px;
  font-variant-numeric: tabular-nums;
  color: var(--accent-2);
}
.race-name { font-size: 15px; font-weight: 700; }
.race-date { font-size: 13px; color: var(--ink-2); margin-top: 4px; }

.chip-row {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.feed { display: flex; flex-direction: column; gap: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--team-color, var(--accent));
  border-radius: 14px;
  padding: 16px 16px 14px;
}
.card-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.team-badge {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--team-color, var(--accent)) 22%, transparent);
  color: var(--team-color, var(--accent));
}
.card-time { font-size: 12px; color: var(--muted); }
.card-title { font-size: 16px; font-weight: 700; line-height: 1.4; margin: 0 0 6px; }
.card-body { font-size: 14px; color: var(--ink-2); line-height: 1.55; margin: 0 0 10px; }
.card-full { font-size: 14px; color: var(--ink); line-height: 1.6; margin: 0 0 10px; padding-top: 2px; border-top: 1px dashed var(--border); padding-top: 10px; }
.card-source { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.card-source a { color: var(--muted); text-decoration: none; border-bottom: 1px dotted var(--muted); }

.more-btn {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: none; color: var(--accent); font-size: 13px; font-weight: 700;
  padding: 0; margin: 2px 0 10px; cursor: pointer;
}
.lock-icon { font-size: 12px; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
  width: 100%; max-width: 340px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 18px;
  padding: 22px 20px; text-align: center;
}
.modal-title { font-size: 17px; font-weight: 800; margin-bottom: 6px; }
.modal-sub { font-size: 13px; color: var(--ink-2); margin-bottom: 16px; }
.modal-input {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--ink); font-size: 14px; margin-bottom: 8px;
}
.modal-input:focus { outline: 2px solid var(--accent); }
.modal-error { color: #ff6a6a; font-size: 12px; min-height: 16px; margin-bottom: 4px; }
.modal-submit {
  width: 100%; padding: 12px; border-radius: 10px; border: none;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #1a0e05;
  font-size: 14px; font-weight: 800; cursor: pointer; margin-top: 6px;
}
.modal-cancel {
  width: 100%; padding: 10px; border-radius: 10px; border: none; background: none;
  color: var(--muted); font-size: 13px; margin-top: 6px; cursor: pointer;
}

/* 일정 탭 */
.schedule-list { display: flex; flex-direction: column; gap: 10px; }
.race-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 16px; opacity: 0.55;
}
.race-row.is-next { opacity: 1; border-color: var(--accent); background: radial-gradient(120% 140% at 0% 0%, rgba(255,106,61,0.14), transparent 60%), var(--surface); }
.race-row.is-done { opacity: 0.4; }
.race-round {
  flex: 0 0 34px; height: 34px; border-radius: 50%; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; color: var(--ink-2);
}
.race-row.is-next .race-round { background: var(--accent); color: #1a0e05; }
.race-info { flex: 1; min-width: 0; }
.race-info .name { font-size: 14px; font-weight: 700; }
.race-info .place { font-size: 12px; color: var(--muted); margin-top: 1px; }
.race-date-badge { font-size: 12px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.race-row.is-next .race-date-badge { color: var(--accent-2); }
.race-status { font-size: 16px; flex: 0 0 auto; color: var(--muted); }
.race-row.has-results { cursor: pointer; }

.race-row-wrap { display: flex; flex-direction: column; }
.race-results {
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height 0.25s ease, opacity 0.2s ease, margin 0.25s ease;
  margin-top: 0;
  background: var(--surface-2); border-radius: 0 0 14px 14px;
  border: 1px solid var(--border); border-top: none;
}
.race-results.open { max-height: 220px; opacity: 1; margin-top: -8px; padding-top: 8px; }
.result-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 16px 7px 20px;
  border-left: 3px solid var(--team-color, var(--accent));
  font-size: 13px;
}
.result-pos { flex: 0 0 26px; font-weight: 800; color: var(--muted); }
.result-name { flex: 1; font-weight: 700; }
.result-team { font-size: 12px; color: var(--muted); }

/* 순위 탭 */
.standings-toggle { display: flex; gap: 8px; margin-bottom: 14px; }
.seg {
  flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 700; cursor: pointer;
}
.seg.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.standings-list { display: flex; flex-direction: column; gap: 8px; }
.standing-row-wrap { display: flex; flex-direction: column; }
.standing-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--team-color, var(--accent));
  border-radius: 12px; padding: 11px 16px;
}
.standing-row.has-profile { cursor: pointer; }
.standing-caret { font-size: 12px; color: var(--muted); flex: 0 0 auto; }
.standing-profile {
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.25s ease;
  padding: 0 16px; border-radius: 0 0 12px 12px;
}
.standing-profile.open { max-height: 160px; opacity: 1; padding: 10px 16px 12px; background: var(--surface-2); margin-top: -2px; }
.profile-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.profile-flag { font-size: 16px; }
.profile-chip { font-size: 11px; font-weight: 700; color: var(--ink-2); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px; }
.profile-bio { font-size: 13px; color: var(--ink-2); line-height: 1.5; }

.history-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 16px;
}
.history-year { flex: 0 0 46px; font-size: 16px; font-weight: 800; color: var(--accent-2); font-variant-numeric: tabular-nums; }
.history-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.history-line { display: flex; align-items: baseline; gap: 8px; }
.history-label { font-size: 11px; font-weight: 700; color: var(--muted); flex: 0 0 62px; }
.history-name { font-size: 13px; font-weight: 700; border-left: 3px solid var(--team-color, var(--accent)); padding-left: 8px; }
.standing-pos { flex: 0 0 22px; font-size: 15px; font-weight: 800; color: var(--muted); }
.standing-row:nth-child(1) .standing-pos { color: #ffd54a; }
.standing-row:nth-child(2) .standing-pos { color: #d8d8d8; }
.standing-row:nth-child(3) .standing-pos { color: #d6996b; }
.standing-info { flex: 1; min-width: 0; }
.standing-info .name { font-size: 14px; font-weight: 700; }
.standing-info .team { font-size: 12px; color: var(--muted); }
.standing-pts { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.standings-note { text-align: center; font-size: 12px; color: var(--muted); margin-top: 14px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-around;
  background: rgba(15,15,18,0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.tab {
  background: none; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; padding: 4px 14px; cursor: pointer;
}
.tab .tab-icon { font-size: 19px; filter: grayscale(1) opacity(0.6); }
.tab.active { color: var(--ink); }
.tab.active .tab-icon { filter: none; }

.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--border);
  padding: 10px 18px; border-radius: 999px; font-size: 13px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all 0.25s ease;
  z-index: 20; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 640px) {
  .countdown-timer { font-size: 46px; }
}
