:root {
  --primary: #1a56db;
  --primary-light: #3f83f8;
  --primary-dark: #1e429f;
  --primary-gradient: linear-gradient(135deg, #1a56db 0%, #4f46e5 100%);
  --secondary: #111827;
  --accent: #00b8d9;
  --success: #31c48d;
  --warning: #ff9800;
  --danger: #f05252;
  --bg-white: #ffffff;
  --bg-light: #f9fafb;
  --bg-lighter: #f3f4f6;
  --bg-dark: #111827;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-tertiary: #6b7280;
  --text-light: #9ca3af;
  --text-white: #ffffff;
  --border-light: #e5e7eb;
  --border-medium: #d1d5db;
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --card-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --header-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius-sm: 0.375rem;
  --border-radius-md: 0.5rem;
  --border-radius-lg: 0.75rem;
  --border-radius-xl: 1rem;
  --border-radius-full: 9999px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-light);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-header {
  background: var(--bg-white);
  box-shadow: var(--header-shadow);
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--primary);
}

.logo-icon {
  background: var(--primary-gradient);
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.logo-text {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
}

.container {
  max-width: 1200px;
  width: calc(100% - 3rem);
  margin: 2.5rem auto;
}

.card {
  background-color: var(--bg-white);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--card-shadow);
  transition: var(--transition-normal);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--card-shadow-hover);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.card-icon {
  background: var(--primary-gradient);
  width: 32px;
  height: 32px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-content {
  padding: 2rem;
}

.card-badge {
  background: rgba(26, 86, 219, 0.1);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: var(--border-radius-full);
  display: inline-flex;
  align-items: center;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  letter-spacing: -0.025em;
}

p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.text-gradient {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-fill-color: transparent;
}

.text-lg {
  font-size: 1.125rem;
}

.text-xl {
  font-size: 1.25rem;
}

.text-2xl {
  font-size: 1.5rem;
}

.text-3xl {
  font-size: 1.875rem;
}

.font-bold {
  font-weight: 700;
}

.font-semibold {
  font-weight: 600;
}

.font-medium {
  font-weight: 500;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: all 200ms ease;
  border: none;
  outline: none;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.1);
  opacity: 0;
  transition: var(--transition-fast);
}

.btn:hover::after {
  opacity: 1;
}

.btn:active::after {
  background: rgba(0, 0, 0, 0.1);
  opacity: 1;
}

.btn-primary {
  background: var(--primary-gradient);
  color: var(--text-white);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.btn-secondary {
  background: var(--bg-white);
  color: var(--primary);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border-light);
}

.btn-accent {
  background: var(--accent);
  color: var(--text-white);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.form-control {
  width: 100%;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  background-color: var(--bg-white);
  border: 1px solid var(--border-medium);
  border-radius: var(--border-radius-md);
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(63, 131, 248, 0.25);
}

.form-control:disabled {
  background-color: var(--bg-lighter);
  opacity: 0.7;
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 0.375rem;
  background: var(--border-light);
  border-radius: var(--border-radius-full);
  outline: none;
  margin: 0.625rem 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--primary-gradient);
  cursor: pointer;
  box-shadow: 0 0 0 4px rgba(63, 131, 248, 0.1);
  transition: var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 8px rgba(63, 131, 248, 0.2);
}

input[type="range"]::-moz-range-thumb {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--primary-gradient);
  cursor: pointer;
  box-shadow: 0 0 0 4px rgba(63, 131, 248, 0.1);
  transition: var(--transition-fast);
  border: none;
}

input[type="range"]::-moz-range-thumb:hover {
  box-shadow: 0 0 0 8px rgba(63, 131, 248, 0.2);
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 1.5rem;
  position: relative;
}

.tab {
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: var(--transition-normal);
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tab::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--primary-gradient);
  opacity: 0;
  transition: var(--transition-normal);
}

.tab.active {
  color: var(--primary);
}

.tab.active::after {
  opacity: 1;
}

.tab:hover {
  color: var(--primary-light);
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-row {
  flex-direction: row;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.items-center {
  align-items: center;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-4 {
  gap: 1rem;
}

.gap-6 {
  gap: 1.5rem;
}

.gap-8 {
  gap: 2rem;
}

.mt-2 {
  margin-top: 0.5rem;
}

.mt-4 {
  margin-top: 1rem;
}

.mt-6 {
  margin-top: 1.5rem;
}

.mt-8 {
  margin-top: 2rem;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.mb-6 {
  margin-bottom: 1.5rem;
}

.mb-8 {
  margin-bottom: 2rem;
}

.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-cols-1 {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

.grid-cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.numberpad-option {
  background-color: var(--bg-lighter);
  border-radius: var(--border-radius-md);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.switch-input {
  height: 0;
  width: 0;
  visibility: hidden;
  position: absolute;
}

.switch-label {
  cursor: pointer;
  width: 48px;
  height: 24px;
  background: var(--border-medium);
  display: inline-block;
  border-radius: var(--border-radius-full);
  position: relative;
  transition: background-color var(--transition-fast);
}

.switch-label::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--bg-white);
  border-radius: 50%;
  transition: transform var(--transition-fast);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.switch-input:checked + .switch-label {
  background: var(--primary);
}

.switch-input:checked + .switch-label::after {
  transform: translateX(24px);
}

.numberpad {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.375rem;  /* Slightly larger gap for bigger buttons */
  margin: 1rem 0;
  width: fit-content;  /* Only as wide as needed */
  margin-left: auto;
  margin-right: auto;
}

.numberpad-button {
  width: 3.5rem;  /* Significantly larger buttons */
  height: 3.5rem;  /* Match width for square buttons */
  font-size: 1.25rem;  /* Larger font size */
  font-weight: 600;
  background: var(--bg-white);
  border: 1px solid var(--border-medium);  /* Thin border */
  border-radius: var(--border-radius-sm);  /* Slightly rounded corners */
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
}

.numberpad-button:hover {
  background: var(--bg-lighter);
  border-color: var(--primary);
  color: var(--primary);
  z-index: 1;  /* Ensure hover state shows above adjacent buttons */
}

.numberpad-button:active {
  transform: scale(0.95);
}

.numberpad-button.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-white);
}

.button-clicked { background-color: #1e429f; color: white; }

/* Custom styles for PASAT */
#answerInput {
  font-size: 1.5rem;
  text-align: center;
  height: 3.75rem;
  border-radius: var(--border-radius-lg);
  border: 2px solid var(--border-medium);
  transition: var(--transition-normal);
  margin: 1.25rem 0;
  width: 100%;
  font-weight: 600;
  color: var(--text-primary);
}

#answerInput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(63, 131, 248, 0.25);
}

#answerInput:disabled {
  background-color: var(--bg-lighter);
  opacity: 0.7;
}

#statusMessage {
  font-size: 1.25rem;
  font-weight: 500;
  text-align: center;
  min-height: 5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: var(--border-radius-lg);
  background-color: var(--bg-lighter);
  margin: 1.25rem 0;
  padding: 1.25rem;
  transition: var(--transition-normal);
}

.timer-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-lighter);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-md);
}

.timer-indicator {
  position: relative;
  width: 2.5rem;
  height: 2.5rem;
}

.timer-circle {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: conic-gradient(var(--primary) 0% 0%, var(--border-light) 0% 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-inner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background-color: var(--bg-white);
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-value {
  font-weight: 600;
  color: var(--text-tertiary);
  font-size: 0.875rem;
}

.counter-dots {
  display: flex;
  gap: 0.375rem;
  margin-top: 0.625rem;
}

.counter-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background-color: var(--bg-lighter);
  transition: var(--transition-fast);
}

.counter-dot.correct {
  background: linear-gradient(135deg, #31c48d 0%, #0e9f6e 100%);
}

.counter-dot.incorrect {
  background: linear-gradient(135deg, #f05252 0%, #e02424 100%);
}

.stat-card {
  background-color: var(--bg-lighter);
  border-radius: var(--border-radius-lg);
  padding: 1.5rem;
  transition: var(--transition-normal);
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--primary-gradient);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 0.5rem;
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.stat-value .unit {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-tertiary);
}

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

.history-item {
  padding: 1rem;
  border-radius: var(--border-radius-md);
  background-color: var(--bg-lighter);
  margin-bottom: 0.75rem;
  border-left: 4px solid transparent;
  transition: var(--transition-fast);
}

.history-item:hover {
  transform: translateX(4px);
}

.history-item.correct {
  border-left-color: var(--success);
}

.history-item.incorrect {
  border-left-color: var(--danger);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: var(--border-radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background-color: rgba(49, 196, 141, 0.1);
  color: var(--success);
}

.badge-danger {
  background-color: rgba(240, 82, 82, 0.1);
  color: var(--danger);
}

.key-point {
  background-color: rgba(63, 131, 248, 0.05);
  border-left: 3px solid var(--primary);
  padding: 1.25rem;
  border-radius: var(--border-radius-md);
  margin-bottom: 1.5rem;
}

.highlight-text {
  color: var(--primary);
  font-weight: 600;
}

.progress-bar {
  height: 0.5rem;
  background-color: var(--bg-lighter);
  border-radius: var(--border-radius-full);
  overflow: hidden;
  margin-top: 0.625rem;
}

.progress-fill {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: var(--border-radius-full);
  width: 0%;
  transition: width 0.3s;
}

.parameter-card {
  background-color: var(--bg-lighter);
  border-radius: var(--border-radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.parameter-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-tertiary);
}

.parameter-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary);
}

.audio-status {
  display: inline-block;
  margin-top: 0.5rem;
  border-radius: var(--border-radius-md);
  padding: 0.5rem 1rem;
  background-color: rgba(63, 131, 248, 0.1);
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 500;
}

.audio-status.warning {
  background-color: rgba(255, 152, 0, 0.1);
  color: var(--warning);
}

.audio-status.error {
  background-color: rgba(240, 82, 82, 0.1);
  color: var(--danger);
}

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

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

.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}

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

/* Media queries for responsive design */
@media screen and (max-width: 768px) {
  .container {
    width: calc(100% - 2rem);
    margin: 1.5rem auto;
  }
  
  .card-header {
    padding: 1.25rem 1.5rem;
  }
  
  .card-content {
    padding: 1.5rem;
  }
  
  .grid-cols-3, .grid-cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  
  .btn-lg {
    padding: 0.625rem 1.25rem;
  }
  
  .numberpad {
    grid-template-columns: repeat(6, 1fr);  /* Keep 6 columns even on mobile */
    gap: 0.25rem;  /* Comfortable gap on mobile */
  }
  
  .numberpad-button {
    width: 2.75rem;  /* Large enough for mobile */
    height: 2.75rem;
    font-size: 1.125rem;  /* Clear and readable font */
    border-radius: 0.25rem;  /* Slightly rounded corners */
  }
}

/* For very small screens */
@media screen and (max-width: 480px) {
  .numberpad {
    grid-template-columns: repeat(6, 1fr);  /* Keep 6 columns even on smallest screens */
    gap: 0.25rem;  /* Comfortable gap */
  }
  
  .numberpad-button {
    width: 2.5rem;  /* Good size for small screens */
    height: 2.5rem;
    font-size: 1rem;  /* Clear font size */
    border-radius: 0.25rem;
  }
}

@media screen and (max-width: 640px) {
  .grid-cols-2, .grid-cols-3, .grid-cols-4 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }
  
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
}

/* Modal popup styling */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 1.5rem 1rem 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 12px 12px 0 0;
}

.modal-header h3 {
  color: white;
  font-weight: 600;
}

.modal-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.375rem;
  transition: all 0.2s ease;
}

.modal-close-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
  color: white;
}

.modal-body {
  padding: 1.5rem;
  color: #1f2937;
}

.modal-body h4 {
  color: #111827;
  font-weight: 600;
}