:root {
  --ink: #17343b;
  --paper: #fff8e8;
  --navy: #153d4a;
  --cyan: #53bfd1;
  --orange: #e8833b;
  --gold: #e9bd55;
  --red: #c94c40;
  --sand: #d7c39a;
  --shadow: 0 16px 36px rgba(31, 42, 39, 0.2);
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
  background: #d8d0bf;
  color: var(--ink);
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
}
button,
input {
  font: inherit;
}
.game-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 76px minmax(560px, 1fr) 176px;
  overflow: hidden;
}
.topbar {
  display: grid;
  grid-template-columns: 230px 1fr 150px 48px;
  align-items: center;
  gap: 22px;
  padding: 11px 30px;
  background: var(--navy);
  color: #fff;
}
.topbar > div:first-child {
  display: flex;
  flex-direction: column;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #f1c969;
}
.topbar strong {
  font-size: 20px;
}
.route {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.route i {
  width: 34px;
  height: 8px;
  border-radius: 99px;
  background: #52717b;
}
.route i.current {
  background: #fff;
}
.route i.done {
  background: var(--gold);
}
.stress-readout {
  text-align: right;
  display: flex;
  flex-direction: column;
}
.stress-readout span {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #bed2d6;
}
.stress-readout b {
  color: #f1c969;
}
.mute {
  width: 42px;
  height: 42px;
  border: 1px solid #66828b;
  border-radius: 50%;
  background: #234d59;
  color: #fff;
  cursor: pointer;
}
.lab {
  position: relative;
  overflow: hidden;
  padding: 18px 28px;
  background: linear-gradient(#e9e2d1 0 74%, #ba8d5f 74%);
}
.placard {
  position: absolute;
  left: 30px;
  top: 20px;
  z-index: 5;
  padding: 9px 14px;
  border-radius: 12px;
  background: rgba(255, 248, 232, 0.92);
  box-shadow: 0 6px 16px rgba(40, 37, 31, 0.13);
  display: flex;
  gap: 9px;
  align-items: baseline;
}
.placard b {
  font:
    700 17px Georgia,
    serif;
}
.placard span {
  font-size: 11px;
  color: #617175;
}
.fault-table {
  position: absolute;
  left: 5%;
  top: 92px;
  width: 55%;
  height: 320px;
  border: 15px solid #896845;
  border-radius: 28px;
  background: #477989;
  box-shadow:
    inset 0 0 0 8px #b68e5e,
    var(--shadow);
  overflow: hidden;
}
.crust {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 51%;
  overflow: hidden;
  background: repeating-linear-gradient(
    165deg,
    #c9a769 0 23px,
    #b58955 24px 47px,
    #9e754b 48px 69px
  );
  transition: transform 0.22s ease-out;
}
.crust.left {
  left: -4%;
  clip-path: polygon(0 0, 94% 0, 100% 35%, 91% 56%, 100% 74%, 92% 100%, 0 100%);
}
.crust.right {
  right: -4%;
  clip-path: polygon(6% 0, 100% 0, 100% 100%, 8% 100%, 0 74%, 9% 56%, 0 35%);
}
.crust i {
  position: absolute;
  inset: 26px;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.06) 0 4px,
    transparent 4px 25px
  );
}
.crust b {
  position: absolute;
  top: 28px;
  color: #fff;
  text-shadow: 0 2px 4px #553a29;
}
.crust.left b {
  left: 34px;
}
.crust.right b {
  right: 34px;
}
.fault {
  position: absolute;
  z-index: 2;
  left: 48%;
  top: 0;
  bottom: 0;
  width: 4%;
  background: #332e2d;
  transform: skewY(-8deg);
  box-shadow: 0 0 18px rgba(255, 181, 83, 0.2);
}
.fault span {
  display: block;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent 0 13px,
    #e6c169 14px 18px,
    transparent 19px 33px
  );
  opacity: 0.65;
}
.strain-band {
  position: absolute;
  z-index: 4;
  left: 12%;
  right: 12%;
  bottom: 25px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 99px;
  background: #264f5c;
  overflow: hidden;
}
.strain-band span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #5ac3d2, #e8c154, #df7443);
  transition: width 0.16s;
}
.strain-band b {
  position: absolute;
  inset: 2px;
  text-align: center;
  color: #fff;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-shadow: 0 1px 2px #244;
}
.loading-arrows {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  top: 45%;
  display: flex;
  justify-content: space-between;
  padding: 0 55px;
  color: #fff;
  font-size: 44px;
  font-weight: 900;
  opacity: 0.75;
}
.rupture-rings {
  position: absolute;
  z-index: 8;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  opacity: 0;
}
.rupture-rings.on {
  opacity: 1;
}
.rupture-rings i {
  position: absolute;
  inset: 0;
  border: 4px solid #fff3b5;
  border-radius: 50%;
  animation: ring 1s ease-out forwards;
}
.rupture-rings i:nth-child(2) {
  animation-delay: 0.12s;
}
.rupture-rings i:nth-child(3) {
  animation-delay: 0.24s;
}
.fault-table.loaded .crust.left {
  transform: translateX(2%) translateY(-8px);
}
.fault-table.loaded .crust.right {
  transform: translateX(-2%) translateY(8px);
}
.fault-table.slip {
  animation: shake 0.5s ease-out;
}
.condition-board {
  position: absolute;
  right: 3%;
  top: 75px;
  width: 30%;
  padding: 15px 18px 12px;
  border-radius: 18px;
  background: rgba(255, 248, 232, 0.95);
  box-shadow: var(--shadow);
}
.board-title {
  display: block;
  margin-bottom: 8px;
  font:
    700 18px Georgia,
    serif;
}
.condition-board label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  margin: 8px 0;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.condition-board input {
  grid-column: 1/-1;
  width: 100%;
  accent-color: var(--orange);
}
.condition-board.locked {
  opacity: 0.78;
}
.sensor-field {
  position: absolute;
  left: 5%;
  right: 5%;
  top: 90px;
  height: 320px;
  display: none;
  align-items: flex-end;
  justify-content: space-around;
  padding: 0 30px 38px;
  border-radius: 24px;
  background:
    radial-gradient(
      circle at 13% 65%,
      rgba(232, 131, 59, 0.24),
      transparent 42%
    ),
    linear-gradient(#e0dbc9, #a8c4c1);
  box-shadow: var(--shadow);
}
.sensor-field.on {
  display: flex;
}
.wave-key {
  position: absolute;
  top: 18px;
  right: 22px;
  font-size: 11px;
}
.wave-key b {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin: 0 4px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
}
.sensor {
  position: relative;
  width: 25%;
  height: 166px;
  padding: 12px;
  border-radius: 13px;
  background: #fff8e8;
  box-shadow: 0 8px 16px rgba(35, 54, 56, 0.15);
  text-align: center;
}
.sensor:before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -38px;
  width: 5px;
  height: 38px;
  background: #35575d;
}
.sensor i {
  display: block;
  height: 70px;
  margin: 8px 0;
  background: linear-gradient(
    165deg,
    transparent 0 42%,
    #48a9b8 43% 46%,
    transparent 47% 52%,
    #e57a3d 53% 58%,
    transparent 59%
  );
  border-bottom: 1px solid #bdc9c5;
}
.sensor b,
.sensor span {
  display: block;
}
.sensor span {
  font-size: 11px;
  color: #52676c;
}
.structure-bench {
  position: absolute;
  left: 5%;
  right: 5%;
  top: 86px;
  height: 330px;
  display: none;
  align-items: flex-end;
  justify-content: center;
  gap: 105px;
  border-radius: 24px;
  background: linear-gradient(#d9e4df 0 74%, #957857 74%);
  box-shadow: var(--shadow);
}
.structure-bench.on {
  display: flex;
}
.input-tape {
  position: absolute;
  left: 20px;
  top: 18px;
  width: 240px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff8e8;
}
.input-tape span,
.input-tape b {
  display: block;
}
.input-tape span {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.input-tape i {
  display: block;
  height: 24px;
  background: linear-gradient(
    170deg,
    transparent 0 37%,
    #df7540 38% 45%,
    transparent 46% 52%,
    #377f90 53% 59%,
    transparent 60%
  );
}
.building {
  position: relative;
  width: 130px;
  display: flex;
  flex-direction: column-reverse;
  align-items: stretch;
  transform-origin: bottom center;
}
.building span {
  height: 42px;
  border: 6px solid #324b50;
  border-bottom: 0;
  background: rgba(255, 248, 232, 0.65);
}
.building b,
.building small {
  position: absolute;
  left: 50%;
  width: 190px;
  transform: translateX(-50%);
  text-align: center;
}
.building b {
  bottom: -28px;
}
.building small {
  bottom: -47px;
  color: #18343b;
}
.building.braced span {
  background:
    linear-gradient(45deg, transparent 44%, #c85b45 45% 51%, transparent 52%),
    linear-gradient(-45deg, transparent 44%, #c85b45 45% 51%, transparent 52%),
    rgba(255, 248, 232, 0.7);
}
.structure-bench.running .braced {
  animation: sway-small 0.55s ease-out 2;
}
.structure-bench.running .tall {
  animation: sway-large 0.55s ease-out 2;
}
.causal-strip {
  position: absolute;
  left: 5%;
  right: 5%;
  top: 86px;
  height: 330px;
  display: none;
  flex-direction: column;
  gap: 14px;
}
.causal-strip.on {
  display: flex;
}
.causal-pieces,
.causal-slots {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.causal-slots:before {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 42px;
  height: 5px;
  background: #98a7a2;
}
.causal-strip button {
  position: relative;
  z-index: 2;
  min-height: 108px;
  padding: 9px;
  border: 0;
  border-radius: 17px;
  background: #fff8e8;
  box-shadow: var(--shadow);
  cursor: pointer;
  color: var(--ink);
  touch-action: none;
}
.causal-strip button i {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin: 0 auto 6px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-style: normal;
  font-weight: 900;
}
.causal-strip button b,
.causal-strip button small {
  display: block;
}
.causal-strip button.proved {
  background: #dcecd9;
  opacity: 0.48;
}
.causal-strip button.proved i {
  background: #4b8b5d;
}
.causal-strip button.selected {
  box-shadow: 0 0 0 5px var(--gold), var(--shadow);
  transform: translateY(-4px);
}
.causal-slots button {
  min-height: 92px;
  border: 3px dashed #80959a;
  color: #53676b;
  background: rgba(255, 248, 232, 0.72);
}
.causal-slots button.filled {
  border-style: solid;
  border-color: #4b8b5d;
  color: var(--ink);
  background: #dcecd9;
}
.causal-slots button.drop-ready {
  border-color: var(--orange);
  background: #ffe1b7;
  box-shadow: 0 0 0 7px rgba(232, 131, 59, 0.23);
  transform: scale(1.04);
}
.causal-ghost {
  position: fixed;
  z-index: 1000;
  width: 170px;
  min-height: 88px;
  border: 4px solid #fff;
  border-radius: 17px;
  color: var(--ink);
  background: #ffe1b7;
  box-shadow: 0 18px 38px rgba(28, 43, 43, 0.35);
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(-4deg);
}
.energy-card {
  position: absolute;
  left: 5%;
  bottom: 22px;
  min-width: 285px;
  padding: 11px 15px;
  border-radius: 14px;
  background: #173f4b;
  color: #fff;
  box-shadow: var(--shadow);
}
.energy-card span,
.energy-card b,
.energy-card small {
  display: block;
}
.energy-card span {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #bcd2d5;
}
.energy-card b {
  font:
    700 22px Georgia,
    serif;
  color: #f0c86a;
}
.energy-card small {
  font-size: 10px;
}
.impact {
  position: absolute;
  z-index: 20;
  left: 47%;
  top: 48%;
  font:
    900 44px Georgia,
    serif;
  color: #fff;
  text-shadow: 0 5px 12px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.7);
}
.impact.on {
  animation: impact 0.8s ease-out;
}
.toast {
  position: absolute;
  z-index: 20;
  right: 28px;
  bottom: 24px;
  max-width: 370px;
  padding: 12px 17px;
  border-radius: 13px;
  background: #163d49;
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  transition: 0.16s;
}
.toast.on {
  opacity: 1;
  transform: none;
}
.lab.highlight .fault-table,
.lab.highlight .sensor-field,
.lab.highlight .structure-bench,
.lab.highlight .causal-strip {
  filter: drop-shadow(0 0 13px #fff);
}
.action-tray {
  display: grid;
  grid-template-columns: minmax(360px, 0.84fr) minmax(500px, 1.16fr);
  align-items: center;
  gap: 30px;
  padding: 23px 38px;
  background: var(--paper);
  border-top: 1px solid #d2c5ac;
}
.mission-copy span {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #a34234;
}
.mission-copy h1 {
  font:
    700 clamp(24px, 2.3vw, 36px)/1.06 Georgia,
    serif;
  margin: 6px 0;
}
.mission-copy p {
  margin: 0;
  color: #667478;
}
.controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.choice,
.primary,
.quiet,
.load-control {
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  padding: 11px 17px;
  font-weight: 850;
  cursor: pointer;
  transition: transform 0.15s ease-out;
}
.choice {
  background: #e6dece;
}
.choice small {
  display: block;
  font-size: 10px;
  color: #657276;
}
.primary {
  background: var(--navy);
  color: #fff;
}
.primary.gold {
  background: var(--gold);
  color: #19343b;
}
.quiet {
  background: transparent;
  border: 1px solid #bcb29f;
}
.load-control {
  min-width: 220px;
  background: var(--orange);
  color: #fff;
  box-shadow: 0 7px 0 #a65128;
}
.load-control:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 #a65128;
}
.choice:hover,
.primary:hover,
.quiet:hover {
  transform: translateY(-2px);
}
@keyframes ring {
  from {
    transform: scale(0.4);
    opacity: 1;
  }
  to {
    transform: scale(17);
    opacity: 0;
  }
}
@keyframes shake {
  15%,
  45% {
    transform: translateX(-7px);
  }
  30%,
  60% {
    transform: translateX(7px);
  }
  100% {
    transform: none;
  }
}
@keyframes impact {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6);
  }
  35% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.06);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.24);
  }
}
@keyframes sway-small {
  25% {
    transform: rotate(-2deg);
  }
  75% {
    transform: rotate(2deg);
  }
}
@keyframes sway-large {
  25% {
    transform: rotate(-7deg);
  }
  75% {
    transform: rotate(7deg);
  }
}
@media (max-width: 980px) {
  .game-shell {
    grid-template-rows: 72px minmax(640px, 1fr) auto;
  }
  .topbar {
    grid-template-columns: 1fr auto auto;
  }
  .route,
  .stress-readout {
    display: none;
  }
  .lab {
    min-width: 900px;
  }
  .action-tray {
    grid-template-columns: 1fr;
    padding: 22px;
  }
  .controls {
    justify-content: flex-start;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
