.test-lab-panel {
  position: fixed;
  top: 76px;
  right: max(18px, env(safe-area-inset-right));
  z-index: 18;
  width: min(340px, calc(100vw - 32px));
  max-height: calc(100vh - 96px);
  overflow: auto;
  padding: 14px;
  color: #eef4ed;
  background:
    linear-gradient(180deg, rgba(13, 25, 23, 0.94), rgba(7, 12, 13, 0.93)),
    rgba(7, 12, 13, 0.93);
  border: 1px solid rgba(150, 180, 160, 0.24);
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.46), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  scrollbar-width: thin;
  scrollbar-color: rgba(134, 175, 157, 0.58) rgba(255, 255, 255, 0.05);
}

.test-lab-panel.hidden {
  display: none;
}

.test-lab-panel.is-collapsed {
  width: min(220px, calc(100vw - 32px));
  max-height: none;
}

.test-lab-panel.is-collapsed .test-lab-kicker,
.test-lab-panel.is-collapsed .test-lab-body {
  display: none;
}

.test-lab-panel *,
.test-lab-panel *::before,
.test-lab-panel *::after {
  box-sizing: border-box;
}

.test-lab-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
}

.test-lab-head-actions {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.test-lab-kicker {
  display: block;
  margin-bottom: 2px;
  color: #8cd7c5;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.test-lab-head h2 {
  margin: 0;
  color: #ffffff;
  font-size: 1.08rem;
  line-height: 1.2;
}

.test-lab-status {
  padding: 3px 8px;
  color: rgba(233, 240, 232, 0.72);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.test-lab-status.is-live {
  color: #0d1a14;
  background: #8fdcb0;
  border-color: #8fdcb0;
}

.test-lab-collapse {
  padding: 4px 10px;
  color: rgba(233, 240, 232, 0.86);
  font-size: 0.74rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  cursor: pointer;
}

.test-lab-collapse:hover {
  background: rgba(255, 255, 255, 0.16);
}

.test-lab-body {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.test-lab-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.test-lab-counter {
  display: grid;
  gap: 2px;
  padding: 6px 4px;
  text-align: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 6px;
}

.test-lab-counter span {
  color: rgba(228, 238, 229, 0.62);
  font-size: 0.66rem;
  font-weight: 700;
}

.test-lab-counter strong {
  color: #ffffff;
  font-size: 0.92rem;
}

.test-lab-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.test-lab-actions button {
  padding: 8px 4px;
  color: #e9f0e8;
  font-size: 0.76rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 6px;
  cursor: pointer;
}

.test-lab-actions button:hover {
  background: rgba(140, 215, 197, 0.18);
  border-color: rgba(140, 215, 197, 0.45);
}

.test-lab-actions button b {
  font-size: inherit;
}

.test-lab-team {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 6px;
}

.test-lab-team span {
  color: rgba(228, 238, 229, 0.68);
  font-size: 0.74rem;
  font-weight: 700;
}

.test-lab-team button {
  padding: 7px 4px;
  color: rgba(233, 240, 232, 0.72);
  font-size: 0.78rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  cursor: pointer;
}

.test-lab-team button.is-blue.is-active {
  color: #dff1ff;
  background: rgba(84, 156, 227, 0.32);
  border-color: rgba(126, 187, 245, 0.72);
}

.test-lab-team button.is-red.is-active {
  color: #ffe3dd;
  background: rgba(214, 88, 74, 0.32);
  border-color: rgba(240, 133, 118, 0.72);
}

.test-lab-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.test-lab-tab {
  padding: 8px 4px;
  color: rgba(233, 240, 232, 0.68);
  font-size: 0.8rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 6px;
  cursor: pointer;
}

.test-lab-tab.is-active {
  color: #0d1a14;
  background: #8cd7c5;
  border-color: #8cd7c5;
}

.test-lab-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.test-lab-card {
  display: grid;
  gap: 3px;
  padding: 9px 6px;
  text-align: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 6px;
  cursor: pointer;
}

.test-lab-card:hover {
  background: rgba(140, 215, 197, 0.14);
  border-color: rgba(140, 215, 197, 0.4);
}

.test-lab-card.is-active {
  background: rgba(140, 215, 197, 0.26);
  border-color: #8cd7c5;
  box-shadow: inset 0 0 0 1px rgba(140, 215, 197, 0.6);
}

.test-lab-card strong {
  color: #ffffff;
  font-size: 0.82rem;
  line-height: 1.25;
}

.test-lab-card small {
  color: rgba(228, 238, 229, 0.58);
  font-size: 0.66rem;
  line-height: 1.3;
}

.test-lab-hint {
  margin: 0;
  color: rgba(228, 238, 229, 0.6);
  font-size: 0.72rem;
  line-height: 1.5;
}

.test-lab-ghost {
  position: fixed;
  z-index: 40;
  display: grid;
  gap: 1px;
  padding: 6px 10px;
  pointer-events: none;
  color: #eef4ed;
  background: rgba(9, 16, 15, 0.92);
  border: 1px solid rgba(140, 215, 197, 0.55);
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}

.test-lab-ghost.hidden {
  display: none;
}

.test-lab-ghost.is-blue {
  border-color: rgba(126, 187, 245, 0.8);
}

.test-lab-ghost.is-red {
  border-color: rgba(240, 133, 118, 0.8);
}

.test-lab-ghost strong {
  font-size: 0.82rem;
}

.test-lab-ghost span {
  color: rgba(228, 238, 229, 0.66);
  font-size: 0.68rem;
}

body.test-lab-placing canvas {
  cursor: crosshair;
}

@media (max-width: 760px) {
  .test-lab-panel {
    top: auto;
    right: 10px;
    bottom: 12px;
    width: min(320px, calc(100vw - 20px));
    max-height: min(62vh, 520px);
  }

  .test-lab-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
