:root {
  color-scheme: light;
  --bg: #f4f0e6;
  --bg-accent: #e8e2d6;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --ink: #0f1a3d;
  --muted: #6b7280;
  --line: rgba(27, 45, 107, 0.14);
  --brand: #1b2d6b;
  --brand-mid: #243680;
  --brand-strong: #0f1a3d;
  --brand-accent: #99ccff;
  --brand-soft: rgba(153, 204, 255, 0.2);
  --warning: #cc2229;
  --warning-soft: rgba(204, 34, 41, 0.12);
  --warning-border: rgba(204, 34, 41, 0.24);
  --shadow: 0 18px 40px rgba(15, 26, 61, 0.12);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 999px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: "DM Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.55), transparent 35%),
    radial-gradient(circle at bottom right, rgba(153, 204, 255, 0.2), transparent 28%),
    linear-gradient(145deg, var(--bg), var(--bg-accent));
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--brand-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.app-shell {
  width: min(1100px, calc(100% - 24px));
  margin: 0 auto;
  padding: 20px 0 40px;
}

.hero {
  padding: 24px 18px 20px;
  background: linear-gradient(135deg, var(--brand-strong) 0%, var(--brand) 62%, var(--brand-mid) 100%);
  color: white;
  border-radius: var(--radius-lg);
  border-bottom: 4px solid var(--brand-accent);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--brand-accent);
}

.hero h1 {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: clamp(2.1rem, 6vw, 3.8rem);
  line-height: 0.98;
  overflow-wrap: break-word;
}

.hero-copy {
  margin: 14px 0 0;
  max-width: 56ch;
  font-size: 1rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.76);
}

.hero-actions {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--brand-strong);
  text-decoration: none;
  font-weight: 700;
  border: 1px solid rgba(153, 204, 255, 0.45);
  box-shadow: 0 10px 24px rgba(15, 26, 61, 0.18);
}

.hero-link:hover,
.hero-link:focus-visible {
  background: white;
}

.layout {
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.controls-panel {
  position: sticky;
  top: 10px;
  z-index: 10;
  padding: 18px;
}

.sync-banner {
  display: none;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.sync-banner[data-state="firebase"] {
  display: block;
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.sync-banner[data-state="local"] {
  display: block;
  background: var(--warning-soft);
  color: var(--warning);
}

.search-stack {
  display: grid;
  gap: 8px;
}

.field-label {
  margin: 0 0 8px;
  font-size: 0.83rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.search-input {
  width: 100%;
  padding: 16px 18px;
  border: 1px solid transparent;
  border-radius: 18px;
  background: var(--surface-strong);
  box-shadow: inset 0 0 0 1px rgba(31, 29, 25, 0.04);
}

.search-input:focus {
  outline: none;
  border-color: rgba(153, 204, 255, 0.8);
  box-shadow: 0 0 0 4px rgba(153, 204, 255, 0.2);
}

.filters {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.94rem;
}

.chip[aria-pressed="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.stat-card {
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.accent-card {
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: white;
  border-color: transparent;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: inherit;
  opacity: 0.78;
}

.stat-value {
  display: block;
  margin-top: 6px;
  font-size: 1.7rem;
}

.roster-panel {
  padding: 18px;
}

.summary-layout {
  grid-template-columns: minmax(0, 1fr);
}

.summary-panel {
  padding: 18px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.results-header > div {
  min-width: 0;
}

.results-summary {
  margin: 4px 0 0;
  color: var(--muted);
}

.ghost-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}

.roster-list {
  display: grid;
  gap: 12px;
}

.summary-grid {
  display: grid;
  gap: 12px;
}

.shirt-list {
  display: grid;
  gap: 10px;
}

.shirt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.shirt-row > div {
  min-width: 0;
}

.shirt-row[data-present="true"] {
  border-color: rgba(153, 204, 255, 0.75);
  background: linear-gradient(180deg, rgba(153, 204, 255, 0.38), rgba(224, 240, 255, 0.72));
}

.shirt-row[data-present="false"] {
  background: linear-gradient(180deg, var(--bg-accent), var(--bg));
  border-color: rgba(27, 45, 107, 0.08);
}

.shirt-row[data-present="true"] .shirt-row-meta {
  color: var(--brand-mid);
  font-weight: 500;
}

.shirt-row-name {
  margin: 0;
  font-size: 1.05rem;
  overflow-wrap: break-word;
}

.shirt-row-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.shirt-size-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  background: var(--brand-soft);
  color: var(--brand-strong);
  border: 1px solid rgba(153, 204, 255, 0.4);
}

.summary-card {
  padding: 16px;
  border-radius: 20px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.summary-card-head {
  margin-bottom: 14px;
}

.summary-title {
  margin: 0;
  font-size: 1.2rem;
  overflow-wrap: break-word;
}

.stats-inline {
  margin-top: 0;
}

.roster-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 20px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  animation: card-in 220ms ease;
}

.roster-card[data-present="true"] {
  border-color: rgba(153, 204, 255, 0.55);
  background: linear-gradient(180deg, rgba(153, 204, 255, 0.18), rgba(255, 255, 255, 0.98));
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.card-head > div {
  min-width: 0;
}

.person-name {
  margin: 0;
  font-size: 1.2rem;
  overflow-wrap: break-word;
}

.person-meta {
  margin: 6px 0 0;
  color: var(--muted);
  overflow-wrap: break-word;
}

.status-pill {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--bg-accent);
  color: var(--muted);
}

.roster-card[data-present="true"] .status-pill {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.person-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 0;
}

.person-details div {
  padding: 12px;
  border-radius: 14px;
  background: rgba(244, 240, 230, 0.85);
}

.person-details dt {
  margin: 0 0 4px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.person-details dd {
  margin: 0;
  font-weight: 500;
}

.card-actions {
  display: flex;
}

.checkin-button {
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 14px 16px;
  background: var(--brand);
  color: white;
  font-weight: 700;
  transition: transform 0.1s ease, opacity 0.1s ease;
}

.checkin-button:active {
  transform: scale(0.96);
  opacity: 0.85;
}

.roster-card[data-present="true"] .checkin-button {
  background: var(--warning-soft);
  color: var(--warning);
  border: 1.5px solid var(--warning-border);
}

.empty-state {
  padding: 26px 18px;
  border-radius: 18px;
  text-align: center;
  background: var(--surface-strong);
  color: var(--muted);
  border: 1px dashed var(--line);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 860px) {
  .layout {
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    align-items: start;
  }

  .summary-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .roster-card {
    grid-template-columns: minmax(0, 1fr) 170px;
    align-items: center;
  }

  .card-actions {
    justify-content: end;
  }

  .checkin-button {
    max-width: 150px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(calc(100% - 16px), 640px);
  }

  .hero {
    padding-inline: 16px;
  }

  .controls-panel {
    position: static;
  }

  .controls-panel,
  .roster-panel,
  .summary-panel {
    padding: 14px;
  }

  /* Keep stats 3-column; only collapse person-details */
  .person-details {
    display: none;
  }

  /* Horizontally scrollable chip rows — no wrapping on mobile */
  .chip-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .chip-row::-webkit-scrollbar {
    display: none;
  }

  /* Prevent iOS Safari from zooming in on small-font interactive elements */
  .chip,
  .search-input {
    font-size: 1rem;
  }

  /* Ensure chip buttons meet minimum 44px tap-target height on mobile */
  .chip {
    padding: 12px 14px;
  }

  /* Side-by-side card layout: info on left, action button on right */
  .roster-card {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: 12px;
    gap: 10px;
  }

  /* Right-side action column stretches to full card height */
  .card-actions {
    align-self: stretch;
    display: flex;
    align-items: stretch;
    justify-content: flex-end;
  }

  /* Large, thumb-friendly check-in button */
  .checkin-button {
    width: auto;
    min-width: 90px;
    min-height: 60px;
    border-radius: 14px;
    padding: 10px 14px;
    font-size: 0.88rem;
    line-height: 1.25;
  }

  /* Status pill is redundant on mobile — button color/text already signals state */
  .status-pill {
    display: none;
  }

  /* Keep the 3-column stat grid from overflowing on small phones */
  .stats {
    gap: 8px;
  }

  .stat-card {
    padding: 12px 10px;
  }

  .stat-value {
    font-size: 1.4rem;
  }
}