*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #1a1a1f;
  --panel: #252530;
  --panel-border: #3a3a48;
  --text: #e8e8ef;
  --muted: #9a9aad;
  --accent: #e6392f;
  --accent-dark: #b82820;
  --green: #2ecc71;
  --green-dark: #1e9e55;
  --yellow: #f4c430;
  --orange: #ff7a1a;
  /* Proporção fixa tipo YouTube */
  --stage-ratio: 16 / 9;
  --letterbox: #0c0c10;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--letterbox);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}

/**
 * Stage 16:9 (YouTube): maior área possível na janela, sem esticar.
 * Sem transform:scale — coords do gancho/mira batem com o layout.
 * --ui-scale: referência ao design 1920 (cargas etc.).
 */
#game-app {
  display: flex;
  flex-direction: column;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  max-width: 100vw;
  max-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  position: relative;
  container-type: size;
  container-name: game;
  --ui-scale: 1;
  --boom-base-w: 13cqw;
  --boom-base-h: 12cqw;
  --boom-arm-h: 2.4cqw;
  --boom-min-w: 9cqw;
  --boom-max-w: 74cqw;
}

.hud-top {
  padding: 10px 20px;
  background: linear-gradient(180deg, #2a2a35 0%, #1f1f28 100%);
  border-bottom: 2px solid var(--panel-border);
  flex-shrink: 0;
}

.hud-top h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.hud-top p {
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

.hud-top strong {
  color: var(--green);
}

.game-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

#scene {
  flex: 1;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 40%, #2a2a32 0%, var(--bg) 70%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 39px,
      rgba(255, 255, 255, 0.02) 39px,
      rgba(255, 255, 255, 0.02) 40px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 39px,
      rgba(255, 255, 255, 0.02) 39px,
      rgba(255, 255, 255, 0.02) 40px
    );
}

#world {
  position: absolute;
  inset: 0;
}

.berco-wrap {
  position: absolute;
  width: 72%;
  left: 14%;
  z-index: 4;
  pointer-events: none;
}

#berco-wrap-2 { top: 8%; }
#berco-wrap-1 { top: 52%; }

.berco {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

/* Contorno tracejado do berço selecionado */
.berco-wrap::after {
  content: "";
  position: absolute;
  inset: 0.5% 0.35%;
  border: 3px dashed transparent;
  border-radius: 4px;
  box-sizing: border-box;
  opacity: 0;
  transition: border-color 0.2s ease, opacity 0.2s ease;
  pointer-events: none;
  z-index: 3;
}

/* Recolore o texto "BERÇO N" pintado no PNG (faixa esquerda) */
.berco-tint {
  position: absolute;
  left: 0.5%;
  top: 4%;
  width: 9.5%;
  height: 92%;
  background: #ffffff;
  mix-blend-mode: color;
  opacity: 0;
  transition: opacity 0.2s ease, background-color 0.2s ease;
  pointer-events: none;
  z-index: 2;
}

.berco-name-label {
  position: absolute;
  left: 0.6%;
  top: 50%;
  transform: translateY(-50%) rotate(180deg);
  writing-mode: vertical-rl;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 800;
  font-size: clamp(16px, 2.35cqw, 38px);
  letter-spacing: 0.12em;
  line-height: 1;
  color: #ffffff;
  -webkit-text-stroke: 0.5px rgba(0, 0, 0, 0.45);
  opacity: 1;
  transition: color 0.2s ease;
  pointer-events: none;
  z-index: 4;
  white-space: nowrap;
}

.berco-wrap.is-selected::after {
  opacity: 1;
  border-color: #f5c400;
}

.berco-wrap.is-selected .berco-tint {
  opacity: 1;
}

.berco-wrap.is-selected.is-approach::after {
  border-color: #2ecc71;
}

.berco-wrap.is-selected.is-approach .berco-tint {
  background: #2ecc71;
}

.berco-wrap.is-selected.is-approach .berco-name-label {
  color: #2ecc71;
}

.berco-wrap.is-selected.is-retreat::after {
  border-color: #e74c3c;
}

.berco-wrap.is-selected.is-retreat .berco-tint {
  background: #e74c3c;
}

.berco-wrap.is-selected.is-retreat .berco-name-label {
  color: #e74c3c;
}

/* SOS: borda + texto do berço piscando em vermelho */
.berco-wrap.is-sos::after {
  opacity: 1;
  border-color: #ff0808;
  animation: berco-sos-border-flash 0.45s ease-in-out infinite;
}

.berco-wrap.is-sos .berco-tint {
  background: #ff0808;
  opacity: 1;
  animation: berco-sos-tint-flash 0.45s ease-in-out infinite;
}

.berco-wrap.is-sos .berco-name-label {
  color: #ff0808;
  opacity: 1;
  animation: berco-sos-text-flash 0.45s ease-in-out infinite;
}

@keyframes berco-sos-border-flash {
  0%, 100% {
    border-color: #ff0808;
    opacity: 1;
  }
  50% {
    border-color: #ffffff;
    opacity: 0.55;
  }
}

@keyframes berco-sos-tint-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

@keyframes berco-sos-text-flash {
  0%, 100% {
    color: #ff0808;
    opacity: 1;
  }
  50% {
    color: #ffffff;
    opacity: 0.4;
  }
}

/* Áreas verdes de espera dos operadores */
.op-zone {
  position: absolute;
  background: #45b649;
  border: 2px solid #2e8a3e;
  z-index: 2;
  pointer-events: none;
}

.op-zone-2 {
  left: 1.5%;
  top: 15%;
  width: 10.5%;
  height: 21%;
}

.op-zone-1 {
  left: 88%;
  top: 59%;
  width: 10.5%;
  height: 21%;
}

/* Alerta visual — giroflex + megafone no canto do berço */
.berth-alert {
  position: absolute;
  display: flex;
  flex-direction: row-reverse; /* megafone para dentro, giroflex na borda */
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
  z-index: 16;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -50%);
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.berth-alert.active {
  opacity: 1;
  visibility: visible;
}

#berth-alert-2 {
  left: calc(14% + 72% - 2%);
  top: calc(8% + 4%);
}

#berth-alert-1 {
  left: calc(14% + 72% - 2%);
  top: calc(52% + 4%);
}

/* ── Giroflex (luz rotativa) ── */
.giroflex {
  position: relative;
  width: 28px;
  height: 34px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
}

.giroflex-base {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 18px;
  height: 7px;
  margin-left: -9px;
  border-radius: 2px;
  background: linear-gradient(180deg, #555 0%, #222 100%);
  border: 1px solid #111;
}

.giroflex-dome {
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 22px;
  height: 22px;
  margin-left: -11px;
  border-radius: 50% 50% 45% 45%;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.55), transparent 45%);
}

.giroflex-beam {
  position: absolute;
  inset: -20%;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    transparent 55deg,
    rgba(255, 255, 255, 0.95) 90deg,
    transparent 125deg,
    transparent 360deg
  );
  opacity: 0.85;
}

.berth-alert.approach .giroflex-dome {
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.7), transparent 42%),
    radial-gradient(circle at 50% 55%, #3dff8a 0%, #129a4a 70%, #0a5c2c 100%);
  box-shadow:
    0 0 14px rgba(46, 255, 120, 0.95),
    0 0 28px rgba(46, 204, 113, 0.7);
  animation: giroflex-glow-green 0.55s linear infinite;
}

.berth-alert.retreat .giroflex-dome {
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.75), transparent 42%),
    radial-gradient(circle at 50% 55%, #ff6b5a 0%, #e02018 70%, #8a100a 100%);
  box-shadow:
    0 0 16px rgba(255, 40, 30, 1),
    0 0 32px rgba(255, 0, 0, 0.8);
  animation: giroflex-glow-red 0.45s linear infinite;
}

.berth-alert.active .giroflex-beam {
  animation: giroflex-spin 0.55s linear infinite;
}

.berth-alert.retreat.active .giroflex-beam {
  animation-duration: 0.4s;
}

@keyframes giroflex-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes giroflex-glow-green {
  0%, 100% {
    box-shadow: 0 0 10px rgba(46, 255, 120, 0.55), 0 0 18px rgba(46, 204, 113, 0.35);
  }
  50% {
    box-shadow: 0 0 22px rgba(80, 255, 150, 1), 0 0 40px rgba(46, 255, 120, 0.85);
  }
}

@keyframes giroflex-glow-red {
  0%, 100% {
    box-shadow: 0 0 10px rgba(255, 40, 30, 0.55), 0 0 18px rgba(255, 0, 0, 0.35);
  }
  50% {
    box-shadow: 0 0 24px rgba(255, 60, 40, 1), 0 0 44px rgba(255, 0, 0, 0.9);
  }
}

/* ── Megafone + ondas sonoras (apontando para dentro do berço) ── */
.megaphone {
  position: relative;
  display: flex;
  align-items: center;
  opacity: 0;
  /* Espelha: bocão + ondas ficam à esquerda, para dentro do berço */
  transform: translateX(4px) scaleX(-1);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.berth-alert.sound-on .megaphone {
  opacity: 1;
  transform: translateX(0) scaleX(-1);
}

.megaphone-icon {
  display: block;
  overflow: visible;
}

.megaphone-body,
.megaphone-handle {
  fill: #f0f2f5;
  stroke: #1a1a22;
  stroke-width: 2;
}

.berth-alert.approach .megaphone-body,
.berth-alert.approach .megaphone-handle {
  fill: #b8ffd0;
}

.berth-alert.retreat .megaphone-body,
.berth-alert.retreat .megaphone-handle {
  fill: #ffc4bc;
}

.sound-waves {
  position: absolute;
  left: 34px;
  top: 50%;
  width: 22px;
  height: 28px;
  margin-top: -14px;
  pointer-events: none;
}

.sound-waves .wave {
  position: absolute;
  left: 0;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border: 2.5px solid rgba(255, 255, 255, 0.95);
  border-left: none;
  border-radius: 0 50% 50% 0;
  opacity: 0;
}

.berth-alert.approach .sound-waves .wave {
  border-color: rgba(90, 255, 150, 0.95);
}

.berth-alert.retreat .sound-waves .wave {
  border-color: rgba(255, 90, 70, 0.98);
}

.berth-alert.sound-on .wave.w1 {
  animation: sound-wave 0.9s ease-out infinite;
  animation-delay: 0s;
}

.berth-alert.sound-on .wave.w2 {
  width: 16px;
  height: 16px;
  margin-top: -8px;
  animation: sound-wave 0.9s ease-out infinite;
  animation-delay: 0.18s;
}

.berth-alert.sound-on .wave.w3 {
  width: 22px;
  height: 22px;
  margin-top: -11px;
  animation: sound-wave 0.9s ease-out infinite;
  animation-delay: 0.36s;
}

@keyframes sound-wave {
  0% {
    opacity: 0;
    transform: scale(0.55);
  }
  35% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.15);
  }
}

/* Zonas CARGA (carregar / descarregar) */
#cargo-slots {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.cargo-slot {
  position: absolute;
  width: 7.5%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 2px dashed rgba(60, 180, 255, 0.45);
  border-radius: 4px;
  background: rgba(60, 180, 255, 0.08);
  box-sizing: border-box;
  animation: cargo-slot-pulse 2.4s ease-in-out infinite;
}

@keyframes cargo-slot-pulse {
  0%, 100% {
    border-color: rgba(60, 180, 255, 0.3);
    background: rgba(60, 180, 255, 0.05);
    box-shadow: 0 0 6px rgba(60, 180, 255, 0.12);
  }
  50% {
    border-color: rgba(90, 210, 255, 0.85);
    background: rgba(60, 180, 255, 0.2);
    box-shadow: 0 0 16px rgba(60, 180, 255, 0.4);
  }
}

.cargo-slot::after {
  content: "X";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0;
  color: rgba(220, 245, 255, 0.98);
  text-shadow: 0 0 8px rgba(60, 180, 255, 0.9);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.cargo-slot.active {
  animation: none;
  border-color: rgba(80, 200, 255, 0.98);
  background: rgba(60, 180, 255, 0.28);
  box-shadow: 0 0 14px rgba(60, 180, 255, 0.55);
}

.cargo-slot.active::after {
  opacity: 1;
}

.crane-static {
  position: absolute;
  top: 1%;
  left: 2%;
  width: 55%;
  pointer-events: none;
  z-index: 5;
  transform: scaleX(-1) rotate(-8deg);
  transform-origin: left top;
  opacity: 0.95;
}

.crane-static img {
  width: 100%;
  height: auto;
  display: block;
}

/* ── Guindaste segmentado — SEMPRE acima de cargas e operadores ── */
.crane-active {
  position: absolute;
  right: 2%;
  bottom: -1%;
  width: 65%;
  height: 55%;
  z-index: 22;
  pointer-events: none;
}

.crane-pivot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  transform-origin: 92% 88%;
}

.crane-base {
  position: absolute;
  right: 0;
  bottom: -4%;
  width: var(--boom-base-w);
  height: auto;
  z-index: 1;
  filter: drop-shadow(2px 4px 8px rgba(0, 0, 0, 0.6));
}

.crane-boom {
  position: absolute;
  right: calc(var(--boom-base-w) * 0.76);
  bottom: calc(var(--boom-base-h) * 0.08);
  width: var(--boom-min-w);
  height: var(--boom-arm-h);
  transform-origin: 100% 50%;
  z-index: 5;
  overflow: visible;
}

.crane-boom-segments {
  position: absolute;
  inset: 0;
  background: url("../assets/pedaco-braca-guindaste.png") repeat-x left center;
  background-size: auto 100%;
  filter: drop-shadow(2px 4px 8px rgba(0, 0, 0, 0.5));
}

.hook-mount {
  position: absolute;
  left: 0;
  top: 50%;
  width: 1px;
  height: 1px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 4;
}

/* Guincho + cabo: ponta do gancho acima do braço */
.hook-assembly {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 24;
  pointer-events: none;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hook-cable {
  display: block;
  width: 3px;
  height: 10px;
  background: linear-gradient(180deg, #666, #222);
  border-radius: 1px;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}

.crane-hook {
  display: block;
  width: max(10px, 0.91cqw);
  height: auto;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
  pointer-events: none;
  flex-shrink: 0;
}

/* Mira no plano dos berços — acima do guindaste para não sumir */
.hook-tracker {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  z-index: 30;
  pointer-events: none;
}

.hook-tracker-line {
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 80px;
  margin-left: -1.5px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(40, 48, 60, 0.35) 0 7px,
    transparent 7px 13px
  );
  display: block;
}

.hook-tracker-dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 16px;
  margin: -8px 0 0 -16px;
  border-radius: 50%;
  background: rgba(255, 210, 40, 0.25);
  border: 2px solid rgba(255, 220, 50, 0.95);
  box-shadow: 0 0 10px rgba(255, 200, 40, 0.4);
  display: block;
}

.hook-tracker-dot.over-target {
  background: rgba(70, 180, 90, 0.5);
  border-color: rgba(30, 140, 60, 0.95);
  box-shadow: 0 0 14px rgba(50, 200, 90, 0.5);
}

.hook-tracker-dot.on-floor {
  background: rgba(230, 80, 60, 0.4);
  border-color: rgba(200, 50, 40, 0.75);
  box-shadow: 0 0 12px rgba(220, 60, 50, 0.35);
}

/* Cargas no chão — abaixo do guindaste e dos operadores */
#cargos {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 11;
}

/* Operadores acima das cargas no chão, ABAIXO do braço do guindaste */
#special-operators,
#operators {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 12;
}

#special-operators {
  z-index: 13;
}

/* Carga engatada — abaixo do braço (nada passa na frente do guindaste) */
#cargos-air {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 14;
}

.cargo-item {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5));
  transition: filter 0.2s, outline 0.2s;
}

.cargo-item.crate {
  width: calc(52px * var(--ui-scale, 1));
  height: auto;
}

.cargo-item.tubes {
  width: calc(70px * var(--ui-scale, 1)) !important;
  max-width: calc(70px * var(--ui-scale, 1)) !important;
  height: auto !important;
}

.cargo-item.tubo {
  width: calc(160px * var(--ui-scale, 1)) !important;
  max-width: calc(160px * var(--ui-scale, 1)) !important;
  height: auto !important;
}

.cargo-item.tools {
  width: calc(53px * var(--ui-scale, 1)) !important;
  max-width: calc(53px * var(--ui-scale, 1)) !important;
  max-height: calc(53px * var(--ui-scale, 1)) !important;
  height: auto !important;
  object-fit: contain;
}

.cargo-item.container {
  width: calc(156px * var(--ui-scale, 1)) !important;
  max-width: calc(156px * var(--ui-scale, 1)) !important;
  height: auto !important;
}

.cargo-item.selected {
  filter:
    drop-shadow(0 0 10px rgba(70, 180, 255, 0.85))
    drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5))
    brightness(1.18)
    saturate(1.25);
  outline: 2px solid rgba(80, 190, 255, 0.9);
  outline-offset: 3px;
}

.cargo-item.working {
  filter:
    drop-shadow(0 0 12px rgba(255, 180, 60, 0.9))
    drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5))
    brightness(1.12);
  animation: cargo-work-pulse 0.6s ease-in-out infinite;
}

.cargo-item.attached {
  filter: drop-shadow(0 0 8px rgba(230, 57, 47, 0.6)) drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5));
}

@keyframes cargo-work-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.04); }
}

.operator.busy img {
  animation: op-busy 0.45s ease-in-out infinite alternate;
}

@keyframes op-busy {
  from { transform: translateY(0); }
  to { transform: translateY(-3px); }
}

/* Raio de segurança — centrado na bolinha do chão */
.safety-radius {
  position: absolute;
  border-radius: 50%;
  border: 4px dashed rgba(255, 20, 20, 0.98);
  background: radial-gradient(
    circle,
    rgba(255, 30, 20, 0.32) 0%,
    rgba(255, 15, 15, 0.16) 55%,
    rgba(255, 0, 0, 0.05) 100%
  );
  box-shadow:
    0 0 18px rgba(255, 20, 20, 0.7),
    inset 0 0 16px rgba(255, 30, 20, 0.28);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  transition: opacity 0.25s ease, width 0.2s ease, height 0.2s ease;
}

.safety-radius.active {
  animation: safety-blink 1.8s ease-in-out infinite;
}

@keyframes safety-blink {
  0%, 100% {
    opacity: 0.72;
    border-color: rgba(255, 20, 20, 0.9);
    box-shadow:
      0 0 14px rgba(255, 15, 15, 0.55),
      inset 0 0 12px rgba(255, 20, 20, 0.22);
  }
  50% {
    opacity: 1;
    border-color: #ff2020;
    box-shadow:
      0 0 34px rgba(255, 0, 0, 0.9),
      0 0 12px rgba(255, 80, 40, 0.9),
      inset 0 0 22px rgba(255, 20, 20, 0.38);
  }
}

.safety-radius.sos-flash {
  animation: safety-sos-flash 0.28s ease-in-out infinite;
  z-index: 25;
}

@keyframes safety-sos-flash {
  0%, 100% {
    opacity: 0.85;
    border-color: #ff1010;
    border-width: 5px;
    box-shadow:
      0 0 28px rgba(255, 0, 0, 0.95),
      0 0 60px rgba(255, 40, 20, 0.75),
      inset 0 0 30px rgba(255, 30, 20, 0.5);
  }
  50% {
    opacity: 1;
    border-color: #fff;
    border-width: 7px;
    box-shadow:
      0 0 55px rgba(255, 0, 0, 1),
      0 0 90px rgba(255, 80, 40, 1),
      0 0 24px rgba(255, 255, 255, 0.85),
      inset 0 0 45px rgba(255, 50, 30, 0.65);
  }
}

.operator,
.special-operator {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 1;
}

.operator img {
  display: block;
  height: calc(42px * var(--ui-scale, 1));
  width: auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.special-operator {
  z-index: 2;
}

.special-operator img {
  display: block;
  height: calc(38px * var(--ui-scale, 1));
  width: auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
  transition: height 0.2s ease;
}

/* Idle fica no tamanho normal; só o GIF fica maior (+200% = 3×) */
.special-operator.signal-pose {
  z-index: 3;
}

.special-operator.signal-pose img {
  height: calc(114px * var(--ui-scale, 1));
}

/* ── Painel ── */
.controls-panel {
  width: min(460px, 24cqw);
  flex-shrink: 0;
  background: var(--panel);
  border-left: 2px solid var(--panel-border);
  padding: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  min-height: 0;
  align-self: stretch;
}

.btn-info {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  width: 36px;
  height: 36px;
  border: 1px solid var(--panel-border);
  border-radius: 50%;
  background: #2f2f3a;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.btn-info:hover {
  color: var(--text);
  background: #3a3a48;
  border-color: #555;
}

.controls-crane {
  padding-right: 36px;
  flex-shrink: 0;
}

.tablet-section {
  flex: 1 1 0;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tablet-frame-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--panel-border);
  background: #ffffff;
}

.tablet-root {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.panel-section h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}

.controls-crane .control-subtitle {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: rgba(255, 255, 255, 0.45);
  margin: 12px 0 8px;
}

.controls-crane .control-subtitle:first-of-type {
  margin-top: 0;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.dot.orange { background: var(--orange); }
.dot.yellow { background: var(--yellow); }
.dot.red { background: var(--accent); }
.dot.green { background: #45b649; }
.dot.muted { background: #7a7a8a; }

/* Legenda flutuante no cenário */
.scene-legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 30;
  max-width: min(280px, 42vw);
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(18, 18, 24, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.scene-legend.is-on {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scene-legend ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.scene-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.3;
}

.scene-legend strong {
  color: var(--text);
}

/* Modal de informações */
.info-modal {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.info-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.info-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.info-modal-card {
  position: relative;
  width: min(480px, 100%);
  max-height: min(86vh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.info-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--panel-border);
}

.info-modal-header h2 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
}

.btn-info-close {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.btn-info-close:hover {
  background: #3a3a48;
  color: var(--text);
}

.info-modal-body {
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.info-modal-body h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 6px;
}

.info-modal-body p,
.info-legend-list li {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.info-modal-body strong {
  color: var(--green);
}

.info-legend-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.info-legend-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.info-modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--panel-border);
}

.btn-modal-action {
  flex: 1 1 160px;
  padding: 10px 12px;
  font-size: 0.75rem;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 0.65rem;
  background: #3a3a48;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: lowercase;
}

.controls-crane .crane-controls-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0;
}

.controls-crane .joystick-xy {
  width: 140px;
  height: 140px;
}

.controls-crane .btn-hook {
  width: 52px;
  height: 64px;
}

.controls-crane .joystick {
  padding: 0;
  flex-shrink: 0;
}

.controls-crane h2 {
  margin-bottom: 6px;
}

.hook-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex-shrink: 0;
}

.btn-hook {
  width: 60px;
  height: 74px;
  min-width: 60px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.hook-arrow {
  width: 32px;
  height: 32px;
  fill: currentColor;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
  pointer-events: none;
}

.btn-hook-up {
  background: linear-gradient(180deg, #6eb6ff 0%, #2a6fbf 100%);
  color: #041018;
  box-shadow: 0 4px 0 #1a4a85, inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn-hook-down {
  background: linear-gradient(180deg, #ff8a7a 0%, #c43a2e 100%);
  color: #1a0806;
  box-shadow: 0 4px 0 #8a241c, inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.btn-hook:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 transparent;
}

/* ── Joystick 2 eixos ── */
.joystick {
  display: flex;
  justify-content: center;
  padding: 4px 0;
}

.joystick-xy {
  width: 180px;
  height: 180px;
  border-radius: 50%;
}

.joystick-base {
  position: relative;
  background:
    radial-gradient(circle at 35% 30%, #5a5a68 0%, #2e2e38 45%, #1a1a22 100%);
  border: 4px solid #111;
  box-shadow:
    inset 0 2px 8px rgba(255, 255, 255, 0.08),
    inset 0 -4px 12px rgba(0, 0, 0, 0.5),
    0 6px 20px rgba(0, 0, 0, 0.6);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.joystick-base:active { cursor: grabbing; }

.joystick-ring {
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.12);
  pointer-events: none;
}

.joystick-ring::before,
.joystick-ring::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.08);
}

.joystick-ring::before {
  top: 50%;
  left: 8%;
  right: 8%;
  height: 2px;
  transform: translateY(-50%);
}

.joystick-ring::after {
  left: 50%;
  top: 8%;
  bottom: 8%;
  width: 2px;
  transform: translateX(-50%);
}

.joystick-stick {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #ff6b60 0%, var(--accent) 50%, var(--accent-dark) 100%);
  border: 3px solid #111;
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.5),
    inset 0 2px 4px rgba(255, 255, 255, 0.25);
  pointer-events: none;
}

.joystick-label {
  position: absolute;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.joystick-label.top { top: 8px; left: 50%; transform: translateX(-50%); }
.joystick-label.bottom { bottom: 8px; left: 50%; transform: translateX(-50%); }
.joystick-label.left { left: 8px; top: 50%; transform: translateY(-50%); }
.joystick-label.right { right: 8px; top: 50%; transform: translateY(-50%); }

.joystick-hint {
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 6px;
}

.btn-row {
  display: flex;
  gap: 8px;
}

.btn {
  flex: 1;
  padding: 10px 8px;
  border: none;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }

.btn-approach {
  background: linear-gradient(180deg, #3ddc84 0%, var(--green-dark) 100%);
  color: #0a2015;
  box-shadow: 0 3px 0 #157a42;
}

.btn-retreat {
  background: linear-gradient(180deg, #ff9a4a 0%, #cc6010 100%);
  color: #1a0e00;
  box-shadow: 0 3px 0 #8a4208;
}

.legend ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend li {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
}

.legend strong {
  color: var(--text);
  font-weight: 600;
}

/* Mesmas proporções do braço em telas estreitas */
@media (max-width: 900px) {
  #game-app {
    --boom-base-w: 13cqw;
    --boom-base-h: 12cqw;
    --boom-arm-h: 2.4cqw;
    --boom-min-w: 9cqw;
    --boom-max-w: 74cqw;
  }
}

/* ── Modo desenvolvimento: nomes ao passar o mouse ── */
.dev-label-tooltip {
  position: fixed;
  z-index: 10000;
  padding: 5px 10px;
  background: rgba(12, 18, 28, 0.94);
  border: 1px solid rgba(79, 195, 247, 0.85);
  color: #e1f5fe;
  font: 600 11px/1.35 ui-monospace, "Cascadia Code", Consolas, monospace;
  border-radius: 5px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

html.dev-labels-on [data-dev-name].dev-label-highlight {
  outline: 2px solid rgba(79, 195, 247, 0.95);
  outline-offset: 2px;
}

.btn-dev-toggle {
  width: 100%;
  flex: none;
  cursor: pointer;
  background: linear-gradient(180deg, #5a6070 0%, #3a3f4a 100%);
  color: #e8ecf0;
  box-shadow: 0 3px 0 #252830;
}

.btn-dev-toggle.active {
  background: linear-gradient(180deg, #4fc3f7 0%, #0288d1 100%);
  color: #061018;
  box-shadow: 0 3px 0 #01579b;
}

.dev-panel .joystick-hint {
  margin-top: 8px;
}
