:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --surface: #ffffff;
  --male: #2563eb;
  --male-soft: #dbeafe;
  --female: #ec4899;
  --female-soft: #fce7f3;
  --stat-total-bg: #f3e8ff;
  --stat-male-bg: #e0f2fe;
  --stat-female-bg: #fce7f3;
  --host-bg: #fef3c7;
  --host-text: #b45309;
  --crown: #f59e0b;
  --success-gradient: linear-gradient(90deg, #16a34a, #0ea5e9);
  --danger-hover: #dc2626;
  --info-bg: #eff6ff;
  --info-text: #475569;
  --info-icon: #2563eb;
  --line: #e2e8f0;
  --bg: #ffffff;
  --bg-soft: #f4f7fb;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #16a34a;
  --accent-2: #0ea5e9;
  --accent-3: #f59e0b;
  --accent-4: #f43f5e;
  --danger: #ef4444;
  --border: rgba(15, 23, 42, 0.08);
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Inter, ui-sans-serif, system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 14px 48px;
  min-height: 100vh;
}

/* ---------- Header / hero ---------- */
.hero.card {
  background: linear-gradient(120deg, #16a34a 0%, #0ea5e9 100%);
  color: #ffffff;
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 14px 34px rgba(14, 165, 233, 0.28);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.hero-top h1 {
  margin: 0;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hero p {
  margin: 8px 0 0;
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, 0.92);
}

/* ---------- Generic card ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

label {
  display: block;
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 600;
  margin-top: 4px;
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  margin-top: 6px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: var(--text);
  font-size: 0.95rem;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18);
}

button {
  cursor: pointer;
  width: 100%;
  padding: 11px;
  margin-top: 6px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(90deg, var(--accent) 0%, #0ea5e9 100%);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 8px 20px rgba(22, 163, 74, 0.25);
}

button:hover {
  transform: translateY(-1px);
}

button.ghost {
  width: auto;
  padding: 8px 14px;
  background: rgba(15, 23, 42, 0.06);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

button.ghost:hover {
  background: rgba(15, 23, 42, 0.12);
}

button.secondary {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.primary {
  margin-top: 10px;
}

.grid-form {
  display: grid;
  gap: 8px;
}

.participants {
  margin-top: 10px;
  border-top: 1px dashed rgba(148, 163, 184, 0.45);
  padding-top: 10px;
}

.participant-slot {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 8px;
}

.participant-slot-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.participant-slot-index {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.08);
  font-size: 0.75rem;
  font-weight: 700;
}

.participant-slot-name {
  font-weight: 600;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-slot-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.participant-slot-controls select,
.participant-slot-controls input[type="text"] {
  width: auto;
  min-width: 120px;
  margin-top: 0;
  padding: 6px 8px;
  font-size: 0.85rem;
}

.participant-slot label.inline-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  margin: 0;
  white-space: nowrap;
}

.participant-slot label.inline-checkbox input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.participant-slot-restore {
  width: auto;
  padding: 6px 10px;
  font-size: 0.78rem;
  margin: 0;
}

/* ---------- Create-session form: date/time fields ---------- */
.date-field {
  position: relative;
}

.date-field input {
  padding-right: 38px;
  cursor: pointer;
}

/* Hide the native (uncolored) picker icon; the emoji icon is shown instead.
   The indicator still stretches over the field so clicking opens the picker. */
.date-field input::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.date-field-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(calc(-50% + 3px));
  font-size: 1rem;
  pointer-events: none;
}

.time-range-field {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.time-range-field input {
  cursor: pointer;
}

#duration-hint {
  font-weight: 600;
  color: var(--accent-2);
}

/* ---------- Create-session form: participant editor ---------- */
.participant-slot-controls select,
.participant-slot-controls input[type="text"] {
  flex: 1 1 120px;
  min-width: 0;
}

.participant-slot-controls .gender-toggle {
  margin-left: auto;
}

.gender-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  overflow: hidden;
  background: #f8fafc;
}

.gender-btn {
  width: 40px;
  height: 34px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--text);
  opacity: 0.55;
}

.gender-btn + .gender-btn {
  border-left: 1px solid #cbd5e1;
}

.gender-btn:hover {
  transform: none;
  opacity: 0.85;
}

.gender-btn[aria-pressed="true"] {
  opacity: 1;
}

.gender-btn.gender-male[aria-pressed="true"] {
  background: rgba(14, 165, 233, 0.2);
}

.gender-btn.gender-female[aria-pressed="true"] {
  background: rgba(236, 72, 153, 0.2);
}

.participant-slot-remove {
  width: 32px !important;
  height: 32px;
  flex: 0 0 auto;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: none;
}

.participant-slot-remove:hover {
  background: rgba(239, 68, 68, 0.22);
  transform: none;
}

.add-participant-btn {
  background: #ffffff;
  border: 1.5px dashed rgba(14, 165, 233, 0.5);
  color: var(--accent-2);
  box-shadow: none;
}

.add-participant-btn:hover {
  background: rgba(14, 165, 233, 0.08);
  transform: none;
}

@media (max-width: 420px) {
  .time-range-field {
    grid-template-columns: 1fr;
  }
}

.muted {
  color: var(--muted);
  margin: 0 0 8px;
}

/* ---------- Home card grid ---------- */
.card-grid {
  display: grid;
  gap: 14px;
}

.nav-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  height: auto;
  text-align: left;
  background: var(--card);
  color: var(--text);
  font-weight: 400;
  cursor: pointer;
  box-shadow: none;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
}

.nav-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.12);
  border-color: transparent;
}

.nav-card .icon-badge {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: #ffffff;
}

.nav-card .nav-card-body {
  flex: 1 1 auto;
}

.nav-card h2 {
  margin: 0 0 4px;
  font-size: 1.02rem;
}

.nav-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.nav-card .chevron {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 1.2rem;
}

.icon-history { background: linear-gradient(135deg, #0ea5e9, #38bdf8); }
.icon-hof { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.icon-qr { background: linear-gradient(135deg, #8b5cf6, #a78bfa); }
.icon-create { background: linear-gradient(135deg, #16a34a, #22c55e); }

.support-dev-card {
  border: 1px dashed rgba(139, 92, 246, 0.4);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.06), rgba(167, 139, 250, 0.03));
}

/* ---------- Back link ---------- */
.back-btn {
  width: auto;
  margin-bottom: 12px;
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  padding: 8px 14px;
}

.back-btn:hover {
  background: var(--bg-soft);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab-btn {
  width: auto;
  flex: 1 1 0;
  background: var(--bg-soft);
  color: var(--muted);
  box-shadow: none;
  font-weight: 700;
  font-size: 0.86rem;
  padding: 10px 6px;
}

.tab-btn.active {
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #ffffff;
}

/* ---------- Lists / cards ---------- */
.list {
  display: grid;
  gap: 10px;
}

.list-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.list-item:hover {
  transform: translateY(-2px);
}

.list-item .item-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.list-item strong {
  font-size: 1rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
}

.status-finished {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
}

.status-ongoing {
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
}

.list-item .item-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.badge {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.18);
  color: #b45309;
  font-size: 0.75rem;
  font-weight: 700;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-soft);
  font-weight: 800;
  color: var(--muted);
  margin-right: 8px;
  flex: 0 0 auto;
}

.rank-1 { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #fff; }
.rank-2 { background: linear-gradient(135deg, #cbd5e1, #94a3b8); color: #fff; }
.rank-3 { background: linear-gradient(135deg, #f0b27a, #d97706); color: #fff; }

.empty {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 24px 10px;
}

.qr {
  display: block;
  margin: 8px auto 0;
  width: 220px;
  max-width: 100%;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.auth-form {
  display: grid;
  gap: 8px;
}

.auth-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hidden {
  display: none !important;
}

.error {
  color: var(--danger);
}

.detail-panel {
  margin-top: 0;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  width: 100%;
  max-width: 420px;
  margin: 0;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
}

.auth-title-row {
  position: sticky;
  top: -16px;
  margin: -16px -16px 10px;
  padding: 16px 16px 10px;
  background: var(--card);
  border-radius: 18px 18px 0 0;
  z-index: 1;
}

.modal-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

.session-detail-grid {
  display: grid;
  gap: 8px;
  font-size: 0.92rem;
}

.session-detail-grid .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 6px;
}

.session-detail-grid .row span:first-child {
  color: var(--muted);
}

.session-detail-grid .row span:last-child {
  font-weight: 700;
  text-align: right;
}

/* ---------- Toasts ---------- */
#toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: grid;
  gap: 8px;
  width: 100%;
  max-width: 420px;
  padding: 0 16px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
  border-left: 5px solid var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  animation: toast-in 0.25s ease;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast .toast-icon {
  font-size: 1.3rem;
  flex: 0 0 auto;
}

.toast.fade-out {
  animation: toast-out 0.25s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* ---------- Hero match card ---------- */
.hero-match {
  background: linear-gradient(135deg, rgba(22, 163, 74, 0.14) 0%, rgba(14, 165, 233, 0.14) 100%);
  border: 1px solid rgba(14, 165, 233, 0.25);
  box-shadow: 0 16px 34px rgba(14, 165, 233, 0.16);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.hero-match::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
  pointer-events: none;
}

.hero-match-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.hero-match-tag {
  font-weight: 800;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.hero-match-countdown {
  font-weight: 700;
  font-size: 0.82rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: #b45309;
}

.hero-match-location {
  margin: 0 0 4px;
  font-size: 1.15rem;
}

.hero-match-time,
.hero-match-count {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 0.92rem;
}

.hero-match-count {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hero-match-avatars {
  display: flex;
  align-items: center;
  margin: 8px 0 12px;
  padding-left: 6px;
}
.hero-avatar-item {
  flex: none;
  display: inline-flex;
  margin-left: -8px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #fff;
}
.hero-avatar-more {
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  background: #e2e8f0;
  color: #475569;
  font-size: 0.75rem;
  font-weight: 700;
}

.hero-match-action button {
  margin-top: 0;
}

.hero-match-joined {
  margin: 0;
  font-weight: 700;
  color: #15803d;
  background: rgba(22, 163, 74, 0.12);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: center;
}

/* ---------- Compact "more upcoming" list ---------- */
.upcoming-compact-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-soft);
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
}

.upcoming-compact-item .compact-main strong {
  display: block;
  font-size: 0.92rem;
}

.upcoming-compact-item .compact-main span {
  color: var(--muted);
  font-size: 0.82rem;
}

.upcoming-compact-item .compact-count {
  flex: 0 0 auto;
  font-weight: 700;
  color: var(--accent-2);
  font-size: 0.86rem;
}

.view-all-link {
  width: auto;
  margin-top: 10px;
  background: none;
  color: var(--accent-2);
  box-shadow: none;
  font-weight: 700;
  padding: 6px 4px;
  text-align: left;
}

/* ---------- Weekly highlights carousel ---------- */
.carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.carousel::-webkit-scrollbar {
  height: 4px;
}

.carousel-card {
  flex: 0 0 auto;
  scroll-snap-align: start;
  width: 68%;
  max-width: 220px;
  border-radius: 16px;
  padding: 14px;
  color: #ffffff;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.carousel-card h3 {
  margin: 0 0 8px;
  font-size: 0.86rem;
  font-weight: 800;
  opacity: 0.92;
}

.carousel-card .carousel-name {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0 0 4px;
}

.carousel-card .carousel-meta {
  font-size: 0.82rem;
  opacity: 0.9;
  margin: 0;
}

.carousel-card.attendance { background: linear-gradient(135deg, #f59e0b, #f97316); }
.carousel-card.streak { background: linear-gradient(135deg, #f43f5e, #ec4899); }
.carousel-card.newcomer { background: linear-gradient(135deg, #0ea5e9, #6366f1); }

/* ---------- Bottom navigation + FAB ---------- */
body.has-bottom-nav .app {
  padding-bottom: 92px;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: #ffffff;
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1 1 0;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 4px 2px;
}

.nav-tab-icon {
  font-size: 1.25rem;
}

.nav-tab.active {
  color: var(--accent);
}

.fab {
  position: fixed;
  right: 16px;
  bottom: 78px;
  width: auto;
  height: 52px;
  padding: 0 22px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 12px 26px rgba(22, 163, 74, 0.4);
  z-index: 41;
  white-space: nowrap;
}

.fab-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.fab-label {
  line-height: 1;
}

@media (max-width: 400px) {
  .hero-top h1 {
    font-size: 1.1rem;
  }
}

/* ---------- Profile page ---------- */
#profile-user-panel {
  position: relative;
}

.profile-streak-badge {
  position: absolute;
  top: 14px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(249, 115, 22, 0.12);
  color: #c2410c;
  font-size: 0.78rem;
  font-weight: 700;
}

.profile-streak-icon {
  font-size: 1rem;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.profile-avatar-wrap {
  flex: 0 0 auto;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: var(--bg-soft);
}

.profile-header-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.profile-header-info strong {
  font-size: 1.1rem;
  overflow-wrap: anywhere;
}

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

.profile-edit-actions button {
  flex: 1 1 0;
}

.comment-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.comment-avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.comment-content {
  min-width: 0;
  flex: 1 1 auto;
}

.member-name-link {
  color: var(--text);
  font-weight: inherit;
  text-decoration: none;
}

.member-name-link:hover,
.member-name-link:focus-visible {
  color: var(--accent-2);
}

textarea {
  width: 100%;
  padding: 10px 12px;
  margin-top: 6px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
}

textarea:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18);
}

/* ---------- Gender radio (register) & participant summary ---------- */
.gender-radio {
  display: flex;
  width: 100%;
}

.gender-option {
  flex: 1;
  margin: 0;
  cursor: pointer;
  text-align: center;
}

.gender-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.gender-option span {
  display: block;
  padding: 10px 0;
  font-weight: 600;
  opacity: 0.6;
  transition: background 0.15s, opacity 0.15s;
}

.gender-option + .gender-option {
  border-left: 1px solid #cbd5e1;
}

.gender-option input:checked + span {
  opacity: 1;
}

.gender-option.gender-male input:checked + span {
  background: rgba(14, 165, 233, 0.2);
}

.gender-option.gender-female input:checked + span {
  background: rgba(236, 72, 153, 0.2);
}

.gender-option input:focus-visible + span {
  outline: 2px solid var(--primary, #0ea5e9);
  outline-offset: -2px;
}

.gender-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.gender-chip.gender-male {
  background: rgba(14, 165, 233, 0.18);
  color: #0369a1;
}

.gender-chip.gender-female {
  background: rgba(236, 72, 153, 0.18);
  color: #be185d;
}

.participant-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

a.participant-card {
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

a.participant-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.participant-card.gender-male {
  background: #eff8ff;
  border-color: #bae6fd;
}

.participant-card.gender-female {
  background: #fdf2f8;
  border-color: #fbcfe8;
}

.participant-avatar {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: #e2e8f0;
}

.participant-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.participant-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-gender {
  font-size: 0.85rem;
  font-weight: 600;
}

.gender-male .participant-gender {
  color: #0369a1;
}

.gender-female .participant-gender {
  color: #be185d;
}

.participant-chevron {
  flex: 0 0 auto;
  font-size: 1.6rem;
  line-height: 1;
  color: #94a3b8;
}

.participant-item .item-meta {
  margin-top: 8px;
}

.participant-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.participant-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 4px;
  border-radius: 14px;
  text-align: center;
  min-width: 0;
}

.participant-stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  background: #fff;
}

.participant-stat-count {
  font-size: 1.4rem;
  line-height: 1.2;
}

.participant-stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
}

.participant-stat.stat-total {
  background: #f3e8ff;
}

.participant-stat.stat-total .participant-stat-icon {
  color: #7e22ce;
}

.participant-stat.stat-male {
  background: #e0f2fe;
}

.participant-stat.stat-male .participant-stat-icon {
  color: #0369a1;
}

.participant-stat.stat-female {
  background: #fce7f3;
}

.participant-stat.stat-female .participant-stat-icon {
  color: #be185d;
}

.participant-join-btn {
  width: 100%;
  margin-top: 12px;
}

.participant-item {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.participant-gender {
  color: #64748b;
}

/* ---------- Icons / avatars / info notes ---------- */
.icon {
  flex: none;
  display: inline-block;
  vertical-align: middle;
}

.avatar {
  flex: none;
  width: var(--avatar-size, 44px);
  height: var(--avatar-size, 44px);
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e2e8f0;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-initials {
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
}

.info-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 12px;
  background: var(--info-bg);
}
.info-note .icon {
  margin-top: 1px;
}
.info-note p {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--info-text);
}

.icon-close {
  flex: none;
  width: 40px;
  height: 40px;
  min-height: 40px;
  margin: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: none;
  background: var(--bg-soft);
  color: #334155;
  box-shadow: none;
}
.icon-close:hover {
  background: #e2e8f0;
  transform: none;
}

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

/* ---------- Match detail popup ---------- */
.match-detail-modal .modal-content {
  width: min(100% - 32px, 480px);
  max-width: 480px;
  max-height: 90vh;
  max-height: 90dvh;
  border-radius: 20px;
  padding: 16px;
  overflow-x: hidden;
  overflow-y: auto;
}
.match-detail-modal .auth-title-row {
  border-radius: 20px 20px 0 0;
  gap: 12px;
  margin-bottom: 4px;
}
.match-detail-modal .auth-title-row h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  align-items: center;
  gap: 8px;
}
.venue-name {
  min-width: 0;
  overflow-wrap: anywhere;
}
.session-detail-grid {
  gap: 0;
  font-size: 0.9375rem;
}
.session-detail-grid .row {
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dotted #cbd5e1;
}
.session-detail-grid .row-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  flex: none;
}
.session-detail-grid .row-value {
  color: var(--text);
  font-weight: 700;
  text-align: right;
  min-width: 0;
  overflow-wrap: anywhere;
}
.host-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 16px;
  background: linear-gradient(135deg, #ecfdf5, #e0f7fa);
  border: 1px solid rgba(13, 148, 136, 0.25);
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.host-avatar-wrap {
  position: relative;
  flex: none;
  width: 48px;
  height: 48px;
}
.host-crown {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.2);
}
.participant-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 8px;
}
.participant-section-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9375rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.participant-section-title .icon {
  flex: none;
}
.participant-add-btn {
  position: relative;
  flex: none;
  width: auto;
  height: 36px;
  min-height: 36px;
  margin: 0;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: none;
}
.participant-add-btn::after,
.add-result-btn::after {
  content: "";
  position: absolute;
  inset: -4px 0;
}
.participant-add-btn:hover,
.add-result-btn:hover:not(:disabled),
.add-submit:hover:not(:disabled) {
  background: var(--primary-hover);
}
#match-participant-list {
  display: block;
}
.participant-item {
  margin: 0 0 8px;
}
.participant-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
}
.participant-card.gender-male,
.participant-card.gender-female {
  background: #fff;
  border-color: var(--line);
}
a.participant-card:active,
a.host-card:active {
  transform: scale(0.98);
}
.participant-name {
  font-weight: 700;
}
.participant-gender {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
}
.gender-male .participant-gender,
.gender-female .participant-gender {
  color: var(--muted);
}
.participant-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.participant-chevron {
  flex: none;
  display: inline-flex;
}
.host-badge {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--host-bg);
  color: var(--host-text);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.4;
}
.participant-item .item-meta {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.participant-action-btn,
.participant-item .item-meta button.secondary {
  width: 100%;
  min-height: 44px;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: none;
}
.participant-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}
.participant-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 4px;
  border-radius: 16px;
  text-align: center;
  min-width: 0;
}
.participant-stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}
.participant-stat-count {
  font-size: 1.5rem;
  line-height: 1.2;
  font-weight: 700;
}
.participant-stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
}
.participant-stat.stat-total { background: var(--stat-total-bg); }
.participant-stat.stat-male { background: var(--stat-male-bg); }
.participant-stat.stat-female { background: var(--stat-female-bg); }
.participant-join-btn,
.action-finish,
.action-delete {
  width: 100%;
  min-height: 48px;
  margin: 8px 0 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 14px;
  color: #fff;
  font-weight: 700;
}
.participant-join-btn {
  margin-top: 16px;
  background: var(--primary);
  box-shadow: none;
}
.action-finish {
  background: var(--success-gradient);
  box-shadow: none;
}
.action-delete {
  background: var(--danger);
  box-shadow: none;
}
.action-delete:hover {
  background: var(--danger-hover);
}
.action-finish.hidden,
.action-delete.hidden {
  display: none !important;
}
.match-detail-modal #finish-match-btn {
  margin-top: 16px;
}

/* ---------- Add-participant modal ---------- */
.add-participant-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.5);
}
.add-participant-sheet {
  position: fixed;
  top: var(--vv-top, 0);
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  height: var(--vv-height, 100dvh);
  display: flex;
  flex-direction: column;
  background: #fff;
  overflow: hidden;
  animation: add-sheet-in 0.18s ease-out;
}
.add-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: env(safe-area-inset-top) 16px 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.add-header h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
}
.add-tabs-wrap {
  flex: none;
  padding: 12px 16px 0;
}
.add-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--bg-soft);
}
.add-tab {
  min-height: 44px;
  margin: 0;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 0.875rem;
  box-shadow: none;
}
.add-tab:hover {
  transform: none;
}
.add-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}
.add-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.add-body [hidden] {
  display: none !important;
}
.search-field {
  position: relative;
}
.search-field .icon {
  position: absolute;
  left: 14px;
  top: 15px;
  pointer-events: none;
}
.add-body input[type="search"],
.add-body input[type="text"] {
  width: 100%;
  height: 48px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 1rem;
}
.add-body input[type="search"] {
  padding-left: 42px;
}
.add-body input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}
.add-section-title {
  margin: 16px 0 4px;
  font-size: 0.9375rem;
  font-weight: 700;
}
.add-results {
  display: block;
}
.add-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.add-result-btn {
  position: relative;
  flex: none;
  width: auto;
  min-width: 64px;
  height: 36px;
  min-height: 36px;
  margin: 0;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 0.8125rem;
  box-shadow: none;
  white-space: nowrap;
}
.add-result-btn:disabled {
  background: var(--bg-soft);
  color: #475569;
  cursor: not-allowed;
  transform: none;
}
.add-status {
  padding: 20px 8px;
  text-align: center;
  color: var(--muted);
}
.add-status p {
  margin: 0 0 8px;
}
.add-status-error p {
  color: #b91c1c;
}
.add-retry {
  width: auto;
  min-height: 44px;
  padding: 0 20px;
  background: var(--primary);
  box-shadow: none;
}
.skeleton {
  display: block;
  background: linear-gradient(90deg, #e2e8f0, #f1f5f9, #e2e8f0);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s linear infinite;
  border-radius: 8px;
}
.skeleton-avatar {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
}
.skeleton-line {
  flex: 1;
  height: 14px;
}
.add-label {
  display: block;
  margin: 16px 0 8px;
  font-weight: 600;
  font-size: 0.9rem;
}
.add-label:first-child {
  margin-top: 0;
}
.add-counter {
  margin-top: 4px;
  text-align: right;
  font-size: 0.75rem;
  color: var(--muted);
}
.add-error {
  min-height: 0;
  color: #b91c1c;
  font-size: 0.8125rem;
}
.add-error:not(:empty) {
  margin-top: 4px;
}
.add-gender {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.gender-opt {
  min-height: 48px;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 12px;
  border: 2px solid transparent;
  box-shadow: none;
}
.gender-opt-male {
  background: var(--male-soft);
  color: #1d4ed8;
}
.gender-opt-female {
  background: var(--female-soft);
  color: #be185d;
}
.gender-opt-male.active {
  background: var(--male);
  color: #fff;
}
.gender-opt-female.active {
  background: var(--female);
  color: #fff;
}
.gender-opt-female.active {
  background: #db2777;
}
.add-submit {
  width: 100%;
  min-height: 48px;
  margin: 16px 0 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  background: var(--primary);
  box-shadow: none;
}
.add-submit:disabled {
  background: #cbd5e1;
  color: #475569;
  cursor: not-allowed;
  transform: none;
}

@keyframes add-sheet-in {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes skeleton-shimmer {
  to { background-position: -200% 0; }
}

@media (min-width: 641px) {
  .add-participant-sheet {
    position: relative;
    top: auto;
    left: auto;
    width: min(100% - 32px, 480px);
    height: auto;
    max-height: 90vh;
    max-height: 90dvh;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.3);
  }
  .add-header {
    min-height: 64px;
    padding-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .add-participant-sheet,
  .skeleton {
    animation: none;
  }
}

/* ---------- Match detail screen (redesign) ---------- */
.match-detail-modal {
  --text: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --border: #e2e8f0;
  --soft: #f8fafc;
  --soft-2: #f1f5f9;
  z-index: 900;
  padding: 16px;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: none;
}
body.match-detail-open {
  overflow: hidden;
}
.match-detail-modal .match-detail-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  max-height: 90dvh;
  padding: 0;
  overflow: hidden;
  background: #fff;
  border-radius: 20px;
  border: none;
  box-shadow: none;
  color: var(--text);
  font-size: 0.875rem;
}
.match-detail-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.icon-btn {
  position: relative;
  flex: none;
  width: 38px;
  height: 38px;
  min-height: 38px;
  margin: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  background: var(--soft-2);
  color: #334155;
  box-shadow: none;
}
.icon-btn:hover {
  background: var(--border);
  transform: none;
}
.icon-btn.hidden {
  display: none !important;
}
.match-detail-heading {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.match-detail-heading h2 {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}
.match-detail-heading h2 .icon {
  flex: none;
}
.match-detail-heading .venue-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-pill {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--soft-2);
  color: #475569;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}
.status-pill.is-live {
  background: #dcfce7;
  color: #166534;
}
.match-detail-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 12px;
}
.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
}
.info-card {
  min-width: 0;
  padding: 8px 10px;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.info-card-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--muted);
}
.info-card-label .icon {
  flex: none;
}
.info-card-value {
  display: block;
  margin-top: 2px;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  overflow-wrap: anywhere;
}
.stat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 12px;
}
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.stat-chip.stat-total {
  background: #f3e8ff;
  color: #6b21a8;
}
.stat-chip.stat-male {
  background: #e0f2fe;
  color: #075985;
}
.stat-chip.stat-female {
  background: #fce7f3;
  color: #9d174d;
}
.match-detail-modal .participant-section-header {
  margin: 0;
  padding: 0 12px 8px;
}
.match-detail-modal .participant-section-title {
  flex: 0 1 auto;
  font-size: 0.9375rem;
}
.match-detail-modal .participant-add-btn {
  flex: none;
  width: auto;
  height: 38px;
  min-height: 38px;
  padding: 0 13px;
  font-size: 0.8125rem;
}
.participant-rows {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 0 12px;
}
.participant-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px 8px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}
.participant-row.is-host {
  background: #ecfdf5;
  border-color: #99f6e4;
}
.participant-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}
.participant-avatar-wrap {
  position: relative;
  flex: none;
  width: 40px;
  height: 40px;
}
.avatar-pastel {
  font-size: 0.8125rem;
}
.participant-row .host-crown {
  top: -6px;
  left: -6px;
  width: 19px;
  height: 19px;
  box-shadow: none;
}
.participant-row .participant-name {
  font-size: 0.875rem;
  font-weight: 700;
}
.participant-row .participant-gender {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}
.participant-row .host-badge {
  padding: 1px 8px;
  font-size: 0.6875rem;
}
.participant-action-slot {
  flex: none;
  width: 38px;
  height: 38px;
}
.participant-more-btn {
  background: transparent;
  color: var(--muted);
}
.participant-empty,
.participant-hint {
  padding: 0 12px;
}
.match-detail-modal .info-note {
  margin: 8px 12px 0;
}
.match-detail-modal .participant-join-btn {
  width: calc(100% - 24px);
  margin: 12px 12px 0;
}
.match-detail-footer {
  flex: none;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: #fff;
}
.match-detail-footer .action-finish {
  margin: 0;
}
.popup-menu {
  position: fixed;
  z-index: 1200;
  width: 210px;
  padding: 4px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}
.popup-menu-item {
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #0f172a;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  box-shadow: none;
}
.popup-menu-item:hover,
.popup-menu-item:focus-visible {
  background: #f1f5f9;
  transform: none;
}
.popup-menu-item.danger {
  color: #dc2626;
}
.popup-menu-divider {
  height: 1px;
  margin: 4px 0;
  background: #e2e8f0;
}
.simple-dialog-overlay {
  z-index: 1100;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: none;
}
.simple-dialog {
  max-width: 360px;
  padding: 20px;
  border-radius: 20px;
}
.simple-dialog-title {
  margin: 0 0 8px;
  font-size: 1.0625rem;
  font-weight: 600;
}
.simple-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.simple-dialog-actions button {
  min-height: 40px;
  margin: 0;
  border-radius: 12px;
}
.simple-dialog-danger {
  background: #dc2626;
  color: #fff;
}
.simple-dialog-danger:hover {
  background: #b91c1c;
}

@media (max-width: 640px) {
  .match-detail-modal {
    padding: 0;
    background: #fff;
    align-items: stretch;
    justify-content: stretch;
  }
  .match-detail-modal .match-detail-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }
  .simple-dialog-overlay {
    padding: 16px;
  }
}

.finish-session-overlay {
  z-index: 1300;
}

.match-detail-footer {
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}
.match-detail-footer .action-finish {
  height: 48px;
  min-height: 48px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

/* ---------- QR sheet ---------- */
body.qr-sheet-open {
  overflow: hidden;
}
.qr-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(15, 23, 42, 0.5);
  animation: qr-fade 0.18s ease-out;
}
.qr-sheet {
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #fff;
  color: #0f172a;
  border-radius: 20px 20px 0 0;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  animation: qr-slide 0.18s ease-out;
}
.qr-sheet-handle {
  width: 36px;
  height: 4px;
  margin: 0 auto 8px;
  border-radius: 2px;
  background: #cbd5e1;
}
.qr-sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.qr-sheet-heading {
  min-width: 0;
}
.qr-sheet-heading h3 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 500;
}
.qr-sheet-sub {
  margin: 2px 0 0;
  font-size: 13px;
  color: #64748b;
  overflow-wrap: anywhere;
}
.qr-sheet-x {
  flex: none;
  width: 38px;
  height: 38px;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  color: #475569;
  border: none;
  border-radius: 12px;
  box-shadow: none;
}
.qr-sheet-amount {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  background: #eff6ff;
  border-radius: 12px;
}
.qr-sheet-amount-label {
  display: block;
  font-size: 12px;
  color: #64748b;
}
.qr-sheet-amount strong {
  display: block;
  font-size: 17px;
  font-weight: 500;
  color: #1d4ed8;
  white-space: nowrap;
}
.qr-sheet-amount > div {
  min-width: 0;
}
.qr-sheet-copy {
  flex: none;
  width: auto;
  height: 38px;
  margin: 0;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #2563eb;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: 10px;
  box-shadow: none;
}
.qr-sheet-box {
  margin-top: 12px;
  padding: 14px;
  background: #fff1e2;
  border: 1px solid #fed7aa;
  border-radius: 18px;
  text-align: center;
}
.qr-sheet-inner {
  width: min(236px, 100%);
  margin: 0 auto;
  padding: 8px;
  background: #fff;
  border-radius: 12px;
  box-sizing: border-box;
  overflow: hidden;
}
.qr-sheet-img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 220px;
  object-fit: contain;
  border-radius: 12px;
  margin: 0 auto;
}
.qr-sheet-skeleton {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  background: linear-gradient(90deg, #f1f5f9, #e2e8f0, #f1f5f9);
  background-size: 200% 100%;
  animation: qr-shimmer 1.2s linear infinite;
}
.qr-sheet-skeleton[hidden],
.qr-sheet-img[hidden],
.qr-sheet-error[hidden] {
  display: none;
}
.qr-sheet-error {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  color: #64748b;
}
.qr-sheet-retry {
  width: auto;
  margin: 0;
  height: 36px;
  padding: 0 16px;
  background: #2563eb;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: 10px;
  box-shadow: none;
}
.qr-sheet-caption {
  margin: 8px 0 0;
  font-size: 12px;
  color: #64748b;
}
.qr-sheet-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.qr-sheet-action {
  flex: 1;
  height: 46px;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #fff;
  color: #0f172a;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: none;
}
@media (min-width: 641px) {
  .qr-sheet-overlay {
    align-items: center;
    padding: 16px;
  }
  .qr-sheet {
    max-width: 420px;
    border-radius: 20px;
    padding-bottom: 14px;
  }
  .qr-sheet-handle {
    display: none;
  }
}
@keyframes qr-slide {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes qr-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes qr-shimmer {
  to { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .qr-sheet-overlay,
  .qr-sheet {
    animation: none;
  }
  .qr-sheet-skeleton {
    animation: none;
  }
}

/* ---------- Create-session screen ---------- */
.create-overlay {
  --text: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --border: #e2e8f0;
  --soft: #f8fafc;
  --soft-2: #f1f5f9;
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.5);
  color: var(--text);
}
.create-overlay.hidden {
  display: none;
}
body.create-open {
  overflow: hidden;
}
.create-sheet {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  max-height: 90dvh;
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
}
.create-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.create-back {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  min-width: 38px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--soft-2);
  color: var(--text);
  box-shadow: none;
}
.create-header-text {
  min-width: 0;
}
.create-header h1 {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.create-header p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.create-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1px 0;
}
.create-card {
  margin: 12px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.create-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}
.create-field {
  min-width: 0;
}
.create-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.create-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}
.create-input,
.create-input-wrap input {
  width: 100%;
  height: 46px;
  margin: 0;
  padding: 0 12px;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  box-sizing: border-box;
}
.create-input.ellipsis {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
.create-input:focus,
.create-input-wrap input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 0;
  border-color: var(--primary);
}
.create-field.has-error .create-input,
.create-field.has-error .create-input-wrap input {
  border-color: #dc2626;
}
.create-error {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: #dc2626;
}
.create-error:empty {
  display: none;
}
.create-input-wrap {
  position: relative;
}
.date-wrap input {
  cursor: pointer;
  color: transparent;
}
.date-wrap input::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.date-display {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9375rem;
  color: var(--text);
  pointer-events: none;
}
.date-display.is-empty {
  color: var(--faint);
}
.weekday-pill {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  padding: 3px 10px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1e40af;
  font-size: 0.75rem;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
}
.weekday-pill.hidden {
  display: none;
}
.money-wrap input {
  padding-right: 28px;
}
.money-suffix {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.9375rem;
  pointer-events: none;
}
.duration-chip {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  font-size: 0.8125rem;
  font-weight: 600;
}
.total-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: #ecfdf5;
  border: 1px solid #99f6e4;
  border-radius: 12px;
}
.total-strip span {
  font-size: 0.8125rem;
  color: #0f766e;
}
.total-strip strong {
  font-size: 1rem;
  font-weight: 600;
  color: #0f766e;
}
.create-participants {
  padding: 0;
}
.create-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 46px;
  margin: 0;
  background: #eff6ff;
  color: var(--primary);
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  font-size: 0.9375rem;
  font-weight: 600;
  box-shadow: none;
}
.create-footer {
  flex: none;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: #fff;
}
.create-save {
  width: 100%;
  height: 48px;
  margin: 0;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(90deg, #16a34a, #0ea5e9);
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  box-shadow: none;
}
.create-save:disabled {
  opacity: 0.6;
}
@media (max-width: 640px) {
  .create-overlay {
    background: #fff;
  }
  .create-sheet {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }
}

.match-summary {
  margin: 0 12px 12px;
  padding: 12px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
}
.match-summary-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 500;
}
.match-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  font-size: 14px;
}
.match-summary-row > span {
  color: #64748b;
}
.match-summary-row > strong {
  font-weight: 500;
  text-align: right;
}
.match-summary-row.is-total > span {
  color: #0f172a;
  font-weight: 500;
}
.match-summary-divider {
  height: 1px;
  margin: 4px 0;
  background: #e2e8f0;
}
.match-summary-per {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  padding: 12px;
  background: #ecfdf5;
  border: 1px solid #99f6e4;
  border-radius: 14px;
}
.match-summary-per-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}
.match-summary-per-label {
  font-size: 13px;
  color: #0f766e;
}
.match-summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  background: #fff;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}
.match-summary-per-value {
  flex: 0 1 auto;
  font-size: clamp(22px, 7vw, 26px);
  font-weight: 500;
  color: #0f766e;
  white-space: nowrap;
}
.match-summary-qr-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 44px;
  min-height: 44px;
  margin: 8px 0 0;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  color: #2563eb;
  cursor: pointer;
}
.participant-amount {
  position: static;
  flex: 0 0 auto;
  margin-left: auto;
  font-size: 13px;
  font-weight: 500;
  color: #0f766e;
  white-space: nowrap;
}
.match-detail-scroll {
  padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
}
.participant-row .participant-name {
  display: block;
  min-width: 0;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.participant-row .participant-name-row {
  min-width: 0;
}
.participant-row {
  box-sizing: border-box;
  width: 100%;
  padding: 8px 12px 8px 10px;
  margin-bottom: 7px;
  overflow: hidden;
}
.participant-row .participant-main {
  flex: 1 1 auto;
  min-width: 0;
}
.participant-row .participant-info {
  min-width: 0;
}
.participant-rows {
  gap: 0;
}
.participant-row .participant-action-slot {
  padding-right: 0;
}
.finish-dialog h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}
.finish-preview {
  margin: 0;
  padding: 8px 12px;
  background: #ecfdf5;
  border: 1px solid #99f6e4;
  border-radius: 12px;
  color: #0f766e;
  font-size: 13px;
}
.finish-submit {
  height: 48px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(90deg, #16a34a, #0ea5e9);
  color: #fff;
  font-weight: 500;
}
.finish-submit.is-loading::after {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 8px;
  vertical-align: -2px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: finish-spin 0.7s linear infinite;
}
@keyframes finish-spin {
  to {
    transform: rotate(360deg);
  }
}

.participant-login-wrap {
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 20px);
}
.participant-login-btn {
  width: 100%;
  height: 48px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(90deg, #16a34a, #0ea5e9);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  box-shadow: none;
}
.participant-login-btn:focus-visible {
  outline: 3px solid #0369a1;
  outline-offset: 2px;
}

#login-modal {
  z-index: 1400;
}
