/* ============================================================================
   AP TOURNAMENTS — SHARED UI DESIGN SYSTEM & TOKENS
   Esports Dark Obsidian & Radiant Amber/Gold Aesthetic
   Engineered for Mobile-First, Responsive Continuum & Low-End Androids
   ============================================================================ */

:root {
  /* STEP 21 — Core Design Tokens */
  --bg: #0E0F13;
  --surface: #16181F;
  --raised: #1E212A;
  --primary-hover: #FF7A45;
  --primary-press: #E8430A;
  --danger: #F0454F;
  --text: #F2F3F5;
  --muted: #8B91A0;
  --radius: 12px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.22);
  --motion-fast: 150ms;

  /* Surfaces: Ink & Obsidian Ramp (Clean, purposeful neutrals) */
  --bg-main: #0b0e13;
  --bg-surface: #121722;
  --bg-elevated: #191f2b;
  --bg-card: #121722;
  --bg-card-hover: #171d28;

  /* Primary Accent: Tournament Gold/Amber (Single crisp, refined accent) */
  --primary: #ff6a00;
  --primary-hover: #ff8533;
  --primary-subtle: rgba(255, 106, 0, 0.13);

  --gold: #ff8a1f;
  --gold-hover: #ffa347;
  --gold-subtle: rgba(255, 138, 31, 0.13);

  --cyan: #0284c7;
  --cyan-subtle: rgba(2, 132, 199, 0.12);

  /* Text & Structural Hierarchy */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --border: #273043;
  --border-light: #344057;
  --border-gold: rgba(255, 138, 31, 0.3);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --info: #0284c7;
  --info-bg: rgba(2, 132, 199, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition: all 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Short compositor-only motion keeps navigation responsive without delaying data. */
@media (prefers-reduced-motion: no-preference) {
  .tab-content.active,
  .admin-tab-pane.active {
    animation: ap-surface-enter 320ms cubic-bezier(.22, 1, .36, 1) both;
  }
  :is(.match-card, .explore-card, .metric-card, .table-card, .compact-menu-item) {
    transition: transform 160ms cubic-bezier(.2, .8, .2, 1), border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
  }

}

@keyframes ap-surface-enter {
  from { opacity: .72; transform: translate3d(0, 5px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

/* Keep every surface scrollable without showing native scrollbars. */
html,
body,
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

html:has(.modal-overlay.active),
body:has(.modal-overlay.active) {
  overflow: hidden;
  overscroll-behavior: none;
}

.modal-overlay {
  overscroll-behavior: contain;
}

/* Numbers tabular formatting */
.metric-value, .balance-amount, .vault-val, .tnum, table td {
  font-variant-numeric: tabular-nums;
}

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100%;
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Typography Hierarchy */
h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

/* Tabular numbers for financial stats and clocks */
.tnum {
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  min-height: var(--btn-h); /* Touch Target Compliance */
  padding: 10px 18px;
  font-size: var(--fs-base);
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  user-select: none;
  touch-action: manipulation;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
}

.btn:focus-visible,
.modal-close:focus-visible,
.form-input:focus-visible,
.form-select:focus-visible,
.form-textarea:focus-visible {
  outline: 3px solid rgba(255, 170, 0, 0.72);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: #0a0d14;
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: 0.2px;
  box-shadow: none;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-light);
}

.btn-gold {
  background: var(--primary);
  color: #0a0d14;
  font-family: var(--font-sans);
  font-weight: 600;
  box-shadow: none;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.btn-gold:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-google {
  background: #ffffff;
  color: #1f2937;
  font-weight: 600;
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.btn-google:hover:not(:disabled) {
  background: #f9fafb;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  transform: translateY(-1px);
}

.btn-google-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #ffffff;
  color: #0f172a;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--fs-sm);
  padding: 7px 14px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 100%;
  text-transform: none;
  text-decoration: none;
  min-height: var(--btn-h-sm);
}

.btn-google-action:hover {
  background: #f8fafc;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.btn-google-action:active {
  transform: translateY(0);
}

.btn-google-action svg {
  width: 16px;
  height: auto;
  min-width: 16px;
  min-height: 0;
  margin: 0;
  flex-shrink: 0;
  display: block;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  font-weight: 600;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline:hover:not(:disabled) {
  background: var(--primary-subtle);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-sm {
  min-height: var(--btn-h-sm);
  padding: 6px 14px;
  font-size: var(--fs-sm);
}

#active-pay-retry[hidden] {
  display: none;
}

.btn-block {
  width: 100%;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-upcoming { background: var(--info-bg); color: var(--info); border: 1px solid rgba(2, 132, 199, 0.25); }
.badge-open { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.25); }
.badge-full { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.25); }
.badge-live { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-completed { background: rgba(148, 163, 184, 0.1); color: var(--text-muted); border: 1px solid var(--border); }
.badge-cancelled { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.25); }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 13, 20, 0.85);
  backdrop-filter: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 280ms ease, visibility 0s linear 280ms;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateY(24px);
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

@media (prefers-reduced-motion: no-preference) {
  .modal-overlay { transition-duration: 280ms, 0s; transition-delay: 0s, 280ms; }
  .modal-overlay.active { transition-delay: 0s; }
  .modal-card { transition-duration: 320ms; }

  :is(#deposit-modal, #withdraw-modal) {
    opacity: 1;
    overflow: hidden;
    pointer-events: none;
    transition: visibility 0s linear 320ms;
  }

  :is(#deposit-modal, #withdraw-modal).active {
    pointer-events: auto;
    transition-delay: 0s;
  }

  :is(#deposit-modal, #withdraw-modal) .modal-card {
    transform: translate3d(0, 44px, 0);
    transition: transform 320ms cubic-bezier(.22, 1, .36, 1);
  }

  :is(#deposit-modal, #withdraw-modal).active .modal-card {
    transform: translate3d(0, 0, 0);
  }
}

@media (max-width: 600px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal-card {
    max-width: 100%;
    max-height: 88vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: var(--transition);
  min-width: 44px;
  min-height: 44px;
}

.modal-close:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  min-height: var(--input-h);
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: var(--fs-base);
  font-family: inherit;
  transition: var(--transition);
}

/* Prevent auto-zooming on mobile iOS and Android */
@media (max-width: 768px) {
  .form-input, .form-select, .form-textarea {
    font-size: var(--fs-base);
  }
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-subtle);
}

.form-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 72px;
  right: 24px;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

@media (max-width: 600px) {
  .toast-container {
    top: auto;
    bottom: 76px;
    left: 14px;
    right: 14px;
    max-width: none;
  }
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0,0,0,0.7), 0 0 1px rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  animation: slideDown 320ms cubic-bezier(0.22, 1, 0.36, 1);
  transition: opacity 320ms ease, transform 320ms ease;
}

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

.toast.fade-out {
  opacity: 0;
  transform: translateY(-8px);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Loaders & Skeletons */
.loader-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 85, 0, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   CONTEST DETAILS & TOURNAMENT MODAL UPGRADES (Khiladi Style)
   ============================================================ */
.match-modal-hero {
  position: relative;
  height: 110px;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}

.match-modal-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.match-modal-hero .hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.2) 0%, rgba(15, 21, 35, 0.95) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px 14px;
  align-items: center;
  text-align: center;
}

.match-modal-hero .hero-tag-badge {
  align-self: center;
  background: rgba(255, 85, 0, 0.25);
  color: #ffaa55;
  border: 1px solid rgba(255, 85, 0, 0.45);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 4px;
}

.match-modal-hero h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  margin: 0;
  line-height: 1.2;
}

/* Live Countdown Box */
.match-modal-countdown {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #34d399;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
}

.match-modal-countdown.imminent {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

/* Match Specifications 2x3 Grid */
.specs-table-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.spec-cell {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: center;
}

.spec-cell .cell-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 2px;
}

.spec-cell .cell-value {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
}

/* Rank-wise Prize Table */
.prize-breakdown-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
}

.prize-box-title {
  font-size: 12px;
  font-weight: 800;
  color: #ffaa55;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.prize-ranks-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prize-rank-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.prize-rank-row:last-child {
  border-bottom: none;
}

.prize-rank-row .rank-name {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.prize-rank-row .rank-payout {
  font-weight: 800;
  color: #34d399;
}

/* Detailed Rules & Prohibited Items Box */
.rules-container-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 16px;
}

.rules-container-box h4 {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--primary-hover);
  margin: 0 0 8px 0;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

.match-rules-copy {
  display: grid;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.55;
}

.match-rules-copy p { margin: 0; }

.rules-specs-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.rule-chip-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  color: var(--text-main);
  font-weight: 600;
}

.ban-alert-strip {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 11px;
  color: #fca5a5;
  margin-top: 8px;
  line-height: 1.4;
}

/* View Joinings & Confirm Buttons Group */
.match-actions-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#match-details-modal .modal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#match-details-modal .modal-header {
  flex: 0 0 auto;
}

#match-details-modal .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.match-details-loading {
  min-height: 220px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.onboarding-uid-note.is-highlighted {
  padding: 10px;
  border: 1px solid rgba(255, 136, 0, 0.55);
  border-radius: var(--radius-md);
  background: rgba(255, 136, 0, 0.08);
}

.profile-device-header { flex-wrap: nowrap; }
.profile-device-actions .badge { white-space: nowrap; }

@media (max-width: 420px) {
  .profile-device-header h3 { font-size: 11px; letter-spacing: 0.25px; }
  .profile-device-actions { gap: 4px; }
}

.join-confirm-sheet[hidden] {
  display: none;
}

.join-confirm-sheet {
  position: absolute;
  inset: 0;
  z-index: calc(var(--z-sticky) + 2);
  display: flex;
  align-items: flex-end;
  background: rgba(5, 8, 13, 0.72);
  opacity: 0;
  transition: opacity 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.join-confirm-sheet.active {
  opacity: 1;
}

.join-confirm-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: transparent;
  cursor: default;
}

.join-confirm-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -18px 40px rgba(0, 0, 0, 0.45);
  transform: translateY(100%);
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.join-confirm-sheet.active .join-confirm-panel {
  transform: translateY(0);
}

#deposit-step-payment,
#deposit-step-success { animation: none; }

.join-confirm-handle {
  width: 38px;
  height: 4px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
}

.join-confirm-heading,
.join-player-card,
.join-payment-summary > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.join-confirm-heading {
  align-items: flex-start;
  margin-bottom: 12px;
}

.join-confirm-heading span,
.join-player-card span,
.join-payment-summary span {
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.join-confirm-heading h3 {
  margin: 2px 0 0;
  color: var(--text-main);
  font-size: 16px;
}

.join-confirm-close {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text-main);
  font-size: 21px;
  cursor: pointer;
}

.join-player-card {
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
}

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

.join-player-card > div:last-child {
  text-align: right;
}

.join-player-card span,
.join-player-card strong {
  display: block;
}

.join-player-card strong {
  max-width: 150px;
  overflow: hidden;
  color: var(--text-main);
  font-size: var(--fs-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.join-payment-summary {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 0 2px;
}

.join-payment-summary strong {
  color: var(--text-main);
  font-size: 13px;
}

.join-payment-summary .join-balance-after {
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.join-payment-summary .join-balance-after strong {
  color: var(--success);
}

.join-confirm-note {
  margin: 0 0 12px;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.45;
}

.match-detail-tabs {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin: 0 0 12px;
  padding: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.match-detail-tabs.has-slot-tab {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.join-slot-picker {
  display: grid;
  gap: 7px;
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.match-slot-roster {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}

.match-slot-roster h4 { margin: 0 0 5px; color: var(--text-main); font-size: 13px; }
.match-slot-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px; border-radius: 8px; background: rgba(255,255,255,.025); color: var(--text-dim); font-size: 11px; }
.match-slot-row strong { color: var(--success); text-align: right; }
.match-slot-row.is-occupied strong { color: var(--text-main); }

.match-detail-panel,
.specs-table-grid,
.spec-cell { min-width: 0; }

.spec-cell .cell-value {
  overflow-wrap: anywhere;
  white-space: normal;
  line-height: 1.3;
}

.match-detail-tab {
  min-width: 0;
  min-height: 36px;
  padding: 6px 4px;
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.match-detail-tab.active {
  background: var(--primary);
  color: #0a0d14;
}

#match-details-modal [data-match-detail-panel][hidden] {
  display: none;
}

.match-detail-panel {
  min-height: 150px;
}

.match-players-summary {
  display: grid;
  gap: 14px;
  padding: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

.match-players-summary strong,
.match-players-summary span {
  display: block;
}

.match-players-summary strong {
  color: var(--text-main);
  font-size: 15px;
}

.match-players-summary span {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 12px;
}

.btn-gold-view {
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #fbbf24;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-weight: 800;
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-gold-view:hover {
  background: #f59e0b;
  color: #0b0e14;
}

/* Match details behaves like a native inner screen on mobile. */
@media (max-width: 700px) {
  #match-details-modal {
    align-items: stretch;
    padding: 0;
    background: var(--bg-main);
    backdrop-filter: none;
  }

  #match-details-modal .modal-card {
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    transform: translateX(100%);
    transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  #match-details-modal.active .modal-card {
    transform: translateX(0);
  }

  #match-details-modal .modal-header {
    min-height: 46px;
    padding: calc(5px + env(safe-area-inset-top, 0px)) 10px 5px;
    background: var(--bg-surface);
    z-index: 5;
  }

  #match-details-modal .modal-header h3 {
    font-size: 16px;
  }

  #match-details-modal .modal-close {
    order: -1;
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    font-size: 22px;
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    transition: transform 320ms ease, background-color 320ms ease, border-color 320ms ease;
  }

  #match-details-modal .modal-close:hover,
  #match-details-modal .modal-close:focus-visible {
    border-color: var(--primary);
    background: rgba(255, 85, 0, 0.18);
    transform: translateX(-3px) scale(1.06);
  }

  #match-details-modal .modal-body {
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  #match-details-modal .match-modal-hero {
    height: 88px;
    border-radius: 10px;
  }

  #match-details-modal .specs-table-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-bottom: 10px;
  }

  #match-details-modal .spec-cell {
    min-height: 58px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 8px;
    text-align: left;
  }

  #match-details-modal .spec-cell .cell-label { font-size: 10px; letter-spacing: 0.04em; }
  #match-details-modal .spec-cell .cell-value { font-size: 12px; }

  #match-details-modal .match-detail-tabs { gap: 3px; }
  #match-details-modal .match-detail-tab {
    min-height: 38px;
    padding: 6px 2px;
    font-size: 10px;
    white-space: nowrap;
  }

  #match-details-modal .match-modal-hero .hero-tag-badge {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 9px;
  }

  #match-details-modal .match-modal-hero h3 {
    max-width: 100%;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    font-size: 16px;
  }

  #match-details-modal .match-actions-group {
    position: sticky;
    bottom: calc(-12px - env(safe-area-inset-bottom, 0px));
    z-index: 4;
    margin: 0 -10px -10px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    background: rgba(11, 14, 20, 0.98);
    border-top: 1px solid var(--border);
  }
}

/* Keep important controls visible in long views without enlarging the cards. */
#match-details-modal .match-detail-tabs {
  position: sticky;
  top: 0;
  z-index: calc(var(--z-sticky) + 1);
  margin-bottom: 0;
  background: rgba(17, 24, 39, .98);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .24);
}

.wallet-history-header {
  position: sticky;
  top: calc(var(--header-h) + var(--safe-top));
  z-index: var(--z-sticky);
  padding-block: var(--space-2);
  background: rgba(11, 14, 20, .96);
  backdrop-filter: blur(10px);
}

.admin-layout .admin-topbar {
  position: sticky;
  top: 0;
  z-index: calc(var(--z-sticky) + 2);
  background: rgba(11, 14, 20, .98);
  backdrop-filter: blur(10px);
}

.admin-layout .table-responsive .data-table th {
  position: sticky;
  top: 0;
  z-index: var(--z-base);
  background: var(--bg-elevated);
}

.admin-layout :is(.table-card, .admin-card, .metric-card) :is(p, td, .badge) {
  font-size: var(--a-fs-table);
  line-height: 1.4;
}

/* ============================================================
   REFER & EARN SYSTEM (VIRAL GROWTH MODAL)
   ============================================================ */
.refer-card-header {
  text-align: center;
  padding: 10px 0 16px 0;
}

.refer-gift-icon {
  width: 58px;
  height: 58px;
  background: radial-gradient(circle, rgba(255, 85, 0, 0.25) 0%, rgba(15, 21, 35, 0.9) 100%);
  border: 2px solid var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px auto;
  color: var(--primary);
  box-shadow: 0 0 20px rgba(255, 85, 0, 0.3);
}

.refer-code-box {
  background: rgba(147, 51, 234, 0.1);
  border: 2px dashed rgba(168, 85, 247, 0.5);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  margin: 14px 0;
}

.refer-code-label {
  font-size: 11px;
  text-transform: uppercase;
  color: #c084fc;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.refer-code-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}

.refer-code-text {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 2px;
}

.btn-copy-code {
  background: rgba(168, 85, 247, 0.25);
  border: 1px solid rgba(168, 85, 247, 0.6);
  color: #e9d5ff;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  cursor: pointer;
  font-weight: 700;
}

.btn-copy-code:hover {
  background: #9333ea;
  color: #fff;
}

.social-share-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.btn-social-share {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s ease;
}

.btn-social-share:hover {
  transform: translateY(-2px);
}

.share-whatsapp {
  background: #25D366;
  color: #fff;
}

.share-telegram {
  background: #0088cc;
  color: #fff;
}

.share-facebook {
  background: #1877F2;
  color: #fff;
}

/* ============================================================
   CATEGORIZED FAQ & POLICY ACCORDION
   ============================================================ */
.faq-filter-strip {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  margin-bottom: 14px;
  scrollbar-width: none;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
  touch-action: pan-x;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.faq-filter-strip::-webkit-scrollbar {
  display: none;
}

.faq-pill {
  flex: 0 0 auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
  scroll-snap-align: start;
}

.faq-modal-header {
  min-height: 74px;
}

.faq-modal-title span {
  display: block;
  margin-bottom: 3px;
  color: var(--primary);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.faq-modal-title h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

.faq-pill.active {
  background: var(--primary);
  color: #0b0e14;
  border-color: var(--primary);
}

.faq-accordion-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.faq-accordion-item:hover {
  border-color: rgba(255, 85, 0, 0.4);
}

.faq-accordion-header {
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  user-select: none;
}

.faq-accordion-header .faq-arrow {
  transition: transform 0.2s ease;
  color: var(--text-dim);
}

.faq-accordion-item.open .faq-arrow {
  transform: rotate(180deg);
  color: var(--primary);
}

.faq-accordion-body {
  display: none;
  padding: 0 14px 14px 14px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: 4px;
  padding-top: 10px;
}

.faq-accordion-item.open .faq-accordion-body {
  display: block;
}

.network-status-banner {
  position: sticky;
  top: 0;
  z-index: 10000;
  width: 100%;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(245, 158, 11, 0.45);
  background: #2a1b08;
  color: #fbbf24;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

.network-status-banner[hidden] {
  display: none;
}

.network-status-banner[data-status="backend"] {
  border-bottom-color: rgba(239, 68, 68, 0.55);
  background: #2a1010;
  color: #fecaca;
}

.network-status-banner[data-status="maintenance"] {
  border-bottom-color: rgba(59, 130, 246, 0.5);
  background: #0d1d35;
  color: #bfdbfe;
}

.app-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(3px);
}

.app-confirm-sheet {
  width: min(100%, 420px);
  padding: 10px 14px 14px;
  border: 1px solid var(--border-light);
  border-radius: 16px;
  background: var(--bg-surface);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
  animation: confirm-sheet-in 160ms ease-out;
}

.app-confirm-handle {
  width: 34px;
  height: 3px;
  margin: 0 auto 10px;
  border-radius: 99px;
  background: var(--border-light);
}

.app-confirm-sheet h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.app-confirm-sheet p {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-line;
}

.app-input-control { width: 100%; margin: 0 0 12px; resize: vertical; }

.app-confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@keyframes confirm-sheet-in {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (min-width: 640px) {
  .app-confirm-overlay { align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  .app-confirm-sheet { animation: none; }
}
/* Canonical token-sized components. Feature files may change colour and layout, not control size. */
.is-hidden,
[hidden] { display: none; }

.btn {
  position: relative;
  display: inline-flex;
  min-height: var(--btn-h);
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding-inline: var(--space-4);
  border-radius: var(--radius);
  font-size: var(--fs-base);
  line-height: 1;
  transition: background-color var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast), transform var(--motion-fast);
}

.btn-sm { min-height: var(--btn-h-sm); padding-inline: var(--space-3); font-size: var(--fs-sm); }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #0a0d14; }
.btn-secondary { background: var(--bg-surface); color: var(--text-main); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-main); }
.btn-danger { background: var(--danger); color: #fff; }
.btn:disabled { cursor: not-allowed; opacity: 0.55; transform: none; }

.icon-btn,
.header-notif-btn,
.modal-close {
  position: relative;
  display: inline-grid;
  width: var(--icon-btn);
  min-width: var(--icon-btn);
  height: var(--icon-btn);
  place-items: center;
  border-radius: var(--radius);
}

.icon-btn::after,
.header-notif-btn::after,
.modal-close::after {
  position: absolute;
  width: 44px;
  height: 44px;
  content: '';
}

.join-confirm-close,
.match-info-icon-btn,
.explore-back,
.btn-copy-code {
  position: relative;
}

.join-confirm-close::after,
.match-info-icon-btn::after,
.explore-back::after,
.btn-copy-code::after {
  position: absolute;
  width: 44px;
  height: 44px;
  content: '';
}

.form-input,
.form-select,
.form-textarea,
input,
select,
textarea {
  min-height: var(--input-h);
  border-radius: var(--radius);
  font-size: var(--fs-base);
}

.form-textarea,
textarea { min-height: calc(var(--input-h) * 2.5); resize: vertical; }

.badge,
.chip,
.filter-chip,
.status-chip {
  display: inline-flex;
  min-height: var(--btn-h-sm);
  align-items: center;
  gap: var(--space-1);
  padding-inline: var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
}

.card {
  padding: var(--card-pad);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.tabs,
.pills,
.filter-chips { display: flex; gap: var(--space-2); overflow-x: auto; }
.tab,
.pill { min-height: var(--btn-h-sm); padding-inline: var(--space-3); border-radius: var(--radius-pill); font-size: var(--fs-sm); }

.toggle { position: relative; width: calc(var(--btn-h-sm) * 1.7); height: var(--btn-h-sm); border-radius: var(--radius-pill); }

.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.data-table th,
.data-table td { min-height: var(--input-h); padding: var(--space-2) var(--space-3); }
.data-table th { position: sticky; top: 0; z-index: var(--z-base); }

.pagination { display: flex; min-height: var(--btn-h-sm); align-items: center; justify-content: center; gap: var(--space-2); }
.toast { z-index: var(--z-modal); padding: var(--card-pad); border-radius: var(--radius); box-shadow: var(--shadow-md); font-size: var(--fs-sm); }
.notification-item { padding: var(--card-pad); border-radius: var(--radius); }
.notification-bell { width: var(--icon-btn); height: var(--icon-btn); }
.bottom-nav .nav-item { min-height: var(--bottom-nav-h); font-size: var(--fs-xs); }
.desktop-nav-link { min-height: var(--btn-h-sm); font-size: var(--fs-sm); }

.modal,
.sheet,
.modal-content {
  z-index: var(--z-modal);
  padding: var(--card-pad);
  border-radius: var(--radius-lg);
}

.progress { display: grid; gap: var(--space-1); }
.progress__head { display: flex; justify-content: space-between; gap: var(--space-2); font-size: var(--fs-xs); }
.progress__track { height: var(--progress-h); overflow: hidden; border-radius: var(--radius-pill); background: var(--skel-base); }
.progress__fill { width: var(--p, 0%); height: 100%; border-radius: inherit; background: var(--success); transition: width var(--motion-slow) ease; }
.progress[data-state="filling"] .progress__fill { background: var(--warning); }
.progress[data-state="almost"] .progress__fill { background: var(--primary); }
.progress[data-state="full"] .progress__fill { background: var(--danger); }
.progress--sm { --progress-h: 4px; }
.progress--lg { --progress-h: 10px; }
.progress--steps .progress__fill { background: repeating-linear-gradient(90deg, var(--success) 0 18%, transparent 18% 20%); }

@media (prefers-reduced-motion: reduce) {
  .progress__fill { transition: none; }
}

.card-art {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 82% 18%, rgba(255, 122, 26, 0.55), transparent 42%),
    linear-gradient(135deg, #111827, #241049 55%, #071c36);
}
.card-art::after { position: absolute; inset: 0; background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.08), transparent 70%); content: ''; }
.card-art__icon { position: absolute; right: var(--space-3); bottom: var(--space-2); z-index: var(--z-base); color: rgba(255,255,255,0.32); }
.card-art__icon svg { width: var(--icon-btn); height: var(--icon-btn); fill: currentColor; }
.match-start-chip { position: absolute; right: var(--space-2); bottom: var(--space-2); z-index: calc(var(--z-base) + 1); padding: var(--space-1) var(--space-2); border-radius: var(--radius-pill); background: rgba(6,9,14,0.82); font-size: var(--fs-xs); }
.match-meta-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-1); font-size: var(--fs-xs); }
.match-meta-row span { min-width: 0; color: var(--text-muted); }
.match-meta-row strong { display: block; overflow: hidden; color: var(--text-main); text-overflow: ellipsis; white-space: nowrap; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.skeleton-group { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: var(--gap); width: 100%; }
.skeleton {
  display: block;
  overflow: hidden;
  border-radius: var(--skel-radius);
  background: linear-gradient(90deg, var(--skel-base) 25%, var(--skel-highlight) 50%, var(--skel-base) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer var(--skel-duration) linear infinite;
}
.skeleton--text { width: 72%; height: 0.9em; }
.skeleton--title { width: 54%; height: 1.3em; }
.skeleton--avatar { width: var(--icon-btn); height: var(--icon-btn); border-radius: 50%; }
.skeleton--btn { width: 100%; height: var(--btn-h); }
.skeleton--chip { width: 30%; height: var(--btn-h-sm); border-radius: var(--radius-pill); }
.skeleton--banner { width: 100%; aspect-ratio: 16 / 7; }
.skeleton-row { display: flex; min-height: var(--input-h); align-items: center; justify-content: space-between; gap: var(--gap); }
.skeleton-card { display: grid; gap: var(--space-2); padding: var(--card-pad); border-radius: var(--radius); background: var(--bg-surface); }
.skeleton-card--kpi { min-height: calc(var(--card-pad) * 5); }
.skeleton-row--table { padding: var(--space-2); border-bottom: 1px solid var(--border); }
.error-state,
.empty-state { display: grid; place-items: center; gap: var(--space-3); min-height: calc(var(--input-h) * 3); padding: var(--card-pad); text-align: center; }
@keyframes skeleton-shimmer { to { background-position-x: -200%; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; background-position: 0 0; } }

@media (max-width: 767px) {
  .match-card { max-height: none; overflow: visible; }
  .match-card-banner { height: clamp(88px, 26vw, 112px); min-height: clamp(88px, 26vw, 112px); }
  .match-card-body { gap: var(--space-1); padding: var(--space-2); }
  .match-card .btn { min-height: var(--btn-h-sm); }
}

/* Compact joined-match cards and details dialog across viewport sizes. */
#my-rooms-container {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 290px));
  gap: 10px;
}

#my-rooms-container .room-card {
  max-width: 290px;
  border-radius: 12px;
}

#my-rooms-container .room-card .match-card-banner {
  height: calc(var(--match-card-art-h) - var(--space-2));
  min-height: calc(var(--match-card-art-h) - var(--space-2));
}

#my-rooms-container .room-card .match-card-body {
  padding: 7px 9px 8px;
  gap: 3px;
}

#my-rooms-container .room-card .match-title {
  font-size: var(--fs-sm);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#my-rooms-container .room-card :is(.match-code-tag, .mode-tag, .badge, .metric-label, .metric-value) {
  font-size: var(--fs-xs);
}

#my-rooms-container .room-card :is(.credentials-vault, .room-card-expand) {
  margin-top: 2px;
}

#my-rooms-container .room-card .credentials-vault {
  padding: 5px 7px;
  font-size: var(--fs-xs);
}

.room-card-top-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.room-card-top-actions .match-info-icon-btn,
.room-card-top-actions .room-card-delete-btn {
  flex: 0 0 var(--space-6);
  width: var(--space-6);
  min-width: var(--space-6);
  height: var(--space-6);
  min-height: var(--space-6);
  aspect-ratio: 1;
  align-self: center;
  padding: 0;
  border-radius: 50%;
  box-sizing: border-box;
}

.room-card-top-actions .match-info-icon-btn {
  border-color: rgba(34, 197, 94, .45);
  background: rgba(34, 197, 94, .12);
  color: var(--success);
}

.room-card-top-actions .match-info-icon-btn svg {
  display: block;
  flex: 0 0 auto;
}

.room-card-delete-btn {
  width: var(--space-6);
  min-width: var(--space-6);
  height: var(--space-6);
  min-height: var(--space-6);
  padding: 0;
  border: 1px solid rgba(239, 68, 68, .38);
  border-radius: 50%;
  background: rgba(239, 68, 68, .1);
  color: var(--danger);
  font-size: var(--fs-base);
  line-height: 1;
  cursor: pointer;
}

#my-rooms-container .room-card .room-card-expand {
  min-height: calc(var(--btn-h-sm) - var(--space-1));
  height: calc(var(--btn-h-sm) - var(--space-1));
  padding: 3px 8px;
  font-size: var(--fs-xs);
}

#match-details-modal .modal-card {
  width: min(92vw, 560px);
  max-height: min(88dvh, 700px);
}

#match-details-modal .modal-header {
  min-height: 40px;
  padding: 5px 9px;
}

#match-details-modal .modal-header h3 { font-size: 14px; }
#match-details-modal .modal-body { padding: 7px 9px 9px; font-size: 11px; }
#match-details-modal .match-modal-hero { height: 68px; }
#match-details-modal .match-modal-hero h3 { font-size: 14px; }
#match-details-modal .match-modal-countdown { margin: 6px 0; padding: 6px 8px; font-size: 10px; }
#match-details-modal .match-decision-summary { gap: 6px; margin: 6px 0; padding: 7px; font-size: 10px; }
#match-details-modal .match-detail-tabs { margin-bottom: 7px; }
#match-details-modal .match-detail-tab { min-height: 30px; padding: 4px 2px; font-size: 9px; }
#match-details-modal .match-detail-panel { min-height: 90px; }
#match-details-modal .specs-table-grid { gap: 5px; margin-bottom: 7px; }
#match-details-modal .spec-cell { min-height: 44px; padding: 6px; }
#match-details-modal .spec-cell .cell-label { font-size: 9px; }
#match-details-modal .spec-cell .cell-value { font-size: 10px; }
#match-details-modal .match-rules-copy { padding: 8px; font-size: 10px; line-height: 1.35; }
#match-details-modal .match-actions-group .btn { min-height: var(--btn-h-sm); padding-block: 5px; font-size: var(--fs-xs); }

@media (max-width: 700px) {
  #my-rooms-container { grid-template-columns: minmax(0, 1fr); }
  #my-rooms-container .room-card { max-width: min(100%, 310px); }
  #match-details-modal { align-items: center; padding: 8px; background: rgba(5, 8, 13, .84); }
  #match-details-modal .modal-card {
    width: min(100%, 520px);
    height: min(92dvh, 680px);
    max-height: 92dvh;
    border: 1px solid var(--border);
    border-radius: 14px;
    transform: translateY(24px);
  }
  #match-details-modal.active .modal-card { transform: translateY(0); }
  #match-details-modal .modal-body { padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px)); }
  #match-details-modal .match-actions-group { margin-inline: -8px; padding-inline: 8px; }
}

#match-details-modal #match-details-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  color: var(--text-main);
  font-size: var(--fs-xs);
  line-height: 1.35;
  text-align: left;
}

#match-details-modal #match-details-content > * { margin-block: 0; }

#match-details-modal .match-modal-hero .hero-overlay,
#match-details-modal .match-rules-copy,
#match-details-modal .spec-cell,
#match-details-modal .match-slot-roster,
#match-details-modal .prize-breakdown-box {
  text-align: left;
}

#match-details-modal :is(
  .match-decision-summary,
  .spec-cell,
  .prize-breakdown-box,
  .rules-container-box,
  .match-slot-roster,
  .matches-element-style-8,
  .matches-element-style-16
) {
  border-radius: var(--radius-sm);
}

#match-details-modal .match-decision-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-1);
  padding: var(--space-2);
}

#match-details-modal .match-decision-summary > div,
#match-details-modal .spec-cell {
  min-height: 0;
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

#match-details-modal .match-decision-summary :is(dt, dd),
#match-details-modal .spec-cell :is(.cell-label, .cell-value) {
  margin: 0;
  font-size: var(--fs-xs);
  line-height: 1.3;
}

#match-details-modal .match-decision-summary :is(dt, .cell-label),
#match-details-modal .spec-cell .cell-label {
  color: var(--text-dim);
  font-weight: 600;
}

#match-details-modal .match-decision-summary dd,
#match-details-modal .spec-cell .cell-value {
  margin-top: var(--space-1);
  color: var(--text-main);
  font-weight: 700;
}

#match-details-modal :is(.prize-breakdown-box, .rules-container-box, .match-slot-roster) {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-2);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

#match-details-modal :is(.prize-box-title, .rules-container-box h4, .match-slot-roster h4) {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  color: var(--text-main);
  font-size: var(--fs-sm);
  line-height: 1.3;
}

#match-details-modal .prize-ranks-list { display: grid; gap: var(--space-1); }

#match-details-modal .prize-rank-row,
#match-details-modal .match-slot-row {
  min-height: 0;
  margin: 0;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  line-height: 1.3;
}

#match-details-modal .prize-rank-row :is(.rank-name, .rank-payout),
#match-details-modal .match-slot-row :is(span, strong) {
  min-width: 0;
  font-size: var(--fs-xs);
  overflow-wrap: anywhere;
}

#match-details-modal .match-rules-copy {
  display: grid;
  gap: var(--space-1);
  padding: 0;
  background: transparent;
  border: 0;
  font-size: var(--fs-xs);
}

#match-details-modal .match-rules-copy :is(.rule-language-block, p) {
  margin: 0;
  font-size: var(--fs-xs);
  line-height: 1.4;
}

#match-details-modal :is(.matches-element-style-8, .matches-element-style-16) {
  padding: var(--space-2);
  margin: 0;
  text-align: left;
}

#match-details-modal :is(.matches-element-style-9, .matches-element-style-10, .matches-element-style-17, .matches-element-style-18, .matches-element-style-19) {
  margin-block: 0;
  font-size: var(--fs-xs);
  line-height: 1.35;
}

#match-details-modal .match-unlock-note {
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  font-size: var(--fs-xs);
  text-align: left;
}

#match-details-modal .match-actions-group {
  gap: var(--space-1);
  margin-top: 0;
}

@media (max-width: 520px) {
  #match-details-modal .match-decision-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #match-details-modal .specs-table-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.admin-layout {
  --fs-base: var(--a-fs-base);
  --fs-sm: var(--a-fs-table);
  --fs-xs: var(--a-fs-label);
  --btn-h: var(--a-btn-h);
  --btn-h-sm: var(--a-btn-h-sm);
  --input-h: var(--a-input-h);
  --icon-btn: var(--a-icon-btn);
  --card-pad: var(--a-card-pad);
  --gap: var(--a-gap);
  --page-pad: var(--a-page-pad);
}

@media (width < 600px) {
  #matches-list-container { grid-template-columns: minmax(0, 1fr); }
}

@media (600px <= width < 1024px) {
  #matches-list-container { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  #matches-list-container { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

#matches-list-container .match-card { max-width: none; }

.tab-content {
  width: min(100%, var(--container-max));
  margin-inline: auto;
  padding-inline: var(--page-pad);
}

.filter-chips { position: sticky; top: calc(var(--header-h) + var(--safe-top)); z-index: var(--z-sticky); padding-block: var(--space-2); }
.match-day-header { position: sticky; top: calc(var(--header-h) + var(--btn-h-sm) + var(--safe-top)); z-index: var(--z-base); padding-block: var(--space-2); }

@media (max-width: 767px) {
  .modal-overlay.active {
    align-items: end;
    padding: 0 var(--safe-right) 0 var(--safe-left);
  }
  .modal-overlay.active .modal-card {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - var(--safe-top));
    margin: 0;
    padding-bottom: calc(var(--card-pad) + var(--safe-bottom));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}

@media (max-width: 700px) {
  #match-details-modal.active .modal-card {
    max-height: 100dvh;
    padding-bottom: 0;
    border-radius: 0;
  }
}

@media (min-width: 1024px) {
  #tab-home.active {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 24px;
  }
  #tab-home.active > * { margin-block: 0; }
  #tab-wallet .wallet-layout-wrap,
  #tab-profile > * { margin-inline: auto; }
}

.app-container .app-header {
  min-height: var(--header-h);
  flex-wrap: nowrap;
  padding-inline: var(--page-pad);
}

.app-header .header-actions,
.app-header .desktop-nav {
  align-items: center;
}

.app-header .header-actions > :is(button, .balance-pill),
.app-header .desktop-nav-link {
  flex: 0 0 auto;
  height: var(--btn-h-sm);
  min-height: var(--btn-h-sm);
  font-size: var(--fs-sm);
  white-space: nowrap;
}

.app-header .balance-pill {
  height: var(--balance-pill-h);
  min-height: var(--balance-pill-h);
}

.app-header #header-install-btn:not([hidden]) {
  display: inline-flex;
  justify-content: center;
}

.app-header .header-notif-btn { width: 36px; min-width: 36px; }
.bottom-nav .nav-item span { font-size: var(--fs-sm); }

.bottom-nav .nav-item {
  gap: 2px;
  padding-block: 4px;
}

.bottom-nav .nav-icon {
  width: var(--bottom-nav-icon-size);
  height: var(--bottom-nav-icon-size);
}

@media (max-width: 480px) {
  .app-header #header-install-btn:not([hidden]) {
    width: 36px;
    padding: 0;
    gap: 0;
    font-size: 0;
  }

  .app-header #header-install-btn svg { color: var(--accent); }
}

#tab-home {
  padding: var(--page-pad);
}

#tab-home > .hero-live-match {
  min-height: 172px;
  margin-block: 0 24px;
  backdrop-filter: none;
}

#hero-live-title {
  display: grid;
  align-items: center;
  min-height: 2.5em;
  line-height: 1.25;
}

#tab-home .esports-hero-banner {
  height: auto;
  max-height: none;
  padding: clamp(16px, 3vw, 28px);
  margin-bottom: 24px;
}

#tab-home .hero-title {
  font-size: clamp(24px, 3.2vw, 38px);
  line-height: 1.18;
}

#tab-home .hero-subtitle { font-size: clamp(14px, 1.5vw, 16px); }
#tab-home .section-heading { font-size: clamp(20px, 2vw, 24px); }
#tab-home .section-subheading,
#tab-home .mode-card-desc { font-size: var(--fs-sm); }
#tab-home .modes-card-grid { gap: 12px; }
#tab-home .mode-card { padding: 16px; }
#tab-home .mode-card-title { font-size: clamp(var(--fs-base), 2vw, var(--fs-h3)); }
#tab-home .home-upcoming-btn { width: 100%; margin-block: 16px 24px; }

:is(#matches-list-container, #my-rooms-container) {
  gap: 16px;
  padding-inline: 0;
}

:is(#matches-list-container, #my-rooms-container) :is(.tournament-match-card, .room-card) {
  max-height: none;
}

:is(#matches-list-container, #my-rooms-container) .match-card-banner {
  height: var(--card-art-h);
  min-height: var(--card-art-h);
}

:is(#matches-list-container, #my-rooms-container) .match-card-body {
  padding: 16px;
  gap: 10px;
}

:is(#matches-list-container, #my-rooms-container) .match-title {
  font-size: clamp(16px, 1.6vw, 18px);
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
  -webkit-line-clamp: unset;
}

:is(#matches-list-container, #my-rooms-container) .match-meta-row {
  font-size: 13px;
  flex-wrap: wrap;
}

:is(#matches-list-container, #my-rooms-container) :is(.match-card-body .btn, .room-card-expand) {
  min-height: var(--btn-h);
  height: auto;
}

#tab-wallet .wallet-layout-wrap { padding-inline: 0; }
@media (prefers-reduced-motion: no-preference) {
  .join-confirm-sheet,
  .join-confirm-panel { transition-duration: 320ms; }

  .app-confirm-sheet { animation-duration: 320ms; }

  #tab-matches.active .explore-grid,
  #tab-matches.active .mode-screen-header,
  #tab-matches.active.mode-screen-open #matches-list-container {
    animation: ap-mode-slide calc(160ms * var(--screen-animation-scale)) cubic-bezier(.22, 1, .36, 1) both;
  }

  #tab-matches.active .explore-grid { --mode-slide-start: -28px; }
}

@keyframes ap-mode-slide {
  from { opacity: .35; transform: translateX(var(--mode-slide-start, 28px)); }
  to { opacity: 1; transform: translateX(0); }
}

#explore-section .explore-card {
  border-color: rgba(248, 113, 113, .72);
  box-shadow: 0 0 8px rgba(239, 68, 68, .12);
}

.app-container .compact-back-btn,
#match-details-modal .modal-close.compact-back-btn,
.mode-screen-back-wrap .compact-back-btn {
  width: var(--btn-h);
  min-width: var(--btn-h);
  height: var(--btn-h);
  min-height: var(--btn-h);
  flex-basis: var(--btn-h);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elevated);
  box-shadow: none;
}

.back-link {
  gap: 8px;
  border-radius: 12px;
}

.back-link svg { flex-shrink: 0; }

@media (max-width: 599px) {
  #tab-home .modes-card-grid {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 76%;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding-bottom: 8px;
  }

  #tab-home .mode-card { scroll-snap-align: start; }
}

@media (prefers-reduced-motion: no-preference) {
  :is(button, .btn, .nav-item) {
    transition: transform var(--motion-fast) ease-out, background-color var(--motion-fast),
      border-color var(--motion-fast), color var(--motion-fast), opacity var(--motion-fast);
  }

}

#matches-list-container .skeleton-group { grid-column: 1 / -1; }
#matches-list-container .skeleton-card { min-height: var(--match-skeleton-h); }

.match-decision-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.match-decision-summary dd {
  margin: 4px 0 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.match-unlock-note { margin: 0 0 12px; }

#match-details-modal :is(.modal-body, .match-modal-hero, .match-rules-copy, .spec-cell) {
  text-align: center;
}

#match-details-modal :is(.match-modal-countdown, .match-detail-tabs) {
  justify-content: center;
}

@media (max-width: 767px) {
  #match-details-modal .match-actions-group {
    position: sticky;
    bottom: 0;
    z-index: var(--z-sticky);
    padding-block: 8px max(8px, var(--safe-bottom));
    background: var(--bg-surface);
  }
}

.app-container .tab-content:not(#tab-home) { padding-inline: var(--page-pad); }

.app-container :is(.rooms-header-card, .wallet-card, .profile-card),
.admin-layout .metric-card {
  padding: var(--card-pad);
}

.app-container :is(.rooms-header-card, .wallet-card, .profile-card) {
  margin-bottom: var(--space-4);
}

.admin-layout .admin-content {
  padding: var(--space-4) var(--a-page-pad) var(--space-8);
}

.admin-layout .admin-content:has(.admin-tab-pane.active:not(#admin-pane-dashboard)) {
  padding-inline: 12px;
}

.admin-layout .admin-topbar {
  min-height: var(--a-topbar-h);
  padding: 5px var(--a-page-pad);
}
.admin-layout .admin-topbar .topbar-title { font-size: 15px; }
.admin-layout .admin-topbar .hamburger-btn,
.admin-layout .admin-topbar .btn.btn-sm {
  width: auto;
  min-width: var(--a-input-h);
  height: var(--a-input-h);
  min-height: var(--a-input-h);
  padding: 5px 10px;
  font-size: var(--a-fs-table);
}
.admin-layout .admin-topbar .hamburger-btn { width: 36px; padding: 0; }
.admin-layout .table-card { margin-bottom: var(--space-4); }
.admin-layout .table-card .table-header { padding: var(--a-card-pad); }
.admin-layout .btn { min-height: var(--a-btn-h); height: auto; }
.admin-layout .btn.btn-sm { min-height: var(--a-btn-h-sm); }

@media (max-width: 600px) {
  .admin-layout .admin-topbar #btn-admin-sync-all {
    width: var(--a-input-h);
    min-width: var(--a-input-h);
    height: var(--a-input-h);
    min-height: var(--a-input-h);
    padding: 0;
  }
}

.app-container .tab-content > :is(.rooms-header-card, .compact-page-header, .wallet-layout-wrap, .profile-card, .compact-menu-list) {
  margin-inline: auto;
}

#tab-profile .page-back-bar {
  justify-content: flex-start;
  text-align: start;
}

#tab-menu .compact-menu-item > span:nth-child(2) {
  justify-self: stretch;
  text-align: left;
}

@media (prefers-reduced-motion: no-preference) {
  #tab-home .modes-carousel { overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
  #tab-home .modes-carousel::-webkit-scrollbar { display: none; }
  #tab-home .modes-carousel .mode-card { scroll-snap-align: start; }

  #tab-home .modes-carousel .modes-card-grid {
    display: grid;
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: calc((100% - 36px) / 4);
    overflow: visible;
  }
}

@media (600px <= width < 880px) and (prefers-reduced-motion: no-preference) {
  #tab-home .modes-carousel .modes-card-grid {
    grid-auto-columns: calc((100% - 24px) / 3);
  }
}

@media (max-width: 599px) and (prefers-reduced-motion: no-preference) {
  #tab-home .modes-carousel .modes-card-grid { grid-auto-columns: 76%; }
}

@media (prefers-reduced-motion: no-preference) {
  :is(.desktop-nav-link, .compact-back-btn, .admin-nav-item, .explore-chip, .match-detail-tab) {
    transition: transform var(--motion-fast) ease-out, background-color var(--motion-fast), color var(--motion-fast);
  }

}

#my-rooms-container .room-card {
  width: 100%;
  max-width: none;
}

#my-rooms-container .room-card .room-card-expand {
  width: 100%;
  margin: 0;
}

@media (max-width: 599px) {
  #my-rooms-container {
    padding-inline: 2px;
    gap: var(--space-2);
  }
}

/* Final match-details normalization: every panel stays readable and in flow. */
#match-details-modal #match-details-content,
#match-details-modal #match-details-content :is(.match-rules-copy, .spec-cell, .rules-container-box, .prize-breakdown-box, .match-slot-roster) {
  text-align: left;
}

#match-details-modal #match-details-content > * {
  flex: 0 0 auto;
}

#match-details-modal #match-details-content :is(.match-decision-summary, .specs-table-grid, .prize-ranks-list, .match-slot-roster, .match-rules-copy) {
  gap: var(--space-1);
}

#match-details-modal #match-details-content :is(.match-decision-summary > div, .spec-cell, .prize-rank-row, .match-slot-row, .match-unlock-note, .matches-element-style-8, .matches-element-style-16) {
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  line-height: 1.4;
}

#match-details-modal #match-details-content :is(.prize-box-title, .rules-container-box h4, .match-slot-roster h4, .matches-element-style-9, .matches-element-style-17) {
  font-size: var(--fs-sm);
  line-height: 1.35;
}

#match-details-modal #match-details-content :is(.match-rules-copy, .match-rules-copy p, .match-rules-copy strong, .prize-rank-row span, .match-slot-row span, .match-slot-row strong, .matches-element-style-10, .matches-element-style-18, .matches-element-style-19) {
  font-size: var(--fs-xs);
  line-height: 1.45;
}

#match-details-modal #match-details-content .match-detail-panel { min-height: 0; }

#match-details-modal #match-details-content .match-actions-group {
  position: static;
  inset: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

#my-rooms-container .room-card {
  width: 100%;
  max-width: 310px;
}

@media (max-width: 700px) {
  #match-details-modal .modal-card {
    width: min(100%, 430px);
    height: min(94dvh, 720px);
  }

  #match-details-modal #match-details-content {
    padding: var(--space-2);
    font-size: var(--fs-xs);
  }

  #match-details-modal #match-details-content .match-actions-group {
    position: static;
    margin: 0;
    padding: 0;
  }
}

#match-details-modal #match-details-content :is(.match-rules-copy, .match-rules-copy p, .prize-rank-row, .match-slot-row, .spec-cell .cell-value) {
  font-size: var(--fs-sm);
}

#my-rooms-container .room-card .match-title { font-size: var(--fs-base); }

#my-rooms-container .room-card :is(.match-code-tag, .mode-tag, .badge, .credentials-vault, .room-card-expand) {
  font-size: var(--fs-sm);
}
