
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  background: #f5f7f8;
  font-family: Arial, Helvetica, sans-serif;
  color: #222;
}

body {
  overflow-x: hidden;
}


/* =====================================================
   TOP SIMULATION
   ===================================================== */

#simulationArea {
  position: relative;
  width: 100%;
  height: 72vh;
  min-height: 590px;
  max-height: 760px;
  overflow: hidden;
  background: #cfe8f3;
  border-bottom: 1px solid #aaa;
}

#viewport {
  position: absolute;
  inset: 0;
  z-index: 1;
}

#viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
}


/* =====================================================
   TITLE
   ===================================================== */

#sceneTitle {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: min(800px, calc(100% - 30px));
  z-index: 4;
  text-align: center;
  pointer-events: none;
}

#sceneTitle h1 {
  margin: 0;
  color: brown;
  font-family: 'Roboto', serif;
  font-size: 27px;
  font-weight: 900;
  text-shadow:
    0 1px 2px white,
    0 0 4px white;
}


/* =====================================================
   CONTROLS - TOP CENTER / HORIZONTAL
   ===================================================== */

#controlsOverlay {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;

  width: min(1220px, calc(100% - 24px));

  color: #111;
  text-align: center;
}


/* no large panel */

.control-panel {
  width: 100%;

  padding: 0;
  margin: 0;

  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.control-panel h2 {
  display: none;
}


/* =====================================================
   THREE MAIN SLIDERS
   ===================================================== */

.controls-main-row {
  display: flex;
  justify-content: center;
  align-items: flex-start;

  gap: 28px;

  width: 100%;
  margin: 0 auto;

  flex-wrap: nowrap;
}


.control-group {
  width: 31%;
  max-width: 350px;
  min-width: 250px;

  margin: 0;

  color: #111;
  font-weight: bold;
  text-align: left;

  text-shadow:
    0 1px 2px rgba(255,255,255,.95),
    0 0 4px rgba(255,255,255,.95);
}


.slider-row {
  display: flex;
  align-items: center;

  gap: 9px;

  width: 100%;
  margin-top: 5px;
}


.slider-row input[type="range"] {
  flex: 1;
  min-width: 0;
}


.slider-row input[type="text"] {
  width: 62px;
  min-width: 62px;

  padding: 5px;

  color: #000 !important;
  background: #fff !important;

  border: 1px solid #555;
  border-radius: 4px;

  text-align: center;
  font-weight: bold;
}


.minmax {
  display: flex;
  justify-content: space-between;

  margin-top: 2px;
  padding-right: 72px;

  color: #222;
  font-size: 12px;
  font-weight: normal;

  text-shadow:
    0 1px 2px white,
    0 0 4px white;
}


/* =====================================================
   LIVE DATA
   ===================================================== */

.data-grid {
  display: flex;
  justify-content: center;
  align-items: center;

  gap: 18px;

  margin: 9px auto 0;

  color: #111;
  font-size: 13px;
  font-weight: bold;
  text-align: center;

  text-shadow:
    0 1px 2px white,
    0 0 4px white;
}


.data-grid > div {
  display: flex;
  align-items: center;

  gap: 6px;

  white-space: nowrap;
}


.data-grid input {
  width: 64px;

  margin: 0;
  padding: 5px;

  color: #000 !important;
  background: #fff !important;

  border: 1px solid #555;
  border-radius: 4px;

  text-align: center;
  font-weight: bold;
}


/* =====================================================
   BUTTONS
   ===================================================== */

.button-row {
  display: flex;
  justify-content: center;
  align-items: center;

  gap: 8px;

  flex-wrap: wrap;

  margin-top: 8px;
}


.button-row .btn {
  min-height: 40px;
}


/* put both button rows close together */

.button-row + .button-row {
  margin-top: 6px;
}


/* =====================================================
   ACCESSIBILITY
   ===================================================== */

button:focus,
button:focus-visible,
input:focus,
input:focus-visible,
select:focus,
select:focus-visible {
  outline: 3px solid #005fcc;
  outline-offset: 2px;
}


/* =====================================================
   STUDENT EXERCISE
   ===================================================== */

#exerciseSection {
  background: #fff;

  padding: 30px 20px 32px;

  border-bottom: 1px solid #ddd;
}


#exerciseSection h2 {
  margin: 0 0 22px;

  color: brown;

  text-align: center;
  font-weight: 700;
}


.exercise-grid {
  max-width: 1050px;
  margin: 0 auto;

  display: grid;

  grid-template-columns:
    repeat(4, minmax(180px, 1fr));

  gap: 16px;

  align-items: end;
}


.exercise-item label {
  display: block;

  margin-bottom: 6px;

  color: #222;
  font-weight: bold;
}


.exercise-item input,
.exercise-item select {
  width: 100%;
  min-height: 40px;

  padding: 7px 9px;

  color: #000 !important;
  background: #fff !important;

  border: 1px solid #777;
  border-radius: 4px;
}


.exercise-check .btn {
  width: 100%;
  min-height: 40px;
}


#resultMessage {
  display: none;

  width: fit-content;
  max-width: 900px;

  margin: 18px auto 0;
  padding: 10px 14px;

  background: #f0fff0;

  border: 1px solid #8bbd8b;
  border-radius: 6px;

  color: green;
  font-weight: bold;
  text-align: center;
}

#check-box {
  position: absolute;
  left: -9999px;
}


/* =====================================================
   INSTRUCTION / SEO CONTENT
   ===================================================== */

#seoContent {
  max-width: 1050px;

  margin: 0 auto;
  padding: 36px 24px 44px;

  background: #fff;

  font-size: 17px;
  line-height: 1.65;
}


#seoContent h2 {
  margin-top: 28px;

  color: brown;

  font-size: 25px;
}


#seoContent h3 {
  margin-bottom: 5px;

  font-size: 19px;
}


.formula-box {
  max-width: 520px;

  margin: 16px auto;
  padding: 12px 18px;

  background: #f4f8fb;

  border: 1px solid #b9ccd8;
  border-radius: 8px;

  font-size: 21px;
  font-weight: bold;
  text-align: center;
}


.related-links {
  columns: 2;

  padding-left: 24px;
}


footer {
  padding: 22px;

  background: #eceff1;

  border-top: 1px solid #ccc;

  text-align: center;
}


/* =====================================================
   POPUPS
   ===================================================== */

.popup-overlay {
  position: fixed;
  inset: 0;

  display: flex;
  justify-content: center;
  align-items: center;

  z-index: 9999;

  background: rgba(0,0,0,.55);
}


.popup-overlay[hidden] {
  display: none !important;
}


.popup-box {
  width: min(540px, 90%);

  padding: 20px;

  background: #fff;

  border: 3px solid #333;
  border-radius: 12px;

  box-shadow:
    0 8px 25px rgba(0,0,0,.35);

  font-size: 17px;
  line-height: 1.5;
}

.popup-box h2 {
  margin-top: 0;

  color: brown;

  text-align: center;
}


.popup-box button {
  display: block;

  margin: 15px auto 0;
}

.control-group {
  flex: 1 1 0;
  max-width: 360px;
  min-width: 0;
  margin: 0;
}
/* =========================================================
   FOOTER
   ========================================================= */

footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px;
  background: #1d3557;
  color: #fff;
  text-align: center;
}

footer a {
  color: #ffd166;
}
.controls-main-row {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: nowrap;
  width: 100%;
}

.control-group {
  flex: 1 1 0;
  max-width: 360px;
  min-width: 0;
  margin: 0;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

@media (max-width: 1000px) {

  #simulationArea {
    height: 760px;
    max-height: none;
  }

  #controlsOverlay {
    top: 54px;
  }

  .controls-main-row {
    gap: 14px;
  }

  .control-group {
    min-width: 210px;
  }

  .exercise-grid {
    grid-template-columns: 1fr 1fr;
  }
}


@media (max-width: 760px) {

  #simulationArea {
    height: 850px;
  }

  #sceneTitle h1 {
    font-size: 21px;
  }

  #controlsOverlay {
    top: 50px;
    width: calc(100% - 16px);
  }

  .controls-main-row {
    flex-wrap: wrap;
  }

  .control-group {
    width: 100%;
    max-width: 430px;
  }

  .data-grid {
    flex-wrap: wrap;
  }

  .exercise-grid {
    grid-template-columns: 1fr;
  }

  .related-links {
    columns: 1;
  }
}

