:root {
  --navy: #2c3e50;
  --teal: #1abc9c;
  --gold: #f1c40f;
  --coral: #e74c3c;
  --bg: #f0f4f8;
  --card: #ffffff;
  --text: #2c3e50;
  --border: #dde3ea;
}

/* --------------------------------
   Accessibility
----------------------------------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--navy);
  color: #fff;
  padding: 8px 16px;
  z-index: 1000;
  font-size: 0.9rem;
  text-decoration: none;
}

.skip-link:focus {
  left: 8px;
  top: 8px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --------------------------------
   Layout
----------------------------------- */
.main-content {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px;
  flex: 1;
}
.instructions {
    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);
}

.instructions a {
    color: var(--teal);
    font-weight: 700;
    text-decoration: underline;
}

.instructions a:hover {
    color: #16a085;
}
/* --------------------------------
   Header
----------------------------------- */
.page-header {
  text-align: center;
  margin-bottom: 24px;
}

.page-title {
  margin: 0 0 6px;
  font-size: clamp(1.3rem, 3vw, 2rem);
  font-weight: 700;
}

.page-subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: #6b7c8d;
  font-weight: 400;
}

/* --------------------------------
   Two-panel layout
----------------------------------- */
.sim-layout {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 24px;
  align-items: start;
}

.panel {
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

/* Apparatus panel */
.apparatus-panel {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.apparatus-panel canvas {
  display: block;
  max-width: 100%;
  height: auto;
  touch-action: none;
}

/* Controls panel */
.controls-panel {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* --------------------------------
   Sim controls
----------------------------------- */
.sim-controls {
  display: flex;
  gap: 10px;
}

/* --------------------------------
   Data table
----------------------------------- */
.data-table-heading {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.data-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

.data-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.toggle-label input[type='checkbox'] {
  accent-color: var(--teal);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: center;
}

.data-table th {
  background: var(--bg);
  font-weight: 600;
  font-size: 0.85rem;
}

.data-table td input {
  width: 80px;
  padding: 4px 6px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.data-table td input:focus {
  border-color: var(--teal);
}

/* --------------------------------
   Buttons
----------------------------------- */
.btn-reset {
  background: #0e8a72;
  color: #fff;
}

.btn-reset:hover {
  background: #0a7462;
}

.btn-clear {
  background: transparent;
  color: #c0392b;
  border: 1.5px solid #c0392b;
}

.btn-clear:hover {
  background: #c0392b;
  color: #fff;
}

/* --------------------------------
   Investigation section
----------------------------------- */
.investigation-section {
  margin-top: 24px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.investigation-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--navy);
  color: #fff;
  border: none;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.investigation-toggle:hover {
  background: #34495e;
}

.chevron {
  transition: transform 0.3s;
}

.investigation-toggle.open .chevron {
  transform: rotate(180deg);
}

.investigation-body {
  display: none;
  background: var(--card);
  padding: 20px 24px;
}

.investigation-body.open {
  display: block;
}

.investigation-body ol {
  margin: 0;
  padding-left: 1.5rem;
}

.investigation-body li {
  margin-bottom: 10px;
  font-size: 0.9rem;
  line-height: 1.65;
}

.investigation-body li:last-child {
  margin-bottom: 0;
}

/* --------------------------------
   Footer
----------------------------------- */
.site-footer {
  background: var(--navy);
  color: #fff;
  text-align: center;
  padding: 16px;
  font-size: 0.8rem;
  margin-top: 32px;
}

.site-footer p {
  margin: 0;
}

/* --------------------------------
   Canvas focus
----------------------------------- */
.apparatus-panel canvas:focus {
  outline: 3px solid var(--navy);
  outline-offset: 2px;
}

/* --------------------------------
   Reduced motion
----------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .chevron {
    transition: none;
  }

  .investigation-toggle {
    transition: none;
  }
}

/* --------------------------------
   Responsive — stacked on mobile
----------------------------------- */
@media (max-width: 800px) {
  .sim-layout {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 16px 12px;
  }

  .controls-panel {
    padding: 16px;
  }

  .data-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
