/* Reusable UI components: buttons, cards, badges, spinner. Grows per phase. */

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  font-size: var(--f-md);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease;
}
.btn:active {
  filter: brightness(0.92);
}
.btn--primary {
  background: var(--c-accent);
  color: #1a1206;
}
.btn--ghost {
  background: transparent;
  color: var(--c-text);
  border-color: var(--c-border);
}
.btn--danger {
  background: transparent;
  color: var(--c-danger);
  border-color: var(--c-danger);
}
.btn--block {
  display: block;
  width: 100%;
}
.btn--sm {
  padding: 4px 12px;
  font-size: var(--f-sm);
  margin-left: auto;
}

/* Spinner */
.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid var(--c-surface-3);
  border-top-color: var(--c-accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Badges / pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: var(--f-xs);
  font-weight: 700;
  background: var(--c-surface-3);
  color: var(--c-text-muted);
}
.badge--accent {
  background: var(--c-accent-soft);
  color: var(--c-accent);
}

/* Generic card */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  box-shadow: var(--shadow-1);
}

/* Empty / error states */
.state {
  text-align: center;
  color: var(--c-text-muted);
  padding: var(--s-8) var(--s-4);
}
.state__emoji {
  font-size: 34px;
  margin-bottom: var(--s-2);
}

/* Skill-tinted badges */
.badge.skill--beginner {
  background: rgba(74, 168, 255, 0.16);
  color: var(--c-beginner);
}
.badge.skill--intermediate {
  background: rgba(55, 201, 120, 0.16);
  color: var(--c-intermediate);
}
.badge.skill--advanced {
  background: var(--c-accent-soft);
  color: var(--c-accent);
}
.badge--danger {
  background: rgba(255, 84, 112, 0.16);
  color: var(--c-danger);
}

/* Avatar with initials fallback */
.avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  background: var(--c-surface-3);
  color: var(--c-text);
  font-weight: 700;
  flex: 0 0 auto;
}
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar__initials {
  position: relative;
  z-index: 0;
}

/* Section title */
.section-title {
  font-size: var(--f-sm);
  font-weight: 700;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: var(--s-5) 0 var(--s-3);
}

/* Header back button */
.app-header__back {
  border: 0;
  background: transparent;
  color: var(--c-text);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  padding: 0 var(--s-1) 0 0;
}

/* Tab badge */
.tabbar__icon {
  position: relative;
}
.tabbar__badge {
  position: absolute;
  top: -6px;
  right: -10px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--c-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Sign in ---- */
.screen--bare {
  padding: 0;
}
.signin {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--s-10) var(--s-6) var(--s-8);
  background: radial-gradient(120% 60% at 50% 0%, #23180d 0%, var(--c-bg) 55%);
}
.signin__brand {
  margin-top: 12vh;
  text-align: center;
}
.signin__logo {
  font-size: 64px;
}
.signin__name {
  font-size: var(--f-3xl);
  font-weight: 800;
  margin-top: var(--s-2);
}
.signin__name span {
  color: var(--c-accent);
}
.signin__tag {
  color: var(--c-text-muted);
  margin-top: var(--s-3);
  font-size: var(--f-md);
  line-height: 1.5;
}
.signin__actions {
  text-align: center;
}
.signin__note {
  color: var(--c-text-faint);
  font-size: var(--f-xs);
  margin-top: var(--s-3);
}
.gbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-4);
  border-radius: var(--r-md);
  border: 0;
  background: #fff;
  color: #1f1f1f;
  font-size: var(--f-md);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.gbtn:active {
  filter: brightness(0.95);
}
.gbtn__g {
  font-weight: 800;
  color: #4285f4;
  font-size: var(--f-lg);
}

/* Account chooser sheet */
.chooser {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
}
.chooser[hidden] {
  display: none;
}
.chooser__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.chooser__sheet {
  position: relative;
  width: 100%;
  background: var(--c-surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--s-5) var(--s-4) var(--s-6);
  box-shadow: var(--shadow-2);
  animation: sheet-up 0.22s ease;
}
@keyframes sheet-up {
  from {
    transform: translateY(40px);
    opacity: 0.6;
  }
}
.chooser__title {
  font-weight: 700;
  font-size: var(--f-lg);
  margin-bottom: var(--s-3);
}
.chooser__acc {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-3);
  border: 0;
  background: transparent;
  color: var(--c-text);
  cursor: pointer;
  border-radius: var(--r-md);
  text-align: left;
}
.chooser__acc:active,
.chooser__acc.is-loading {
  background: var(--c-surface-2);
}
.chooser__acc-text {
  display: flex;
  flex-direction: column;
}
.chooser__acc-name {
  font-weight: 600;
}
.chooser__acc-email {
  font-size: var(--f-sm);
  color: var(--c-text-muted);
}

/* ---- Home ---- */
.home__greeting {
  font-size: var(--f-xl);
  line-height: 1.4;
  margin-bottom: var(--s-4);
}
.home__greeting span {
  font-size: var(--f-sm);
  color: var(--c-text-muted);
}

/* Filter bar */
.filterbar {
  position: sticky;
  top: calc(-1 * var(--s-4));
  background: var(--c-bg);
  padding: var(--s-2) 0 var(--s-3);
  margin: 0 0 var(--s-3);
  z-index: 5;
}
.filterbar__chips {
  display: flex;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
}
.filterbar__selects {
  display: flex;
  gap: var(--s-2);
}
.chip {
  padding: 6px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--c-border);
  background: transparent;
  color: var(--c-text-muted);
  font-size: var(--f-sm);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.chip.is-on {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #1a1206;
}
.select,
.input {
  flex: 1;
  padding: var(--s-3);
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
  background: var(--c-surface-2);
  color: var(--c-text);
  font-size: var(--f-md);
  font-family: inherit;
}

/* Game card */
.gamecard {
  display: block;
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  margin-bottom: var(--s-3);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-1);
}
.gamecard:active {
  background: var(--c-surface-2);
}
.gamecard__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.gamecard__when {
  font-weight: 700;
  color: var(--c-accent);
  font-size: var(--f-md);
}
.gamecard__dist {
  font-size: var(--f-sm);
  color: var(--c-text-muted);
}
.gamecard__court {
  font-size: var(--f-lg);
  font-weight: 700;
  margin: 2px 0 var(--s-3);
}
.gamecard__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--s-3);
}
.gamecard__players {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.gamecard__count {
  font-size: var(--f-sm);
  font-weight: 700;
  color: var(--c-text-muted);
  white-space: nowrap;
}

/* Progress bar */
.progress {
  flex: 1;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--c-surface-3);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  background: var(--c-accent);
  border-radius: var(--r-pill);
  transition: width 0.4s ease;
}

/* ---- Game detail ---- */
.detail__hero {
  margin: calc(-1 * var(--s-4)) calc(-1 * var(--s-4)) var(--s-4);
  position: relative;
  background: linear-gradient(135deg, #2a1c0e, #171a21);
}
.detail__map {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
  background: transparent;
}
.detail__court {
  font-size: var(--f-2xl);
  font-weight: 800;
  padding: var(--s-3) var(--s-4) 0;
}
.detail__area {
  color: var(--c-text-muted);
  font-size: var(--f-sm);
  padding: 2px var(--s-4) 0;
}
.detail__when {
  font-size: var(--f-md);
  margin: var(--s-2) 0;
}
.detail__meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.detail__actions {
  margin-top: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.detail__cancelled {
  color: var(--c-danger);
  text-align: center;
  padding: var(--s-4);
}

/* Roster */
.roster {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.roster__row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-md);
}
.roster__name {
  font-weight: 600;
}
.roster__area {
  color: var(--c-text-faint);
  font-size: var(--f-sm);
  margin-left: auto;
}
.roster__row .badge {
  margin-left: var(--s-2);
}
.roster__row--empty {
  color: var(--c-text-faint);
  font-size: var(--f-sm);
  border-style: dashed;
  justify-content: center;
  background: transparent;
}
/* Privacy: a stranger whose identity is hidden on a public game. */
.roster__row--masked {
  background: transparent;
  border-style: dashed;
}
.roster__row--masked .roster__name {
  color: var(--c-text-faint);
  font-weight: 500;
  font-style: italic;
}
.avatar--masked {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--c-surface-3);
  font-size: 16px;
}
/* "Friend" marker so you can tell at a glance who's in your network. */
.badge--friend {
  background: rgba(55, 201, 120, 0.16);
  color: var(--c-intermediate, #37c978);
}
.roster--requests .roster__row {
  gap: var(--s-2);
}

/* ---- Profile ---- */
.profile__head {
  text-align: center;
  margin-bottom: var(--s-5);
}
.profile__name {
  font-size: var(--f-xl);
  font-weight: 800;
  margin-top: var(--s-2);
}
.profile__area {
  color: var(--c-text-muted);
  font-size: var(--f-sm);
}
.field {
  display: block;
  margin-bottom: var(--s-4);
}
.field__label {
  display: block;
  font-size: var(--f-sm);
  color: var(--c-text-muted);
  margin-bottom: 6px;
}
.field--row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.field--row input[type='checkbox'] {
  width: 20px;
  height: 20px;
  accent-color: var(--c-accent);
}
.field .input,
.field .select {
  width: 100%;
}
.chips {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}

/* Visibility segmented options (create / manage) */
.vis {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.vis__opt {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  padding: var(--s-3);
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
  background: var(--c-surface-2);
  color: var(--c-text);
  font-family: inherit;
  cursor: pointer;
}
.vis__opt.is-on {
  border-color: var(--c-accent);
  background: var(--c-accent-soft);
}
.vis__title {
  font-weight: 700;
  font-size: var(--f-md);
}
.vis__desc {
  font-size: var(--f-sm);
  color: var(--c-text-muted);
}

/* ---- Notifications ---- */
.notif-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.notif {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  border-radius: var(--r-md);
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  cursor: pointer;
}
.notif.is-unread {
  border-left: 3px solid var(--c-accent);
  background: var(--c-surface-2);
}
.notif__icon {
  font-size: 20px;
}
.notif__msg {
  font-size: var(--f-md);
}

/* ---- Find players (the centerpiece) ---- */
.find__ctx {
  margin-bottom: var(--s-3);
}
.find__court {
  font-size: var(--f-xl);
  font-weight: 800;
}
.find__when {
  color: var(--c-text-muted);
  font-size: var(--f-sm);
}
.find__progress {
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-lg);
  padding: var(--s-3) var(--s-4);
  box-shadow: var(--shadow-1);
}
.find__count {
  font-size: var(--f-md);
  margin-bottom: var(--s-2);
}
.find__count b {
  color: var(--c-accent);
}
/* leave room for the sticky action bar */
.find {
  padding-bottom: 84px;
}
.find__groups {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
}

/* Candidate card */
.candidate {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  margin-bottom: var(--s-2);
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.candidate:active {
  background: var(--c-surface-2);
}
.candidate.is-selected {
  border-color: var(--c-accent);
  background: var(--c-accent-soft);
}
.candidate__check {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid var(--c-border);
  position: relative;
}
.candidate.is-selected .candidate__check {
  background: var(--c-accent);
  border-color: var(--c-accent);
}
.candidate.is-selected .candidate__check::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #1a1206;
  font-size: 13px;
  font-weight: 900;
}

/* Transparent score ring (conic gauge) */
.score-ring {
  --pct: 0;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--ring-color) calc(var(--pct) * 1%), var(--c-surface-3) 0);
}
.score-ring__num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--c-surface);
  display: grid;
  place-items: center;
  font-size: var(--f-sm);
  font-weight: 800;
}
.score--high {
  --ring-color: var(--c-intermediate, #37c978);
}
.score--mid {
  --ring-color: var(--c-accent);
}
.score--low {
  --ring-color: var(--c-text-faint);
}
.candidate__main {
  flex: 1;
  min-width: 0;
}
.candidate__head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: 6px;
}
.candidate__name {
  font-weight: 700;
}
.candidate__reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.rchip {
  font-size: var(--f-xs);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--c-surface-3);
  color: var(--c-text-muted);
}

/* Invite tracking rows */
.invite-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-md);
  margin-bottom: var(--s-2);
}
.invite-row__status {
  margin-left: auto;
  font-size: var(--f-sm);
  font-weight: 700;
  white-space: nowrap;
}
.status--pending {
  color: var(--c-text-muted);
}
.status--accepted {
  color: var(--c-intermediate, #37c978);
}
.status--declined {
  color: var(--c-danger);
}

/* Sticky action bar */
.findbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  background: linear-gradient(to top, var(--c-bg) 70%, transparent);
  z-index: 6;
}

/* ---- Toasts ---- */
.toasts {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar-h) + var(--s-3));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  pointer-events: none;
  z-index: 30;
  padding: 0 var(--s-4);
}
.toast {
  max-width: 90%;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-pill);
  background: var(--c-elevated);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  font-size: var(--f-sm);
  box-shadow: var(--shadow-2);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-in {
  opacity: 1;
  transform: translateY(0);
}
.toast--success {
  border-color: var(--c-success);
}
.toast--error {
  border-color: var(--c-danger);
}
