:root {
  --color-bg: #0f172a;
  --color-bg-soft: #152033;
  --color-surface: rgba(30, 41, 59, 0.92);
  --color-surface-strong: #1e293b;
  --color-border: #334155;
  --color-border-soft: rgba(148, 163, 184, 0.18);
  --color-accent: #3b82f6;
  --color-accent-soft: rgba(59, 130, 246, 0.16);
  --color-serve: #f59e0b;
  --color-team1: #3b82f6;
  --color-team2: #ef4444;
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-danger: #f87171;
  --color-text: #f8fafc;
  --color-muted: #94a3b8;
  --shadow-card: 0 18px 40px rgba(15, 23, 42, 0.34);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
  --safe-left: env(safe-area-inset-left);
  --safe-right: env(safe-area-inset-right);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.16), transparent 36%),
    radial-gradient(circle at top right, rgba(245, 158, 11, 0.12), transparent 30%),
    linear-gradient(180deg, #111827 0%, var(--color-bg) 50%, #0b1220 100%);
  color: var(--color-text);
  font-family: "Segoe UI Variable", "Segoe UI", sans-serif;
}

body {
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

#root {
  min-height: 100vh;
}

.app-shell {
  min-height: 100vh;
  padding: max(16px, var(--safe-top)) max(16px, calc(16px + var(--safe-right))) max(96px, calc(80px + var(--safe-bottom))) max(16px, calc(16px + var(--safe-left)));
}

.app-shell--game {
  padding: 0;
}

.app-view {
  min-height: calc(100vh - max(96px, calc(80px + var(--safe-bottom))));
}

.page {
  min-height: 100%;
}

.container {
  width: min(100%, 960px);
  margin: 0 auto;
}

.container--narrow {
  width: min(100%, 720px);
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.title {
  margin: 0;
  font-size: clamp(1.75rem, 2.6vw, 2.35rem);
  line-height: 1.05;
  font-weight: 900;
}

.subtitle {
  margin: 8px 0 0;
  max-width: 48ch;
  color: var(--color-muted);
  line-height: 1.55;
}

.section,
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-soft);
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-lg);
}

.section {
  padding: 20px;
  margin-bottom: 18px;
}

.card {
  padding: 18px;
}

.card--team1 {
  border-color: rgba(59, 130, 246, 0.24);
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.12), rgba(30, 41, 59, 0.92));
}

.card--team2 {
  border-color: rgba(239, 68, 68, 0.24);
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.12), rgba(30, 41, 59, 0.92));
}

.section-title {
  margin: 0 0 14px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-muted);
}

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

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

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

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

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: rgba(30, 41, 59, 0.84);
  color: var(--color-text);
  font-weight: 700;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.button:hover,
.button:focus-visible {
  border-color: rgba(59, 130, 246, 0.8);
  outline: none;
}

.button:active {
  transform: scale(0.98);
}

.button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.button--primary {
  background: linear-gradient(135deg, var(--color-accent), #2563eb);
  border-color: transparent;
}

.button--warning {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.92), rgba(217, 119, 6, 0.92));
  border-color: transparent;
  color: #111827;
}

.button--danger {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.9), rgba(220, 38, 38, 0.9));
  border-color: transparent;
}

.button--ghost {
  background: rgba(15, 23, 42, 0.48);
}

.button--chip {
  min-height: 42px;
  padding: 0 14px;
}

.button--chip.is-active {
  background: var(--color-accent-soft);
  border-color: rgba(59, 130, 246, 0.66);
  color: #dbeafe;
}

.button--chip.is-active.button--warning {
  color: #111827;
}

.button--block {
  width: 100%;
}

.field__label {
  display: block;
  margin: 0 0 8px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #dbe4f0;
}

.field__note,
.muted {
  color: var(--color-muted);
  font-size: 0.88rem;
}

.field__input,
.field__textarea {
  width: 100%;
  min-height: 50px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: rgba(15, 23, 42, 0.78);
  color: var(--color-text);
  padding: 0 14px;
}

.field__input:focus,
.field__textarea:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.8);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

.field__textarea {
  min-height: 110px;
  padding-top: 12px;
  padding-bottom: 12px;
  resize: vertical;
}

.selector {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.selector__picked {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: rgba(15, 23, 42, 0.62);
}

.selector__quick {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(135deg, #334155, #475569);
  color: var(--color-text);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.avatar--sm {
  width: 40px;
  height: 40px;
  font-size: 0.85rem;
}

.avatar--md {
  width: 58px;
  height: 58px;
  font-size: 1.1rem;
}

.avatar--lg {
  width: 84px;
  height: 84px;
  font-size: 1.65rem;
}

.avatar--serving {
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.75), 0 0 0 7px rgba(15, 23, 42, 0.9);
}

.avatar__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar__serve {
  position: absolute;
  right: -2px;
  top: -2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--color-serve);
  color: #111827;
  font-size: 0.68rem;
  font-weight: 900;
}

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  padding: 10px max(16px, calc(16px + var(--safe-right))) calc(10px + var(--safe-bottom)) max(16px, calc(16px + var(--safe-left)));
  background: rgba(15, 23, 42, 0.88);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.nav__list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: min(100%, 720px);
  gap: 10px;
}

.nav__link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 58px;
  border-radius: 16px;
  color: var(--color-muted);
}

.nav__link--active {
  background: rgba(59, 130, 246, 0.12);
  color: #dbeafe;
}

.nav__icon {
  font-size: 1.15rem;
}

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

.list-card {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-soft);
  background: rgba(30, 41, 59, 0.88);
}

.list-card__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.badge--accent {
  background: rgba(59, 130, 246, 0.14);
  color: #bfdbfe;
}

.badge--warning {
  background: rgba(245, 158, 11, 0.18);
  color: #fde68a;
}

.badge--success {
  background: rgba(34, 197, 94, 0.16);
  color: #bbf7d0;
}

.badge--danger {
  background: rgba(239, 68, 68, 0.18);
  color: #fecaca;
}

.empty-state {
  min-height: 44vh;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--color-muted);
}

.empty-state__icon {
  font-size: 3.4rem;
  display: block;
  margin-bottom: 14px;
}

.game-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 50% 12%, rgba(59, 130, 246, 0.13), transparent 28%),
    radial-gradient(circle at 50% 88%, rgba(239, 68, 68, 0.12), transparent 26%),
    linear-gradient(180deg, #0b1220 0%, #0f172a 100%);
}

.game-topbar {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: max(16px, var(--safe-top)) max(16px, calc(16px + var(--safe-right))) 12px max(16px, calc(16px + var(--safe-left)));
}

.game-toolbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.game-meta {
  justify-self: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  color: var(--color-muted);
  font-size: 0.88rem;
}

.game-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.game-dots__item {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.22);
}

.game-dots__item--team1 {
  background: var(--color-team1);
}

.game-dots__item--team2 {
  background: var(--color-team2);
}

.game-layout {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.team-panel {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px 36px;
  text-align: center;
  border: 0;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  background: transparent;
}

.team-panel--serving {
  background: rgba(245, 158, 11, 0.06);
}

.team-panel__inner {
  width: min(100%, 420px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.team-panel__players {
  display: flex;
  align-items: center;
  gap: 12px;
}

.team-panel__name {
  font-size: 1rem;
  font-weight: 800;
}

.team-panel__score {
  font-family: "Arial Rounded MT Bold", "Segoe UI Variable", sans-serif;
  font-size: clamp(4.5rem, 18vw, 9rem);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.08em;
}

.team-panel__hint {
  max-width: 22ch;
  color: var(--color-muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.serve-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.serve-pill__dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: currentColor;
  animation: pulse 1.1s infinite;
}

.score-orb {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.92);
  color: var(--color-muted);
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.45);
  font-weight: 900;
}

.game-help {
  display: flex;
  justify-content: center;
  padding: 12px 16px max(16px, calc(16px + var(--safe-bottom)));
  color: var(--color-muted);
  font-size: 0.88rem;
}

.game-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 23, 0.75);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.game-overlay__card {
  width: min(100%, 420px);
  padding: 28px;
  text-align: center;
  border-radius: 28px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(59, 130, 246, 0.18);
  box-shadow: var(--shadow-card);
}

.settings-grid {
  display: grid;
  gap: 14px;
}

.toggle {
  position: relative;
  width: 58px;
  height: 34px;
  border-radius: 999px;
  background: rgba(51, 65, 85, 0.92);
  transition: background 0.18s ease;
}

.toggle.is-on {
  background: rgba(59, 130, 246, 0.95);
}

.toggle__knob {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: white;
  transition: transform 0.18s ease;
}

.toggle.is-on .toggle__knob {
  transform: translateX(24px);
}

.media-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.media-row__content {
  flex: 1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hidden {
  display: none;
}

@media (min-width: 760px) {
  .page-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
  }

  .page-grid > .section,
  .page-grid > .card {
    margin-bottom: 0;
  }
}

@media (orientation: landscape) and (min-height: 420px) {
  .game-layout {
    flex-direction: row;
  }

  .team-panel {
    border-top: 0;
    border-left: 1px solid rgba(148, 163, 184, 0.12);
  }

  .team-panel:first-child {
    border-left: 0;
  }

  .team-panel__score {
    font-size: clamp(4rem, 12vw, 8rem);
  }
}

@media (max-width: 640px) {
  .grid--2,
  .grid--3,
  .selector__quick,
  .game-toolbar {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
  }

  .score-orb {
    width: 64px;
    height: 64px;
    font-size: 0.92rem;
  }

  .media-row {
    flex-direction: column;
  }
}

@keyframes pulse {
  0%,
  100% { opacity: 1; }
  50% { opacity: 0.45; }
}