/* Bottom HUD dock: left tools · center chat · right tools */
.hud-dock{
  position:fixed;
  z-index:12;
  left:50%;
  bottom:max(22px,env(safe-area-inset-bottom));
  transform:translateX(-50%);
  width:min(980px,calc(100vw - 20px));
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 12px;
  direction:ltr;
  border:1px solid #ffffff22;
  border-radius:28px;
  background:linear-gradient(180deg,#1a3f72f2,#0d2448f5 55%,#0a1b38f8);
  box-shadow:0 18px 50px #000a,0 0 0 1px #78b7ff33 inset,0 8px 24px #2f7dff44;
  backdrop-filter:blur(16px);
  pointer-events:auto;
}
.hud-cluster{display:flex;align-items:center;gap:8px;flex:0 0 auto}
.hud-dock .hud-btn,
.hud-dock .settings-launch,
.hud-dock .wheel-launch,
.hud-dock .open-chat{
  position:relative !important;
  left:auto !important;
  right:auto !important;
  top:auto !important;
  bottom:auto !important;
  width:52px !important;
  height:52px !important;
  min-width:52px;
  padding:0 !important;
  display:grid !important;
  place-items:center;
  gap:0 !important;
  border:2px solid #9fd2ffaa !important;
  border-radius:50% !important;
  background:radial-gradient(circle at 30% 25%,#7ec8ff,#2b6fd6 58%,#1a4ea8) !important;
  color:#fff !important;
  box-shadow:0 8px 18px #0a2a6a88, inset 0 -3px 8px #0a2f7a66, inset 0 2px 6px #ffffff55 !important;
  cursor:pointer;
  transition:transform .18s ease,filter .18s ease,box-shadow .18s ease;
  animation:none !important;
}
.hud-btn:hover{transform:translateY(-3px) scale(1.05);filter:brightness(1.06)}
.hud-btn:active{transform:scale(.95)}
.hud-btn span{font-size:22px;line-height:1;filter:drop-shadow(0 2px 2px #0006)}
.hud-btn b{display:none}
.hud-btn .hud-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
.hud-btn i{
  position:absolute;
  top:-4px;
  right:-4px;
  display:grid;
  place-items:center;
  min-width:20px;
  height:20px;
  padding:0 5px;
  border-radius:999px;
  background:#ff5267;
  border:2px solid #12366f;
  color:#fff;
  font-size:10px;
  font-style:normal;
  font-weight:900;
  box-shadow:0 3px 8px #0007;
}
.hud-btn.open-chat i{
  width:12px;
  min-width:12px;
  height:12px;
  padding:0;
  background:#62f4bd;
  border-color:#12366f;
}
.hud-btn.open-chat.active,
.hud-btn.emoji-toggle.open{
  border-color:#ffe383;
  box-shadow:0 0 0 3px #ffd45e55,0 8px 18px #0a2a6a88;
  background:radial-gradient(circle at 30% 25%,#ffe9a8,#3d7ff0 55%,#2456b8);
}
.hud-btn.wheel-launch{border-color:#ffd45e99;background:radial-gradient(circle at 30% 25%,#ffe9a8,#f0a12b 45%,#c46b12)}
.hud-btn.settings-launch{border-color:#9fd2ffaa}

/* Reset legacy #chat panel styles so the pill stays one horizontal row */
#chat.hud-chat,
.hud-chat{
  position:relative !important;
  flex:1 1 auto !important;
  flex-direction:row !important;
  align-items:center !important;
  justify-content:flex-start !important;
  min-width:0 !important;
  width:auto !important;
  height:52px !important;
  margin:0 !important;
  display:flex !important;
  gap:8px !important;
  padding:4px 6px 4px 8px !important;
  direction:rtl !important;
  border:2px solid #cfe7ff !important;
  border-radius:999px !important;
  background:linear-gradient(180deg,#ffffff,#e8f3ff) !important;
  box-shadow:inset 0 2px 8px #9ec4ef55,0 6px 16px #06183055 !important;
  overflow:visible !important;
}
.hud-chat-icon{
  flex:0 0 auto;
  width:34px;
  height:34px;
  display:grid;
  place-items:center;
  border-radius:50%;
  background:radial-gradient(circle at 30% 25%,#8fd0ff,#2f74d8);
  font-size:16px;
  line-height:1;
  box-shadow:0 3px 8px #1a4ea866;
}
#chat.hud-chat input,
.hud-chat input{
  flex:1 1 auto !important;
  min-width:0 !important;
  width:auto !important;
  height:40px !important;
  margin:0 !important;
  padding:0 6px !important;
  border:0 !important;
  outline:0 !important;
  background:transparent !important;
  color:#16325c !important;
  font-size:16px !important;
  font-weight:700 !important;
  line-height:40px !important;
  text-align:right !important;
  box-shadow:none !important;
}
.hud-chat input::placeholder{color:#7e97b5;font-weight:600;line-height:40px}
.english .hud-chat{direction:ltr !important}
.english .hud-chat input{text-align:left !important}
#chat.hud-chat .hud-send,
.hud-send{
  flex:0 0 auto !important;
  width:40px !important;
  height:40px !important;
  margin:0 !important;
  padding:0 !important;
  border:0 !important;
  border-radius:50% !important;
  background:linear-gradient(145deg,#5fd7ff,#2b78e8) !important;
  color:#fff !important;
  font-size:18px !important;
  font-weight:900 !important;
  line-height:1 !important;
  cursor:pointer;
  box-shadow:0 4px 12px #1e62c066 !important;
}
.hud-send:hover{filter:brightness(1.08)}

.hud-chat .emoji-picker{
  position:absolute;
  left:50%;
  bottom:calc(100% + 12px);
  transform:translateX(-50%);
  width:min(360px,78vw);
  max-height:180px;
  z-index:5;
  margin:0;
  border:1px solid #ffffff22;
  border-radius:18px;
  background:linear-gradient(180deg,#16345ef8,#0d213ffb);
  box-shadow:0 18px 50px #000b;
}

/* Large chat history window — sit clearly above the dock */
.chat-window{
  position:fixed !important;
  z-index:13 !important;
  left:50% !important;
  right:auto !important;
  top:auto !important;
  bottom:calc(128px + env(safe-area-inset-bottom)) !important;
  width:min(720px,calc(100vw - 24px)) !important;
  height:min(480px,calc(100dvh - 170px)) !important;
  transform:translateX(-50%) !important;
  transform-origin:bottom center !important;
  display:flex;
  flex-direction:column;
  direction:rtl;
  border:1px solid #8ec7ff55 !important;
  border-radius:22px !important;
  overflow:hidden;
  background:linear-gradient(160deg,#142c52f7,#0a1830fb 60%,#07101efc) !important;
  backdrop-filter:blur(18px);
  box-shadow:0 28px 90px #000c,0 0 0 1px #ffffff14 inset,0 0 60px #2f7dff33 !important;
  transition:opacity .28s ease,transform .35s cubic-bezier(.2,.9,.2,1),visibility .35s !important;
}
.chat-window.minimized{
  opacity:0 !important;
  visibility:hidden;
  pointer-events:none !important;
  transform:translateX(-50%) translateY(28px) scale(.92) !important;
}
.chat-window .panel-title{
  height:64px !important;
  padding:0 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  background:linear-gradient(90deg,#1a3f72,#16345e) !important;
  border-bottom:1px solid #ffffff14;
}
.chat-window .panel-title b{font-size:18px}
.chat-window .panel-title span{color:#8fd0ff;font-size:12px}
.chat-window .messages{
  flex:1 1 auto;
  height:auto !important;
  min-height:0;
  padding:16px 18px;
  overflow:auto;
}
.chat-window .shield{display:none}
.chat-window .close-chat{width:38px !important;height:38px !important}

/* Hide legacy floating launches now in the dock */
.hud-settings-source{display:none !important}
body:not(.arcade-playing):not(.bubble-playing) .settings-launch:not(.hud-btn),
body:not(.arcade-playing):not(.bubble-playing) .wheel-launch:not(.hud-btn),
body:not(.arcade-playing):not(.bubble-playing) .open-chat:not(.hud-btn){display:none !important}

body.arcade-playing .hud-dock,
body.bubble-playing .hud-dock,
body.arcade-playing .chat-window,
body.bubble-playing .chat-window{
  visibility:hidden !important;
  pointer-events:none !important;
}

@media (max-width:820px){
  .hud-dock{
    width:calc(100vw - 12px);
    gap:8px;
    padding:8px;
    border-radius:22px;
    bottom:max(16px,env(safe-area-inset-bottom));
  }
  .hud-dock .hud-btn{width:44px !important;height:44px !important;min-width:44px}
  .hud-btn span{font-size:18px}
  #chat.hud-chat,.hud-chat{height:46px !important;padding:3px 5px 3px 7px !important}
  #chat.hud-chat input,.hud-chat input{height:36px !important;font-size:14px !important;line-height:36px !important}
  .hud-chat-icon{width:28px;height:28px;font-size:13px}
  #chat.hud-chat .hud-send,.hud-send{width:34px !important;height:34px !important;font-size:15px !important}
  .chat-window{
    width:calc(100vw - 12px) !important;
    height:min(42dvh,380px) !important;
    bottom:calc(118px + env(safe-area-inset-bottom)) !important;
  }
}
@media (max-width:560px){
  .hud-left .hud-btn:nth-child(4),
  .hud-right .hud-btn:nth-child(3){display:none}
  .hud-dock{gap:6px;padding:7px}
  .hud-dock .hud-btn{width:40px !important;height:40px !important;min-width:40px}
}

/* Bag profile: level, points, character preview, wear/remove */
.items-panel.bag-mode{width:min(820px,calc(100% - 24px));max-height:min(760px,calc(100dvh - 24px))}
.items-panel.bag-mode .items-grid{grid-template-columns:repeat(3,minmax(0,1fr));align-content:start}
.bag-profile{
  grid-column:1/-1;
  display:grid;
  grid-template-columns:160px 1fr;
  gap:16px;
  padding:16px;
  border:1px solid #ffffff18;
  border-radius:18px;
  background:linear-gradient(135deg,#1a3358ee,#0d1a30f2 55%,#0a1424f8);
  box-shadow:inset 0 0 0 1px #57e6d322;
}
.bag-preview-stage{
  display:grid;
  place-items:center;
  border-radius:16px;
  background:radial-gradient(circle at 50% 30%,#355f7844,#0a1220 70%);
  border:1px solid #ffffff12;
  min-height:230px;
  overflow:hidden;
}
.bag-preview-stage canvas{display:block;width:150px;height:230px}
.bag-profile-info{display:flex;flex-direction:column;gap:8px;min-width:0;text-align:right}
.english .bag-profile-info{text-align:left}
.bag-profile-info>small{color:#69dff0;letter-spacing:1.5px;font-size:10px;font-weight:800}
.bag-profile-info h3{margin:0;font-size:22px;color:#fff}
.bag-stats{display:flex;flex-wrap:wrap;gap:10px}
.bag-stats span{
  display:inline-flex;align-items:center;gap:6px;
  padding:8px 12px;border-radius:12px;
  background:#08111fcc;border:1px solid #ffffff14;
  color:#c5d2e6;font-size:13px;
}
.bag-stats b{color:#ffd45e;font-size:16px}
.bag-xp{height:10px;border-radius:999px;background:#0a1528;border:1px solid #ffffff12;overflow:hidden}
.bag-xp i{display:block;height:100%;width:0;background:linear-gradient(90deg,#57e6d3,#7ee0ff);border-radius:inherit}
.bag-gear{display:flex;flex-wrap:wrap;gap:8px;margin-top:2px}
.bag-gear .gear-empty{color:#8fa0b8;font-size:12px;padding:6px 0}
.bag-gear-chip{
  display:inline-flex;align-items:center;gap:7px;
  padding:7px 10px 7px 8px;border-radius:999px;
  border:1px solid color-mix(in srgb,var(--accent) 55%,#fff 10%);
  background:color-mix(in srgb,var(--accent) 18%,#0b1526 82%);
  color:#eef5ff;font-size:12px;font-weight:700;cursor:pointer;
}
.bag-gear-chip:hover{filter:brightness(1.08);transform:translateY(-1px)}
.bag-gear-chip b{font-size:15px;line-height:1}
.bag-gear-chip i{font-style:normal;opacity:.75;margin-inline-start:2px}
.bag-profile-info p{margin:2px 0 0;color:#9eb0c8;font-size:12px;line-height:1.4}
.items-panel.bag-mode .item-card.worn{border-color:#57e6d388;box-shadow:inset 0 0 0 1px #57e6d333}
@media(max-width:700px){
  .bag-profile{grid-template-columns:1fr;padding:12px}
  .bag-preview-stage{min-height:200px}
  .items-panel.bag-mode .items-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
