/* ============================================
   KatChamp Theme System
   Dark Mode (default) + Light Mode
============================================ */

/* ============================================
   DARK MODE (Default)
============================================ */
:root {
  --bg-app: #000000;
  --bg-card: #1c1c1e;
  --bg-card-rgb: 28, 28, 30;
  --bg-glass: rgba(28, 28, 30, 0.65);
  --bg-input: #1c1c1e;
  --bg-gradient-start: #1a1a1a;
  --bg-gradient-end: #000000;
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-input: rgba(255, 255, 255, 0.15);
  
  --text-primary: #FFFFFF;
  --text-secondary: #8E8E93;
  --text-tertiary: #48484A;
  --text-on-accent: #FFFFFF;
  
  --accent-blue: #0A84FF;
  --accent-blue-dark: #0051a8;
  --accent-green: #30D158;
  --accent-red: #FF453A;
  --accent-orange: #FF9F0A;
  --accent-gold: #FFD60A;
  
  --tesla-red: #E82127;
  
  --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.3);
  --blur-strength: blur(20px);
  
  --overlay-bg: rgba(0, 0, 0, 0.7);
  --modal-bg: #1c1c1e;
  
  --radius-l: 22px;
  --radius-m: 14px;
  --radius-s: 8px;
  
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 24px);
  --android-nav-height: 48px;
  --nav-height: calc(70px + var(--safe-area-bottom));
  
  color-scheme: dark;
}

/* ============================================
   LIGHT MODE
============================================ */
:root.light-mode {
  --bg-app: #F2F2F7;
  --bg-card: #FFFFFF;
  --bg-card-rgb: 255, 255, 255;
  --bg-glass: rgba(255, 255, 255, 0.75);
  --bg-input: #FFFFFF;
  --bg-gradient-start: #E5E5EA;
  --bg-gradient-end: #F2F2F7;
  --border-subtle: rgba(0, 0, 0, 0.1);
  --border-input: rgba(0, 0, 0, 0.15);
  
  --text-primary: #000000;
  --text-secondary: #6C6C70;
  --text-tertiary: #AEAEB2;
  --text-on-accent: #FFFFFF;
  
  --accent-blue: #007AFF;
  --accent-blue-dark: #0051a8;
  --accent-green: #34C759;
  --accent-red: #FF3B30;
  --accent-orange: #FF9500;
  --accent-gold: #FFCC00;
  
  --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
  --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.08);
  
  --overlay-bg: rgba(0, 0, 0, 0.4);
  --modal-bg: #FFFFFF;
  
  color-scheme: light;
}

/* System preference detection */
@media (prefers-color-scheme: light) {
  :root:not(.dark-mode) {
    --bg-app: #F2F2F7;
    --bg-card: #FFFFFF;
    --bg-card-rgb: 255, 255, 255;
    --bg-glass: rgba(255, 255, 255, 0.75);
    --bg-input: #FFFFFF;
    --bg-gradient-start: #E5E5EA;
    --bg-gradient-end: #F2F2F7;
    --border-subtle: rgba(0, 0, 0, 0.1);
    --border-input: rgba(0, 0, 0, 0.15);
    
    --text-primary: #000000;
    --text-secondary: #6C6C70;
    --text-tertiary: #AEAEB2;
    --text-on-accent: #FFFFFF;
    
    --accent-blue: #007AFF;
    --accent-blue-dark: #0051a8;
    --accent-green: #34C759;
    --accent-red: #FF3B30;
    --accent-orange: #FF9500;
    --accent-gold: #FFCC00;
    
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
    --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.08);
    
    --overlay-bg: rgba(0, 0, 0, 0.4);
    --modal-bg: #FFFFFF;
    
    color-scheme: light;
  }
}

/* Android-specific safe area */
@supports not (padding-bottom: env(safe-area-inset-bottom)) {
  :root {
    --safe-area-bottom: 24px;
  }
}

/* ============================================
   RESET & BASE
============================================ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom, 48px);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-size: 16px;
  letter-spacing: -0.01em;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  overflow-anchor: none;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ============================================
   GLASS MORPHISM & CARDS
============================================ */
.card, .modal, .nav-tabs {
  background: var(--bg-card);
  transition: background-color 0.3s ease;
}

.glass {
  background: var(--bg-glass);
  backdrop-filter: var(--blur-strength);
  -webkit-backdrop-filter: var(--blur-strength);
}

/* ============================================
   FORM INPUTS (theme-aware)
============================================ */
input, select, textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  color: var(--text-primary);
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

input::placeholder, textarea::placeholder {
  color: var(--text-tertiary);
}

/* ============================================
   MODAL OVERLAY (theme-aware)
============================================ */
.modal-overlay {
  background: var(--overlay-bg);
}

.modal {
  background: var(--modal-bg);
}

/* ============================================
   THEME TOGGLE SPECIFIC STYLES
============================================ */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-m);
  margin-bottom: 8px;
}

.theme-toggle-switch {
  position: relative;
  width: 51px;
  height: 31px;
  background: var(--text-tertiary);
  border-radius: 16px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.theme-toggle-switch.active {
  background: var(--accent-blue);
}

.theme-toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.theme-toggle-switch.active::after {
  transform: translateX(20px);
}

/* Theme icon in toggle */
.theme-icon {
  font-size: 18px;
  transition: opacity 0.3s ease;
}

:root.light-mode .theme-icon-sun { opacity: 1; }
:root.light-mode .theme-icon-moon { opacity: 0.3; }
:root:not(.light-mode) .theme-icon-sun { opacity: 0.3; }
:root:not(.light-mode) .theme-icon-moon { opacity: 1; }
      }
    }

    /* ============================================
       RESET & BASE
    ============================================ */
    * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
    
    body {
      margin: 0;
      padding: 0;
      padding-bottom: env(safe-area-inset-bottom, 48px);
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
      background: var(--bg-app);
      color: var(--text-primary);
      height: 100vh;
      height: 100dvh;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      font-size: 16px;
      letter-spacing: -0.01em;
      -webkit-user-select: none;
      user-select: none;
    }
    
    /* Allow text selection in inputs and textareas */
    input, textarea {
      -webkit-user-select: text;
      user-select: text;
    }

    /* ============================================
       LAYOUT & UTILS
    ============================================ */
    .app-container {
      flex: 1;
      display: flex;
      flex-direction: column;
      overflow: hidden; /* Don't scroll the whole container */
      padding-bottom: var(--nav-height); /* Space for bottom tab bar */
    }
    
    #app-section {
      display: flex;
      flex-direction: column;
      height: 100vh;
      height: 100dvh; /* Dynamic viewport height for mobile */
      overflow: hidden;
    }
    
    #app-section.hidden {
      display: none !important;
    }
    
    /* Scrollable tournament feed */
    .tournament-feed-scroll {
      flex: 1;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      padding-bottom: calc(80px + env(safe-area-inset-bottom, 24px));
    }

    .hidden { display: none !important; }
    .text-center { text-align: center; }
    .fade-in { animation: fadeIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); }
    
    @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
    @keyframes slideUp { from { opacity: 0; transform: translateY(100px); } to { opacity: 1; transform: translateY(0); } }

    /* ============================================
       COMPONENTS: Glass Cards
    ============================================ */
    .glass-panel {
      background: var(--bg-card);
      border: 1px solid var(--border-subtle);
      border-radius: var(--radius-l);
      padding: 20px;
      margin-bottom: 16px;
      position: relative;
      overflow: hidden;
    }

    /* ============================================
       COMPONENTS: Inputs & Forms
    ============================================ */
    .form-group { margin-bottom: 20px; }
    
    label {
      display: block;
      margin-bottom: 8px;
      font-size: 13px;
      font-weight: 600;
      color: var(--text-secondary);
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }
    
    input, select {
      width: 100%;
      background: rgba(255,255,255,0.08);
      border: 1px solid transparent;
      border-radius: 12px;
      padding: 16px;
      color: #fff;
      font-size: 17px;
      font-family: inherit;
      transition: all 0.2s ease;
    }
    
    input:focus, select:focus {
      outline: none;
      background: rgba(255,255,255,0.12);
      border-color: var(--accent-blue);
    }
    
    /* Custom Select Arrow */
    select {
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238E8E93' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 16px center;
      appearance: none;
    }

    /* ============================================
       COMPONENTS: Buttons
    ============================================ */
    .btn {
      width: 100%;
      padding: 16px;
      border: none;
      border-radius: 14px;
      font-size: 17px;
      font-weight: 600;
      cursor: pointer;
      position: relative;
      overflow: hidden;
      transition: transform 0.1s;
    }
    
    .btn:active { transform: scale(0.96); }
    
    .btn-primary { 
      background: var(--accent-blue); 
      color: white;
      box-shadow: 0 4px 15px rgba(10, 132, 255, 0.3);
    }
    
    .btn-success { 
      background: var(--accent-green); 
      color: black; 
    }
    
    .btn-danger { 
      background: rgba(255, 69, 58, 0.15); 
      color: var(--accent-red); 
    }
    
    .btn-secondary { 
      background: var(--bg-highlight-strong); 
      color: white; 
    }
    
    .btn-warning { 
      background: var(--accent-orange); 
      color: black; 
    }
    
    .btn:disabled,
    .btn[disabled] {
      opacity: 0.4;
      cursor: not-allowed;
      pointer-events: none;
    }

    .btn-live {
      background: var(--accent-red);
      color: white;
      box-shadow: 0 4px 15px rgba(255, 69, 58, 0.3);
    }

    .notification-badge {
      position: absolute;
      top: -8px;
      right: -8px;
      min-width: 22px;
      height: 22px;
      background: var(--accent-red);
      color: white;
      font-size: 12px;
      font-weight: 700;
      border-radius: 11px;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0 6px;
      box-shadow: 0 2px 8px rgba(255, 69, 58, 0.5);
      animation: pulse-badge 2s ease-in-out infinite;
    }

    @keyframes pulse-badge {
      0%, 100% { transform: scale(1); }
      50% { transform: scale(1.1); }
    }

    /* ============================================
       AUTH SCREEN
    ============================================ */
    #auth-section {
      height: 100vh;
      display: flex;
      flex-direction: column;
      justify-content: center;
      padding: 24px;
      background: radial-gradient(circle at top right, #1a1a1a, #000);
    }
    
    .auth-logo {
      text-align: center;
      margin-bottom: 40px;
    }
    .auth-logo h1 { font-size: 28px; font-weight: 800; letter-spacing: -1px; margin: 0; }
    .auth-logo p { color: var(--text-secondary); margin-top: 8px; font-size: 15px; }

    .tabs {
      background: rgba(118, 118, 128, 0.24);
      padding: 2px;
      border-radius: 9px;
      display: flex;
      margin-bottom: 24px;
    }
    
    .tab {
      flex: 1;
      padding: 8px;
      border-radius: 7px;
      border: none;
      background: transparent;
      color: white;
      font-weight: 500;
      font-size: 13px;
    }
    
    .tab.active {
      background: rgba(99, 99, 102, 0.8);
      box-shadow: 0 3px 8px rgba(0,0,0,0.2);
    }

    /* Role Selection Cards */
    .role-card {
      background: var(--bg-card);
      border: 2px solid var(--border-subtle);
      border-radius: 16px;
      padding: 24px;
      cursor: pointer;
      transition: all 0.2s ease;
    }
    
    .role-card:active {
      transform: scale(0.98);
    }
    
    .role-card.selected {
      border-color: var(--accent-blue);
      background: rgba(10, 132, 255, 0.1);
    }

    /* Auth Wrapper (for email verification screen) */
    .auth-wrapper {
      height: 100vh;
      height: 100dvh;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      padding: 24px;
      background: radial-gradient(circle at top right, #1a1a1a, #000);
    }
    
    .auth-card {
      background: var(--bg-card);
      border: 1px solid var(--border-subtle);
      border-radius: var(--radius-l);
      padding: 32px 24px;
      width: 100%;
      max-width: 400px;
      box-shadow: var(--shadow-glass);
    }

    /* ============================================
       MEMBERSHIP CARD (Flip Card)
    ============================================ */
    .card-container {
      margin: 20px;
      height: 280px;
      perspective: 1000px;
    }
    
    .card-flipper {
      position: relative;
      width: 100%;
      height: 100%;
      transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
      transform-style: preserve-3d;
    }
    
    .card-container.flipped .card-flipper {
      transform: rotateY(180deg);
    }
    
    /* Disable pointer events on hidden face */
    .card-container .card-back {
      pointer-events: none;
    }
    .card-container.flipped .card-front {
      pointer-events: none;
    }
    .card-container.flipped .card-back {
      pointer-events: auto;
    }
    
    .card-front, .card-back {
      position: absolute;
      width: 100%;
      height: 100%;
      backface-visibility: hidden;
      border-radius: 24px;
      padding: 20px;
      padding-bottom: 80px;
      display: flex;
      flex-direction: column;
      border: 1px solid var(--border-subtle);
      box-shadow: var(--shadow-card);
    }
    
    .card-front {
      background: linear-gradient(135deg, #1a3a52, #0a1628);
    }
    
    .card-back {
      background: linear-gradient(135deg, #2d1f3d, #1a0a28);
      transform: rotateY(180deg);
    }
    
    .card-header {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      margin-bottom: 12px;
    }
    
    .card-badge {
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 1px;
      color: var(--accent-blue);
    }
    
    .card-back .card-badge {
      color: var(--accent-orange);
    }
    
    .card-member-since {
      font-size: 10px;
      color: var(--text-secondary);
    }
    
    .card-profile {
      display: flex;
      align-items: center;
      gap: 12px;
      margin-bottom: 16px;
    }
    
    .card-avatar {
      width: 48px;
      height: 48px;
      border-radius: 50%;
      background: linear-gradient(135deg, var(--accent-blue), #0050a0);
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 700;
      font-size: 18px;
    }
    
    .card-name {
      font-size: 18px;
      font-weight: 700;
    }
    
    .card-location {
      font-size: 12px;
      color: var(--text-secondary);
    }
    
    .card-stats {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 6px;
      flex: 1;
    }
    
    .card-stat {
      background: rgba(255,255,255,0.05);
      border-radius: 10px;
      padding: 8px 6px;
      text-align: center;
    }
    
    .card-stat-value {
      font-size: 15px;
      font-weight: 700;
      color: #fff;
    }
    
    .card-stat-label {
      font-size: 9px;
      color: var(--text-secondary);
      text-transform: uppercase;
      margin-top: 2px;
    }
    
    .card-balance-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding-top: 12px;
      border-top: 1px solid var(--border-subtle);
      position: absolute;
      bottom: 16px;
      left: 20px;
      right: 20px;
    }
    
    .card-balance {
      display: flex;
      align-items: center;
      gap: 8px;
    }
    
    .card-balance-amount {
      font-size: 20px;
      font-weight: 700;
      color: var(--accent-green);
    }
    
    .card-flip-btn {
      background: var(--bg-highlight-strong);
      border: none;
      color: var(--text-secondary);
      font-size: 11px;
      padding: 6px 12px;
      border-radius: 20px;
      cursor: pointer;
    }
    
    .card-add-btn {
      background: var(--accent-green);
      border: none;
      color: #000;
      font-size: 12px;
      font-weight: 600;
      padding: 8px 16px;
      border-radius: 20px;
      cursor: pointer;
    }

    /* ============================================
       APP HEADER
    ============================================ */
    .header-dynamic {
      padding: calc(var(--safe-area-top) + 16px) 20px 10px 20px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      background: rgba(0,0,0,0.8);
      backdrop-filter: blur(10px);
      position: sticky;
      top: 0;
      z-index: 50;
    }
    
    .header-title { font-size: 24px; font-weight: 700; }
    .header-user { display: flex; align-items: center; gap: 10px; }
    .avatar-circle {
      width: 36px; height: 36px;
      background: linear-gradient(135deg, #333, #555);
      border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      font-weight: 600; font-size: 14px;
    }

    /* ============================================
       WALLET CARD (Apple Wallet Style)
    ============================================ */
    .wallet-card {
      margin: 20px;
      height: 200px;
      border-radius: 24px;
      background: linear-gradient(135deg, #2c3e50, #000000);
      position: relative;
      padding: 24px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      box-shadow: var(--shadow-card);
      border: 1px solid var(--border-subtle);
      overflow: hidden;
    }
    
    /* Mesh Gradient Effect */
    .wallet-card::before {
      content: '';
      position: absolute;
      top: -50%; right: -50%;
      width: 100%; height: 100%;
      background: radial-gradient(circle, rgba(10, 132, 255, 0.4), transparent 60%);
      filter: blur(40px);
    }
    
    .wallet-label { font-size: 12px; text-transform: uppercase; opacity: 0.7; letter-spacing: 1px; }
    .wallet-balance { font-size: 38px; font-weight: 700; color: white; margin-top: 4px; }
    .wallet-chip {
      width: 45px; height: 30px;
      background: linear-gradient(135deg, #e2e2e2 0%, #a0a0a0 100%);
      border-radius: 6px;
      opacity: 0.8;
    }

    /* ============================================
       TOURNAMENT LIST ITEMS
    ============================================ */
    .list-item {
      background: rgba(28, 28, 30, 0.6);
      border-radius: 16px;
      padding: 16px;
      margin: 0 20px 12px 20px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      border: 1px solid rgba(255,255,255,0.05);
    }
    
    .list-content h3 { margin: 0 0 4px 0; font-size: 16px; font-weight: 600; }
    .list-content p { margin: 0; font-size: 13px; color: var(--text-secondary); }
    
    .status-pill {
      font-size: 11px;
      font-weight: 700;
      padding: 4px 8px;
      border-radius: 100px;
      text-transform: uppercase;
    }
    .status-pill.live { background: var(--accent-red); color: white; animation: pulse 2s infinite; }
    .status-pill.upcoming { background: rgba(10, 132, 255, 0.2); color: var(--accent-blue); }
    .status-pill.completed { background: var(--bg-highlight-strong); color: var(--text-secondary); }
    .status-pill.registered { background: rgba(48, 209, 88, 0.2); color: var(--accent-green); }

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

    /* ============================================
       BOTTOM NAVIGATION (Tab Bar)
    ============================================ */
    /* Single FAB Navigation */
    .fab-container {
      position: fixed;
      bottom: calc(24px + env(safe-area-inset-bottom, 48px));
      left: 50%;
      transform: translateX(-50%);
      z-index: 500;
    }
    
    .main-fab {
      width: 60px;
      height: 60px;
      border-radius: 50%;
      background: var(--accent-blue);
      border: none;
      color: white;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      box-shadow: 0 4px 20px rgba(10, 132, 255, 0.4);
      transition: all 0.2s;
    }
    
    .main-fab:active {
      transform: scale(0.95);
    }
    
    .main-fab.live {
      background: var(--accent-green);
      box-shadow: 0 0 20px rgba(48, 209, 88, 0.6), 0 0 40px rgba(48, 209, 88, 0.3);
      animation: fab-glow 2s ease-in-out infinite;
    }
    
    .main-fab.live.action-ready {
      background: linear-gradient(135deg, var(--accent-green), var(--accent-blue));
      box-shadow: 0 0 25px rgba(48, 209, 88, 0.7), 0 0 50px rgba(10, 132, 255, 0.4);
      animation: fab-glow-action 1.5s ease-in-out infinite;
    }
    
    @keyframes fab-glow {
      0%, 100% { box-shadow: 0 0 20px rgba(48, 209, 88, 0.6), 0 0 40px rgba(48, 209, 88, 0.3); }
      50% { box-shadow: 0 0 30px rgba(48, 209, 88, 0.8), 0 0 60px rgba(48, 209, 88, 0.5); }
    }
    
    @keyframes fab-glow-action {
      0%, 100% { 
        box-shadow: 0 0 25px rgba(48, 209, 88, 0.7), 0 0 50px rgba(10, 132, 255, 0.4);
        transform: scale(1);
      }
      50% { 
        box-shadow: 0 0 35px rgba(48, 209, 88, 0.9), 0 0 70px rgba(10, 132, 255, 0.6);
        transform: scale(1.05);
      }
    }
    
    .main-fab.pending-review {
      background: var(--accent-orange);
      box-shadow: 0 0 20px rgba(255, 159, 10, 0.6), 0 0 40px rgba(255, 159, 10, 0.3);
      animation: fab-glow-gold 2s ease-in-out infinite;
    }
    
    @keyframes fab-glow-gold {
      0%, 100% { box-shadow: 0 0 20px rgba(255, 159, 10, 0.6), 0 0 40px rgba(255, 159, 10, 0.3); }
      50% { box-shadow: 0 0 30px rgba(255, 159, 10, 0.8), 0 0 60px rgba(255, 159, 10, 0.5); }
    }
    
    .main-fab svg {
      width: 28px;
      height: 28px;
    }
    
    /* Events Modal Tabs */
    .events-tab {
      flex: 1;
      padding: 12px 16px;
      border: none;
      background: rgba(255,255,255,0.08);
      color: var(--text-secondary);
      font-size: 14px;
      font-weight: 600;
      border-radius: 10px;
      cursor: pointer;
      transition: all 0.2s;
    }
    
    .events-tab.active {
      background: var(--accent-blue);
      color: white;
    }

    /* ============================================
       MODAL (Bottom Sheet)
    ============================================ */
    .modal-overlay {
      position: fixed;
      top: 0; left: 0; right: 0; bottom: 0;
      background: var(--overlay-bg);
      backdrop-filter: blur(5px);
      z-index: 1000;
      display: none;
      align-items: flex-end; /* Align to bottom */
      opacity: 0;
      transition: opacity 0.3s;
    }
    
    .modal-overlay.active { display: flex; opacity: 1; }
    
    .modal {
      background: var(--bg-card);
      width: 100%;
      max-height: 90vh;
      border-radius: 24px 24px 0 0;
      padding: 24px;
      padding-bottom: calc(60px + env(safe-area-inset-bottom, 60px));
      transform: translateY(100%);
      transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
      overflow-y: auto;
      border-top: 1px solid var(--border-subtle);
      position: relative;
    }
    
    .modal-overlay.active .modal { transform: translateY(0); }
    
    .modal-title { font-size: 20px; font-weight: 700; margin-bottom: 24px; }

    /* Centered Dialog Modals (confirm, prompt) */
    .modal-overlay.centered {
      align-items: center;
      justify-content: center;
      padding: 20px;
      z-index: 2000; /* Above other modals */
    }
    
    .modal-overlay.centered .modal {
      width: auto;
      min-width: 300px;
      max-width: 360px;
      border-radius: 20px;
      transform: scale(0.9);
      opacity: 0;
    }
    
    .modal-overlay.centered.active .modal {
      transform: scale(1);
      opacity: 1;
    }
    
    .modal-close { 
      position: absolute; 
      top: 16px; 
      right: 16px; 
      background: var(--bg-highlight-strong); 
      border: none; 
      width: 32px; 
      height: 32px; 
      border-radius: 50%; 
      color: #fff; 
      font-size: 18px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: background 0.2s;
    }
    .modal-close:hover {
      background: rgba(255,255,255,0.2);
    }

    /* ============================================
       STATUS TOAST
    ============================================ */
    #status {
      position: fixed;
      top: calc(var(--safe-area-top) + 10px);
      left: 50%;
      transform: translateX(-50%);
      padding: 10px 20px;
      border-radius: 50px;
      font-size: 13px;
      font-weight: 600;
      z-index: 10000;
      backdrop-filter: blur(10px);
      box-shadow: 0 4px 12px rgba(0,0,0,0.2);
      transition: all 0.3s;
      opacity: 0;
      pointer-events: none;
    }
    #status.info { background: var(--bg-highlight-strong); color: white; opacity: 1; }
    #status.success { background: rgba(48, 209, 88, 0.2); color: var(--accent-green); border: 1px solid var(--accent-green); opacity: 1; }
    #status.error { background: rgba(255, 69, 58, 0.2); color: var(--accent-red); border: 1px solid var(--accent-red); opacity: 1; }
    #status.warning { background: rgba(255, 159, 10, 0.2); color: var(--accent-orange); border: 1px solid var(--accent-orange); opacity: 1; }

    /* ============================================
       PROFILE DROPDOWN MENU
    ============================================ */
    .avatar-circle {
      cursor: pointer;
      transition: transform 0.2s, box-shadow 0.2s;
    }
    .avatar-circle:active {
      transform: scale(0.95);
    }

    .profile-menu {
      position: fixed;
      top: calc(var(--safe-area-top) + 60px);
      right: 16px;
      background: var(--bg-card);
      border: 1px solid var(--border-subtle);
      border-radius: 16px;
      min-width: 200px;
      z-index: 200;
      overflow: hidden;
      box-shadow: var(--shadow-card);
      animation: slideDown 0.2s ease;
    }

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

    .profile-menu.hidden {
      display: none;
    }

    .profile-menu-header {
      padding: 16px;
      border-bottom: 1px solid var(--border-subtle);
      background: rgba(255,255,255,0.03);
    }

    .profile-menu-item {
      padding: 14px 16px;
      cursor: pointer;
      transition: background 0.2s;
      font-size: 15px;
    }

    .profile-menu-item:hover, .profile-menu-item:active {
      background: rgba(255,255,255,0.05);
    }

    .profile-menu-overlay {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      z-index: 199;
    }

    .profile-menu-overlay.hidden {
      display: none;
    }

    /* Email Preferences */
    .email-pref-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 14px 0;
      border-bottom: 1px solid var(--border-subtle);
      cursor: pointer;
    }
    .email-pref-item span {
      font-size: 14px;
      color: var(--text-primary);
    }
    .email-pref-item input[type="checkbox"] {
      width: 22px;
      height: 22px;
      accent-color: var(--accent-blue);
    }

    /* ============================================
       YOUTUBE LIVE TABS
    ============================================ */
    .yt-tab {
      flex: 1;
      padding: 12px;
      background: transparent;
      border: none;
      color: var(--text-secondary);
      font-size: 14px;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.2s;
    }

    .yt-tab.active {
      color: var(--accent-blue);
      border-bottom: 2px solid var(--accent-blue);
    }

    /* ============================================
       CHAT STYLES
    ============================================ */
    .chat-unread-badge {
      position: absolute;
      top: 4px;
      right: 4px;
      background: var(--accent-red);
      color: white;
      font-size: 10px;
      font-weight: 700;
      min-width: 16px;
      height: 16px;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0 4px;
    }
    
    .chat-unread-badge.hidden {
      display: none;
    }
    
    .chat-list {
      flex: 1;
      overflow-y: auto;
      padding: 16px;
    }
    
    .chat-room-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 14px;
      background: rgba(255,255,255,0.03);
      border-radius: 12px;
      margin-bottom: 10px;
      cursor: pointer;
      transition: background 0.2s;
    }
    
    .chat-room-item:active {
      background: rgba(255,255,255,0.08);
    }
    
    .chat-room-icon {
      width: 44px;
      height: 44px;
      border-radius: 12px;
      background: var(--accent-blue);
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }
    
    .chat-room-icon.announcement {
      background: var(--accent-orange);
    }
    
    .chat-room-icon.dm {
      background: var(--accent-green);
    }
    
    .chat-room-info {
      flex: 1;
      min-width: 0;
    }
    
    .chat-room-name {
      font-weight: 600;
      font-size: 15px;
      margin-bottom: 2px;
    }
    
    .chat-room-preview {
      font-size: 13px;
      color: var(--text-secondary);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    
    .chat-room-meta {
      text-align: right;
      flex-shrink: 0;
    }
    
    .chat-room-time {
      font-size: 11px;
      color: var(--text-tertiary);
    }
    
    .chat-room-unread {
      background: var(--accent-blue);
      color: white;
      font-size: 11px;
      font-weight: 700;
      min-width: 18px;
      height: 18px;
      border-radius: 9px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      margin-top: 4px;
    }
    
    .chat-messages {
      flex: 1;
      overflow-y: auto;
      padding: 16px;
      display: flex;
      flex-direction: column;
      gap: 12px;
    }
    
    .chat-message {
      max-width: 80%;
      padding: 10px 14px;
      border-radius: 16px;
      font-size: 14px;
      line-height: 1.4;
    }
    
    .chat-message.incoming {
      background: var(--bg-highlight-strong);
      align-self: flex-start;
      border-bottom-left-radius: 4px;
    }
    
    .chat-message.outgoing {
      background: var(--accent-blue);
      align-self: flex-end;
      border-bottom-right-radius: 4px;
    }
    
    .chat-message.announcement {
      background: rgba(255, 159, 10, 0.2);
      border: 1px solid rgba(255, 159, 10, 0.3);
      align-self: stretch;
      max-width: 100%;
      text-align: center;
    }
    
    .chat-message-sender {
      font-size: 11px;
      font-weight: 600;
      color: var(--accent-blue);
      margin-bottom: 4px;
    }
    
    .chat-message-time {
      font-size: 10px;
      color: var(--text-tertiary);
      margin-top: 4px;
    }
    
    .chat-message.outgoing .chat-message-time {
      color: rgba(255,255,255,0.6);
    }
    
    .chat-input-bar {
      display: flex;
      gap: 10px;
      padding: 12px 16px;
      padding-bottom: calc(12px + env(safe-area-inset-bottom, 48px));
      background: var(--bg-overlay-dark);
      border-top: 1px solid var(--border-subtle);
    }
    
    .chat-input {
      flex: 1;
      padding: 12px 16px;
      border: 1px solid var(--border-subtle);
      border-radius: 20px;
      background: rgba(255,255,255,0.05);
      color: white;
      font-size: 15px;
      font-family: inherit;
      outline: none;
    }
    
    .chat-input:focus {
      border-color: var(--accent-blue);
    }
    
    .chat-send-btn {
      width: 44px;
      height: 44px;
      border-radius: 22px;
      background: var(--accent-blue);
      border: none;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      flex-shrink: 0;
    }
    
    .chat-send-btn:disabled {
      opacity: 0.5;
    }
    
    .chat-empty {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      color: var(--text-secondary);
      padding: 40px;
      text-align: center;
    }
    
    .chat-empty svg {
      margin-bottom: 16px;
      opacity: 0.3;
    }
    
    .chat-pending-indicator {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 16px;
      background: rgba(255, 159, 10, 0.15);
      color: var(--accent-orange);
      font-size: 12px;
    }
    
    .chat-connection-status {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 6px 12px;
      font-size: 11px;
      color: var(--text-secondary);
    }
    
    .chat-connection-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: var(--accent-red);
    }
    
    .chat-connection-dot.connected {
      background: var(--accent-green);
    }
    
    /* Chat notification toast */
    .chat-notification-toast {
      position: fixed;
      top: 20px;
      left: 50%;
      transform: translateX(-50%) translateY(-100px);
      background: var(--bg-card);
      border: 1px solid var(--border-subtle);
      border-radius: 16px;
      padding: 12px 16px;
      display: flex;
      align-items: center;
      gap: 12px;
      box-shadow: var(--shadow-card);
      z-index: 9999;
      cursor: pointer;
      max-width: 90%;
      width: 340px;
      transition: transform 0.3s ease;
    }
    
    .chat-notification-toast.show {
      transform: translateX(-50%) translateY(0);
    }
    
    .chat-notification-icon {
      font-size: 24px;
      flex-shrink: 0;
    }
    
    .chat-notification-content {
      flex: 1;
      min-width: 0;
    }
    
    .chat-notification-title {
      font-weight: 600;
      font-size: 14px;
      margin-bottom: 2px;
    }
    
    .chat-notification-body {
      font-size: 13px;
      color: var(--text-secondary);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    
    /* Typing indicator */
    .typing-indicator {
      padding: 8px 16px;
      font-size: 13px;
      color: var(--text-secondary);
      display: flex;
      align-items: center;
      gap: 8px;
      border-top: 1px solid var(--border-subtle);
      background: var(--bg-elevated);
    }
    
    .typing-dots {
      display: inline-flex;
      gap: 3px;
    }
    
    .typing-dots::before,
    .typing-dots::after,
    .typing-dots span {
      content: '';
      width: 6px;
      height: 6px;
      background: var(--text-secondary);
      border-radius: 50%;
      animation: typingBounce 1.4s infinite ease-in-out;
    }
    
    .typing-dots::before {
      animation-delay: 0s;
    }
    
    .typing-dots::after {
      animation-delay: 0.2s;
    }
    
    @keyframes typingBounce {
      0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.4;
      }
      40% {
        transform: translateY(-4px);
        opacity: 1;
      }
    }
    
    /* Hide scrollbar for carousel */
    #carousel-scroll::-webkit-scrollbar {
      display: none;
    }
    
    /* Spin animation for refresh */
    @keyframes spin {
      from { transform: rotate(0deg); }
      to { transform: rotate(360deg); }
    }

    /* ============================================
       WEIGH-IN MODE STYLES
    ============================================ */
    .weighin-success-toast {
      position: fixed;
      top: calc(var(--safe-area-top) + 10px);
      left: 50%;
      transform: translateX(-50%) translateY(-100px);
      background: rgba(48, 209, 88, 0.2);
      color: var(--accent-green);
      border: 1px solid var(--accent-green);
      padding: 12px 24px;
      border-radius: 50px;
      font-size: 14px;
      font-weight: 600;
      z-index: 10001;
      backdrop-filter: blur(10px);
      box-shadow: 0 4px 12px rgba(0,0,0,0.2);
      opacity: 0;
      transition: all 0.3s ease;
    }
    .weighin-success-toast.show {
      transform: translateX(-50%) translateY(0);
      opacity: 1;
    }
    
    .fish-row {
      display: grid;
      grid-template-columns: 1fr 120px 40px;
      gap: 8px;
      margin-bottom: 8px;
      align-items: center;
    }
    .fish-row input {
      padding: 12px;
    }
    .fish-row select {
      padding: 12px;
    }
    .fish-row .remove-fish {
      background: rgba(239, 68, 68, 0.2);
      border: none;
      color: var(--accent-red);
      width: 40px;
      height: 44px;
      border-radius: 8px;
      font-size: 18px;
      cursor: pointer;
    }
    
    .boat-grid-btn {
      padding: 14px 10px;
      border-radius: 10px;
      font-weight: 700;
      font-size: 16px;
      cursor: pointer;
      border: 1px solid var(--border-subtle);
      transition: all 0.15s ease;
    }
    .boat-grid-btn.pending {
      background: var(--bg-highlight);
      color: white;
    }
    .boat-grid-btn.weighed {
      background: rgba(48, 209, 88, 0.2);
      color: var(--accent-green);
      border-color: var(--accent-green);
    }
    .boat-grid-btn.dq {
      background: rgba(255, 69, 58, 0.2);
      color: var(--accent-red);
      border-color: var(--accent-red);
      text-decoration: line-through;
    }
    .boat-grid-btn.dns {
      background: rgba(255, 69, 58, 0.2);
      color: var(--accent-red);
      border-color: var(--accent-red);
      text-decoration: line-through;
    }
    .boat-grid-btn.withdrawn {
      background: rgba(255, 255, 255, 0.03);
      color: var(--text-tertiary);
      border-color: var(--border-subtle);
      opacity: 0.5;
    }
    .boat-grid-btn:active {
      transform: scale(0.95);
    }

    /* Pull-to-refresh styles */
    #pull-refresh-indicator {
      position: fixed;
      top: 0;
      left: 50%;
      transform: translateX(-50%) translateY(-100%);
      z-index: 1000;
      background: var(--bg-card);
      border-radius: 0 0 20px 20px;
      padding: 12px 24px;
      display: flex;
      align-items: center;
      gap: 10px;
      box-shadow: 0 4px 20px rgba(0,0,0,0.3);
      transition: transform 0.2s ease-out;
      border: 1px solid var(--border-subtle);
      border-top: none;
    }
    
    #pull-refresh-indicator.visible {
      transform: translateX(-50%) translateY(0);
    }
    
    #pull-refresh-indicator.pulling {
      transform: translateX(-50%) translateY(var(--pull-progress, 0px));
    }
    
    .pull-refresh-spinner {
      width: 20px;
      height: 20px;
      border: 2px solid var(--border-subtle);
      border-top-color: var(--accent-blue);
      border-radius: 50%;
    }
    
    .pull-refresh-spinner.spinning {
      animation: spin 0.8s linear infinite;
    }
    
    #pull-refresh-indicator .pull-arrow {
      transition: transform 0.2s ease;
    }
    
    #pull-refresh-indicator.ready .pull-arrow {
      transform: rotate(180deg);
    }


/* ============================================
   ADDITIONAL THEME VARIABLES
============================================ */
:root {
  /* Overlay/highlight colors for dark mode */
  --bg-highlight: rgba(255, 255, 255, 0.08);
  --bg-highlight-strong: rgba(255, 255, 255, 0.12);
  --bg-highlight-subtle: rgba(255, 255, 255, 0.05);
  --bg-overlay-dark: rgba(0, 0, 0, 0.6);
  --bg-overlay-medium: rgba(0, 0, 0, 0.4);
  --bg-surface: #000000;
}

:root.light-mode {
  /* Overlay/highlight colors for light mode */
  --bg-highlight: rgba(0, 0, 0, 0.06);
  --bg-highlight-strong: rgba(0, 0, 0, 0.1);
  --bg-highlight-subtle: rgba(0, 0, 0, 0.03);
  --bg-overlay-dark: rgba(0, 0, 0, 0.5);
  --bg-overlay-medium: rgba(0, 0, 0, 0.3);
  --bg-surface: #F2F2F7;
}

@media (prefers-color-scheme: light) {
  :root:not(.dark-mode) {
    --bg-highlight: rgba(0, 0, 0, 0.06);
    --bg-highlight-strong: rgba(0, 0, 0, 0.1);
    --bg-highlight-subtle: rgba(0, 0, 0, 0.03);
    --bg-overlay-dark: rgba(0, 0, 0, 0.5);
    --bg-overlay-medium: rgba(0, 0, 0, 0.3);
    --bg-surface: #F2F2F7;
  }
}

    /* Split option buttons */
    .split-option-btn {
      padding: 10px 12px;
      background: var(--bg-highlight);
      border: 1px solid var(--border-subtle);
      border-radius: 10px;
      color: white;
      cursor: pointer;
      transition: all 0.15s ease;
      text-align: center;
    }
    .split-option-btn:active {
      transform: scale(0.97);
    }
    .split-option-btn.active {
      background: rgba(0,122,255,0.2);
      border-color: var(--accent-blue);
    }
