.merge-game {
  display: grid;
  gap: 14px;
}

.merge-prompt,
.merge-status {
  min-width: 0;
  border: 1px solid #d3dbe7;
  border-radius: 8px;
  background: #f8fafc;
  color: #344054;
  padding: 10px 12px;
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.merge-status-good {
  border-color: #0f766e;
  background: #d7f4ef;
  color: #0f514b;
}

.merge-status-warn {
  border-color: #b45309;
  background: #fff7ed;
  color: #8a3b07;
}

.merge-scoreboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.merge-stat {
  min-width: 0;
  border: 1px solid #d3dbe7;
  border-radius: 8px;
  background: #ffffff;
  padding: 9px 10px;
  box-shadow: 0 8px 18px rgba(20, 31, 50, 0.05);
}

.merge-stat span {
  display: block;
  color: #667085;
  font-size: 12px;
  line-height: 1.25;
}

.merge-stat strong {
  display: block;
  min-height: 24px;
  margin-top: 3px;
  color: #17202a;
  font-size: 19px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.merge-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.42fr);
  gap: 12px;
  align-items: stretch;
}

.merge-stage,
.merge-console {
  min-width: 0;
  border: 1px solid #d3dbe7;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 22px rgba(20, 31, 50, 0.06);
}

.merge-stage {
  display: grid;
  gap: 12px;
  padding: 12px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 249, 250, 0.96)),
    repeating-linear-gradient(90deg, rgba(15, 118, 110, 0.05) 0, rgba(15, 118, 110, 0.05) 1px, transparent 1px, transparent 24px);
}

.merge-console {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 12px;
}

.merge-label {
  color: #475467;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
}

.merge-axis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0;
  min-height: 24px;
  color: #667085;
  font-size: 11px;
}

.merge-axis span {
  min-width: 0;
  text-align: center;
}

.merge-deck-wrap,
.merge-rail-wrap {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.merge-deck {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  gap: 8px;
}

.merge-card,
.merge-rail-card {
  min-width: 0;
  min-height: 54px;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #17202a;
  padding: 8px;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  display: grid;
  gap: 6px;
  align-content: center;
  box-shadow: 0 6px 14px rgba(20, 31, 50, 0.06);
}

.merge-card:active,
.merge-rail-card:active,
.merge-action-button:active,
.merge-small-button:active {
  transform: scale(0.98);
}

.merge-card:disabled,
.merge-rail-card:disabled,
.merge-action-button:disabled {
  cursor: default;
}

.merge-card-sorted {
  border-color: #0f766e;
  background: #ecfdf5;
  color: #0f514b;
  opacity: 0.72;
}

.merge-card-range,
.merge-rail-range {
  display: block;
  min-width: 0;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  overflow-wrap: anywhere;
}

.merge-mini-track {
  position: relative;
  display: block;
  width: 100%;
  min-height: 8px;
  border-radius: 999px;
  background: #e5eaf1;
  overflow: hidden;
}

.merge-mini-track span {
  position: absolute;
  left: var(--merge-left);
  top: 0;
  bottom: 0;
  width: var(--merge-width);
  border-radius: inherit;
  background: #0f766e;
}

.merge-card-wrong {
  border-color: #b42318;
  background: #fff1f0;
  animation: mergeWrong 360ms ease;
}

.merge-card-pulse {
  animation: mergePulse 560ms ease;
}

.merge-sorted-rail {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
}

.merge-rail-card {
  min-height: 70px;
  padding: 7px 6px;
  background: #f8fafc;
  color: #667085;
}

.merge-rail-ready {
  background: #ffffff;
  color: #17202a;
}

.merge-order-num {
  display: inline-grid;
  place-items: center;
  width: 22px;
  min-height: 22px;
  justify-self: center;
  border-radius: 999px;
  background: #eef2f6;
  color: #475467;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.merge-rail-processed {
  border-color: #0f766e;
}

.merge-rail-active {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12), 0 6px 14px rgba(20, 31, 50, 0.06);
}

.merge-rail-queued {
  border-color: #d97706;
  background: #fff7ed;
  color: #92400e;
}

.merge-rail-incoming {
  border-color: #7c3aed;
  background: #f5f3ff;
  color: #5b21b6;
}

.merge-machine {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.merge-timebar {
  position: relative;
  min-height: 106px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fbfcfe;
  overflow: hidden;
}

.merge-timebar-grid {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0, transparent calc(10% - 1px), rgba(102, 112, 133, 0.15) calc(10% - 1px), rgba(102, 112, 133, 0.15) 10%);
  pointer-events: none;
}

.merge-strip {
  position: absolute;
  left: var(--merge-left);
  width: var(--merge-width);
  min-width: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0 8px;
  min-height: 30px;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(20, 31, 50, 0.12);
}

.merge-strip b {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.merge-strip-current {
  top: 24px;
  background: #2563eb;
  color: #ffffff;
}

.merge-strip-incoming {
  top: 62px;
  background: #f59e0b;
  color: #3b2600;
}

.merge-strip-grow {
  animation: mergeGrow 520ms ease;
}

.merge-gate {
  position: absolute;
  left: 50%;
  top: 16px;
  bottom: 16px;
  width: 2px;
  border-radius: 999px;
  background: #cbd5e1;
}

.merge-gate::before {
  content: "";
  position: absolute;
  left: -8px;
  top: -2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #cbd5e1;
}

.merge-gate-open .merge-gate,
.merge-gate-open .merge-gate::before {
  background: #0f766e;
}

.merge-gate-stop .merge-gate,
.merge-gate-stop .merge-gate::before {
  background: #b45309;
}

.merge-machine-note {
  min-height: 24px;
  color: #475467;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.merge-output {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.merge-output-list {
  display: grid;
  gap: 7px;
  min-height: 44px;
  align-items: center;
}

.merge-output-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  border: 1px solid #d3dbe7;
  border-radius: 8px;
  background: #ffffff;
  padding: 7px;
  animation: mergeDrop 360ms ease;
}

.merge-output-index {
  display: grid;
  place-items: center;
  width: 26px;
  min-height: 26px;
  border-radius: 999px;
  background: #eef2f6;
  color: #475467;
  font-size: 12px;
  font-weight: 900;
}

.merge-output-track {
  position: relative;
  min-width: 0;
  min-height: 12px;
  border-radius: 999px;
  background: #e5eaf1;
  overflow: hidden;
}

.merge-output-track span {
  position: absolute;
  left: var(--merge-left);
  top: 0;
  bottom: 0;
  width: var(--merge-width);
  border-radius: inherit;
  background: #0f766e;
}

.merge-output-row strong {
  color: #17202a;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
}

.merge-empty {
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: #667085;
  font-size: 13px;
  text-align: center;
  padding: 8px;
}

.merge-console-head {
  min-width: 0;
  border: 1px solid #d3dbe7;
  border-radius: 8px;
  background: #fbfcfe;
  padding: 10px;
}

.merge-console-head span {
  display: block;
  color: #667085;
  font-size: 12px;
  line-height: 1.2;
}

.merge-console-head strong {
  display: block;
  margin-top: 4px;
  color: #17202a;
  font-size: 22px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.merge-action-pad {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.merge-action-button {
  min-width: 0;
  min-height: 76px;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #17202a;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  display: grid;
  place-items: center;
}

.merge-action-button:disabled {
  background: #eef2f6;
  opacity: 0.62;
}

.merge-action-hot {
  border-color: #0f766e;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14);
}

.merge-icon {
  position: relative;
  display: block;
  width: 46px;
  height: 38px;
}

.merge-icon-bind::before,
.merge-icon-bind::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  height: 12px;
  border-radius: 999px;
}

.merge-icon-bind::before {
  top: 7px;
  background: #2563eb;
  transform: rotate(-8deg);
}

.merge-icon-bind::after {
  bottom: 7px;
  background: #f59e0b;
  transform: rotate(8deg);
}

.merge-icon-bind span,
.merge-icon-bind i {
  display: none;
}

.merge-icon-bind {
  border-left: 5px solid #0f766e;
  border-right: 5px solid #0f766e;
  border-radius: 8px;
}

.merge-icon-drop::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 2px;
  width: 16px;
  height: 18px;
  border-radius: 4px;
  background: #2563eb;
}

.merge-icon-drop::after {
  content: "";
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 3px;
  height: 11px;
  border: 4px solid #0f766e;
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

.merge-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.merge-small-button {
  min-height: 44px;
  border: 1px solid #d3dbe7;
  border-radius: 8px;
  background: #ffffff;
  color: #17202a;
  padding: 0 13px;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.merge-small-button-primary {
  border-color: #0f766e;
  background: #0f766e;
  color: #ffffff;
}

.merge-small-button:focus-visible,
.merge-card:focus-visible,
.merge-rail-card:focus-visible,
.merge-action-button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

@keyframes mergeWrong {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@keyframes mergePulse {
  0% { box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.34), 0 6px 14px rgba(20, 31, 50, 0.06); }
  100% { box-shadow: 0 0 0 12px rgba(15, 118, 110, 0), 0 6px 14px rgba(20, 31, 50, 0.06); }
}

@keyframes mergeGrow {
  0% { transform: scaleX(0.88); transform-origin: left center; }
  100% { transform: scaleX(1); transform-origin: left center; }
}

@keyframes mergeDrop {
  0% { transform: translateY(-8px); opacity: 0.35; }
  100% { transform: translateY(0); opacity: 1; }
}

@media (max-width: 760px) {
  .merge-scoreboard {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .merge-stat {
    padding: 8px;
  }

  .merge-stat strong {
    font-size: 17px;
  }

  .merge-workbench {
    grid-template-columns: 1fr;
  }

  .merge-stage,
  .merge-console {
    padding: 10px;
  }

  .merge-deck {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .merge-sorted-rail {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .merge-rail-card {
    min-height: 66px;
  }

  .merge-card-range,
  .merge-rail-range {
    font-size: 14px;
  }

  .merge-timebar {
    min-height: 98px;
  }

  .merge-action-button {
    min-height: 68px;
  }

  .merge-console {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .merge-action-pad,
  .merge-status {
    grid-column: 1 / -1;
  }
}

@media (max-width: 390px) {
  .merge-scoreboard {
    gap: 6px;
  }

  .merge-stat span {
    font-size: 11px;
  }

  .merge-stat strong {
    font-size: 15px;
  }

  .merge-deck,
  .merge-sorted-rail {
    gap: 6px;
  }

  .merge-sorted-rail {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .merge-console {
    grid-template-columns: 1fr;
  }

  .merge-action-pad,
  .merge-status {
    grid-column: auto;
  }

  .merge-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .merge-small-button {
    width: 100%;
  }
}
