/* ── Science Lab (Phòng Thí Nghiệm) — technical illustration: paper, ink lines, blue shadows ── */

.worlds.worlds-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
.world-lab { background: #EEEBE6; box-shadow: inset 0 0 0 6px var(--orange), 0 6px 0 rgba(0, 0, 0, .08); }

.lab-picker {
  flex: 1; min-height: 0; display: grid; gap: var(--touch-gap);
  grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr));
}
.lab-card {
  position: relative; min-width: 96px; min-height: 96px; display: grid; place-items: center;
  border-radius: 24px; background: #EEEBE6; box-shadow: inset 0 0 0 3px var(--ink), 0 6px 0 #2B3A8F;
}
.lab-card:active { transform: translateY(4px); box-shadow: inset 0 0 0 3px var(--ink), 0 2px 0 #2B3A8F; }
.lab-card-ramp { grid-column: 1 / -1; }
.lab-art { width: min(62%, 220px); max-height: 72%; height: auto; }
.lab-card-star { position: absolute; bottom: 10px; right: 14px; width: 32px; height: 32px; }
.lab-card-star svg { width: 100%; height: 100%; fill: rgba(31, 41, 55, .16); }
.lab-card-star.is-done svg { fill: var(--yellow); stroke: var(--ink); stroke-width: 1.2; }
.lab-card.is-locked .lab-art { opacity: .45; filter: saturate(.35); }

.room-lab[data-screen="stage"] { gap: 12px; }
.lab-body { flex: 1; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 12px; }
.lab-view {
  position: relative; min-height: 0; border-radius: 28px; overflow: hidden;
  background: #EEEBE6; box-shadow: inset 0 0 0 3px var(--ink);
}
.lab-canvas { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }
.lab-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.lab-steps { display: flex; gap: 10px; }
.lab-step {
  position: relative; min-width: 64px; height: 64px; padding: 0 18px; border-radius: 999px;
  background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 3px var(--ink);
  font: 800 26px/1 var(--font-display); transition: background .2s ease, color .2s ease, transform .15s ease;
}
.lab-step .lab-step-num { display: inline-grid; place-items: center; }
.lab-step svg { width: 28px; height: 28px; fill: var(--yellow); stroke: var(--ink); stroke-width: 1.4; }
.lab-step.is-active { background: var(--ink); color: var(--paper); transform: translateY(-2px); }
.lab-step.is-done::after { content: ""; position: absolute; top: 6px; right: 8px; width: 12px; height: 12px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px var(--ink); }
.lab-tray { display: flex; gap: 10px; flex-wrap: wrap; }
.lab-tray[hidden], .lab-run[hidden] { display: none; }
.lab-item {
  width: 72px; height: 72px; border-radius: 18px; display: grid; place-items: center; touch-action: none;
  background: var(--paper); box-shadow: inset 0 0 0 3px var(--ink), 0 4px 0 #2B3A8F; transition: opacity .2s ease, transform .15s ease;
}
.lab-item:active { transform: translateY(3px); }
.lab-icon { width: 52px; height: 52px; }
.lab-item.is-used { opacity: .35; }
.lab-item.is-selected { box-shadow: inset 0 0 0 4px var(--yellow), 0 0 0 3px var(--ink), 0 4px 0 #2B3A8F; }
.lab-item.is-hint { animation: lab-hint 1s ease-in-out 3; }
.lab-run { width: 96px; height: 96px; margin-left: auto; border-radius: 50%; display: grid; place-items: center; filter: drop-shadow(0 6px 0 #2B3A8F); }
.lab-run svg { width: 96px; height: 96px; }
.lab-run:active { transform: translateY(3px); }
.lab-sticker { position: absolute; top: 18px; left: 50%; width: 110px; height: 110px; margin-left: -55px; pointer-events: none; animation: lab-pop .7s cubic-bezier(.3, 1.6, .5, 1) both; }
.lab-sticker svg { width: 100%; height: 100%; fill: var(--yellow); stroke: var(--ink); stroke-width: .9; filter: drop-shadow(4px 6px 0 #2B3A8F); }
.lab-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 14px; pointer-events: none; }
.lab-loading i { width: 22px; height: 22px; border-radius: 6px; background: var(--orange); box-shadow: inset 0 0 0 2px var(--ink); animation: bob 1s ease-in-out infinite; }
.lab-loading i:nth-child(2) { background: var(--blue); animation-delay: -.33s; }
.lab-loading i:nth-child(3) { background: var(--yellow); animation-delay: -.66s; }

@keyframes lab-pop { from { transform: scale(.2) rotate(-30deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes lab-hint { 0%, 100% { transform: none; } 50% { transform: translateY(-6px) scale(1.06); box-shadow: inset 0 0 0 4px var(--yellow), 0 0 0 3px var(--ink), 0 8px 0 #2B3A8F; } }

@media (orientation: landscape) {
  .lab-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
  .lab-card-ramp { grid-column: auto; }
}
/* Wide screens: the panel becomes a column on the right, steps stacked like the reference. */
@media (orientation: landscape) and (min-width: 900px) {
  .lab-body { grid-template-columns: minmax(0, 1fr) 248px; grid-template-rows: minmax(0, 1fr); }
  .lab-panel { flex-direction: column; flex-wrap: nowrap; align-items: stretch; align-content: flex-start; }
  .lab-steps { flex-direction: column; }
  .lab-step { width: 100%; }
  .lab-tray { display: grid; grid-template-columns: repeat(3, 72px); }
  .lab-run { margin: auto auto 0; }
}
@media (prefers-reduced-motion: reduce) {
  .lab-item.is-hint, .lab-sticker, .lab-loading i { animation: none; }
}
