:root {
  --safc-red: #C8102E;
  --safc-gold: #D4AF37;
  --bg-dark: #0F172A;
  --card-bg: #1E293B;
  --border-color: #334155;
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --green: #10B981;
}

* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
}

body { 
  background-color: var(--bg-dark); 
  color: var(--text-main); 
  min-height: 100vh; 
  padding-bottom: 90px; 
  overflow-x: hidden; 
}

.app-container { 
  max-width: 480px; 
  margin: 0 auto; 
  min-height: 100vh; 
  position: relative; 
  background: #0b1120; 
  box-shadow: 0 0 40px rgba(0,0,0,0.8); 
}

/* --- HEADER & BRAND --- */
header { 
  background: linear-gradient(180deg, #1e0508 0%, var(--bg-dark) 100%); 
  border-bottom: 2px solid var(--safc-red); 
  padding: 12px 16px; 
  position: sticky; 
  top: 0; 
  z-index: 50; 
}

.header-content { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
}

.brand { 
  display: flex; 
  align-items: center; 
  gap: 10px; 
}

.crest-badge { 
  width: 36px; 
  height: 36px; 
  border-radius: 50%; 
  background: linear-gradient(135deg, var(--safc-red), #fff); 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  font-weight: 900; 
  color: #000; 
  border: 2px solid var(--safc-gold); 
  font-size: 12px; 
}

.brand-title { 
  font-size: 15px; 
  font-weight: 800; 
}

.brand-sub { 
  font-size: 10px; 
  color: var(--safc-gold); 
  font-weight: 700; 
  text-transform: uppercase; 
}

/* --- ADMIN QUICK BAR --- */
.admin-bar { 
  background: var(--safc-red); 
  color: #fff; 
  font-size: 11px; 
  font-weight: 700; 
  padding: 6px 16px; 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
}

.admin-btn-pill { 
  background: var(--safc-gold); 
  color: #000; 
  font-weight: 800; 
  border: none; 
  padding: 3px 10px; 
  border-radius: 12px; 
  font-size: 10px; 
  cursor: pointer; 
  display: flex; 
  align-items: center; 
  gap: 4px; 
}

.badge-count { 
  background: #ef4444; 
  color: #fff; 
  font-size: 9px; 
  padding: 1px 5px; 
  border-radius: 10px; 
  font-weight: 900; 
}

/* --- TABS & CARDS --- */
.tab-view { 
  display: none; 
  padding: 14px; 
}

.tab-view.active { 
  display: block; 
}

.card { 
  background: var(--card-bg); 
  border: 1px solid var(--border-color); 
  border-radius: 12px; 
  padding: 14px; 
  margin-bottom: 12px; 
}

.card-title { 
  font-size: 13px; 
  font-weight: 700; 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  margin-bottom: 8px; 
}

/* --- BUTTONS & FORMS --- */
.btn { 
  width: 100%; 
  padding: 11px; 
  border-radius: 8px; 
  border: none; 
  font-weight: 700; 
  font-size: 13px; 
  cursor: pointer; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  gap: 6px; 
}

.btn-red { background: var(--safc-red); color: #fff; }
.btn-gold { background: var(--safc-gold); color: #000; }
.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-main); }
.btn-sm { padding: 5px 8px; font-size: 11px; width: auto; border-radius: 6px; }
.btn-block { width: 100%; }

.form-group { margin-bottom: 10px; }
.form-label { display: block; font-size: 10px; font-weight: 700; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; }
.form-input, .form-select { width: 100%; padding: 8px; border-radius: 6px; background: #0f172a; border: 1px solid var(--border-color); color: #fff; font-size: 12px; }

/* --- BOTTOM NAV & BADGES --- */
.bottom-nav { 
  position: fixed; 
  bottom: 0; 
  left: 0; 
  right: 0; 
  max-width: 480px; 
  margin: 0 auto; 
  background: rgba(15, 23, 42, 0.98); 
  border-top: 1px solid var(--border-color); 
  display: none; 
  justify-content: space-around; 
  padding: 8px 0; 
  z-index: 40; 
}

.nav-item { 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  gap: 2px; 
  background: none; 
  border: none; 
  color: var(--text-muted); 
  font-size: 9px; 
  font-weight: 600; 
  cursor: pointer; 
  width: 20%; 
  position: relative; 
}

.nav-item.active { color: var(--safc-red); }
.nav-icon { font-size: 17px; }

.nav-badges-wrap { position: absolute; top: -2px; right: 12px; display: flex; gap: 2px; }
.badge-red { background: #ef4444; color: #fff; font-size: 8px; font-weight: 900; padding: 1px 4px; border-radius: 8px; border: 1px solid #0f172a; }
.badge-gold { background: var(--safc-gold); color: #000; font-size: 8px; font-weight: 900; padding: 1px 4px; border-radius: 8px; border: 1px solid #0f172a; }

/* --- FUNDRAISER GRIDS --- */
.grid-40 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; max-height: 380px; overflow-y: auto; }
.grid-cell { background: #0f172a; border: 1px solid var(--border-color); border-radius: 6px; padding: 6px 2px; text-align: center; font-size: 9px; font-weight: 600; min-height: 40px; display: flex; flex-direction: column; justify-content: center; align-items: center; cursor: pointer; }
.grid-cell.claimed { background: #1e1b4b; border-color: #4338ca; cursor: not-allowed; }
.cell-owner { font-size: 8px; color: var(--safc-gold); font-weight: 700; margin-top: 2px; text-overflow: ellipsis; overflow: hidden; width: 100%; white-space: nowrap; padding: 0 1px; }

.grid-bonus { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.bonus-cell { background: #0f172a; border: 1px solid var(--border-color); border-radius: 6px; padding: 4px 1px; text-align: center; min-height: 40px; display: flex; flex-direction: column; justify-content: center; align-items: center; }

/* --- STANDARD MODALS --- */
.modal-backdrop { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.85); z-index: 100; align-items: flex-end; justify-content: center; }
.modal-sheet { background: var(--card-bg); border-radius: 20px 20px 0 0; width: 100%; max-width: 480px; padding: 18px; border-top: 3px solid var(--safc-red); max-height: 90vh; overflow-y: auto; }

#modal-confirm { z-index: 200 !important; }
#modal-ticket-thread { z-index: 220 !important; }
#modal-transcript { z-index: 250 !important; }

/* --- ADMIN DRAWER MODAL OVERLAY --- */
.hidden {
  display: none !important;
}

#admin-drawer,
#settings-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.98);
  backdrop-filter: blur(8px);
  z-index: 9999;
  overflow-y: auto;
  padding: 20px 16px 80px 16px;
  box-sizing: border-box;
}

#admin-drawer.hidden,
#settings-drawer.hidden {
  display: none !important;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--safc-gold);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.btn-close {
  background: #1e293b;
  border: 1px solid #475569;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close:hover {
  background: var(--safc-red);
  border-color: var(--safc-red);
}

/* --- ADMIN TOOL PICKER & DROPDOWN --- */
.admin-tool-picker-card {
  background: #0B1120;
  border: 1.5px solid var(--safc-gold);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 16px;
}

.tool-picker-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--safc-gold);
  letter-spacing: 0.8px;
  margin-bottom: 6px;
  display: block;
}

#admin-tool-select {
  width: 100%;
  background: #1E293B;
  color: #fff;
  border: 1px solid var(--border-color);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 12px;
  border-radius: 8px;
}

/* --- ADMIN PANES & UTILITIES --- */
.admin-pane {
  display: block;
  animation: fadeIn 0.15s ease-in-out;
}

.admin-pane.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.admin-card {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
}

.highlight-box {
  background: #0f172a;
  border: 1px solid #334155;
  padding: 12px;
  border-radius: 8px;
}

.treasury-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.text-xs { font-size: 11px; }
.text-muted { color: var(--text-muted); }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; }

/* ========================================================
   MODAL Z-INDEX FIX, PROFILE AVATAR & MULTI-BOOKING STYLES
   ======================================================== */

/* Ensure all modals & backdrops sit firmly above the admin drawer */
.modal-backdrop,
#modal-transcript,
#modal-confirm,
#modal-ticket-thread {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  z-index: 999999 !important;
}

.modal-sheet {
  position: relative !important;
  z-index: 1000000 !important;
  max-height: 85vh;
  overflow-y: auto;
}

/* Explicitly cap admin drawer beneath active dialogs */
.admin-drawer {
  z-index: 10000 !important;
}

/* Member Profile Card & Avatar */
.profile-header-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.profile-avatar-container {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.profile-avatar-img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--safc-gold, #facc15);
  background: #1e293b;
  display: block;
}

.profile-avatar-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: var(--safc-red, #dc2626);
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  border: 2px solid #0f172a;
}

/* Multi-Passenger Party Selection */
.party-member-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0f172a;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 11px;
  border-left: 3px solid var(--safc-gold, #facc15);
}

.party-member-row.lead {
  border-left-color: var(--safc-red, #dc2626);
}

.party-member-row.guest {
  border-left-color: #3b82f6;
}

.autocomplete-dropdown {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  max-height: 120px;
  overflow-y: auto;
  position: absolute;
  width: 100%;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.autocomplete-item {
  padding: 6px 10px;
  font-size: 11px;
  cursor: pointer;
  border-bottom: 1px solid #334155;
}

.autocomplete-item:hover {
  background: #334155;
  color: var(--safc-gold, #facc15);
}

/* Rich Announcement Images & Links */
.announcement-banner-img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 6px;
  margin: 8px 0;
  display: block;
}

.announcement-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #1e293b;
  color: var(--safc-gold, #facc15);
  border: 1px solid var(--safc-gold, #facc15);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  margin-top: 6px;
}

.announcement-link-btn:hover {
  background: var(--safc-gold, #facc15);
  color: #0f172a;
}

/* ========================================================
   UI SCALE ENGINE & WCAG 2.2 ACCESSIBILITY MODES
   ======================================================== */

   .size-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
  }
  
  .size-option-btn {
    background: #0f172a;
    border: 1.5px solid #334155;
    color: var(--text-muted);
    border-radius: 8px;
    padding: 10px 6px;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 54px;
  }
  
  .size-option-btn.active {
    background: rgba(212, 175, 55, 0.16);
    border-color: var(--safc-gold);
    color: #ffffff;
  }
  
  .settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #1e293b;
    cursor: pointer;
    font-size: 12px;
  }
  
  .settings-toggle-row:last-child {
    border-bottom: none;
  }
  
  .settings-toggle-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    accent-color: var(--safc-gold);
  }
  
  /* --- MEDIUM SCALE (DEFAULT: THUMB-FRIENDLY 44PX+ TARGETS) --- */
  [data-ui-size="medium"] .brand-title { font-size: 17px; }
  [data-ui-size="medium"] .brand-sub { font-size: 11.5px; }
  [data-ui-size="medium"] .crest-badge { width: 42px; height: 42px; font-size: 13px; }
  
  [data-ui-size="medium"] .btn {
    min-height: 46px;
    padding: 12px 14px;
    font-size: 15px;
  }
  
  [data-ui-size="medium"] .btn-sm {
    min-height: 38px;
    padding: 8px 12px;
    font-size: 13px;
  }
  
  [data-ui-size="medium"] .form-label {
    font-size: 12px !important;
    margin-bottom: 5px;
  }
  
  [data-ui-size="medium"] .form-input,
  [data-ui-size="medium"] .form-select {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 14px !important;
  }
  
  [data-ui-size="medium"] .bottom-nav { padding: 10px 0; }
  [data-ui-size="medium"] .nav-item { font-size: 11px; gap: 3px; }
  [data-ui-size="medium"] .nav-icon { font-size: 20px; }
  
  [data-ui-size="medium"] .card { padding: 16px; margin-bottom: 14px; }
  [data-ui-size="medium"] .card-title { font-size: 15px; }
  [data-ui-size="medium"] .text-xs { font-size: 13px !important; }
  [data-ui-size="medium"] .badge-gold,
  [data-ui-size="medium"] .badge-red { font-size: 11px !important; padding: 3px 7px !important; }
  
  [data-ui-size="medium"] [style*="font-size:9px"],
  [data-ui-size="medium"] [style*="font-size: 9px"] { font-size: 11.5px !important; }
  [data-ui-size="medium"] [style*="font-size:10px"],
  [data-ui-size="medium"] [style*="font-size: 10px"] { font-size: 12.5px !important; }
  [data-ui-size="medium"] [style*="font-size:11px"],
  [data-ui-size="medium"] [style*="font-size: 11px"] { font-size: 13.5px !important; }
  [data-ui-size="medium"] [style*="font-size:12px"],
  [data-ui-size="medium"] [style*="font-size: 12px"] { font-size: 14.5px !important; }
  [data-ui-size="medium"] [style*="font-size:13px"],
  [data-ui-size="medium"] [style*="font-size: 13px"] { font-size: 15px !important; }
  [data-ui-size="medium"] [style*="font-size:15px"],
  [data-ui-size="medium"] [style*="font-size: 15px"] { font-size: 17px !important; }
  [data-ui-size="medium"] [style*="font-size:16px"],
  [data-ui-size="medium"] [style*="font-size: 16px"] { font-size: 18.5px !important; }
  
  [data-ui-size="medium"] #football-grid button {
    min-height: 58px !important;
    padding: 8px 4px !important;
  }
  
  /* --- LARGE SCALE (COMFORT / OUTDOOR TERRACE MODE) --- */
  [data-ui-size="large"] .brand-title { font-size: 19px; }
  [data-ui-size="large"] .brand-sub { font-size: 12.5px; }
  [data-ui-size="large"] .crest-badge { width: 46px; height: 46px; font-size: 14px; }
  
  [data-ui-size="large"] .btn {
    min-height: 52px;
    padding: 14px 16px;
    font-size: 17px;
  }
  
  [data-ui-size="large"] .btn-sm {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 14.5px;
  }
  
  [data-ui-size="large"] .form-label {
    font-size: 13.5px !important;
    margin-bottom: 6px;
  }
  
  [data-ui-size="large"] .form-input,
  [data-ui-size="large"] .form-select {
    min-height: 50px;
    padding: 12px 14px;
    font-size: 16px !important;
  }
  
  [data-ui-size="large"] .bottom-nav { padding: 11px 0; }
  [data-ui-size="large"] .nav-item { font-size: 12px; gap: 4px; }
  [data-ui-size="large"] .nav-icon { font-size: 22px; }
  
  [data-ui-size="large"] .card { padding: 18px; margin-bottom: 16px; }
  [data-ui-size="large"] .card-title { font-size: 17px; }
  [data-ui-size="large"] .text-xs { font-size: 14.5px !important; }
  [data-ui-size="large"] .badge-gold,
  [data-ui-size="large"] .badge-red { font-size: 12.5px !important; padding: 4px 8px !important; }
  
  [data-ui-size="large"] [style*="font-size:9px"],
  [data-ui-size="large"] [style*="font-size: 9px"] { font-size: 13px !important; }
  [data-ui-size="large"] [style*="font-size:10px"],
  [data-ui-size="large"] [style*="font-size: 10px"] { font-size: 14px !important; }
  [data-ui-size="large"] [style*="font-size:11px"],
  [data-ui-size="large"] [style*="font-size: 11px"] { font-size: 15px !important; }
  [data-ui-size="large"] [style*="font-size:12px"],
  [data-ui-size="large"] [style*="font-size: 12px"] { font-size: 16px !important; }
  [data-ui-size="large"] [style*="font-size:13px"],
  [data-ui-size="large"] [style*="font-size: 13px"] { font-size: 17px !important; }
  [data-ui-size="large"] [style*="font-size:15px"],
  [data-ui-size="large"] [style*="font-size: 15px"] { font-size: 19px !important; }
  [data-ui-size="large"] [style*="font-size:16px"],
  [data-ui-size="large"] [style*="font-size: 16px"] { font-size: 21px !important; }
  
  [data-ui-size="large"] #football-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
  }
  [data-ui-size="large"] #football-grid button {
    min-height: 66px !important;
    padding: 10px 6px !important;
  }
  
  [data-ui-size="large"] [style*="grid-template-columns:1fr 1fr"],
  [data-ui-size="large"] [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  
  /* --- WCAG 2.2: REDUCE MOTION MODE --- */
  [data-reduce-motion="true"] *,
  [data-reduce-motion="true"] *::before,
  [data-reduce-motion="true"] *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  
  /* --- WCAG 2.2: COLOUR-BLIND SAFE PATTERNS & BORDERS --- */
  [data-colorblind-safe="true"] .badge-gold {
    border: 2px solid #ffffff !important;
    text-decoration: underline;
  }
  [data-colorblind-safe="true"] .badge-red {
    border: 2px dashed #ffffff !important;
  }
  [data-colorblind-safe="true"] #football-grid button[disabled] {
    border: 2px dashed #94a3b8 !important;
    background-image: repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.04),
      rgba(255, 255, 255, 0.04) 6px,
      transparent 6px,
      transparent 12px
    ) !important;
  }