/* Aadu Guru - Playful Energy Theme (Orange-Amber) */

:root {
  /* Color System - Playful Energy Theme */
  --bg-base: #1C1B1B;
  --bg-elevated: #2A2626;
  --bg-interactive: #2A2626;
  --bg-card: #2A2626;
  --primary: #FF6F00;
  --primary-hover: #FF8F00;
  --primary-active: #FFB300;
  --secondary: #FFB300;
  --success: #25D366;
  --danger: #E86868;
  --gold: #FFB300;
  --reward: #FFF59D;
  --text-primary: #FFFFFF;
  --text-secondary: #FFD180;
  --text-tertiary: #FFAB40;
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.15);
  
  /* Typography */
  --font-base: 'Poppins', 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Poppins', 'Inter', sans-serif;
  
  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  
  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  
  /* Shadows - Clean, flat design without glow effects */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.6), 0 8px 10px -6px rgb(0 0 0 / 0.6);
  --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.7);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  /* iOS tap highlight */
  -webkit-tap-highlight-color: rgba(255, 111, 0, 0.2);
}

html {
  /* Prevent iOS text size adjustment */
  -webkit-text-size-adjust: 100%;
  /* Use dynamic viewport height for better iOS support */
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-base);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  /* iOS dynamic viewport height */
  min-height: -webkit-fill-available;
  position: relative;
  /* Prevent horizontal scroll on iOS */
  overflow-x: hidden;
  /* Smooth scrolling for iOS */
  -webkit-overflow-scrolling: touch;
  /* Improve touch interactions */
  touch-action: manipulation;
}

.container, .container-sm {
  position: relative;
  z-index: 1;
}

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  color: #FFFFFF;
}

h1 {
  font-size: 2.75rem;
  margin-bottom: var(--space-lg);
}

h2 {
  font-size: 2.25rem;
  margin-bottom: var(--space-md);
}

h3 {
  font-size: 1.75rem;
  margin-bottom: var(--space-md);
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-lg);
}

.container-sm {
  max-width: 42rem;
  margin: 0 auto;
  padding: var(--space-lg);
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: var(--space-xl);
  transition: all 0.3s ease;
  position: relative;
}

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

.card-interactive {
  cursor: pointer;
}

.card-interactive:hover {
  border-color: var(--primary);
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 1rem 2rem;
  font-size: 1.0625rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  font-family: var(--font-base);
  min-height: 3rem;
  position: relative;
  /* iOS touch optimizations */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
}

.btn-primary {
  background: linear-gradient(135deg, #FF6F00 0%, #FFB300 100%);
  color: white;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #FF8F00 0%, #FFC107 100%);
  transform: scale(1.02);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

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

.btn-secondary:hover {
  background: var(--bg-interactive);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: scale(0.98);
}

.btn-icon {
  width: 3rem;
  height: 3rem;
  padding: 0;
  border-radius: 50%;
  background: var(--bg-interactive);
  border: 1px solid var(--border-subtle);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-strong);
}

.btn-lg {
  padding: 1.25rem 2.5rem;
  font-size: 1.125rem;
  min-height: 3.5rem;
}

.btn-full {
  width: 100%;
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 2px solid var(--border-subtle);
  transition: all 0.2s ease;
}

.btn-outline:hover {
  border-color: var(--primary);
  background: rgba(255, 111, 0, 0.1);
}

.btn-outline.active {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(255, 111, 0, 0.2) 0%, rgba(255, 179, 0, 0.2) 100%);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
}

.btn-success:hover {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  transform: scale(1.02);
}

.btn-success:active {
  transform: scale(0.98);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
  transform: scale(1.02);
}

.btn-danger:active {
  transform: scale(0.98);
}

.difficulty-btn {
  padding: 1rem;
  text-align: center;
  flex-direction: column;
  gap: 0.25rem;
}

/* Radio Buttons */
.radio-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.radio-label:hover {
  color: var(--text-primary);
  background: rgba(255, 111, 0, 0.05);
}

.radio-label input[type="radio"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  border: 2px solid var(--border-subtle);
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
  position: relative;
  background: transparent;
  transition: all 0.2s ease;
}

.radio-label input[type="radio"]:checked {
  border-color: var(--primary);
  background: var(--primary);
}

.radio-label input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: white;
}

.radio-label input[type="radio"]:checked + span {
  color: var(--primary);
  font-weight: 600;
}

.radio-label span {
  user-select: none;
}

/* Forms */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  width: 100%;
  padding: 1rem 1.25rem;
  background: rgba(14, 17, 23, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 1.0625rem;
  font-family: var(--font-base);
  transition: all 0.2s ease;
  box-sizing: border-box;
  /* iOS form optimizations */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

/* Phone input row - force horizontal layout */
.phone-input-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: nowrap;
  width: 100%;
}

.phone-input-row .form-input {
  width: auto !important;
  min-width: 0;
}

.phone-input-row select {
  flex: 0 0 5.25rem;
  max-width: 5.25rem;
  padding: 0.875rem 0.5rem;
}

.phone-input-row input {
  flex: 1;
}

/* Radio button row - force horizontal layout */
.radio-button-row {
  display: flex;
  flex-direction: row;
  gap: var(--space-lg);
  flex-wrap: nowrap;
  align-items: center;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(28, 27, 27, 0.8);
}

.form-input::placeholder {
  color: var(--text-tertiary);
}

/* Date Picker Styling */
input[type="date"] {
  min-width: 180px;
  cursor: pointer;
  color-scheme: dark;
}

input[type="date"]:hover {
  border-color: var(--primary);
}

input[type="date"]:focus {
  outline: none;
  border-color: var(--primary);
}

/* Select/Dropdown Styling */
select.form-input {
  cursor: pointer;
  background-color: rgba(14, 17, 23, 0.6);
  color: var(--text-primary);
}

select.form-input:hover {
  border-color: var(--primary) !important;
}

select.form-input:focus {
  outline: none;
  border-color: var(--primary) !important;
}

select.form-input option {
  background-color: var(--bg-card);
  color: var(--text-primary);
  padding: 0.5rem;
}

/* Grid Layout */
.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid-2 {
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
}

.grid-3 {
  grid-template-columns: 1fr;
}

@media (min-width: 1024px) {
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.grid-4 {
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Modal/Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: #000000 !important;
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-lg);
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--bg-card) !important;
  border-radius: var(--radius-2xl);
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  position: relative;
}

.modal-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  z-index: 10;
}

/* Camera Preview */
.camera-container {
  position: relative;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
}

.camera-preview {
  width: 100%;
  border-radius: var(--radius-xl);
  display: block;
}

.scan-guides {
  position: absolute;
  inset: 10%;
  pointer-events: none;
}

.scan-corner {
  position: absolute;
  width: 40px;
  height: 40px;
  border: 3px solid var(--primary);
  animation: pulse 2s ease-in-out infinite;
}

.scan-corner.top-left {
  top: 0;
  left: 0;
  border-right: none;
  border-bottom: none;
  border-radius: var(--radius-md) 0 0 0;
}

.scan-corner.top-right {
  top: 0;
  right: 0;
  border-left: none;
  border-bottom: none;
  border-radius: 0 var(--radius-md) 0 0;
}

.scan-corner.bottom-left {
  bottom: 0;
  left: 0;
  border-right: none;
  border-top: none;
  border-radius: 0 0 0 var(--radius-md);
}

.scan-corner.bottom-right {
  bottom: 0;
  right: 0;
  border-left: none;
  border-top: none;
  border-radius: 0 0 var(--radius-md) 0;
}

/* Game Canvas */
.game-canvas {
  width: 100%;
  max-width: 500px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  display: block;
  margin: 0 auto;
  touch-action: none;
}

.game-canvas.active {
  border-color: var(--primary);
}

/* Game HUD */
.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  padding: var(--space-lg);
  background: var(--bg-card);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hud-item {
  text-align: center;
  flex: 1;
}

.hud-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.hud-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hud-timer {
  color: var(--success);
}

.hud-timer.warning {
  color: var(--gold);
}

.hud-timer.danger {
  color: var(--danger);
  animation: pulse 0.5s ease-in-out infinite;
}

/* Leaderboard */
.leaderboard-wrapper {
  overflow-x: auto;
  margin-top: var(--space-md);
  -webkit-overflow-scrolling: touch;
  background: var(--bg-card);
  border-radius: 14px;
  padding: var(--space-sm);
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px;
}

.leaderboard-table th {
  text-align: left;
  padding: var(--space-md) var(--space-lg);
  font-size: 0.8125rem;
  font-weight: 700;
  color: #FFFFFF;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
  background: transparent;
}

.leaderboard-table td {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  white-space: nowrap;
  color: var(--text-secondary);
}

.leaderboard-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.03);
}

.leaderboard-table tr:last-child td {
  border-bottom: none;
}

.leaderboard-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
}

/* Highlight current player in leaderboard */
.current-player-row {
  background: rgba(255, 111, 0, 0.15) !important;
  border-left: 4px solid var(--primary) !important;
}

.current-player-row td {
  color: var(--text-primary) !important;
  font-weight: 600;
}

.current-player-row:hover {
  background: rgba(255, 111, 0, 0.25) !important;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.rank-1 {
  background: none;
}

.rank-1::before {
  content: '🥇';
}

.rank-2 {
  background: none;
}

.rank-2::before {
  content: '🥈';
}

.rank-3 {
  background: none;
}

.rank-3::before {
  content: '🥉';
}

.rank-other {
  background: var(--bg-interactive);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  font-size: 0.875rem;
}

/* Icons (simple SVG) */
.icon {
  width: 1.5rem;
  height: 1.5rem;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.icon-lg {
  width: 3rem;
  height: 3rem;
}

/* Badge */
.badge {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  background: var(--bg-interactive);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.badge-primary {
  background: rgba(255, 111, 0, 0.2);
  color: var(--primary);
  border-color: var(--primary);
}

.badge-success {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
  border-color: var(--success);
}

.badge-green {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
  border-color: #22c55e;
}

.badge-orange {
  background: rgba(249, 115, 22, 0.2);
  color: #f97316;
  border-color: #f97316;
}

.badge-yellow {
  background: rgba(234, 179, 8, 0.2);
  color: #eab308;
  border-color: #eab308;
}

.badge-red {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border-color: #ef4444;
}

.badge-gray {
  background: rgba(156, 163, 175, 0.2);
  color: #9ca3af;
  border-color: #9ca3af;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: var(--space-md) 0;
  border-radius: var(--radius-md);
}

.table, .data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.table thead, .data-table thead {
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 10;
}

.table th, .data-table th {
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  font-weight: 700;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border-color);
  background: var(--bg-elevated);
  white-space: nowrap;
}

.table td, .data-table td {
  padding: var(--space-md) var(--space-lg);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.table tbody tr, .data-table tbody tr {
  transition: background-color 0.15s ease;
}

.table tbody tr:hover, .data-table tbody tr:hover {
  background: var(--bg-hover);
}

.table tbody tr:last-child td, .data-table tbody tr:last-child td {
  border-bottom: none;
}

/* Alternating row colors for better readability */
.table tbody tr:nth-child(even), .data-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.01);
}

.table tbody tr:nth-child(even):hover, .data-table tbody tr:nth-child(even):hover {
  background: var(--bg-hover);
}

/* Table cell alignment helpers */
.table td:first-child, .data-table td:first-child {
  font-weight: 600;
}

.table code, .data-table code {
  background: var(--bg-elevated);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: 'Courier New', monospace;
  color: var(--accent-color);
}

/* Responsive table improvements */
@media (max-width: 768px) {
  .table th, .data-table th,
  .table td, .data-table td {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
  }
  
  .table th, .data-table th {
    font-size: 0.75rem;
  }
}

/* Alert */
.alert {
  padding: var(--space-md);
  border-radius: 12px;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.alert-error {
  background: rgba(232, 104, 104, 0.1);
  border: 1px solid rgba(232, 104, 104, 0.3);
  color: #E86868;
}

.alert-success {
  background: rgba(63, 207, 142, 0.1);
  border: 1px solid rgba(63, 207, 142, 0.3);
  color: #3FCF8E;
}

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-pending {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.status-redeemed {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.status-cancelled {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-expired {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

/* Utility Classes */
.text-center {
  text-align: center;
}

.text-secondary {
  color: var(--text-secondary);
}

.text-tertiary {
  color: var(--text-tertiary);
}

.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mt-2xl { margin-top: var(--space-2xl); }

.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.mb-2xl { margin-bottom: var(--space-2xl); }

.hidden {
  display: none !important;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.animate-slide-up {
  animation: slideUp 0.3s ease;
}

/* QR Code Display */
.qr-display {
  background: white;
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  display: inline-block;
}

.qr-display img {
  display: block;
  max-width: 300px;
  width: 100%;
}

/* Admin Controls */
.admin-section {
  margin-bottom: var(--space-2xl);
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

/* Analytics Stats Cards */
.stat-card {
  background: var(--bg-interactive);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
  transition: all 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

/* Daily Chart Bars */
.chart-bar {
  display: flex;
  align-items: flex-end;
  gap: var(--space-xs);
  padding: var(--space-sm);
  border-bottom: 1px solid var(--border-subtle);
  transition: all 0.2s ease;
}

.chart-bar:hover {
  background: var(--bg-interactive);
  border-radius: var(--radius-sm);
}

.chart-label {
  flex: 0 0 80px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.chart-bar-container {
  flex: 1;
  height: 24px;
  background: var(--bg-base);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.chart-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-hover));
  border-radius: var(--radius-sm);
  transition: width 0.3s ease;
}

.chart-value {
  flex: 0 0 40px;
  text-align: right;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Coupon Code Display */
.coupon-code {
  font-family: monospace;
  font-size: 1.125rem;
  font-weight: 700;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-base);
  border-radius: var(--radius-md);
  border: 1px solid var(--primary);
  color: var(--primary);
  user-select: all;
}

/* Loading Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--bg-interactive);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: var(--space-lg) auto;
}

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

/* Mobile Navigation */
.hamburger-btn {
  display: none;
  position: fixed;
  top: var(--space-md);
  right: var(--space-md);
  z-index: 1001;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  cursor: pointer;
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.hamburger-btn:hover {
  background: var(--bg-interactive);
  border-color: var(--primary);
}

.hamburger-btn .icon {
  width: 24px;
  height: 24px;
}

.nav-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1002;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.nav-overlay.active {
  display: block;
  opacity: 1;
}

.mobile-nav {
  position: fixed;
  top: 0;
  left: -280px;
  width: 280px;
  max-width: 80vw;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile browsers */
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-subtle);
  z-index: 1003;
  transition: left 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  pointer-events: auto; /* Ensure nav can receive events when open */
}

.mobile-nav.active {
  left: 0;
}

.mobile-nav-header {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  z-index: 10;
}

.mobile-nav-header h3 {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-nav-header .btn-icon {
  flex-shrink: 0;
  padding: var(--space-xs);
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-interactive);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-nav-header .btn-icon:hover {
  background: var(--bg-base);
  border-color: var(--primary);
}

.mobile-nav-links {
  flex: 1;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  font-size: 0.9375rem;
}

.mobile-nav-link:hover {
  background: var(--bg-interactive);
  color: var(--text-primary);
}

.mobile-nav-link .icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Admin Header */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2xl);
  gap: var(--space-lg);
}

.header-content {
  flex: 1;
  text-align: center;
}

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-xs);
}

.owner-email {
  font-size: 0.875rem;
}

.btn-logout {
  font-size: 0.875rem;
  padding: var(--space-xs) var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.btn-logout .icon {
  width: 14px;
  height: 14px;
}

/* Admin Grid Layouts */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xl);
}

.section-full-width {
  grid-column: span 3;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-lg);
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-xl);
}

/* Coupon Search Results Grid */
.coupon-search-result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 80px auto;
  gap: var(--space-md);
  align-items: center;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  /* Show hamburger navigation on mobile/tablet */
  .hamburger-btn {
    display: block;
  }
  
  /* Improve touch targets - minimum 44x44px */
  .btn,
  .btn-icon,
  button,
  select,
  input[type="checkbox"],
  input[type="radio"],
  a.admin-nav-tab {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Better button sizing on mobile */
  .btn {
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
  }
  
  .btn-sm {
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    min-height: 40px;
  }
  
  /* Larger form inputs for easier mobile interaction */
  .form-input,
  .form-select,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="date"],
  input[type="number"],
  select,
  textarea {
    padding: 0.875rem 1rem;
    font-size: 1rem;
    min-height: 48px;
  }
  
  /* Admin header becomes single column on mobile */
  .admin-header {
    flex-direction: column;
    text-align: center;
    padding-top: var(--space-2xl);
  }
  
  .header-content {
    order: 1;
  }
  
  .header-actions {
    order: 2;
    align-items: center;
    flex-direction: row;
    gap: var(--space-md);
  }
  
  /* Make all grids single column on mobile */
  .admin-grid {
    grid-template-columns: 1fr;
  }
  
  .section-full-width {
    grid-column: span 1;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Make analytics grid single column on mobile */
  .analytics-grid {
    grid-template-columns: 1fr;
  }
  
  /* QR Code responsive sizing */
  .qr-display img {
    max-width: 100%;
    height: auto;
  }
  
  /* Admin actions wrap better on mobile */
  .admin-actions {
    flex-direction: column;
    gap: var(--space-md);
  }
  
  .admin-actions .btn {
    width: 100%;
  }
  
  /* Form grids become single column */
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns: 1fr 150px auto"],
  div[style*="grid-template-columns: 2fr 1fr"] {
    display: flex !important;
    flex-direction: column !important;
    gap: var(--space-md) !important;
  }
  
  /* Form row stacks vertically */
  .form-row {
    flex-direction: column;
    gap: var(--space-md);
  }
  
  .form-row .form-group {
    width: 100%;
  }
  
  /* Ensure all content containers have proper overflow */
  #adminLeaderboard,
  #couponHistory,
  #registeredUsers,
  #historicalLeaderboard,
  #dailyChart,
  #couponSearchResults {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Table responsive improvements */
  .table-responsive {
    margin: 0 calc(-1 * var(--space-lg));
    padding: 0 var(--space-lg);
  }
  
  .table {
    min-width: 600px;
  }
  
  .table th,
  .table td {
    padding: var(--space-sm) var(--space-xs);
    font-size: 0.875rem;
  }
  
  /* Mobile-friendly coupon history table - convert to cards */
  #couponHistory .table-responsive {
    margin: 0 !important;
    padding: 0 !important;
  }
  
  #couponHistory .data-table {
    display: block !important;
    min-width: 100% !important;
  }
  
  #couponHistory .data-table thead {
    display: none !important;
  }
  
  #couponHistory .data-table tbody {
    display: block !important;
  }
  
  #couponHistory .data-table tr {
    display: block !important;
    margin-bottom: var(--space-lg) !important;
    padding: var(--space-md) !important;
    background: var(--bg-card) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 8px !important;
  }
  
  #couponHistory .data-table td {
    display: block !important;
    padding: var(--space-sm) 0 !important;
    border: none !important;
    text-align: left !important;
  }
  
  #couponHistory .data-table td::before {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 0.25rem;
  }
  
  #couponHistory .data-table td:first-child::before {
    content: "Date";
  }
  
  #couponHistory .data-table td:nth-child(2)::before {
    content: "Code";
  }
  
  #couponHistory .data-table td:nth-child(3)::before {
    content: "Winner";
  }
  
  #couponHistory .data-table td:nth-child(4)::before {
    content: "Reward";
  }
  
  #couponHistory .data-table td:nth-child(5)::before {
    content: "Status";
  }
  
  #couponHistory .data-table td:nth-child(6)::before {
    content: "Delivery";
  }
  
  #couponHistory .data-table td:nth-child(7)::before {
    content: "Actions";
  }
  
  /* Make action buttons full width on mobile */
  #couponHistory .data-table td:nth-child(7) > div {
    flex-direction: column !important;
    width: 100% !important;
  }
  
  #couponHistory .data-table td:nth-child(7) button,
  #couponHistory .data-table td:nth-child(7) select {
    width: 100% !important;
    min-width: 100% !important;
  }
  
  /* Make reward rules stack properly */
  #rewardRulesList > div {
    flex-direction: column !important;
    gap: var(--space-md) !important;
  }
  
  /* Button groups stack on mobile */
  .admin-button-group,
  div[style*="display: flex"][style*="gap"] {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: var(--space-md) !important;
  }
  
  .admin-button-group .btn,
  .admin-button-group > button {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
  }
  
  /* Winner section buttons full width */
  #winners-section button.btn,
  #coupon-management-section button.btn {
    width: 100%;
    max-width: 100%;
  }
  
  /* Winner settings grid becomes single column */
  #winners-section > div:first-of-type {
    grid-template-columns: 1fr !important;
  }
  
  /* Coupon management search form stacks vertically on mobile */
  #coupon-management-section > div:first-of-type {
    grid-template-columns: 1fr !important;
  }
  
  /* Coupon search results grid becomes single column - stack all info vertically */
  .coupon-search-result-grid {
    grid-template-columns: 1fr !important;
    gap: var(--space-md) !important;
  }
  
  .coupon-search-result-card {
    padding: var(--space-lg) !important;
  }
  
  /* Action buttons in search results stack vertically */
  .coupon-search-result-card > div[style*="display: flex"] {
    flex-direction: column !important;
  }
  
  .coupon-search-result-card button {
    width: 100% !important;
  }
  
  /* Coupon history filter controls stack */
  #coupon-history-section > div:first-child {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  
  #coupon-history-section > div:first-child > div:last-child {
    flex-direction: column !important;
    width: 100% !important;
  }
  
  #coupon-history-section > div:first-child > div:last-child button,
  #coupon-history-section > div:first-child > div:last-child input {
    width: 100% !important;
  }
  
  /* Historical view filters stack */
  .card[data-testid="section-historical-view"] .form-group,
  .card[data-testid="section-filters"] .form-group {
    margin-bottom: var(--space-md);
  }
  
  /* Make WhatsApp send buttons full width on mobile */
  .whatsapp-send-btn {
    width: 100% !important;
    justify-content: center !important;
  }
  
  /* Improve badge visibility on mobile */
  .badge {
    font-size: 0.8125rem;
    padding: 0.375rem 0.75rem;
  }
  
  /* Better spacing in cards on mobile */
  .card {
    padding: var(--space-lg);
  }
  
  /* Improve modal on mobile */
  .modal-content {
    max-width: 95%;
    padding: var(--space-lg);
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 2.25rem;
  }
  
  h2 {
    font-size: 1.75rem;
  }
  
  h3 {
    font-size: 1.5rem;
  }
  
  .container, .container-sm {
    padding: var(--space-md);
  }
  
  .card {
    padding: var(--space-lg);
  }
  
  .btn {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
  }
  
  .hud-value {
    font-size: 1.5rem;
  }
  
  .leaderboard-table {
    min-width: 450px;
  }
  
  .leaderboard-table th,
  .leaderboard-table td {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
  }
  
  .rank-badge {
    width: 2rem;
    height: 2rem;
    font-size: 1.125rem;
  }
  
  /* Keep stats grid as 2 columns on small mobile for better use of space */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
  }
  
  /* Slightly smaller stat cards on very small screens */
  .stat-card {
    padding: var(--space-md);
  }
  
  .stat-value {
    font-size: 1.75rem;
  }
  
  /* Hide logout text on very small screens */
  .logout-text {
    display: none;
  }
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8) !important;
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: var(--space-lg);
  animation: fadeIn 0.2s ease;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #000000 !important;
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: var(--space-lg);
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
