:root {
  --ink: #173738;
  --muted: #667a76;
  --paper: #fffdf6;
  --cream: #f4efe3;
  --teal: #147f83;
  --teal-dark: #0b555c;
  --coral: #e85d49;
  --coral-dark: #b53d32;
  --gold: #efb84a;
  --blue: #326fa1;
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  min-width: 1080px;
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background: #e9eee8;
  font-family: ui-rounded, "Avenir Next", "Nunito Sans", system-ui, sans-serif;
}
button {
  font: inherit;
}
button:focus-visible,
[draggable="true"]:focus-visible {
  outline: 4px solid #123b69;
  outline-offset: 4px;
}
.game-shell {
  width: min(1340px, calc(100vw - 42px));
  height: min(824px, calc(100vh - 34px));
  margin: 17px auto;
  display: grid;
  grid-template-rows: 50px minmax(0, 1fr) 166px;
  gap: 13px;
}
.topline {
  display: grid;
  grid-template-columns: 260px 1fr 270px;
  align-items: center;
  padding: 0 10px;
}
.brand-mark {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand-mark span,
.eyebrow,
.mission-copy > span {
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.brand-mark strong {
  font-size: 16px;
}
.progress {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.progress i {
  width: 38px;
  height: 7px;
  border-radius: 99px;
  background: #cbd7cf;
  transition:
    transform 150ms ease-out,
    background 150ms ease-out;
}
.progress i.current {
  background: var(--gold);
  transform: scaleX(1.16);
}
.progress i.done {
  background: var(--teal);
}
.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}
.practice-stats {
  display: flex;
  gap: 13px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.practice-stats b {
  color: var(--ink);
  font-size: 18px;
}
.icon-button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 15px;
  color: white;
  background: var(--teal);
  cursor: pointer;
  font-size: 20px;
  box-shadow: 0 5px 0 var(--teal-dark);
}

.workbench {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: 174px minmax(0, 1fr) 204px;
  gap: 18px;
  padding: 21px;
  overflow: hidden;
  border-radius: 32px;
  background: linear-gradient(155deg, #f5e9d5, #ebdfcb);
  box-shadow: 0 20px 55px rgba(35, 65, 51, 0.14);
  isolation: isolate;
}
.workbench::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.1),
    rgba(66, 45, 27, 0.05)
  );
}
.composer,
.receiver {
  align-self: center;
  min-height: 360px;
  padding: 18px 16px;
  border: 1px solid rgba(34, 60, 50, 0.09);
  border-radius: 24px;
  background: rgba(255, 253, 246, 0.88);
  box-shadow: 0 10px 30px rgba(69, 49, 29, 0.09);
}
.composer p,
.receiver p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
}
.doodle,
.rebuilt {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 5px solid white;
  background: white;
  box-shadow: 0 7px 19px rgba(35, 64, 50, 0.12);
}
.doodle {
  width: 132px;
  height: 132px;
  margin: 18px auto 13px;
  transform: rotate(-2deg);
  border-radius: 17px;
}
.rebuilt {
  width: 144px;
  height: 144px;
  margin: 18px auto;
  border-radius: 18px;
  opacity: 0.17;
  transform: scale(0.93);
  transition:
    opacity 240ms ease-out,
    transform 240ms ease-out;
}
.rebuilt.complete {
  opacity: 1;
  transform: scale(1);
}
.tile {
  display: block;
}
.tile-1 {
  background:
    radial-gradient(circle at 75% 30%, #f8c94f 0 14%, transparent 15%),
    linear-gradient(150deg, #8fd9e5 55%, #4e9a72 56%);
}
.tile-2 {
  background: linear-gradient(210deg, #8fd9e5 52%, #4e9a72 53%);
}
.tile-3 {
  background: linear-gradient(28deg, #d9a55a 0 48%, #4e9a72 49%);
}
.tile-4 {
  background: linear-gradient(-24deg, #d9a55a 0 48%, #4e9a72 49%);
}
.split-preview {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}
.split-preview span {
  display: grid;
  place-items: center;
  height: 42px;
  border-radius: 11px 11px 5px 5px;
  color: white;
  background: var(--coral);
  box-shadow: inset 0 -4px 0 rgba(112, 35, 29, 0.22);
  font-weight: 950;
}
.split-preview.is-splitting span {
  animation: packet-pop 300ms ease-out both;
}
.split-preview.is-splitting span:nth-child(2) {
  animation-delay: 60ms;
}
.split-preview.is-splitting span:nth-child(3) {
  animation-delay: 120ms;
}
.split-preview.is-splitting span:nth-child(4) {
  animation-delay: 180ms;
}

.network-card {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(20, 79, 79, 0.12);
  border-radius: 28px;
  background: linear-gradient(180deg, #fdfbf2, #f2f5ec);
  box-shadow:
    inset 0 1px 0 white,
    0 12px 30px rgba(40, 65, 48, 0.1);
}
.network-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 253, 246, 0.08),
    rgba(16, 85, 92, 0.04)
  );
  pointer-events: none;
}
.links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  opacity: 0.78;
}
.links path {
  fill: none;
  stroke: rgba(23, 55, 56, 0.28);
  stroke-width: 7;
  stroke-linecap: round;
  transition:
    stroke 170ms ease-out,
    opacity 170ms ease-out;
}
.links path.active {
  stroke: #236f74;
  filter: drop-shadow(0 2px 2px rgba(14, 87, 92, 0.16));
}
.links path.congested {
  stroke: #bd7f19;
  stroke-dasharray: 11 10;
}
.links path.blocked {
  stroke: #b05c51;
  stroke-dasharray: 7 11;
  opacity: 0.55;
}
.links path.return-link {
  opacity: 0;
}
.links path.return-link.looping {
  opacity: 1;
  stroke: #b9493c;
  stroke-dasharray: 8 10;
}
.building {
  position: absolute;
  z-index: 3;
  width: 78px;
  height: 92px;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  border: 6px solid #f8f3e4;
  border-radius: 27px 27px 15px 15px;
  color: white;
  background: var(--coral);
  box-shadow:
    0 8px 0 #ac3e33,
    0 14px 28px rgba(46, 58, 43, 0.17);
}
.building span {
  font-size: 30px;
}
.building small {
  font-size: 11px;
  font-weight: 900;
}
.sender-building {
  left: 7%;
  top: 50%;
}
.receiver-building {
  left: 93%;
  top: 50%;
  background: var(--teal);
  box-shadow:
    0 8px 0 var(--teal-dark),
    0 14px 28px rgba(46, 58, 43, 0.17);
}
.router {
  position: absolute;
  z-index: 5;
  width: 72px;
  height: 72px;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  padding: 7px;
  border: 5px solid #fffdf6;
  border-radius: 22px;
  color: white;
  background: var(--teal);
  box-shadow:
    0 7px 0 var(--teal-dark),
    0 11px 20px rgba(27, 68, 59, 0.2);
  cursor: pointer;
  transition:
    transform 150ms ease-out,
    filter 150ms ease-out;
}
.router:hover {
  transform: translate(-50%, -54%);
}
.router:active {
  transform: translate(-50%, -48%) scale(0.98);
}
.router > span {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border-radius: 10px;
  color: var(--teal-dark);
  background: #f7ca65;
  font-weight: 1000;
}
.router small {
  font-size: 10px;
  font-weight: 900;
}
.router.active-router {
  animation: router-focus 780ms ease-out infinite alternate;
}
.router.drop-ready {
  filter: brightness(1.15);
  box-shadow:
    0 0 0 9px rgba(239, 184, 74, 0.3),
    0 7px 0 var(--teal-dark);
}
.router-a {
  left: 30%;
  top: 27%;
}
.router-b {
  left: 30%;
  top: 73%;
}
.router-c {
  left: 70%;
  top: 27%;
}
.router-d {
  left: 70%;
  top: 73%;
}
.queue {
  position: absolute;
  left: 61px;
  top: 12px;
  display: flex;
  gap: 3px;
  min-width: 0;
}
.queue b {
  display: block;
  width: 14px;
  height: 20px;
  border-radius: 5px 5px 2px 2px;
  color: white;
  background: var(--coral);
  font: 900 9px/20px system-ui;
}
.packet-layer {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}
.packet {
  position: absolute;
  width: 34px;
  height: 27px;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  border: 3px solid #fff4db;
  border-radius: 8px 8px 4px 4px;
  color: white;
  background: var(--coral);
  box-shadow: 0 4px 9px rgba(90, 45, 35, 0.25);
  font-size: 12px;
  font-weight: 1000;
  transition:
    left 360ms cubic-bezier(0.2, 0.8, 0.25, 1),
    top 360ms cubic-bezier(0.2, 0.8, 0.25, 1),
    opacity 180ms ease-out,
    transform 180ms ease-out;
}
.packet.queued {
  transform: translate(-50%, -50%) rotate(-6deg);
  background: #d98a35;
}
.packet.lost,
.packet.expired {
  opacity: 0.25;
  transform: translate(-50%, -50%) scale(0.72);
}
.map-note {
  position: absolute;
  left: 50%;
  bottom: 13px;
  z-index: 4;
  transform: translateX(-50%);
  padding: 8px 13px;
  border-radius: 99px;
  color: var(--teal-dark);
  background: rgba(255, 253, 246, 0.92);
  box-shadow: 0 6px 18px rgba(45, 73, 60, 0.1);
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.rack {
  display: grid;
  gap: 8px;
  margin-top: 19px;
}
.rack i {
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 2px dashed #c7d4cf;
  border-radius: 12px;
  color: white;
  background: rgba(239, 244, 238, 0.8);
  font-style: normal;
  font-weight: 1000;
  transition:
    transform 170ms ease-out,
    background 170ms ease-out;
}
.rack i.filled {
  border-style: solid;
  background: var(--coral);
  transform: translateX(-4px);
}
.celebration {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}
.celebration i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 18px;
  border-radius: 3px;
  opacity: 0;
}
.celebration.on i {
  animation: confetti 800ms ease-out forwards;
}

.action-tray {
  display: grid;
  grid-template-columns: minmax(330px, 0.9fr) minmax(600px, 1.7fr);
  align-items: center;
  gap: 26px;
  padding: 22px 28px;
  border-radius: 27px;
  background: var(--paper);
  box-shadow: 0 12px 34px rgba(36, 57, 47, 0.11);
}
.mission-copy h1 {
  margin: 5px 0 4px;
  max-width: 520px;
  font-size: clamp(23px, 2vw, 31px);
  line-height: 1.05;
  letter-spacing: -0.035em;
}
.mission-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}
.controls {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 11px;
}
.choice,
.primary,
.route-stamp {
  min-height: 60px;
  border: 0;
  border-radius: 17px;
  cursor: pointer;
  transition:
    transform 140ms ease-out,
    box-shadow 140ms ease-out;
}
.choice:hover,
.primary:hover,
.route-stamp:hover {
  transform: translateY(-3px);
}
.choice:active,
.primary:active,
.route-stamp:active {
  transform: translateY(1px) scale(0.98);
}
.choice {
  min-width: 160px;
  padding: 12px 17px;
  color: var(--ink);
  background: #edf2ed;
  font-weight: 900;
}
.choice small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}
.primary {
  min-width: 204px;
  padding: 14px 24px;
  color: white;
  background: var(--teal);
  box-shadow: 0 7px 0 var(--teal-dark);
  font-size: 16px;
  font-weight: 950;
}
.primary.coral {
  background: var(--coral);
  box-shadow: 0 7px 0 var(--coral-dark);
}
.primary.gold {
  color: #55380c;
  background: var(--gold);
  box-shadow: 0 7px 0 #b97d19;
}
.route-stamp {
  min-width: 170px;
  padding: 10px 16px;
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  background: #f1eee4;
  box-shadow: inset 0 0 0 2px #d8d2c1;
  text-align: left;
  font-weight: 900;
}
.route-stamp span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: white;
  background: var(--coral);
}
.route-stamp small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.feedback {
  max-width: 370px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.35;
}
.feedback strong {
  display: block;
  color: var(--ink);
  font-size: 19px;
}
.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;
}

@keyframes packet-pop {
  from {
    opacity: 0.2;
    transform: translateX(-20px) scale(0.7);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes router-focus {
  to {
    filter: brightness(1.12);
    box-shadow:
      0 0 0 8px rgba(239, 184, 74, 0.26),
      0 7px 0 var(--teal-dark);
  }
}
@keyframes confetti {
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: rotate(var(--angle)) translateY(-190px) rotate(220deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
