/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  background: #000000;
  min-height: 100vh;
  color: #ffffff;
  line-height: 1.6;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="rgba(255,215,0,0.02)"/><circle cx="75" cy="75" r="1" fill="rgba(255,215,0,0.02)"/><circle cx="50" cy="10" r="0.5" fill="rgba(255,215,0,0.01)"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
  pointer-events: none;
  z-index: 1;
}

.container {
  max-width: 650px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Enhanced Header Section */
.header-section {
  margin-bottom: 15px;
}

.title-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(255, 215, 0, 0.2);
  border: 2px solid #ffd700;
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-image {
  width: 80px;
  height: 80px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

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

.calculator-title {
  font-size: 36px;
  font-weight: 800;
  color: #ffffff;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  line-height: 1.1;
}

.calculator-subtitle {
  font-size: 14px;
  color: #ffffff;
  margin: 0;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.8;
  line-height: 1.2;
  margin-top: -2px;
}

/* Enhanced Configuration Section */
.config-section {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(20px);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px rgba(255, 215, 0, 0.1);
  border: 1px solid #ffd700;
}

.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: end;
}

.selector-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.selector-label {
  font-size: 12px;
  font-weight: 600;
  color: #ffd700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.selector-label i {
  color: #ffd700;
}

.button-group {
  display: flex;
  gap: 6px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 215, 0, 0.3);
}

.selector-btn {
  background: transparent;
  border: none;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 8px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.selector-btn.active {
  background: #ffd700;
  color: #000000;
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.5);
}

.selector-btn:hover:not(.active) {
  background: rgba(255, 215, 0, 0.2);
  color: #ffd700;
}

.dropdown-wrapper {
  position: relative;
}

.age-input {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  width: 100%;
  transition: all 0.2s ease;
  text-align: center;
  box-sizing: border-box;
}

.age-input:focus {
  outline: none;
  border-color: #ffd700;
  background: rgba(255, 215, 0, 0.1);
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.2);
}

.age-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

/* Remove number input arrows from age input */
.age-input::-webkit-outer-spin-button,
.age-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

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

.dropdown-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #ffd700;
  pointer-events: none;
  font-size: 12px;
}

.clear-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #ffd700;
  border: 1px solid #ffd700;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.clear-btn:hover {
  background: #ffd700;
  color: #000000;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 215, 0, 0.4);
}

/* Main Calculator */
.calculator-main {
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 32px;
  box-shadow: 0 8px 40px rgba(255, 215, 0, 0.15);
  border: 2px solid #ffd700;
  height: 775px; /* Fixed height to prevent layout changes */
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden; /* Prevent content overflow */
}

.calculator-title {
  text-align: center;
  font-size: 35px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 15px;
}

/* Content Area - Fixed height container for all states */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  height: 100%;
  min-height: 0; /* Allow flex shrinking */
}

/* Input Form Container */
.input-form-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* Event Input Fields */
.events-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
  flex: 1;
}

.event-section {
  text-align: center;
}

.event-section.full-width {
  grid-column: 1 / -1;
}

.event-header {
  font-size: 14px;
  font-weight: 600;
  color: #ffd700;
  margin-bottom: 6px;
}

/* Input Row Layouts */
.dual-input-row {
  display: flex;
  gap: 8px;
}

.single-input-row {
  display: flex;
  justify-content: center;
}

.time-input-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* Input Groups */
.input-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

/* Compact Inputs */
.compact-input {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 8px;
  padding: 12px 8px;
  font-size: 20px;
  font-weight: 600;
  color: #ffffff;
  text-align: center;
  width: 100%;
  min-width: 50px;
  transition: all 0.2s ease;
}

/* Remove number input arrows */
.compact-input::-webkit-outer-spin-button,
.compact-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

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

.compact-input:focus {
  outline: none;
  border-color: #ffd700;
  background: rgba(255, 215, 0, 0.1);
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.2);
}

.compact-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

/* Input Labels */
.input-label {
  font-size: 10px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 4px;
  text-align: center;
}

/* Time Separator */
.time-separator {
  font-size: 20px;
  font-weight: 600;
  color: #ffd700;
  margin-top: -25px;
  align-self: center;
  line-height: 1;
}

/* Calculate Button */
.calculate-btn {
  width: 100%;
  background: linear-gradient(135deg, #b8860b 0%, #daa520 100%);
  color: white;
  border: none;
  border-radius: 16px;
  padding: 18px 24px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 6px 20px rgba(184, 134, 11, 0.4);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.calculate-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s;
}

.calculate-btn:hover::before {
  left: 100%;
}

.calculate-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(184, 134, 11, 0.5);
}

.calculate-btn:active {
  transform: translateY(-1px);
}

/* Loading Section */
.loading-section {
  text-align: center;
  padding: 60px 20px;
  animation: fadeIn 0.5s ease-in-out;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.loading-spinner {
  margin-bottom: 24px;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top: 4px solid #ffd700;
  border-radius: 50%;
  margin: 0 auto;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.loading-text h3 {
  font-size: 20px;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 8px;
}

.loading-text p {
  font-size: 14px;
  color: #718096;
  margin-bottom: 32px;
}

.loading-progress {
  max-width: 300px;
  margin: 0 auto;
  background: #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  height: 8px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #ffd700 0%, #daa520 100%);
  border-radius: 10px;
  width: 0%;
  animation: progressFill 3s ease-in-out forwards;
}

@keyframes progressFill {
  0% {
    width: 0%;
  }
  33% {
    width: 30%;
  }
  66% {
    width: 70%;
  }
  100% {
    width: 100%;
  }
}

/* Back to Events Button */
.back-to-events-btn {
  background: transparent;
  color: #ffd700;
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 15px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Input Recap Section - Hidden on Desktop */
.input-recap-section {
  display: none;
}

.back-to-events-btn:hover {
  background: rgba(255, 215, 0, 0.1);
  border-color: #ffd700;
  color: #ffffff;
}

/* Results Section */
.results-section {
  animation: fadeIn 0.5s ease-in-out;
  margin-top: 0;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto; /* Allow vertical scrolling when needed */
  overflow-x: hidden; /* Prevent horizontal scrolling */
}

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

.results-table {
  background: #1a1a1a;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  margin-bottom: 12px;
  backdrop-filter: blur(10px);
}

.results-row {
  display: grid;
  grid-template-columns: 50px 70px 1fr 70px;
  padding: 15px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  align-items: center;
  transition: all 0.2s ease;
  min-height: 45px;
}

.results-row:last-child {
  border-bottom: none;
}

.results-row:hover {
  background: rgba(255, 215, 0, 0.1);
}

.event-icon {
  width: 32px;
  height: 32px;
  background: rgba(255, 215, 0, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffd700;
  font-size: 14px;
}

.event-name {
  font-weight: 700;
  font-size: 14px;
  color: #ffffff;
  text-align: left;
}

.raw-score {
  text-align: center;
  font-weight: 600;
  color: #cccccc;
  font-size: 14px;
  font-family: "JetBrains Mono", monospace;
}

.points {
  text-align: center;
  font-weight: 700;
  font-size: 16px;
  color: #ffffff;
}

/* High contrast colors for pass/fail status */
.points.pass {
  color: #4caf50;
  background: rgba(76, 175, 80, 0.2);
  border-radius: 4px;
  padding: 2px 6px;
}

.points.fail {
  color: #f44336;
  background: rgba(244, 67, 54, 0.2);
  border-radius: 4px;
  padding: 2px 6px;
}

/* Gold accent for excellent scores (90+ points) */
.points.excellent {
  color: #ffd700;
  background: rgba(255, 215, 0, 0.2);
  border-radius: 4px;
  padding: 2px 6px;
  font-weight: 800;
}

/* Total Score Section */
.total-section {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.total-score {
  flex: 1;
  background: white;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.score-number {
  font-size: 36px;
  font-weight: 700;
  color: #2d3748;
}

.score-max {
  font-size: 20px;
  color: #718096;
}

.pass-fail-indicator {
  flex: 1;
  border-radius: 10px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.pass-fail-indicator.pass {
  background: linear-gradient(135deg, #4caf50 0%, #2e7d32 100%);
}

.pass-fail-indicator.fail {
  background: linear-gradient(135deg, #fc8181 0%, #e53e3e 100%);
}

.status-text {
  font-size: 24px;
  font-weight: 700;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Feedback Section */
.feedback-section {
  background: rgba(255, 215, 0, 0.1);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(255, 215, 0, 0.2);
}

.feedback-text {
  font-size: 14px;
  font-weight: 500;
  color: #ffffff;
  margin: 0;
}

/* Beautiful Error Popup */
.error-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease-out;
}

.error-popup {
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  border: 2px solid #ffd700;
  max-width: 450px;
  width: 100%;
  overflow: hidden;
  animation: slideUp 0.4s ease-out;
  position: relative;
}

.error-popup::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #ffd700 0%, #daa520 100%);
}

.error-header {
  padding: 24px 24px 16px 24px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 215, 0, 0.2);
}

.error-icon {
  width: 60px;
  height: 60px;
  background: rgba(255, 215, 0, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px auto;
  color: #ffd700;
  font-size: 24px;
  animation: pulse 2s infinite;
}

.error-title {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.error-body {
  padding: 20px 24px;
}

.error-message {
  font-size: 16px;
  font-weight: 500;
  color: #cccccc;
  margin: 0 0 16px 0;
  line-height: 1.5;
  text-align: center;
}

.error-details {
  background: rgba(255, 215, 0, 0.1);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid rgba(255, 215, 0, 0.2);
  margin-top: 16px;
}

.error-detail-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  font-size: 14px;
  color: #ffffff;
  border-bottom: 1px solid rgba(255, 215, 0, 0.1);
}

.error-detail-item:last-child {
  border-bottom: none;
}

.error-detail-item i {
  color: #ffd700;
  width: 16px;
  text-align: center;
}

.error-footer {
  padding: 16px 24px 24px 24px;
  text-align: center;
}

.error-btn {
  background: linear-gradient(135deg, #ffd700 0%, #daa520 100%);
  color: #000000;
  border: none;
  border-radius: 12px;
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 16px rgba(255, 215, 0, 0.3);
}

.error-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
  background: linear-gradient(135deg, #ffed4e 0%, #f4d03f 100%);
}

.error-btn:active {
  transform: translateY(0);
}

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

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

/* Mobile App-Like Experience */
@media (max-width: 768px) {
  /* Full screen mobile layout */
  body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
  }

  .container {
    padding: 0;
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }

  /* Compact header for mobile */
  .header-section {
    margin-bottom: 0;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    padding: 12px 16px 8px 16px;
    border-bottom: 2px solid #ffd700;
  }

  .title-container {
    flex-direction: row;
    gap: 12px;
    padding: 0;
    background: transparent;
    backdrop-filter: none;
    border-radius: 0;
    box-shadow: none;
    border: none;
    justify-content: flex-start;
  }

  .logo-image {
    width: 40px;
    height: 40px;
  }

  .title-content {
    text-align: left;
    flex: none;
  }

  .calculator-title {
    font-size: 20px;
    margin: 0;
    line-height: 1.2;
  }

  .calculator-subtitle {
    font-size: 11px;
    margin-top: 2px;
    opacity: 0.9;
  }

  /* Inline config section */
  .config-section {
    background: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%);
    border-radius: 0;
    padding: 12px 16px;
    margin-bottom: 0;
    box-shadow: none;
    border: none;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
  }

  .config-grid {
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: center;
  }

  .selector-group {
    gap: 6px;
  }

  .selector-label {
    font-size: 11px;
    margin-bottom: 2px;
  }

  .button-group {
    padding: 2px;
    gap: 4px;
    border-radius: 8px;
  }

  .selector-btn {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 6px;
  }

  .age-input {
    padding: 14px 12px;
    font-size: 14px;
    border-radius: 8px;
    width: 80px;
    text-align: center;
  }

  /* Full screen calculator */
  .calculator-main {
    padding: 0;
    height: calc(100vh - 120px);
    border-radius: 0;
    background: #1a1a1a;
    border: none;
    box-shadow: none;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /* Content area fills remaining space */
  .content-area {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
  }

  .input-form-container {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
  }

  /* Single combined events section on mobile */
  .events-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
    padding: 16px;
  }

  .event-section {
    background: transparent;
    border-radius: 0;
    padding: 0;
    border: none;
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
  }

  .event-section:last-child {
    margin-bottom: 0;
  }

  .event-header {
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: 700;
  }

  /* Touch-optimized inputs */
  .compact-input {
    font-size: 18px;
    padding: 12px 8px;
    min-height: 48px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 215, 0, 0.3);
  }

  .compact-input:focus {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.15);
  }

  .input-label {
    font-size: 11px;
    margin-top: 4px;
    font-weight: 600;
  }

  .time-separator {
    font-size: 20px;
    margin-top: -28px;
    color: #ffd700;
  }

  /* Prominent calculate button - always visible */
  .calculate-btn {
    padding: 16px;
    font-size: 18px;
    margin-top: 16px;
    border-radius: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 16px rgba(255, 215, 0, 0.3);
    flex-shrink: 0; /* Prevent button from shrinking */
    min-height: 60px; /* Ensure minimum button height */
  }

  /* Full screen loading */
  .loading-section {
    padding: 60px 20px;
    background: #1a1a1a;
  }

  .loading-text h3 {
    font-size: 20px;
  }

  .loading-text p {
    font-size: 14px;
  }

  /* Full screen results - Allow scroll when needed */
  .results-section {
    padding: 16px;
    background: #1a1a1a;
    height: 100%;
    overflow-y: auto; /* Allow vertical scrolling when needed */
    overflow-x: hidden; /* Prevent horizontal scrolling */
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Start from top instead of space-between */
  }

  .back-to-events-btn {
    padding: 8px 16px;
    font-size: 14px;
    margin-bottom: 12px;
    border-radius: 8px;
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.4);
    flex-shrink: 0;
  }

  /* Input Recap Section - Mobile Only */
  .input-recap-section {
    display: block;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid rgba(255, 215, 0, 0.2);
    flex-shrink: 0;
  }

  .recap-header {
    font-size: 16px;
    font-weight: 700;
    color: #ffd700;
    margin-bottom: 10px;
    text-align: center;
  }

  .recap-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .recap-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    border: 1px solid rgba(255, 215, 0, 0.1);
  }

  .recap-label {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
  }

  .recap-value {
    font-size: 12px;
    font-weight: 700;
    color: #ffd700;
  }

  /* Results table takes available space */
  .results-table {
    margin-bottom: 12px;
    border-radius: 12px;
    background: #1a1a1a;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Allow table to shrink if needed */
  }

  .results-row {
    padding: 16px;
    grid-template-columns: 40px 60px 1fr 60px;
    min-height: 50px; /* Set minimum height instead of flex: 1 */
    display: grid;
    align-items: center;
  }

  .event-icon {
    width: 32px;
    height: 32px;
    font-size: 14px;
    background: rgba(255, 215, 0, 0.2);
    color: #ffd700;
  }

  .event-name {
    font-size: 14px;
    font-weight: 800;
    color: #ffffff;
  }

  .raw-score {
    font-size: 13px;
    font-weight: 700;
    color: #cccccc;
  }

  .points {
    font-size: 16px;
    font-weight: 800;
  }

  /* Bottom section - uses remaining space efficiently */
  .results-bottom {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .total-section {
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
  }

  .total-score,
  .pass-fail-indicator {
    padding: 18px;
    border-radius: 12px;
    flex: 1;
  }

  .score-number {
    font-size: 36px;
  }

  .score-max {
    font-size: 20px;
  }

  .status-text {
    font-size: 24px;
  }

  .feedback-section {
    padding: 14px;
    border-radius: 12px;
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    margin-bottom: 0;
  }

  .feedback-text {
    font-size: 14px;
    line-height: 1.3;
    margin: 0;
  }

  /* Mobile Error Popup */
  .error-overlay {
    padding: 16px;
  }

  .error-popup {
    max-width: 100%;
    border-radius: 16px;
  }

  .error-header {
    padding: 20px 20px 12px 20px;
  }

  .error-icon {
    width: 50px;
    height: 50px;
    font-size: 20px;
    margin-bottom: 12px;
  }

  .error-title {
    font-size: 18px;
  }

  .error-body {
    padding: 16px 20px;
  }

  .error-message {
    font-size: 15px;
    margin-bottom: 12px;
  }

  .error-details {
    padding: 12px;
    margin-top: 12px;
  }

  .error-detail-item {
    padding: 6px 0;
    font-size: 13px;
  }

  .error-footer {
    padding: 12px 20px 20px 20px;
  }

  .error-btn {
    padding: 12px 24px;
    font-size: 15px;
    border-radius: 10px;
  }
}

@media (max-width: 480px) {
  /* Ultra-compact mobile app experience */
  .header-section {
    padding: 8px 12px 6px 12px;
  }

  .title-container {
    gap: 8px;
  }

  .logo-image {
    width: 32px;
    height: 32px;
  }

  .calculator-title {
    font-size: 16px;
  }

  .calculator-subtitle {
    font-size: 10px;
  }

  .config-section {
    padding: 8px 12px;
  }

  .config-grid {
    gap: 12px;
  }

  .selector-btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  .age-input {
    padding: 14px 8px;
    font-size: 13px;
    width: 70px;
  }

  .calculator-main {
    height: calc(100vh - 100px);
    overflow: hidden;
  }

  .content-area {
    padding: 12px;
    height: 100%;
    overflow: hidden;
  }

  /* Single combined events section for small screens */
  .events-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
    padding: 12px;
  }

  .event-section {
    background: transparent;
    border: none;
    padding: 0;
    margin-bottom: 10px;
  }

  .event-section:last-child {
    margin-bottom: 0;
  }

  .event-header {
    font-size: 13px;
    margin-bottom: 6px;
  }

  .compact-input {
    font-size: 16px;
    padding: 10px 6px;
    min-height: 44px;
  }

  .input-label {
    font-size: 10px;
    margin-top: 3px;
  }

  .time-separator {
    font-size: 18px;
    margin-top: -26px;
  }

  .calculate-btn {
    padding: 14px;
    font-size: 16px;
    margin-top: 12px;
    flex-shrink: 0; /* Prevent button from shrinking */
    min-height: 50px; /* Ensure minimum button height */
  }

  .loading-section {
    padding: 40px 16px;
  }

  .spinner {
    width: 45px;
    height: 45px;
  }

  .loading-text h3 {
    font-size: 18px;
  }

  .loading-text p {
    font-size: 13px;
  }

  .results-section {
    padding: 12px;
    height: 100%;
    overflow-y: auto; /* Allow vertical scrolling when needed */
    overflow-x: hidden; /* Prevent horizontal scrolling */
  }

  .back-to-events-btn {
    padding: 8px 12px;
    font-size: 13px;
    margin-bottom: 12px;
  }

  .input-recap-section {
    padding: 10px;
    margin-bottom: 10px;
  }

  .recap-header {
    font-size: 14px;
    margin-bottom: 8px;
  }

  .recap-grid {
    gap: 6px;
  }

  .recap-item {
    padding: 5px 6px;
  }

  .recap-label,
  .recap-value {
    font-size: 11px;
  }

  .results-table {
    margin-bottom: 10px;
    min-height: 0; /* Allow table to shrink if needed */
  }

  .results-row {
    grid-template-columns: 35px 50px 1fr 50px;
    padding: 12px 14px;
    min-height: 45px; /* Set minimum height instead of flex: 1 */
  }

  .event-icon {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .event-name {
    font-size: 13px;
    color: #ffffff;
  }

  .raw-score {
    font-size: 12px;
    color: #cccccc;
  }

  .points {
    font-size: 15px;
  }

  .total-section {
    gap: 8px;
    margin-bottom: 8px;
  }

  .total-score,
  .pass-fail-indicator {
    padding: 14px;
  }

  .score-number {
    font-size: 30px;
  }

  .score-max {
    font-size: 16px;
  }

  .status-text {
    font-size: 18px;
  }

  .feedback-section {
    padding: 10px;
    margin-bottom: 0;
  }

  .feedback-text {
    font-size: 12px;
    margin: 0;
  }

  .dual-input-row {
    gap: 8px;
  }

  .time-input-row {
    gap: 4px;
  }
}

/* Extra Small Mobile - Maximum Screen Utilization */
@media (max-width: 360px) {
  /* Minimal header for maximum content space */
  .header-section {
    padding: 6px 10px 4px 10px;
  }

  .logo-image {
    width: 28px;
    height: 28px;
  }

  .calculator-title {
    font-size: 14px;
  }

  .calculator-subtitle {
    font-size: 9px;
  }

  .config-section {
    padding: 6px 10px;
  }

  .config-grid {
    gap: 10px;
  }

  .selector-btn {
    padding: 5px 8px;
    font-size: 11px;
  }

  .age-input {
    padding: 14px 6px;
    font-size: 12px;
    width: 60px;
  }

  .calculator-main {
    height: calc(100vh - 85px);
    overflow: hidden;
  }

  .content-area {
    padding: 10px;
    height: 100%;
    overflow: hidden;
  }

  .events-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
    padding: 10px;
  }

  .event-section {
    background: transparent;
    border: none;
    padding: 0;
    margin-bottom: 8px;
  }

  .event-section:last-child {
    margin-bottom: 0;
  }

  .event-header {
    font-size: 12px;
    margin-bottom: 5px;
  }

  .compact-input {
    font-size: 15px;
    padding: 8px 4px;
    min-height: 40px;
    border-radius: 6px;
  }

  .input-label {
    font-size: 9px;
    margin-top: 2px;
  }

  .time-separator {
    font-size: 16px;
    margin-top: -24px;
  }

  .calculate-btn {
    padding: 12px;
    font-size: 15px;
    margin-top: 10px;
    border-radius: 8px;
    flex-shrink: 0; /* Prevent button from shrinking */
    min-height: 45px; /* Ensure minimum button height */
  }

  .loading-section {
    padding: 30px 12px;
  }

  .spinner {
    width: 40px;
    height: 40px;
  }

  .loading-text h3 {
    font-size: 16px;
  }

  .loading-text p {
    font-size: 12px;
  }

  .results-section {
    padding: 10px;
    height: 100%;
    overflow-y: auto; /* Allow vertical scrolling when needed */
    overflow-x: hidden; /* Prevent horizontal scrolling */
  }

  .back-to-events-btn {
    padding: 6px 10px;
    font-size: 12px;
    margin-bottom: 8px;
    border-radius: 6px;
  }

  .input-recap-section {
    padding: 8px;
    margin-bottom: 8px;
    border-radius: 8px;
  }

  .recap-header {
    font-size: 13px;
    margin-bottom: 6px;
  }

  .recap-grid {
    gap: 4px;
  }

  .recap-item {
    padding: 4px 5px;
    border-radius: 4px;
  }

  .recap-label,
  .recap-value {
    font-size: 10px;
  }

  .results-table {
    margin-bottom: 8px;
    border-radius: 8px;
    min-height: 0; /* Allow table to shrink if needed */
  }

  .results-row {
    grid-template-columns: 30px 45px 1fr 45px;
    padding: 10px 12px;
    min-height: 40px; /* Set minimum height instead of flex: 1 */
  }

  .event-icon {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }

  .event-name {
    font-size: 12px;
    color: #ffffff;
  }

  .raw-score {
    font-size: 11px;
    color: #cccccc;
  }

  .points {
    font-size: 14px;
  }

  .total-section {
    gap: 6px;
    margin-bottom: 6px;
  }

  .total-score,
  .pass-fail-indicator {
    padding: 12px;
    border-radius: 8px;
  }

  .score-number {
    font-size: 26px;
  }

  .score-max {
    font-size: 14px;
  }

  .status-text {
    font-size: 16px;
  }

  .feedback-section {
    padding: 8px;
    border-radius: 8px;
    margin-bottom: 0;
  }

  .feedback-text {
    font-size: 11px;
    margin: 0;
  }

  .dual-input-row {
    gap: 6px;
  }

  .time-input-row {
    gap: 3px;
  }
}

/* Landscape orientation optimizations */
@media (max-width: 768px) and (orientation: landscape) {
  .header-section {
    padding: 4px 12px 2px 12px;
  }

  .config-section {
    padding: 6px 12px;
  }

  .calculator-main {
    min-height: calc(100vh - 70px);
  }

  .content-area {
    padding: 8px 12px;
  }

  .events-container {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
  }

  .event-section.full-width {
    grid-column: 1 / -1;
  }

  .calculate-btn {
    padding: 10px;
    font-size: 16px;
    margin-top: 8px;
  }

  .results-section {
    padding: 8px 12px;
  }

  .total-section {
    flex-direction: row;
    gap: 8px;
  }
}

/* Mobile-specific enhancements */
@media (max-width: 768px) {
  /* Prevent zoom on input focus */
  input[type="number"] {
    font-size: 16px !important;
  }

  /* Better touch targets */
  .selector-btn,
  .calculate-btn,
  .back-to-events-btn {
    min-height: 44px;
    touch-action: manipulation;
  }

  /* Prevent text selection on buttons */
  .selector-btn,
  .calculate-btn,
  .back-to-events-btn {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }

  /* Allow scrolling when content exceeds viewport */
  .results-section {
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Remove tap highlight */
  * {
    -webkit-tap-highlight-color: transparent;
  }

  /* Better focus states for accessibility */
  .compact-input:focus,
  .age-input:focus {
    outline: 3px solid rgba(255, 215, 0, 0.5);
    outline-offset: 2px;
  }

  /* Haptic feedback simulation */
  .selector-btn:active,
  .calculate-btn:active,
  .back-to-events-btn:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }

  /* Status bar safe area (for iOS) */
  @supports (padding-top: env(safe-area-inset-top)) {
    .header-section {
      padding-top: calc(env(safe-area-inset-top) + 8px);
    }
  }

  /* Bottom safe area (for iOS) */
  @supports (padding-bottom: env(safe-area-inset-bottom)) {
    .calculator-main {
      padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
    }
  }

  /* Dark mode optimizations */
  @media (prefers-color-scheme: dark) {
    .results-table {
      background: #1a1a1a;
    }

    .event-section {
      border-color: rgba(255, 215, 0, 0.3);
    }
  }

  /* Reduced motion for accessibility */
  @media (prefers-reduced-motion: reduce) {
    .calculate-btn::before,
    .results-section,
    .loading-section {
      animation: none;
      transition: none;
    }
  }

  /* High contrast mode support */
  @media (prefers-contrast: high) {
    .compact-input,
    .age-input {
      border-width: 3px;
    }

    .selector-btn.active {
      border: 3px solid #000;
    }
  }
}
