:root {
  --navy-900: #0a0e1a;
  --navy-800: #0f1524;
  --navy-700: #161d31;
  --navy-600: #1e2740;
  --navy-500: #2a3552;
  --border: #263252;
  --teal: #2dd4bf;
  --teal-dim: #1a8f82;
  --teal-bg: rgba(45, 212, 191, 0.12);
  --white: #f3f6fb;
  --grey-300: #b7c0d4;
  --grey-400: #8b96b3;
  --grey-500: #6a7593;
  --amber: #f5b942;
  --amber-bg: rgba(245, 185, 66, 0.14);
  --red: #f2637a;
  --red-bg: rgba(242, 99, 122, 0.14);
  --green: #55d18a;
  --green-bg: rgba(85, 209, 138, 0.14);
  --radius: 14px;
  --radius-sm: 10px;
  --touch: 44px;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--navy-900);
  color: var(--white);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--navy-800);
  border-bottom: 1px solid var(--border);
}

.topbar__title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.topbar__title span {
  color: var(--teal);
}

/* ---- Main content ---- */
.view {
  flex: 1;
  padding: 16px 16px calc(var(--touch) + 32px);
  display: none;
}

.view.view--active {
  display: block;
}

.section-heading {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--grey-400);
  margin: 20px 0 10px;
}

.section-heading:first-child {
  margin-top: 0;
}

/* ---- Cards ---- */
.card {
  background: var(--navy-700);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.card--tight {
  padding: 10px 14px;
}

.card__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
}

.card__row + .card__row {
  border-top: 1px solid var(--navy-600);
}

.card__label {
  color: var(--grey-400);
  font-size: 13px;
}

.card__value {
  font-size: 14px;
  font-weight: 600;
  text-align: right;
}

.round-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 4px;
}

.round-sub {
  font-size: 13px;
  color: var(--grey-400);
  margin: 0 0 10px;
}

/* ---- Pills / badges ---- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.pill--live { background: var(--green-bg); color: var(--green); }
.pill--paused { background: var(--amber-bg); color: var(--amber); }
.pill--neutral { background: var(--navy-600); color: var(--grey-300); }
.pill--teal { background: var(--teal-bg); color: var(--teal); }
.pill--error { background: var(--red-bg); color: var(--red); }
.pill--dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ---- Challenge summary rows (Current Round) ---- */
.challenge-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}

.challenge-row__num {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--navy-600);
  color: var(--teal);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.challenge-row__main {
  flex: 1;
  min-width: 0;
}

.challenge-row__title {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.challenge-row__meta {
  font-size: 12px;
  color: var(--grey-400);
  margin-top: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---- Bottom nav ---- */
.bottomnav {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  background: var(--navy-800);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottomnav__btn {
  flex: 1;
  border: none;
  background: none;
  color: var(--grey-400);
  font-size: 12px;
  font-weight: 600;
  padding: 10px 4px 8px;
  min-height: var(--touch);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.bottomnav__btn .icon {
  font-size: 18px;
  line-height: 1;
}

.bottomnav__btn.active {
  color: var(--teal);
}

/* ---- Next Round: round-details form ---- */
.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--grey-300);
  margin-bottom: 6px;
  font-weight: 600;
}

.field .hint {
  font-size: 12px;
  color: var(--grey-500);
  margin-top: 5px;
}

.field .hint--warn {
  color: var(--amber);
}

input[type="text"],
input[type="number"],
input[type="search"] {
  width: 100%;
  min-height: var(--touch);
  padding: 0 12px;
  background: var(--navy-600);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--white);
  font-size: 15px;
}

input:focus {
  outline: none;
  border-color: var(--teal-dim);
}

.field-row {
  display: flex;
  gap: 10px;
}

.field-row > .field {
  flex: 1;
}

/* ---- Segmented control ---- */
.segmented {
  display: flex;
  background: var(--navy-600);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.segmented__opt {
  flex: 1;
  min-height: var(--touch);
  border: none;
  background: none;
  color: var(--grey-300);
  font-weight: 700;
  font-size: 14px;
}

.segmented__opt.selected {
  background: var(--teal);
  color: var(--navy-900);
}

/* ---- Toggle ---- */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--touch);
}

.toggle {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: var(--navy-500);
  border: none;
  flex-shrink: 0;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--grey-300);
  transition: left 0.15s ease, background 0.15s ease;
}

.toggle.on {
  background: var(--teal-bg);
  border: 1px solid var(--teal-dim);
}

.toggle.on::after {
  left: 23px;
  background: var(--teal);
}

/* ---- Searchable selector ---- */
.selector {
  position: relative;
}

.selector__results {
  position: relative;
  margin-top: 6px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--navy-600);
  display: none;
}

.selector__results.open {
  display: block;
}

.selector__result {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  min-height: var(--touch);
  border: none;
  border-bottom: 1px solid var(--navy-500);
  background: none;
  color: var(--white);
  font-size: 14px;
}

.selector__result:last-child {
  border-bottom: none;
}

.selector__result:active {
  background: var(--navy-500);
}

.selector__selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  min-height: var(--touch);
  background: var(--teal-bg);
  border: 1px solid var(--teal-dim);
  border-radius: var(--radius-sm);
  margin-top: 6px;
  font-size: 14px;
  font-weight: 600;
}

.selector__selected button {
  background: none;
  border: none;
  color: var(--grey-300);
  font-size: 13px;
  font-weight: 600;
  min-height: var(--touch);
  padding: 0 4px;
}

/* ---- Challenge carousel (Next Round Builder) ---- */
.builder-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}

.builder-nav__label {
  font-size: 14px;
  font-weight: 700;
  color: var(--grey-300);
  flex: 1;
  text-align: center;
}

.builder-nav__btn {
  min-width: var(--touch);
  min-height: var(--touch);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--navy-700);
  color: var(--white);
  font-size: 18px;
  font-weight: 700;
}

.builder-nav__btn:disabled {
  opacity: 0.35;
}

.builder-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}

.builder-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--navy-700);
  color: var(--grey-400);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.builder-dot.active {
  background: var(--teal);
  color: var(--navy-900);
  border-color: var(--teal);
}

.builder-dot.started:not(.active) {
  border-color: var(--teal-dim);
  color: var(--teal);
}

.carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--navy-700);
}

.carousel::-webkit-scrollbar {
  display: none;
}

.carousel-slot {
  flex: 0 0 100%;
  scroll-snap-align: start;
  max-height: 62vh;
  overflow-y: auto;
  padding: 16px;
}

.slot-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--grey-400);
}

.slot-empty__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 6px;
}

.slot-empty button {
  margin-top: 16px;
}

/* ---- Buttons ---- */
.btn {
  min-height: var(--touch);
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--navy-600);
  color: var(--white);
  font-weight: 700;
  font-size: 14px;
}

.btn--primary {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--navy-900);
}

.btn--full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.4;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn-row .btn {
  flex: 1;
}

/* ---- Autosave / validation status bar ---- */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
}

.validation-panel {
  margin-top: 14px;
}

.validation-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.validation-list li {
  font-size: 13px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.validation-list li.error {
  background: var(--red-bg);
  color: var(--red);
}

.validation-list li.warning {
  background: var(--amber-bg);
  color: var(--amber);
}

.empty-note {
  color: var(--grey-500);
  font-size: 13px;
  text-align: center;
  padding: 10px 0;
}

.more-note {
  color: var(--grey-400);
  font-size: 14px;
  line-height: 1.5;
}
