:root {
  --fire-red: #dc3545;
  --fire-orange: #fd7e14;
  --fire-yellow: #ffc107;
  --dark-bg: #212529;
  --light-bg: #f8f9fa;
}

.simple-card {
  border: 1px solid #dee2e6;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.simple-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

@media (max-width: 767px) {
  html {
    font-size: 14px;
  }
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  line-height: 1.6;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.btn-primary {
  background: linear-gradient(45deg, var(--fire-red), var(--fire-orange));
  border: none;
  border-radius: 25px;
  padding: 12px 30px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(220, 53, 69, 0.4);
  background: linear-gradient(45deg, #c82333, #e66a2e);
}

.btn-success {
  background: linear-gradient(45deg, #28a745, #20c997);
  border: none;
  border-radius: 25px;
  padding: 12px 30px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.btn-warning {
  background: linear-gradient(45deg, var(--fire-orange), var(--fire-yellow));
  border: none;
  border-radius: 25px;
  color: #000000;
  font-weight: 600;
  text-shadow: none;
}

.card {
  border: none;
  border-radius: 15px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

.card-header {
  background: linear-gradient(45deg, var(--fire-red), var(--fire-orange));
  color: white;
  border-bottom: none;
  padding: 20px;
  font-weight: 600;
}

.navbar-brand {
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.nav-link {
  transition: all 0.3s ease;
  border-radius: 20px;
  margin: 0 5px;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.hero-section {
  background: linear-gradient(135deg, var(--fire-red) 0%, var(--fire-orange) 50%, var(--fire-yellow) 100%);
  color: white;
  padding: 80px 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="flame" x="0" y="0" width="20" height="20" patternUnits="userSpaceOnUse"><path d="M10 0 Q15 5 10 10 Q5 5 10 0" fill="rgba(255,255,255,0.1)"/></pattern></defs><rect width="100" height="100" fill="url(%23flame)"/></svg>');
  opacity: 0.3;
}

.hero-content {
  position: relative;
  z-index: 1;
}

.quiz-card {
  background: white;
  border-radius: 20px;
  padding: 30px;
  margin: 20px 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.question-number {
  background: linear-gradient(45deg, var(--fire-red), var(--fire-orange));
  color: white;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  margin-bottom: 20px;
}

.answer-option {
  background: #ffffff;
  border: 2px solid #dee2e6;
  border-radius: 15px;
  padding: 15px 20px;
  margin: 10px 0;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #212529;
}

.answer-option:hover {
  border-color: var(--fire-orange);
  background: rgba(253, 126, 20, 0.15);
  box-shadow: 0 2px 8px rgba(253, 126, 20, 0.2);
}

.answer-option.selected {
  border-color: var(--fire-red);
  background: rgba(220, 53, 69, 0.15);
  color: #212529;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(220, 53, 69, 0.2);
}

.progress-modern {
  height: 8px;
  background: #e9ecef;
  border-radius: 10px;
  overflow: hidden;
}

.progress-modern .progress-bar {
  background: linear-gradient(90deg, var(--fire-red), var(--fire-orange));
  border-radius: 10px;
}

.stats-card {
  background: white;
  border-radius: 15px;
  padding: 25px;
  text-align: center;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.stats-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.stats-icon {
  font-size: 2.5rem;
  margin-bottom: 15px;
  background: linear-gradient(45deg, var(--fire-red), var(--fire-orange));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.table-modern {
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.table-modern thead {
  background: linear-gradient(45deg, var(--fire-red), var(--fire-orange));
  color: white;
}

.alert-modern {
  border: none;
  border-radius: 15px;
  padding: 20px;
  margin: 20px 0;
}

.form-control {
  border-radius: 10px;
  border: 2px solid #e9ecef;
  padding: 12px 15px;
  transition: all 0.3s ease;
}

.form-control:focus {
  border-color: var(--fire-orange);
  box-shadow: 0 0 0 0.2rem rgba(253, 126, 20, 0.25);
}

.animate-fade-in {
  animation: fadeIn 0.6s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.fire-gradient-text {
  background: linear-gradient(45deg, var(--fire-red), var(--fire-orange), var(--fire-yellow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: bold;
}

/* Mobile Optimization */
@media (max-width: 768px) {
  .hero-section {
    padding: 40px 0;
  }
  
  .card {
    margin: 10px;
    border-radius: 10px;
  }
  
  .quiz-card {
    padding: 15px;
    margin: 10px 0;
    border-radius: 15px;
  }
  
  .navbar-brand {
    font-size: 1.1rem !important;
  }
  
  .display-4 {
    font-size: 1.8rem !important;
  }
  
  .btn-lg {
    font-size: 1rem;
    padding: 12px 20px;
  }
  
  .stats-card {
    padding: 15px;
    margin-bottom: 15px;
  }
  
  .stats-icon {
    font-size: 2rem;
    margin-bottom: 10px;
  }
  
  .table-responsive {
    font-size: 0.85rem;
  }
  
  .dropdown-menu {
    font-size: 0.9rem;
  }
  
  .form-control {
    padding: 10px 12px;
  }
  
  .card-header {
    padding: 15px;
  }
  
  .card-body {
    padding: 15px;
  }
}

@media (max-width: 576px) {
  .container-fluid {
    padding-left: 10px;
    padding-right: 10px;
  }
  
  .hero-section {
    padding: 30px 0;
  }
  
  .navbar-brand {
    font-size: 1rem !important;
  }
  
  .display-4 {
    font-size: 1.5rem !important;
  }
  
  .btn {
    font-size: 0.9rem;
    padding: 8px 16px;
  }
  
  .btn-lg {
    font-size: 1rem;
    padding: 10px 18px;
  }
  
  .quiz-card {
    padding: 12px;
    margin: 8px 0;
  }
  
  .question-number {
    width: 35px;
    height: 35px;
    font-size: 0.9rem;
  }
  
  .answer-option {
    padding: 12px 15px;
    margin: 8px 0;
    border-radius: 10px;
  }
  
  .stats-card {
    padding: 12px;
    margin-bottom: 12px;
  }
  
  .stats-icon {
    font-size: 1.8rem;
    margin-bottom: 8px;
  }
  
  .card-header {
    padding: 12px;
  }
  
  .card-body {
    padding: 12px;
  }
  
  .table {
    font-size: 0.8rem;
  }
  
  .table th,
  .table td {
    padding: 0.5rem 0.25rem;
  }
  
  .dropdown-menu {
    font-size: 0.85rem;
  }
  
  .form-control {
    padding: 8px 10px;
    font-size: 0.9rem;
  }
  
  .form-check-input {
    transform: scale(1.1);
  }
  
  .badge {
    font-size: 0.7rem;
  }
  
  .alert {
    padding: 12px;
    margin: 12px 0;
  }
  
  .nav-link {
    padding: 8px 12px;
    margin: 0 2px;
  }
  
  .navbar-toggler {
    padding: 4px 8px;
    font-size: 1rem;
  }
}

/* Touch-optimized elements */
@media (max-width: 768px) {
  .answer-option {
    min-height: 48px;
    touch-action: manipulation;
  }
  
  .btn {
    min-height: 44px;
    touch-action: manipulation;
  }
  
  .form-check-input {
    min-width: 20px;
    min-height: 20px;
    touch-action: manipulation;
  }
  
  .dropdown-toggle {
    min-height: 44px;
  }
  
  .nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  
  .category-item {
    min-height: 80px;
    display: flex;
    align-items: center;
  }
  
  .table-responsive {
    -webkit-overflow-scrolling: touch;
  }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
  .hero-section {
    padding: 20px 0;
  }
  
  .quiz-card {
    padding: 15px;
  }
  
  .question-number {
    width: 30px;
    height: 30px;
    font-size: 0.8rem;
  }
  
  .answer-option {
    padding: 10px 15px;
    margin: 6px 0;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .stats-icon,
  .fas {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* Touch-optimized components */
.touch-btn {
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.touch-btn:active {
  transform: scale(0.98);
}

.touch-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transition: width 0.3s, height 0.3s, top 0.3s, left 0.3s;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.touch-btn:active::before {
  width: 100px;
  height: 100px;
}

.touch-card {
  transition: all 0.3s ease;
}

.touch-card:hover {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

@media (max-width: 768px) {
  .touch-card:active {
    transform: scale(0.99);
  }
  
  .touch-btn {
    font-size: 0.9rem;
    padding: 10px 15px;
  }
  
  .touch-btn.btn-sm {
    font-size: 0.8rem;
    padding: 8px 12px;
  }
}

/* Swipe gesture indicators */
.swipe-indicator {
  position: relative;
}

.swipe-indicator::after {
  content: '↔️';
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8rem;
  opacity: 0.5;
  animation: swipeHint 2s infinite;
}

@keyframes swipeHint {
  0%, 100% { opacity: 0.3; transform: translateX(-50%) scale(1); }
  50% { opacity: 0.8; transform: translateX(-50%) scale(1.1); }
}

/* Dark mode support for mobile */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
  body {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: #ffffff;
  }
  
  .card {
    background-color: #2d2d2d;
    color: #ffffff;
    border: 1px solid #444444;
  }
  
  .quiz-card {
    background-color: #2d2d2d;
    color: #ffffff;
    border: 1px solid #444444;
  }
  
  .answer-option {
    background: #3d3d3d;
    color: #ffffff;
    border-color: #555555;
  }
  
  .answer-option:hover {
    background: rgba(253, 126, 20, 0.25);
    border-color: var(--fire-orange);
  }
  
  .answer-option.selected {
    background: rgba(220, 53, 69, 0.25);
    border-color: var(--fire-red);
    color: #ffffff;
  }
  
  .form-control {
    background-color: #3d3d3d;
    border-color: #555555;
    color: #ffffff;
  }
  
  .form-control:focus {
    background-color: #3d3d3d;
    border-color: var(--fire-orange);
    color: #ffffff;
  }
  
  .table {
    color: #ffffff;
  }
  
  .dropdown-menu {
    background-color: #2d2d2d;
    border-color: #555555;
  }
  
  .dropdown-item {
    color: #ffffff;
  }
  
  .dropdown-item:hover {
    background-color: #3d3d3d;
    color: #ffffff;
  }
  
  .touch-card {
    background-color: #2d2d2d;
    border-color: #555555;
  }
  
  .text-muted {
    color: #aaaaaa !important;
  }
}

/* Mobile navigation enhancements */
@media (max-width: 768px) {
  .navbar-nav {
    padding: 10px 0;
  }
  
  .navbar-nav .nav-link {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 2px 0;
    text-align: center;
  }
  
  .navbar-nav .nav-link:active {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(0.98);
  }
  
  .dropdown-menu {
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  }
  
  .dropdown-item {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 2px 8px;
  }
  
  .dropdown-item:active {
    transform: scale(0.98);
  }
}

/* PWA-specific styles */
#install-banner {
  margin: 10px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(45deg, #17a2b8, #20c997);
  color: white;
  animation: slideDown 0.5s ease-out;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Fullscreen mode adjustments */
:fullscreen {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

:fullscreen .quiz-card {
  max-width: 100%;
  margin: 20px;
  height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
}

:fullscreen .quiz-card .card-body {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Enhanced mobile viewport */
@supports (padding: max(0px)) {
  .container-fluid {
    padding-left: max(15px, env(safe-area-inset-left));
    padding-right: max(15px, env(safe-area-inset-right));
  }
  
  .navbar {
    padding-left: max(15px, env(safe-area-inset-left));
    padding-right: max(15px, env(safe-area-inset-right));
  }
  
  main {
    padding-left: max(15px, env(safe-area-inset-left));
    padding-right: max(15px, env(safe-area-inset-right));
  }
}

/* Status bar adjustments for iOS */
@media (max-width: 768px) {
  .mobile-device.ios {
    padding-top: env(safe-area-inset-top);
  }
  
  .mobile-device.ios .navbar {
    padding-top: calc(env(safe-area-inset-top) + 8px);
  }
}

/* Improved keyboard handling */
.keyboard-open main {
  padding-bottom: 20px;
}

.keyboard-open .quiz-card {
  margin-bottom: 20px;
}

/* Performance optimizations */
.animate-fade-in {
  will-change: opacity, transform;
}

.touch-btn {
  will-change: transform;
}

.card {
  will-change: transform, box-shadow;
}

/* Accessibility and contrast improvements */
.badge {
  font-weight: 600;
  padding: 0.5em 0.75em;
}

.badge.bg-primary {
  background-color: #0d6efd !important;
  color: #ffffff !important;
}

.badge.bg-secondary {
  background-color: #495057 !important;
  color: #ffffff !important;
}

.badge.bg-success {
  background-color: #198754 !important;
  color: #ffffff !important;
}

.badge.bg-warning {
  background-color: #fd7e14 !important;
  color: #000000 !important;
}

.badge.bg-danger {
  background-color: #dc3545 !important;
  color: #ffffff !important;
}

.badge.bg-info {
  background-color: #0dcaf0 !important;
  color: #000000 !important;
}

/* Better contrast for text elements */
.text-muted {
  color: #6c757d !important;
}

.text-success {
  color: #198754 !important;
}

.text-warning {
  color: #fd7e14 !important;
}

.text-danger {
  color: #dc3545 !important;
}

.text-info {
  color: #0dcaf0 !important;
}

.text-primary {
  color: #0d6efd !important;
}

/* Alert improvements */
.alert {
  border: 1px solid transparent;
}

.alert-success {
  background-color: #d1eddf;
  border-color: #badbcc;
  color: #0a3622;
}

.alert-warning {
  background-color: #fff3cd;
  border-color: #ffeaa7;
  color: #664d03;
}

.alert-danger {
  background-color: #f8d7da;
  border-color: #f5c6cb;
  color: #721c24;
}

.alert-info {
  background-color: #d1ecf1;
  border-color: #bee5eb;
  color: #055160;
}

/* Button contrast improvements */
.btn-outline-primary {
  color: #0d6efd;
  border-color: #0d6efd;
}

.btn-outline-primary:hover {
  color: #ffffff;
  background-color: #0d6efd;
  border-color: #0d6efd;
}

.btn-outline-secondary {
  color: #495057;
  border-color: #495057;
}

.btn-outline-secondary:hover {
  color: #ffffff;
  background-color: #495057;
  border-color: #495057;
}

/* Table improvements */
.table-hover tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.075);
}

.table-success {
  background-color: #d1eddf;
  color: #0a3622;
}

/* Form improvements */
.form-control:focus {
  border-color: #fd7e14;
  box-shadow: 0 0 0 0.2rem rgba(253, 126, 20, 0.25);
}

.form-check-input:checked {
  background-color: #fd7e14;
  border-color: #fd7e14;
}

.form-check-input:focus {
  border-color: #fd7e14;
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(253, 126, 20, 0.25);
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .touch-btn:active {
    transform: none;
  }
  
  .answer-option.touched {
    transform: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .answer-option {
    border-width: 3px;
  }
  
  .answer-option.selected {
    border-width: 4px;
    background-color: rgba(220, 53, 69, 0.3);
  }
  
  .btn {
    border-width: 2px;
  }
  
  .card {
    border: 2px solid #000000;
  }
  
  .badge {
    border: 1px solid #000000;
  }
}