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

body {
  font-family: 'Inter', sans-serif;
  background-color: #ecf0f1;
  color: #2c3e50;
  line-height: 1.6;
}

/* Page header */
.header-left {
  justify-self: start;
}

.page-header {
  text-align: center;
  color: var(--navy);
  padding: 1rem;
  position: relative;
}

.header-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.page-title {
  margin: 0;
  justify-self: center; /* ensures exact centering of the title cell */
  font-size: 2rem;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
}
.header-actions {
  justify-self: end;
}

/* mobile: stack nicely */
@media (max-width: 767px) {
  .header-grid {
    grid-template-columns: 1fr; /* stack everything */
    grid-auto-flow: row;
    text-align: left;
  }
  .page-title {
    justify-self: start;
  }
  .header-actions {
    justify-self: start;
    width: 100%;
    margin-top: 8px;
  }
}
.cols {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.page-title {
  margin: 0;
  justify-self: center;
  font-size: 2rem;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
}

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

@media (max-width: 767px) {
  .header-grid {
    grid-template-columns: 1fr; /* stack everything */
    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;
  }
}

:root {
  --navy: #2c3e50;
  --softgray: #ecf0f1;
  --teal: #1abc9c;
  --gold: #f1c40f;
  --slate: #7f8c8d;
  --coral: #e74c3c;
  --white: #ffffff;
  --gray-100: #f7fafc;
  --gray-200: #edf2f7;
  --gray-300: #e2e8f0;
  --teal-h: 174;
  --teal-s: 72%;
  --teal-l: 41%; /* base lightness */
  --teal: hsl(var(--teal-h) var(--teal-s) var(--teal-l));
  --teal-light: hsl(var(--teal-h) var(--teal-s) calc(var(--teal-l) + 12%));
  --teal-dark: hsl(var(--teal-h) var(--teal-s) calc(var(--teal-l) - 12%));
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1em;
  background: var(--white);
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

/* Button styles */
.btn {
  display: inline-block;
  padding: 0.8rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
  border: 1px solid transparent;
  font-size: 1rem;
}

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

.teal-btn:hover {
  background-color: var(--teal-light);
}

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

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

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

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

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

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

.page-header h1 {
  font-family: 'Montserrat', sans-serif;
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  text-align: center;
  color: var(--navy);
}

.summary {
  background: rgba(26, 188, 156, 0.1);
  border: 2px solid var(--teal);
  border-radius: 10px;
  padding: 15px 20px;
  margin-bottom: 20px;
  text-align: center;
  color: var(--navy);
}
.header h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.header p {
  opacity: 0.9;
  font-size: 1.1rem;
  color: var(--softgray);
}

.controls {
  padding: 1.5rem;
  background: var(--gray-200);
  border-bottom: 2px solid var(--gray-300);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: center;
}

.scenario-btn {
  padding: 0.8rem 1.5rem;
  border: none;
  border-radius: 0.5rem;
  background: var(--slate);
  color: var(--white);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1rem;
}

.scenario-btn:hover {
  background: var(--navy);
  transform: translateY(-2px);
}

.scenario-btn.active {
  background: var(--navy);
}

.action-btn {
  display: inline-block;
  padding: 0.8rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
  border: 1px solid transparent;
  font-size: 1rem;
}

.action-btn:hover {
  background: var(--teal-light);
  color: var(--white);
}

.action-btn.active {
  background: var(--teal-dark);
  color: var(--white);
}
/* Prevent text selection and native dragging inside the simulation during interactions */
.simulation-area,
.simulation-area * {
  -webkit-user-select: none; /* Safari */
  -moz-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

.simulation-area {
  user-select: none;
  touch-action: none;
}

.compass,
.magnet,
.plot-point {
  touch-action: none;
}

.simulation-area {
  position: relative;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  height: 600px;
  background: var(--gray-200);
  overflow: hidden;
  cursor: crosshair;
  border: 2px solid var(--gray-300);
  touch-action: none;
}

.simulation-area.drawing-mode {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><circle cx="10" cy="10" r="2" fill="%231ABC9C"/></svg>')
      10 10,
    crosshair;
}

.magnet {
  position: absolute;
  border-radius: 0.2rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 1.125rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.magnet.north {
  background: linear-gradient(135deg, var(--coral), #c0392b);
}

.magnet.south {
  background: linear-gradient(135deg, var(--navy), #2980b9);
}

.compass {
  position: absolute;
  width: 50px;
  height: 50px;
  border: 3px solid var(--navy);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
  touch-action: none;
}

.compass:active {
  cursor: grabbing;
}

.compass-needle {
  width: 40px;
  height: 2px;
  background: linear-gradient(
    90deg,
    var(--coral) 0%,
    var(--coral) 50%,
    var(--navy) 50%,
    var(--navy) 100%
  );
  border-radius: 2px;
  transform-origin: center;
  transition: transform 0.3s ease;
}

.compass-needle {
  position: relative;
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, #2c3e50 0%, #2c3e50 50%, #e74c3c 50%, #e74c3c 100%);
  transform-origin: center;
  transition: transform 0.15s ease, opacity 0.15s ease;
  display: block;

  transform: translateY(-50%);
}

.compass-needle::after {
  content: '';
  position: absolute;
  right: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid #e74c3c;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  pointer-events: none;
}

.plot-point {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--coral);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 50;
}

.field-line {
  position: absolute;
  height: 2px;
  background: var(--teal);
  transform-origin: left center;
  z-index: 10;
  border-radius: 1px;
}

.drawn-line {
  position: absolute;
  background: var(--teal);
  border-radius: 1px;
  z-index: 10;
  pointer-events: none;
}

.instructions {
  background-color: var(--softgray);
  padding: 1rem;
  border-radius: 0.5rem;
}

.instructions h3 {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.instructions ol {
  padding-left: 1.25rem;
}

.instructions li {
  margin-bottom: 0.25rem;
}

.nav {
  background-color: var(--white);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 1rem;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.nav-flex {
  display: flex;
  justify-content: space-between;
  height: 4rem;
  align-items: center;
}

.nav-items {
  display: flex;
  align-items: center;
}

.nav-logo {
  display: flex;
  align-items: center;
}

.logo-icon {
  height: 2rem;
  width: 2rem;
  color: var(--teal);
}

.logo-text {
  margin-left: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
  color: var(--navy);
}

.nav-menu {
  display: none;
}

.nav-link {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--slate);
  text-decoration: none;
  transition: color 0.2s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--teal);
}

.nav-link.active {
  border-bottom: 2px solid var(--teal);
}

.mobile-menu-btn {
  display: flex;
  align-items: center;
}

.menu-icon {
  height: 1.5rem;
  width: 1.5rem;
  color: var(--navy);
}

.mobile-menu {
  padding: 0.5rem 0;
}

.mobile-menu-content {
  padding: 0.5rem 1rem;
}

.mobile-nav-link {
  display: block;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  color: var(--slate);
  text-decoration: none;
}

.mobile-nav-link:hover {
  color: var(--teal);
}

.hidden {
  display: none;
}

.nav-placeholder {
  background-color: var(--gray-200);
  padding: 1rem;
  text-align: center;
  color: var(--slate);
}

/* Footer styles */
.footer {
  background-color: var(--navy);
  color: var(--white);
  padding: 3rem 0;
  margin-top: 2rem;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  margin-bottom: 3rem;
}

.footer-logo {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
}

.footer-icon {
  height: 2rem;
  width: 2rem;
  color: var(--teal);
}

.footer-logo-text {
  margin-left: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
}

.footer-description {
  color: var(--softgray);
  margin-top: 1rem;
}

.footer-heading {
  font-size: 1.125rem;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  margin-bottom: 1rem;
}

.footer-links {
  list-style: none;
}

.footer-links li {
  margin-bottom: 0.5rem;
}

.footer-links a {
  color: var(--softgray);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--teal);
}

.footer-bottom {
  border-top: 1px solid #34495e;
  padding-top: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.copyright {
  color: var(--softgray);
}

.social-links {
  display: flex;
  gap: 1.5rem;
  margin-top: 1rem;
}

.social-icon {
  width: 24px;
  height: 24px;
  color: #e2e8f0;
}

.footer-placeholder {
  background-color: var(--gray-200);
  padding: 2rem;
  text-align: center;
  color: var(--slate);
}

/* Responsive design for components */
@media (min-width: 768px) {
  .nav-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
  }

  .mobile-menu-btn {
    display: none;
  }

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

  .footer-bottom {
    flex-direction: row;
    justify-content: space-between;
  }

  .social-links {
    margin-top: 0;
  }
}

@media (min-width: 1024px) {
  .nav-container,
  .footer-container {
    padding: 0 2rem;
  }
}
