.game-agent-rail {
  position: fixed;
  z-index: 55;
  top: auto;
  bottom: clamp(72px, 13vh, 112px);
  left: clamp(10px, 2vw, 24px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  direction: ltr;
  transform: none;
}

.agent-launcher {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 5px;
  border: 0;
  padding: 0;
  color: #26231f;
  background: transparent;
  font: 600 .62rem "IBM Plex Mono", "Space Grotesk", Consolas, monospace;
  letter-spacing: .04em;
  cursor: pointer;
}

.agent-orb {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(54px, 5.5vw, 68px);
  aspect-ratio: 1;
  border: 1px solid rgba(24, 22, 19, .25);
  border-radius: 50%;
  color: #f6f1e8;
  background: radial-gradient(circle at 35% 28%, #4a4640 0, #24211e 48%, #0d0c0b 100%);
  box-shadow: inset 0 0 0 5px rgba(255,255,255,.035), 0 10px 28px rgba(0,0,0,.2);
  font-size: .84rem;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
  overflow: hidden;
}

.agent-orb img,
.agent-chat-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.agent-launcher[data-agent="r13"] .agent-orb img {
  object-position: 50% 31%;
}

.agent-launcher[data-agent="r14"] .agent-orb img {
  object-position: 50% 24%;
}

.agent-orb::after {
  content: "";
  position: absolute;
  right: 2px;
  bottom: 5px;
  width: 8px;
  height: 8px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #57d988;
  box-shadow: 0 0 10px rgba(87,217,136,.9);
}

.agent-launcher[data-agent="shelon"] .agent-orb {
  border-color: rgba(143, 60, 42, .5);
  color: #f0b8a7;
  background: radial-gradient(circle at 35% 28%, #54352f 0, #271a17 50%, #0d0b0a 100%);
}

.agent-launcher:hover .agent-orb,
.agent-launcher:focus-visible .agent-orb {
  transform: translateX(4px) scale(1.04);
  border-color: #8f3c2a;
  box-shadow: inset 0 0 0 5px rgba(255,255,255,.04), 0 15px 34px rgba(0,0,0,.28);
}

.agent-name {
  padding: 2px 5px;
  border-radius: 8px;
  background: rgba(255,255,255,.74);
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
  backdrop-filter: blur(8px);
}

.agent-chat-overlay[hidden] { display: none; }
.agent-chat-overlay {
  position: fixed;
  z-index: 90;
  inset: 0;
  background: rgba(0,0,0,.54);
  backdrop-filter: blur(5px);
}

.agent-chat-panel {
  position: absolute;
  bottom: 20px;
  left: clamp(82px, 8vw, 112px);
  display: flex;
  flex-direction: column;
  width: min(430px, calc(100% - 125px));
  height: min(690px, calc(100dvh - 40px));
  overflow: hidden;
  border: 1px solid #383838;
  color: #f2eee6;
  background: #111;
  box-shadow: 0 28px 90px rgba(0,0,0,.55);
  animation: agent-panel-in .24s ease-out both;
  direction: rtl;
  font-family: "Vazirmatn", Tahoma, sans-serif;
}

@keyframes agent-panel-in {
  from { opacity: 0; transform: translateY(18px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.agent-chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 12px 14px;
  border-bottom: 1px solid #2d2d2d;
  background: #171717;
}

.agent-chat-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  aspect-ratio: 1;
  flex: 0 0 auto;
  border: 1px solid #484848;
  border-radius: 50%;
  font: 600 .75rem "IBM Plex Mono", "Space Grotesk", Consolas, monospace;
  overflow: hidden;
}

.agent-chat-identity { min-width: 0; flex: 1; }
.agent-chat-identity strong {
  display: block;
  font: 600 .78rem "IBM Plex Mono", "Space Grotesk", "Vazirmatn", sans-serif;
  letter-spacing: .06em;
}
.agent-chat-identity small { color: #71d894; font-size: .68rem; }

.agent-chat-close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid #393939;
  border-radius: 50%;
  color: #ddd7cf;
  background: transparent;
  font-size: 1.15rem;
  cursor: pointer;
}

.agent-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px;
  scrollbar-width: thin;
  scrollbar-color: #555 #111;
}

.agent-message {
  position: relative;
  width: fit-content;
  max-width: 88%;
  margin: 0 0 11px;
  padding: 10px 12px;
  border: 1px solid #343434;
  color: #d8d3ca;
  background: #202020;
  line-height: 1.85;
  font-size: .82rem;
  white-space: pre-wrap;
}

.agent-message:not(.user) {
  margin-right: 50px;
}

.agent-message:not(.user)::before {
  content: "S";
  position: absolute;
  top: 0;
  right: -50px;
  display: grid;
  place-items: center;
  width: 36px;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid #4b403d;
  border-radius: 50%;
  color: #efb7a6;
  background: radial-gradient(circle at 35% 28%, #54352f 0, #271a17 52%, #0d0b0a 100%);
  background-position: center;
  background-size: cover;
  font: 700 .66rem "IBM Plex Mono", Consolas, monospace;
  box-shadow: 0 5px 16px rgba(0,0,0,.32);
}

.agent-chat-overlay[data-active-agent="r13"] .agent-message:not(.user)::before {
  content: "";
  background-image: url("../img/robot-13-avatar.png");
  background-position: 50% 31%;
}

.agent-chat-overlay[data-active-agent="r14"] .agent-message:not(.user)::before {
  content: "";
  background-image: url("../img/robot-14-avatar.png");
  background-position: 50% 24%;
}

.agent-message.user {
  margin-right: auto;
  border-color: #d7cfc2;
  color: #171717;
  background: #e9e2d6;
}

.agent-message.loading { color: #8e8981; }

.agent-chat-quick {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 0 12px 11px;
  scrollbar-width: none;
}

.agent-chat-quick button {
  flex: 0 0 auto;
  border: 1px solid #373737;
  padding: 7px 10px;
  color: #bbb5ab;
  background: transparent;
  font: 600 .68rem "Vazirmatn", Tahoma, sans-serif;
  cursor: pointer;
}

.agent-chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #2d2d2d;
  background: #171717;
}

.agent-chat-form input {
  min-width: 0;
  flex: 1;
  border: 1px solid #383838;
  padding: 11px 12px;
  color: #fff;
  background: #0b0b0b;
  outline: none;
  font-family: "Vazirmatn", Tahoma, sans-serif;
}

.agent-chat-form input:focus { border-color: #8b847a; }
.agent-chat-form button {
  border: 0;
  padding: 0 16px;
  color: #111;
  background: #e7dfd1;
  cursor: pointer;
  font: 800 .75rem "Vazirmatn", Tahoma, sans-serif;
}
.agent-chat-form button:disabled { opacity: .45; cursor: wait; }

@media (max-width: 620px) {
  .game-agent-rail {
    left: 5px;
    bottom: max(96px, calc(env(safe-area-inset-bottom) + 72px));
    gap: 8px;
  }
  .agent-orb { width: 48px; }
  .agent-name { display: none; }
  .agent-chat-panel {
    inset: auto 0 0;
    width: 100%;
    height: min(78dvh, 680px);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
  }
}

@media (max-height: 620px) and (min-width: 621px) {
  .game-agent-rail { gap: 7px; }
  .agent-orb { width: 50px; }
  .agent-name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .agent-chat-panel,
  .agent-orb { animation: none; transition: none; }
}
