:root {
  color-scheme: light;
  --apple-blue: #0071e3;
  --apple-link: #0066cc;
  --system-background: #ffffff;
  --system-gray-6: #f5f5f7;
  --system-gray-5: #e8e8ed;
  --label: #1d1d1f;
  --secondary-label: rgba(0, 0, 0, 0.64);
  --tertiary-label: rgba(0, 0, 0, 0.48);
  --separator: rgba(0, 0, 0, 0.08);
  --nav-fill: rgba(0, 0, 0, 0.8);
  --card-shadow: rgba(0, 0, 0, 0.10) 0 12px 30px 0;
  --space-section: 24px;
  --space-card: 32px;
  --space-card-compact: 24px;
  --space-component: 16px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 64px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--label);
  background: var(--system-gray-6);
  letter-spacing: -0.374px;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 980px;
  padding: 8px 17px;
  color: #ffffff;
  background: var(--apple-blue);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.3;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, opacity 160ms ease;
}

button:hover:not(:disabled) {
  background: #0077ed;
}

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

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--apple-blue);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

input {
  width: min(100%, 28rem);
  min-height: 44px;
  border: 1px solid var(--separator);
  border-radius: 11px;
  padding: 10px 14px;
  color: var(--label);
  background: #ffffff;
  font-size: 17px;
  line-height: 1.47;
}

input::placeholder {
  color: var(--tertiary-label);
}

.global-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 48px;
  color: #ffffff;
  background: var(--nav-fill);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.global-nav-inner {
  display: flex;
  width: min(980px, calc(100% - 32px));
  height: 48px;
  margin: 0 auto;
  gap: 18px;
  align-items: center;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: -0.12px;
}

.global-nav a,
.global-nav span {
  color: rgba(255, 255, 255, 0.86);
  text-decoration: none;
  white-space: nowrap;
}

.global-nav a:hover {
  color: #ffffff;
}

.brand-mark {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  font-weight: 600;
}

.app {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 0 16px 64px;
}

.hero {
  display: grid;
  min-height: clamp(430px, 58vh, 620px);
  place-items: center;
  align-content: center;
  gap: 16px;
  padding: 72px 16px 64px;
  text-align: center;
  background: var(--system-gray-6);
}

.hero h1 {
  max-width: 920px;
  margin: 0;
  color: var(--label);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
  font-size: clamp(40px, 7vw, 56px);
  font-weight: 600;
  letter-spacing: -0.28px;
  line-height: 1.07;
}

.hero-copy {
  max-width: 680px;
  margin: 0;
  color: var(--secondary-label);
  font-size: clamp(19px, 2.2vw, 21px);
  font-weight: 400;
  line-height: 1.38;
  letter-spacing: 0.011em;
}

.eyebrow,
.panel-kicker {
  margin: 0;
  color: var(--secondary-label);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.33;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-section);
}

.panel {
  min-width: 0;
  padding: var(--space-card);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: none;
}

.wide-panel {
  grid-column: 1 / -1;
}

.panel h2 {
  margin: 8px 0 24px;
  color: var(--label);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: 0.004em;
}

.panel-header,
.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-component);
  align-items: center;
  justify-content: space-between;
}

.row {
  justify-content: flex-start;
}

.hero,
.panel {
  scroll-margin-top: 64px;
}

.lobby-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.secondary-button {
  color: var(--apple-link);
  background: #ffffff;
  border-color: var(--apple-link);
}

.secondary-button:hover:not(:disabled) {
  color: #ffffff;
  background: var(--apple-blue);
}

.players,
.rounds,
.messages {
  display: grid;
  gap: 14px;
}

.player-card,
.match-card,
.ranking-card {
  display: flex;
  min-height: 56px;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border: 0;
  border-radius: 12px;
  background: var(--system-gray-6);
}

.player-card strong,
.match-card strong,
.ranking-card strong {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.24;
  color: var(--label);
}

.ranking-card span,
.rematch-card span {
  color: var(--secondary-label);
  font-size: 14px;
  line-height: 1.29;
}

.badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 980px;
  padding: 4px 10px;
  background: var(--system-gray-5);
  color: var(--secondary-label);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.29;
  letter-spacing: -0.224px;
}

.badge.ready,
.badge.win {
  background: var(--apple-blue);
  color: #ffffff;
}

.badge.waiting {
  background: var(--system-gray-5);
  color: var(--tertiary-label);
}

.moves {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.moves button {
  background: #ffffff;
  color: var(--apple-link);
  border-color: var(--apple-link);
}

.moves button:hover:not(:disabled) {
  background: var(--apple-blue);
  color: #ffffff;
}

.match-result {
  flex-basis: 100%;
  border-radius: 12px;
  padding: 12px 14px;
  background: #ffffff;
  color: var(--secondary-label);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.47;
}

.match-result.win {
  color: var(--label);
}

.match-result.tie {
  color: var(--secondary-label);
}

.rematch-card {
  background: #ffffff;
  box-shadow: var(--card-shadow);
}

.rematch-card button {
  margin-left: auto;
}

.empty {
  color: var(--tertiary-label);
  font-size: 17px;
  line-height: 1.47;
}

.rankings {
  display: grid;
  margin: 0;
  padding-left: 0;
  gap: 14px;
  list-style: none;
}

.messages {
  max-height: 14rem;
  overflow: auto;
  color: var(--secondary-label);
  font-size: 14px;
  line-height: 1.43;
  letter-spacing: -0.224px;
}

.messages div {
  padding: 8px 0;
  border-bottom: 1px solid var(--separator);
}

.messages div:last-child {
  border-bottom: 0;
}

@media (max-width: 760px) {
  .global-nav-inner {
    gap: 12px;
  }

  .global-nav a:not(.brand-mark):last-child {
    display: none;
  }

  .app {
    padding-inline: 16px;
  }

  .hero {
    min-height: 390px;
    padding-block: 56px 48px;
  }

  .section-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: var(--space-card-compact);
  }

  .panel-header,
  .row {
    align-items: stretch;
  }

  .row input,
  .row button,
  .lobby-actions,
  .lobby-actions button,
  #start-button {
    width: 100%;
  }

  .player-card,
  .match-card,
  .ranking-card,
  .moves {
    align-items: stretch;
  }

  .moves button {
    flex: 1 1 30%;
  }
}
