:root {
  --navy: #2c3e50;
  --softgray: #ecf0f1;
  --teal: #1abc9c;
  --gold: #f1c40f;
  --slate: #7f8c8d;
  --coral: #e74c3c;
  --white: #ffffff;
  --gray-100: #f7fafc;
  --gray-200: #edf2f7;
  --gray-300: #e2e8f0;
}

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

body {
  font-family:
    'Montserrat',
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    Arial;
  background: linear-gradient(135deg, #ecf0f1 0%, #d6dbdf 100%);
  color: var(--navy);
  line-height: 1.6;
  min-height: 100vh;
  padding: 16px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Header Styles */
.page-header {
  text-align: center;
  color: var(--navy);
  padding: 1rem;
  position: relative;
  margin-bottom: 24px;
}

.header-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.header-left {
  justify-self: start;
}

.page-title {
  margin: 0;
  justify-self: center;
  font-size: clamp(20px, 2.2vw, 28px);
  font-weight: 700;
}

.header-actions {
  justify-self: end;
}

/* Button Styles */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
  border: 1px solid transparent;
  font-size: 16px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.teal-btn {
  background-color: rgba(26, 188, 156, 0.8);
  color: white;
}

.teal-btn:hover {
  background-color: rgba(26, 188, 156, 0.7);
  transform: translateY(-2px);
}

.teal-btn:active {
  background-color: rgba(26, 188, 156, 0.6);
  transform: translateY(0);
}

.gold-btn {
  background-color: rgba(241, 196, 15, 0.8);
  color: var(--navy);
}

.gold-btn:hover {
  background-color: rgba(241, 196, 15, 0.7);
  transform: translateY(-2px);
}

.gold-btn:active {
  background-color: rgba(241, 196, 15, 0.6);
  transform: translateY(0);
}

.coral-btn {
  background-color: rgba(231, 76, 60, 0.8);
  color: white;
}

.coral-btn:hover {
  background-color: rgba(231, 76, 60, 0.7);
  transform: translateY(-2px);
}

.coral-btn:active {
  background-color: rgba(231, 76, 60, 0.6);
  transform: translateY(0);
}

.navy-btn {
  background-color: rgba(44, 62, 80, 0.8);
  color: white;
}

.navy-btn:hover {
  background-color: rgba(44, 62, 80, 0.7);
  transform: translateY(-2px);
}

.navy-btn:active {
  background-color: rgba(44, 62, 80, 0.6);
  transform: translateY(0);
}

/* Simulation Area */
.simulation-area {
  background: var(--gray-100);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
  position: relative;
  height: clamp(250px, 40vw, 300px);
  border: 2px solid #e2e8f0;
  overflow: hidden;
  width: 100%;
}

/* Ramp */
#ramp {
  position: absolute;
  bottom: 80px; /* Fixed position from bottom */
  left: 10%;
  width: 80%;
  height: 12px;
  background: linear-gradient(45deg, #8b4513, #a0522d);
  transform-origin: left bottom;
  border-radius: 4px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* Car */
#car {
  position: absolute;
  width: 60px;
  height: 40px;
  z-index: 10;
  bottom: 90px; /* Align with ramp bottom */
  left: 10%; /* Start at ramp beginning */
  transform-origin: center 110%;
  transition: all 0.1s ease;
}

#car svg {
  width: 100%;
  height: 100%;
}

/* Light Gates */
.light-gate {
  position: absolute;
  width: 6px;
  height: 80px; /* Tall enough to extend above ramp */
  background: #48bb78;
  border-radius: 2px;
  z-index: 5;
  bottom: 80px; /* Align with ramp bottom */
}

.light-gate.active {
  background: #f56565;
  box-shadow: 0 0 10px #f56565;
}

/* Controls */
.controls {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
}

.control-group {
  background: white;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.control-group h3 {
  margin-top: 0;
  margin-bottom: 16px;
  color: var(--navy);
  font-size: 1.2em;
}

.slider-container {
  margin: 15px 0;
}

.slider-container label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #4a5568;
}

.slider {
  width: 100%;
  height: 10px;
  border-radius: 4px;
  background: #e2e8f0;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  touch-action: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #4299e1;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.value-display {
  font-weight: bold;
  color: #2b6cb0;
  margin-left: 10px;
}

.timer-display {
  font-size: clamp(1.5em, 4vw, 2em);
  font-weight: bold;
  text-align: center;
  color: #2d3748;
  background: #edf2f7;
  padding: 12px;
  border-radius: 10px;
  margin: 16px 0;
  border: 2px solid #cbd5e0;
}

.buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 20px 0;
}

.status {
  text-align: center;
  padding: 10px;
  border-radius: 5px;
  margin: 10px 0;
  font-weight: 600;
}

.status.ready {
  background: #c6f6d5;
  color: #22543d;
}

.status.running {
  background: #fed7d7;
  color: #742a2a;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  margin-top: 16px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  min-width: 800px;
}

.data-table th,
.data-table td {
  padding: 12px;
  text-align: center;
  border-bottom: 1px solid #e2e8f0;
}

.data-table th {
  background: #4a5568;
  color: white;
  font-weight: 600;
}

.data-table tr:hover {
  background: #f7fafc;
}

tr.incomplete {
  opacity: 0.7;
  background-color: #fff5f5;
}

tr.incomplete td {
  border-bottom: 2px dashed #e53e3e;
}

.speed-input {
  width: 80px;
  padding: 5px;
  border: 1px solid #cbd5e0;
  border-radius: 4px;
  text-align: center;
  transition: all 0.3s ease;
}

.speed-input.correct {
  background-color: #c6f6d5;
  border-color: #48bb78;
}

.speed-input.incorrect {
  background-color: #fed7d7;
  border-color: #f56565;
}

.validation-icon {
  font-size: 20px;
  display: inline-block;
  width: 24px;
  height: 24px;
  text-align: center;
  line-height: 24px;
  border-radius: 50%;
}

.validation-icon.correct {
  color: #48bb78;
  background-color: #f0fff4;
}

.validation-icon.incorrect {
  color: #e53e3e;
  background-color: #fff5f5;
}

/* Instructions */
.instructions-content ol {
  padding-left: 1.25rem;
}

.instructions-content li {
  margin-bottom: 0.5rem;
}

/* Responsive Design */
@media (min-width: 480px) {
  .buttons {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

@media (min-width: 768px) {
  .simulation-area {
    height: clamp(300px, 40vw, 400px);
  }

  #ramp {
    height: 15px;
    left: 15%;
    width: 70%;
    bottom: 100px;
  }

  #car {
    width: 80px;
    height: 50px;
    left: 15%;
    bottom: 100px;
  }

  .light-gate {
    height: 100px;
    bottom: 100px;
  }

  .controls {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    gap: 24px;
  }
}

@media (min-width: 1024px) {
  #ramp {
    left: 20%;
    width: 60%;
  }

  #car {
    left: 20%;
  }
}

@media (max-width: 767px) {
  .header-grid {
    grid-template-columns: 1fr;
    grid-auto-flow: row;
    text-align: left;
  }

  .page-title {
    justify-self: start;
  }

  .header-actions {
    justify-self: start;
    width: 100%;
    margin-top: 8px;
  }

  .quiz-btn {
    width: 100%;
    max-width: 420px;
  }

  .control-group h3 {
    font-size: 1.1em;
  }

  .instructions-content {
    font-size: 14px;
  }

  .data-table th,
  .data-table td {
    padding: 8px 6px;
    font-size: 14px;
  }
}

#ramp,
#car,
.light-gate {
  visibility: hidden;
}
