:root{
  --bg:#0b0b12;
  --panel:#151428;
  --neon:#7a3cff;
  --neon-2:#00e0ff;
  --text:#f2f2f7;
  --muted:#9aa0b4;
  --accent:#b08cff;
  --danger:#ff4d6d;
  --shadow:0 0 24px rgba(122,60,255,.35), 0 0 8px rgba(0,224,255,.25);
}

*{ box-sizing:border-box }
html,body{ height:100%; }
html{
  -webkit-text-size-adjust:100%;
  overscroll-behavior: none;
}
body{
  margin:0;
  background: radial-gradient(1200px 800px at 20% -10%, rgba(122,60,255,.12), transparent 60%),
              radial-gradient(1000px 600px at 100% 0%, rgba(0,224,255,.10), transparent 60%),
              var(--bg);
  color:var(--text);
  font: 16px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overflow: hidden;
}

* {
  user-select: none;
  -webkit-user-select: none;
}

.app-root{
  min-height: 100svh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

.app-header{
  width:clamp(320px, 100vw, 480px);
  padding:10px 14px;
  display:flex;
  flex-direction:row;
  align-items:center;
  justify-content:center;
  gap:20px;
  margin-top:0;
  margin-bottom:10px;
}

.brand{ display:flex; align-items:center; gap:10px; }
.brand-dot{ width:10px; height:10px; border-radius:50%;
  background: radial-gradient(circle, var(--neon) 0%, #41208b 60%, transparent 70%);
  box-shadow: var(--shadow);
}
.brand-text{ font-weight:700; letter-spacing:.3px; }

.stats{ display:flex; gap:12px; }
.stat{ background:rgba(255,255,255,.03); border:1px solid rgba(255,255,255,.06);
  padding:6px 10px; border-radius:9px; min-width:72px; text-align:center; }
.stat .label{ display:block; font-size:11px; color:var(--muted); }
.stat .value{ font-weight:600; }

.app-shell{
  width:clamp(320px, 100vw, 480px);
  flex: 1 1 auto;
  height: auto;
  padding: 0 14px var(--tabbar-h);
  overflow-y: hidden;
  overflow-x: hidden;
  scrollbar-width:none;
}
.app-shell::-webkit-scrollbar{ display:none; }

.screen{
  position: relative;
  display:block;
  height: 100%;
  padding: 0 14px calc(72px + env(safe-area-inset-bottom, 0));
  overflow: hidden;
}
.screen--scroll{
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

[hidden] { display: none !important; }

.screen--center{ display:flex; align-items:center; justify-content:center; flex-direction:column; gap:12px; height:100%; }
.boot-text{ color:var(--muted); }

.spinner{
  width:28px; height:28px; border-radius:50%;
  border:3px solid rgba(255,255,255,.12);
  border-top-color:var(--neon); animation:spin 1s linear infinite;
}
@keyframes spin{ to{ transform:rotate(360deg) } }

.card{
  background:linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  border:1px solid rgba(255,255,255,.08);
  border-radius:12px;
  padding:14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  margin:12px 0;
}
.card h3{ margin:0 0 6px; font-size:16px; }
.muted{ color:var(--muted); }

.btn{
  appearance:none; border:1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.04);
  color:var(--text); padding:10px 12px; border-radius:10px;
  font-weight:600; cursor:pointer; transition:.15s transform,.15s box-shadow,.15s border-color;
  touch-action: manipulation;
}
.btn:hover{ border-color: rgba(255,255,255,.25) }
.btn:active{ transform:translateY(1px) }
.btn-primary{
  background: linear-gradient(135deg, var(--neon), #5b2bd0);
  border-color: transparent;
  box-shadow: var(--shadow);
}
.btn-outline{
  background: transparent; border-color: var(--neon); color:var(--text);
}
.btn-glow{ box-shadow: var(--shadow); }

.input{
  width:100%; padding:10px 12px; border-radius:10px; border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.03); color:var(--text);
}

.row{ display:flex; gap:12px; }
.row>.card{ flex:1; }
.grid-2{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }

.note{ margin-top:8px; color:var(--muted); font-size:13px; }

.hero{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding:12px 0;
}

#screen-tower{
  display: flex;
  flex-direction: column;
  height: 100%;
}

.hero-tower{
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  height: auto;
  max-height: none;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 0;
}
.hero-tower .tower-background{
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.55) drop-shadow(0 0 8px rgba(122,60,255,.25));
}
.hero-tower .tower-info-bar{
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  text-align: center;
  padding: 12px 6px 20px;
  background: linear-gradient(180deg, rgba(15,12,30,.75), rgba(15,12,30,.0));
  color: var(--text);
  z-index: 2;
}
.hero-tower .tower-info-bar h3{
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.85);
}
.hero-tower .tower-info-bar p{
  margin: 2px 0;
  font-size: 20px;
  line-height: 1.4;
  color: var(--text);
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.85);
}
.hero-tower .camel-btn{
  position: absolute;
  bottom: 16px;
  right: 16px;
  left: auto;
  transform: none;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  overflow: hidden;
  border: none;
  padding: 0;
  background-color: transparent;
  background: none;
  cursor: pointer;
  z-index: 3;
  touch-action: manipulation;
  box-shadow: 0 0 20px rgba(122, 60, 255, 0.55), 0 0 12px rgba(0, 224, 255, 0.3);
}
.hero-tower .camel-btn:active{
  transform: scale(0.95);
}
.hero-tower .camel-btn .camel-img{
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  filter: none;
}

.popup-overlay{
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15,10,30,.75);
  backdrop-filter: blur(6px);
  z-index: 2000;
}
.popup-overlay.active{ display: flex; }
.popup-message{
  background: rgba(25,18,45,.95);
  border: 1px solid var(--neon);
  padding: 18px 22px;
  border-radius: 12px;
  color: var(--text);
  box-shadow: var(--shadow);
  text-align: center;
}
.popup-message h4{ margin: 0 0 6px; font-size: 18px; color: var(--neon); }
.popup-message p{ margin: 0; font-size: 14px; }

.tabbar{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  z-index: 10;
  width: clamp(320px, 100vw, 480px);
  height: 82px;
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: rgba(21,20,40,.8);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255,255,255,.08);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
}
.tabbar-item{
  display:flex; flex-direction:column; gap:4px; align-items:center; justify-content:center;
  color:var(--muted); background:transparent; border:0; cursor:pointer; font-size:11px;
  touch-action: manipulation;
}
.tabbar-item .icon{ width:30px; height:30px; fill: currentColor; }
.tabbar-item span{ display:none; }
.tabbar-item.active{ color: var(--accent); text-shadow: 0 0 18px rgba(122,60,255,.6); }

.table{ width:100%; display:block; overflow:auto; }
.table .row{ display:grid; grid-template-columns: 1fr auto; gap:8px; padding:8px 0; border-bottom:1px dashed rgba(255,255,255,.08); }
.table .row:last-child{ border-bottom:0 }
.table .title{ color:var(--text); }
.table .value{ color:var(--muted) }

.profile-item{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(255,255,255,.08);
}
.profile-item:last-child{ border-bottom: none; }
.profile-item .label{ color: var(--muted); font-size: 15px; }
.profile-item .value{ color: var(--text); font-weight: 600; font-size: 15px; }

.tabs{ display:flex; gap:8px; margin:6px 0 10px }
.tab{ padding:8px 10px; border-radius:9px; background:rgba(255,255,255,.04); border:1px solid rgba(255,255,255,.1); color:var(--text); cursor:pointer; touch-action: manipulation; }
.tab.active{ border-color: var(--neon); box-shadow: var(--shadow); }

.safe-area{ display:none; }

@media (max-width:360px){ body{ font-size:15px; } }

button, a { user-select:none; }

.quests-list{
  display:flex;
  flex-direction:column;
  gap:10px;
}
.quest-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 12px;
  border:1px solid rgba(255,255,255,.08);
  border-radius:12px;
  background: radial-gradient(120% 120% at 0% 0%, rgba(122,60,255,.08), rgba(21,20,40,.45));
  box-shadow: 0 0 20px rgba(122,60,255,.08) inset, 0 0 12px rgba(0,224,255,.06) inset;
}

.quest-left{ display:flex; align-items:center; gap:12px; min-width:0; }
.quest-dot{
  width:10px; height:10px; border-radius:50%;
  background: linear-gradient(180deg, #7a3cff, #00e0ff);
  box-shadow: 0 0 10px rgba(122,60,255,.8), 0 0 14px rgba(0,224,255,.6);
  flex: 0 0 auto;
}
.quest-texts{ display:flex; flex-direction:column; gap:2px; min-width:0; }
.quest-title{ color:var(--text); font-weight:600; line-height:1.2; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.quest-reward{ color:var(--muted); font-size:13px; }

.quest-actions{ display:flex; align-items:center; gap:8px; }
.quest-actions .btn{ padding:8px 12px; }

.quest-complete{
  display:flex; align-items:center; gap:6px;
  color:#58d68d; font-weight:700;
  text-shadow: 0 0 10px rgba(88,214,141,.35);
}
.quest-complete svg{ width:18px; height:18px; fill:#58d68d; filter: drop-shadow(0 0 6px rgba(88,214,141,.45)); }

.quests-list .empty{ padding:8px 0; }

#screen-leaderboards .tabs{
  display: flex;             
  justify-content: center;   
  align-items: center;
  gap: 8px;                  
  flex-wrap: wrap;           
  margin: 14px 0 16px;
}

#screen-leaderboards .tabs .tab{
  flex: 0 0 auto;            
  min-width: 110px;          
  text-align: center;
}

@media (max-width: 360px){
  #screen-leaderboards .tabs .tab{ min-width: 96px; }
}

#screen-leaderboards .tabs + .card{
  margin-top: 12px; 
}

#screen-leaderboards.screen--scroll{
  padding-top: 8px; 
}

/* ===== Referrals ===== */
.ref-hero{
  background: radial-gradient(140% 120% at 0% 0%, rgba(122,60,255,.10), rgba(21,20,40,.55));
  box-shadow: inset 0 0 28px rgba(122,60,255,.10), inset 0 0 14px rgba(0,224,255,.08);
}
.ref-sub{ margin-top: 2px; }

.ref-stats{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 10px 0 12px;
}
.ref-stat{
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255,255,255,.02);
}
.ref-stat-label{ color: var(--muted); font-size: 12px; }
.ref-stat-value{
  font-weight: 700;
  font-size: 18px;
  margin-top: 2px;
}

.ref-link-row{
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
}
.ref-link{
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  text-overflow: ellipsis;
}
@media (max-width: 360px){
  .ref-stats{ grid-template-columns: 1fr 1fr; }
  .ref-link-row{ grid-template-columns: 1fr; }
  #ref-copy, #ref-share{ width: 100%; }
}

/* ===== Profile (visual only) ===== */
.profile-card{
  background: radial-gradient(140% 120% at 0% 0%, rgba(122,60,255,.10), rgba(21,20,40,.50));
  box-shadow: inset 0 0 28px rgba(122,60,255,.10), inset 0 0 14px rgba(0,224,255,.08);
}
.profile-card > h3{
  margin-bottom: 8px;
}

.profile-box{
  display: grid;
  gap: 8px;
}

.profile-item{
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 14px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 12px;
  background: rgba(255,255,255,.03);
  transition: border-color .2s ease, background .2s ease, transform .1s ease;
  overflow: hidden;
}
.profile-item::before{
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #00e0ff, #7a3cff);
  box-shadow: 0 0 10px rgba(122,60,255,.35), 0 0 8px rgba(0,224,255,.25);
  opacity: .8;
}
.profile-item:hover{
  background: rgba(255,255,255,.05);
  border-color: rgba(255,255,255,.16);
  transform: translateY(-1px);
}

.profile-item .label{
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .2px;
}
.profile-item .value{
  font-weight: 800;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
}

@media (max-width: 360px){
  .profile-item{
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .profile-item .value{ text-align: left; }
}

/* Top Clans: аккуратная раскладка + центрованная кнопка одинаковой ширины */
#clan-table .row{
  display: grid;
  grid-template-columns: 1fr auto;                
  grid-template-areas:
    "name  power"
    "btn   btn";
  align-items: center;
  gap: 6px 10px;
}

#clan-table .row .title{ grid-area: name; }
#clan-table .row .value{
  grid-area: power;
  text-align: right;
  white-space: nowrap;
}

#clan-table .row .clan-join{
  grid-area: btn;                                 
  justify-self: center;                            
  width: min(100%, 260px);                         
  height: 44px;                                    
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: 8px;
}

@media (max-width: 360px){
  #clan-table .row .clan-join{ width: 100%; }
}

.hidden{display:none!important}

/* overlay */
.neon-overlay{
  position:fixed; inset:0; z-index:9999;
  display:flex; align-items:center; justify-content:center;
  background: radial-gradient(120% 120% at 50% 50%, rgba(0, 255, 255, .08), rgba(0,0,0,.65) 60%);
  backdrop-filter: blur(2.5px);
}

/* modal card */
.neon-modal{
  position:relative;
  width:min(90vw, 380px);
  background:#0b0f17;
  border:1px solid rgba(0,255,255,.25);
  border-radius:20px;
  padding:24px 22px;
  box-shadow:
    0 0 40px rgba(0,229,255,.35),
    inset 0 0 30px rgba(0,255,255,.08);
  animation: neon-pop .24s ease-out;
}
@keyframes neon-pop{from{transform:scale(.96);opacity:0}to{transform:scale(1);opacity:1}}

.neon-title{margin:0 0 6px; font-size:20px; font-weight:800; letter-spacing:.3px}
.neon-sub{margin:0 0 14px; color:#c7e9ff; opacity:.9}

.neon-cta{
  width:100%;
  border:0; border-radius:14px; padding:12px 14px;
  font-weight:800; letter-spacing:.3px;
  background: linear-gradient(90deg, #00e5ff, #7af5ff);
  color:#0a0f14;
  box-shadow: 0 0 24px rgba(0,229,255,.35), 0 8px 24px rgba(0,0,0,.35);
  cursor:pointer;
}
.neon-cta:active{transform:translateY(1px)}

.neon-close{
  position:absolute; top:8px; right:10px;
  background:transparent; border:0; color:#8df1ff;
  font-size:20px; line-height:1; cursor:pointer; opacity:.7;
}
.neon-close:hover{opacity:1}