:root{
  --bg:#0b1020;
  --text:#e9ecff;
  --muted:#aab2e8;
  --border:rgba(255,255,255,.08);
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --danger:#ff6b86;
  --ok:#49f2a6;
}

*{box-sizing:border-box}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 20% 0%, rgba(124,92,255,.25), transparent 60%),
              radial-gradient(900px 500px at 80% 20%, rgba(0,200,255,.12), transparent 60%),
              var(--bg);
  color:var(--text);
  min-height:100vh;
}
.msgId{
  margin-left: 10px;
  opacity: .65;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

#plannerCanvas,
#plannerAiCanvas {
  position: absolute;
  pointer-events: auto;
  left: 0;
  top: 0;
}

#plannerCanvas {
  pointer-events: auto;
}

.msg.pinned{
  border: 1px solid rgba(255,215,0,.55);
  box-shadow: 0 0 0 1px rgba(255,215,0,.18) inset;
}

.plannerArmyToggle {
  position: absolute;
  top: 58px;
  left: 12px;
  z-index: 60;
  background: rgba(16,18,24,0.94);
  border: 1px solid rgba(255,255,255,0.10);
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(0,0,0,0.28);
}

@media (max-width: 700px) {
  .plannerArmyToggle {
    top: 54px;
    left: 8px;
    font-size: 13px;
    padding: 7px 10px;
  }
}






.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:14px 16px;
  border-bottom:1px solid var(--border);
  background: rgba(18,26,51,.8);
  backdrop-filter: blur(10px);
  position:sticky;
  top:0;
  z-index:10;
}
.brand{display:flex; gap:12px; align-items:center}
.logo{
  width:38px;height:38px;border-radius:12px;
  display:grid;place-items:center;
  background: linear-gradient(135deg, rgba(124,92,255,.9), rgba(0,200,255,.5));
  box-shadow: var(--shadow);
}
.title{font-weight:800}
.subtitle{color:var(--muted); font-size:12px}
.status{color:var(--muted); font-size:12px}

.layout{
  display:grid;
  grid-template-columns: 360px 1fr;
  gap:14px;
  padding:14px;
  max-width:1200px;
  margin:0 auto;
}

.card{
  background: rgba(18,26,51,.85);
  border:1px solid var(--border);
  border-radius:18px;
  padding:14px;
  box-shadow: var(--shadow);
  margin-bottom:14px;
}
.cardTitle{font-weight:800; margin-bottom:10px}

.label{display:block; color:var(--muted); font-size:12px; margin:10px 0 6px}
.input{
  width:100%;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid var(--border);
  background: rgba(15,22,48,.9);
  color:var(--text);
  outline:none;
}
.input:focus{border-color: rgba(124,92,255,.6)}

.btn{
  margin-top:12px;
  width:100%;
  padding:10px 12px;
  border:0;
  border-radius:14px;
  background: linear-gradient(135deg, rgba(124,92,255,1), rgba(0,200,255,.85));
  color:#071022;
  font-weight:900;
  cursor:pointer;
}
.btn:active{transform: translateY(1px)}

.row{display:flex; gap:10px; align-items:center; justify-content:space-between}
.pill{
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(15,22,48,.8);
  color: var(--muted);
  font-size:12px;
  white-space:nowrap;
}
.btnSmall{
  padding:8px 10px;
  border-radius:12px;
  border:1px solid var(--border);
  background: rgba(15,22,48,.8);
  color:var(--text);
  cursor:pointer;
}
.btnSmall:active{transform: translateY(1px)}
.btnSmall.danger{border-color: rgba(255,107,134,.4); color: var(--danger);}
.btnSmall.ok{border-color: rgba(73,242,166,.35); color: var(--ok);}

.err{color:var(--danger); font-size:12px; margin-top:10px; min-height:16px}
.mutedSmall{color:var(--muted); font-size:12px; margin-top:10px}

.tips{margin:0; padding-left:18px; color:var(--muted); font-size:13px}
.tips b{color:var(--text)}

.tabs{display:flex; gap:10px; margin-top:10px}
.tab{
  flex:1;
  padding:8px 10px;
  border-radius:12px;
  border:1px solid var(--border);
  background: rgba(15,22,48,.7);
  color: var(--text);
  cursor:pointer;
}
.tab.active{outline:2px solid rgba(124,92,255,.35);}

.chat{
  display:flex;
  flex-direction:column;
  height: calc(100vh - 88px);  /* was min-height */
  min-height: 0;               /* important for flex scrolling */
  position:relative;
}

.chatHeader{
  background: rgba(18,26,51,.85);
  border:1px solid var(--border);
  border-radius:18px;
  padding:12px 14px;
  box-shadow: var(--shadow);
}
.room{font-weight:800}
.messages{
  margin-top:12px;
  flex:1;
  min-height: 0;
  overflow-y:auto;
  overflow-x:hidden;
  padding:12px;
  background: rgba(15,22,48,.55);
  border:1px solid var(--border);
  border-radius:18px;
}

.msg{
  padding:10px 12px;
  border-radius:14px;
  border:1px solid var(--border);
  background: rgba(18,26,51,.85);
  margin-bottom:10px;
}
.msg.deleted{opacity:.55}
.msg .meta{display:flex; gap:8px; align-items:baseline; margin-bottom:6px}
.msg .name{font-weight:900}
.nameLink{
  cursor:pointer;
  text-decoration: underline;
  text-decoration-color: rgba(255,255,255,.2);
}
.badge{
  font-size:11px;
  color: var(--muted);
  border:1px solid var(--border);
  padding:2px 8px;
  border-radius:999px;
  background: rgba(15,22,48,.6);
}
.msg .time{color:var(--muted); font-size:12px; margin-left:auto}
.msg .text{white-space:pre-wrap; word-wrap:break-word}
.msg .attachment{
  margin-top:8px;
  padding:8px 10px;
  border:1px dashed var(--border);
  border-radius:12px;
  background: rgba(15,22,48,.5);
}
.msg img.preview{
  margin-top:8px;
  max-width:100%;
  border-radius:12px;
  border:1px solid var(--border);
}
.system{
  color: var(--muted);
  font-size:12px;
  padding:6px 10px;
  margin:8px 0;
  text-align:center;
}

.composer{
  display:flex;
  gap:10px;
  margin-top:12px;
  align-items:center;
}
.composer .input{flex:1}
.composer .btn{width:130px; margin-top:0}

.uploadHint{
  margin-top:10px;
  color: var(--muted);
  font-size:12px;
  padding:8px 10px;
  border:1px solid var(--border);
  border-radius:12px;
  background: rgba(15,22,48,.5);
}

.pinnedBox{
  border:1px solid var(--border);
  border-radius:14px;
  background: rgba(15,22,48,.7);
  padding:10px 12px;
  white-space:pre-wrap;
  word-wrap:break-word;
}

.warBoard{
  margin-top:10px;
  display:grid;
  grid-template-columns: 1fr;
  gap:8px;
}
.warRow{
  border:1px solid var(--border);
  border-radius:14px;
  padding:10px 12px;
  background: rgba(15,22,48,.55);
}
.warTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.warNum{font-weight:900}
.warClaimed{color: var(--muted); font-size:12px}
.warBtns{display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end}
.warNote{
  margin-top:8px;
  width:100%;
  padding:8px 10px;
  border-radius:12px;
  border:1px solid var(--border);
  background: rgba(15,22,48,.8);
  color: var(--text);
}

/* Sheets / Modals */
.actionSheet{
  position:absolute;
  inset:0;
  display:none;
  align-items:flex-end;
  justify-content:center;
  background: rgba(0,0,0,.45);
  padding:14px;
}
.actionSheet.show{display:flex;}
.actionSheetCard{
  width:min(520px, 100%);
  border-radius:18px;
  border:1px solid var(--border);
  background: rgba(18,26,51,.95);
  box-shadow: var(--shadow);
  padding:14px;
}
.actionTitle{font-weight:900; margin-bottom:10px;}
.actionBtns{display:flex; gap:10px; flex-wrap:wrap;}

.modal{
  position:absolute;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.55);
  padding:14px;
  z-index:20;
}
.modal.show{display:flex;}
.modalCard{
  width:min(980px, 100%);
  border-radius:18px;
  border:1px solid var(--border);
  background: rgba(18,26,51,.98);
  box-shadow: var(--shadow);
  overflow:hidden;
}

.profileBanner{
  position:relative;
  height:170px;
  background: radial-gradient(900px 260px at 20% 0%, rgba(124,92,255,.35), transparent 70%),
              radial-gradient(700px 220px at 80% 30%, rgba(0,200,255,.22), transparent 70%),
              rgba(15,22,48,.9);
  background-size: cover;
  background-position: center;
}
.profileBannerOverlay{
  position:absolute; inset:0;
  background: linear-gradient(to bottom, rgba(0,0,0,.0), rgba(0,0,0,.55));
}
.profileHeaderRow{
  position:absolute;
  left:14px; right:14px; bottom:12px;
  display:flex;
  gap:12px;
  align-items:flex-end;
  justify-content:space-between;
  z-index:2;
}
.profileHeaderText{flex:1; min-width:0}
.modalTitle{font-weight:900; font-size:18px}
.profileBody{padding:14px;}

.avatarWrap{
  width:72px; height:72px;
  border-radius:18px;
  border:1px solid var(--border);
  background: rgba(15,22,48,.8);
  box-shadow: var(--shadow);
  overflow:hidden;
  position:relative;
  flex:0 0 auto;
}
.avatar{
  width:100%; height:100%;
  object-fit:cover;
  display:none;
}
.avatarFallback{
  position:absolute; inset:0;
  display:grid; place-items:center;
  font-weight:900;
  color: rgba(255,255,255,.75);
}

.profileGrid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
}
.profileBox{
  border:1px solid var(--border);
  border-radius:14px;
  background: rgba(15,22,48,.7);
  padding:12px;
}
.profileBoxTitle{font-weight:900; margin-bottom:10px}
.profileStat{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:8px 0;
  border-bottom:1px solid rgba(255,255,255,.06);
}
.profileStat:last-child{border-bottom:0}
.profileStat span{color:var(--muted); font-size:13px}
.profileStat b{font-size:14px}

.bioText{
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.06);
  background: rgba(15,22,48,.55);
}

/* Roster modal */
.rosterHeader{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  padding:14px;
  border-bottom:1px solid var(--border);
  background: rgba(15,22,48,.55);
}
.rosterBody{padding:14px;}
.rosterList{
  margin-top:12px;
  display:grid;
  grid-template-columns: 1fr;
  gap:10px;
  max-height: 70vh;
  overflow:auto;
  padding-right: 4px;
}
.rosterItem{
  border:1px solid var(--border);
  border-radius:14px;
  background: rgba(15,22,48,.55);
  padding:10px 12px;
  display:flex;
  gap:12px;
  align-items:center;
  cursor:pointer;
}
.rosterItem:active{transform: translateY(1px);}
.rosterItem.disabled{cursor:default; opacity:.75}
.rosterAvatar{
  width:46px; height:46px;
  border-radius:14px;
  border:1px solid var(--border);
  background: rgba(18,26,51,.9);
  overflow:hidden;
  position:relative;
  flex:0 0 auto;
}
.rosterAvatar img{
  width:100%; height:100%;
  object-fit:cover;
  display:none;
}
.rosterAvatar .fallback{
  position:absolute; inset:0;
  display:grid; place-items:center;
  font-weight:900;
  color: rgba(255,255,255,.75);
}
.rosterMain{flex:1; min-width:0}
.rosterName{font-weight:900; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.rosterSub{
  color:var(--muted);
  font-size:12px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis
}
.rosterBadges{display:flex; gap:8px; align-items:center; flex-wrap:wrap; justify-content:flex-end}
.rosterBadge{
  font-size:11px;
  color: var(--muted);
  border:1px solid var(--border);
  padding:2px 8px;
  border-radius:999px;
  background: rgba(18,26,51,.65);
}
.rosterBadge.ok{border-color: rgba(73,242,166,.35); color: var(--ok);}
.rosterBadge.warn{border-color: rgba(255,107,134,.35); color: var(--danger);}

@media (max-width: 900px){
  .layout{grid-template-columns: 1fr}
//  .chat{min-height: 60vh}
  .composer .btn{width:100px}
  .profileGrid{grid-template-columns: 1fr}
}
/* ===== Role colours ===== */
.badge.role-leader {
  background: #ff4757;
  color: #fff;
}

.badge.role-coleader {
  background: #ffa502;
  color: #000;
}

.badge.role-elder {
  background: #1e90ff;
  color: #fff;
}

.badge.role-member {
  background: #57606f;
  color: #fff;
}

/* ===== Players list box ===== */
.playersCount{
  margin-bottom: 8px;
}

/* ===== Players list box: compact single-line rows ===== */
.playersList{
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(15,22,48,.55);
  padding: 6px;
}

/* row container */
.playerRow{
  display:flex;
  align-items:center;
  gap:8px;
  padding: 6px 8px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.06);
  background: rgba(18,26,51,.55);
  margin: 5px 0;
}

/* left side */
.playerLeft{
  display:flex;
  align-items:center;
  gap:8px;
  min-width:0;      /* critical for ellipsis */
  flex:1 1 auto;
}

/* dot */
.playerDot{
  width:8px;
  height:8px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.12);
  flex: 0 0 auto;
}

/* single-line text */
.playerName{
  font-weight: 800;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* online highlight */
.playerRow.online{
  outline: 2px solid rgba(73,242,166,.22);
  background: rgba(73,242,166,.06);
}

.playerRow.online .playerDot{
  background: rgba(73,242,166,.9);
  border-color: rgba(73,242,166,.6);
}

.playerRow.offline{
  opacity: .78;
}


/* --- Image upload UI --- */
.btnIcon{
  width:44px;
  min-width:44px;
  height:44px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.06);
  color:#fff;
  cursor:pointer;
}
.btnIcon:disabled{ opacity:.45; cursor:not-allowed; }
.uploadRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:8px 10px;
  margin-top:8px;
  border-radius:12px;
  border:1px dashed rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
}
.uploadMeta{ font-size:13px; opacity:.9; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* --- Message image thumbnail --- */
.msgThumb{
  display:block;
  margin-top:8px;
  max-width:160px;
  max-height:160px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.10);
  object-fit:cover;
  cursor:pointer;
}


/* Profile stats */
.profileStatsBox{
  margin: 10px 0 14px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  background: rgba(0,0,0,.18);
}
.profileStatsTop{
  display:flex;
  justify-content: space-between;
  gap:10px;
  align-items:flex-start;
}
.profileStatsName{ font-weight: 800; font-size: 16px; }
.profileStatsBadges{ display:flex; gap:8px; align-items:center; }
.badgeImg{ width:32px; height:32px; object-fit:contain; }
.profileStatsGrid{
  margin-top: 10px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat{
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
}
.stat .k{ font-size: 12px; opacity: .75; }
.stat .v{ font-size: 14px; font-weight: 700; margin-top: 2px; }
@media (max-width: 520px){
  .profileStatsGrid{ grid-template-columns: 1fr; }
}

.msgThumb{
  display:block;
  max-width: 260px;
  max-height: 260px;
  width:auto;
  height:auto;
  margin-top: 6px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.15);
  cursor: zoom-in;
}

.plannerOverlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 9999;
  display:flex;
  flex-direction:column;
}

.plannerTop{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 12px;
  background: rgba(10,12,20,.92);
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.plannerTitle{
  font-weight:700;
  font-size:13px;
  opacity:.9;
  white-space:nowrap;
}

.plannerTools{
  display:flex;
  align-items:center;
  gap:8px;
  flex:1;
  flex-wrap:wrap;
}

.plannerTools .btn{
  padding:6px 10px;
  font-size:12px;
}


.pbtn{
  padding:6px 10px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.06);
  color:#fff;
  font-size:12px;
  cursor:pointer;
}

.pbtn:hover{
  background: rgba(255,255,255,.12);
}
.pbtn.selected{ outline:2px solid rgba(0,255,120,.35); }

.pbtn.danger{
  border-color: rgba(255,70,70,.25);
}

.plbl{
  display:flex;
  align-items:center;
  gap:6px;
  font-size:12px;
  opacity:.9;
  white-space:nowrap;
}

.plbl span{ opacity:.8; }

#penWidth{
  width: 90px;
}

.planStatus{
  font-size:12px;
  opacity:.85;
  white-space:nowrap;
}



.toolLbl{
  display:flex;
  gap:6px;
  align-items:center;
  font-size:12px;
  opacity:.9;
}

#penWidth{ width: 90px; }

.plannerStage{
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  display:flex;
  justify-content:center;
  align-items:center;
}

.plannerWrap{
  position: relative;
  display: inline-block;
}

/* --- Channels list --- */
.channelSelect{
  width: 100%;
  background: rgba(15,22,48,.70);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  color: var(--text);
  outline: none;
  font-size: 14px;
}
.channelSelect:disabled{ opacity: .6; }
.channelSelect option{ padding: 8px; }


#plannerImg{
  display:block;
  max-width: 95vw;
  max-height: 85vh;
  border-radius: 14px;
}

#plannerCanvas{
  position:absolute;
  left: 0;
  top: 0;
  pointer-events: auto;
}
.plannerTools{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.toolLbl{ display:flex; gap:6px; align-items:center; font-size:12px; opacity:.9; }
#plannerCanvas{ cursor: crosshair; }


/* ===== Player Stats: completion + heroes ===== */
.completionBox{
  margin-top:12px;
  padding:10px;
  border:1px solid rgba(255,255,255,.12);
  border-radius:12px;
  background: rgba(0,0,0,.12);
}
.completionTitle{ font-weight:700; margin-bottom:6px; }
.completionRow{ display:grid; grid-template-columns: 70px 1fr 46px; gap:8px; align-items:center; margin-top:6px; }
.completionLabel{ font-size:12px; opacity:.85; }
.completionTrack{ height:10px; background: rgba(255,255,255,.10); border-radius:999px; overflow:hidden; }
.completionFill{ height:100%; background: rgba(120,220,255,.85); }
.completionValue{ text-align:right; font-size:12px; opacity:.9; }

.heroesBox{
  margin-top:12px;
  padding:10px;
  border:1px solid rgba(255,255,255,.12);
  border-radius:12px;
  background: rgba(0,0,0,.10);
}
.heroesTitle{ font-weight:700; margin-bottom:6px; }
.heroesGroupTitle{ font-size:12px; opacity:.85; margin-top:8px; margin-bottom:6px; }
.heroesGrid{ display:flex; flex-wrap:wrap; gap:8px; }
.heroChip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 8px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  font-size:12px;
  white-space:nowrap;
}
.heroIcon{ font-size:14px; }
.heroName{ opacity:.9; }
.heroLvl{ font-weight:700; }
