:root{
  --bg: #f3f5f9;
  --bg-2: #eef2f8;

  --panel: rgba(255,255,255,.86);
  --panel-solid: #ffffff;
  --card: rgba(255,255,255,.92);
  --card-strong: #ffffff;

  --text: #121826;
  --muted: #6b7280;
  --line: rgba(18,24,38,.08);
  --line-strong: rgba(18,24,38,.14);

  --accent: #0a84ff;
  --accent-hover: #0077ed;
  --accent-soft: rgba(10,132,255,.10);
  --accent-border: rgba(10,132,255,.20);

  --success: #16a34a;
  --danger: #dc2626;

  --input-bg: rgba(255,255,255,.95);

  --radius-xs: 12px;
  --radius-sm: 16px;
  --radius-md: 20px;
  --radius-lg: 24px;
  --radius-xl: 28px;

  --shadow-xs: 0 2px 8px rgba(15,23,42,.04);
  --shadow-sm: 0 8px 24px rgba(15,23,42,.08);
  --shadow-md: 0 18px 48px rgba(15,23,42,.12);
  --shadow-lg: 0 32px 80px rgba(15,23,42,.16);

  --blur: saturate(180%) blur(20px);

  --panel-width: 430px;
  --header-h: 74px;
}

*{
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body{
  margin: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at top left, rgba(10,132,255,.10), transparent 28%),
    radial-gradient(circle at top right, rgba(124,77,255,.06), transparent 24%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--text);
  font-family:
    "SF Pro Display",
    "SF Pro Text",
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body{
  overflow: hidden;
}

body.wallet-modal-open{
  overflow: hidden !important;
}

/* ===== LAYOUT ===== */
.layout{
  position: relative;
  width: 100vw;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.hidden{
  display: none !important;
}
#map{
  position: relative;
  z-index: 1;
  width: 100%;
  height: 54dvh;
  transition: opacity .22s ease, transform .22s ease;
}

body.wallet-modal-open #map{
  opacity: .18;
  pointer-events: none;
  transform: scale(1.01);
}

.leaflet-container{
  width: 100%;
  height: 100%;
  background: #dbe7f3;
  font: inherit;
}

.leaflet-control{
  z-index: 10 !important;
}

.leaflet-top,
.leaflet-bottom{
  z-index: 20 !important;
}

/* ===== PANEL ===== */
.panel{
  position: relative;
  z-index: 30;
  width: 100%;
  height: 46dvh;
  display: flex;
  flex-direction: column;
  border-top: 1px solid rgba(255,255,255,.65);
  background: var(--panel);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 -18px 48px rgba(15,23,42,.10);
  transition:
    transform .30s cubic-bezier(.2,.8,.2,1),
    opacity .22s ease,
    visibility .22s ease;
  will-change: transform, opacity;
}
.sheetHandle{
  display: none;
  width: 44px;
  height: 5px;
  border-radius: 999px;
  background: rgba(18,24,38,.16);
  margin: 10px auto 0;
  flex: 0 0 auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.panel.sheet-mid{
  height: 52dvh;
}

.panel.sheet-full{
  height: 88dvh;
}

.panel.sheet-compact{
  height: 34dvh;
}

body.wallet-modal-open .panel{
  transform: translateY(160%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ===== HEADER ===== */
.header{
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255,255,255,.82) 0%, rgba(255,255,255,.60) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex: 0 0 auto;
    touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.brand{
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo{
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 12px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.92), transparent 40%),
    linear-gradient(135deg, #0a84ff 0%, #6e5bff 55%, #a855f7 100%);
  box-shadow:
    inset 0 1px 1px rgba(255,255,255,.5),
    0 8px 18px rgba(10,132,255,.18);
}

.brandText{
  min-width: 0;
}

.brandText b{
  display: block;
  font-size: 17px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brandText span{
  display: block;
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.2;
  color: var(--muted);
  font-weight: 500;
}

.headerActions{
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

/* ===== INNER ===== */
.panelInner{
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px 14px 20px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.panelInner::-webkit-scrollbar{
  width: 8px;
}

.panelInner::-webkit-scrollbar-track{
  background: transparent;
}

.panelInner::-webkit-scrollbar-thumb{
  background: rgba(17,17,17,.12);
  border-radius: 999px;
}

/* ===== COMMON ===== */
.section{
  margin-top: 10px;
}

.sectionTitle{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 2px 10px;
}

.sectionTitle .title{
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}

.sectionTitle .sub{
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.muted{
  color: var(--muted);
}

.hint{
  margin: 10px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255,255,255,.76);
  box-shadow: var(--shadow-xs);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

/* можно скрывать лишние подсказки, если они пустые */
.hint:empty{
  display: none;
}

/* ===== BUTTONS ===== */
button{
  font: inherit;
}

.btnPrimary{
  appearance: none;
  border: none;
  outline: none;
  border-radius: 999px;
  padding: 11px 16px;
  min-height: 42px;
  background: linear-gradient(180deg, var(--accent-hover) 0%, var(--accent) 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow:
    0 1px 0 rgba(255,255,255,.24) inset,
    0 8px 20px rgba(10,132,255,.22);
  transition:
    transform .18s ease,
    opacity .18s ease,
    box-shadow .18s ease,
    filter .18s ease;
}

.btnPrimary:hover{
  filter: brightness(1.02);
}

.btnPrimary:active{
  transform: scale(.985);
  box-shadow:
    0 1px 0 rgba(255,255,255,.2) inset,
    0 4px 12px rgba(10,132,255,.20);
}

.btnPrimary:disabled{
  opacity: .48;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btnGhost{
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.82);
  color: var(--text);
  border-radius: 999px;
  min-height: 38px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}

.btnGhost:hover{
  background: rgba(255,255,255,.96);
  border-color: var(--line-strong);
}

.btnGhost:active{
  transform: scale(.985);
}

/* ===== TABS ===== */
.tabs{
  position: relative;
  z-index: 3;
  display: flex;
  gap: 8px;
  padding: 8px 0 10px;
  margin-bottom: 8px;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.tabBtn{
  flex: 1 1 0;
  min-width: 0;
  appearance: none;
  border: 1px solid rgba(18,24,38,.06);
  background: rgba(255,255,255,.55);
  color: var(--muted);
  border-radius: 999px;
  padding: 11px 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: none;
  transition:
    background .2s ease,
    border-color .2s ease,
    color .2s ease,
    transform .18s ease;
}
.tabBtn:hover{
  color: var(--text);
  background: rgba(255,255,255,.92);
}

.tabBtn:active{
  transform: scale(.985);
}

.tabBtn.isActive{
  color: var(--text);
  background: rgba(255,255,255,.92);
  border-color: var(--line);
  box-shadow: 0 4px 14px rgba(0,0,0,.05);
}

/* ===== CARDS ===== */
.profileCard,
.rewardCard,
.zoneCard,
.zoneRow{
  border: 1px solid var(--line);
  background: var(--card);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow-sm);
}

.profileCard{
  display: flex;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-lg);
}

.avatar{
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.88), transparent 36%),
    linear-gradient(135deg, #0a84ff 0%, #7c4dff 100%);
  box-shadow:
    inset 0 1px 1px rgba(255,255,255,.4),
    0 10px 22px rgba(10,132,255,.16);
}

.profileMeta{
  min-width: 0;
  width: 100%;
}

.name{
  font-size: 17px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
}

.line{
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
  word-break: break-word;
}

.nameRow{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.lvlBadge{
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.xpWrap{
  margin-top: 12px;
}

.xpBar{
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(17,17,17,.06);
  border: 1px solid rgba(17,17,17,.04);
}

.xpFill{
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0a84ff 0%, #7c4dff 100%);
  transition: width .25s ease;
}

.xpText{
  margin-top: 7px;
  font-size: 12px;
  color: var(--muted);
}

.rankText{
  margin-top: 5px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.rewardCard,
.zoneCard{
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius-lg);
}

.rewardTop{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rewardTitle{
  font-size: 17px;
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-weight: 800;
  color: var(--text);
}

.rewardMeta{
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

/* ===== ZONE CARD / BUY ===== */
.zoneCard{
  position: relative;
  overflow: hidden;
}

.zoneHead{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.zoneTitle{
  font-size: 20px;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 800;
  color: var(--text);
}

.zoneMeta{
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}

.zoneInfo{
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.zoneInfo > div{
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.72);
  font-size: 13px;
  line-height: 1.4;
}

.zoneInfo b{
  display: block;
  margin-top: 4px;
  font-size: 15px;
  color: var(--text);
}

.zoneBuyRow{
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 14px;
  align-items: stretch;
}

.zoneInput{
  width: 100%;
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 14px;
  min-height: 48px;
  font-size: 16px;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.65);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.zoneInput:focus{
  border-color: rgba(10,132,255,.35);
  box-shadow:
    0 0 0 4px rgba(10,132,255,.10),
    inset 0 1px 0 rgba(255,255,255,.75);
  background: #fff;
}

.zoneBuyRow .btnPrimary{
  min-width: 132px;
  min-height: 48px;
  padding-left: 18px;
  padding-right: 18px;
}

#zoneBuyHint{
  margin-top: 10px;
}

/* ===== LIST ===== */
.list{
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.zoneRow{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
}

.zoneRow .left{
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.zoneRow .title{
  font-size: 15px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.zoneRow .meta{
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.zoneRow .right{
  flex: 0 0 auto;
  text-align: right;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.zoneRowBtn{
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card);
  text-align: left;
  cursor: pointer;
  appearance: none;
  transition:
    transform .16s ease,
    box-shadow .16s ease,
    border-color .16s ease,
    background .16s ease;
}

.zoneRowBtn:hover{
  border-color: var(--accent-border);
  background: rgba(255,255,255,.98);
  box-shadow: var(--shadow-md);
}

.zoneRowBtn:active{
  transform: scale(.992);
}

.zoneRowBtn:focus-visible{
  outline: none;
  border-color: rgba(10,132,255,.38);
  box-shadow:
    0 0 0 4px rgba(10,132,255,.10),
    var(--shadow-sm);
}

.footerNote{
  margin-top: 18px;
  padding: 0 2px calc(max(8px, env(safe-area-inset-bottom)));
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

/* ===== TON CONNECT ===== */
#ton-connect-root{
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  pointer-events: none;
}

#ton-connect-root *{
  pointer-events: auto;
}

.tc-root,
[data-tc-root]{
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483647 !important;
  pointer-events: none !important;
}

[data-tc-modal-container],
[data-tc-dropdown-container],
.tc-modal,
.tc-dropdown,
.tc-connect-wallets-modal{
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483647 !important;
  pointer-events: none !important;
  width: 100vw !important;
  height: 100dvh !important;
  max-width: 100vw !important;
  max-height: 100dvh !important;
}

[data-tc-modal-container] *,
[data-tc-dropdown-container] *,
.tc-modal *,
.tc-dropdown *,
.tc-connect-wallets-modal *{
  pointer-events: auto !important;
}

.tc-modal__overlay{
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100dvh !important;
  z-index: 2147483647 !important;
  background: rgba(7,10,18,.34) !important;
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
}

.tc-modal .tc-modal__content,
.tc-connect-wallets-modal__content,
.tc-dropdown__content{
  position: relative !important;
  z-index: 2147483647 !important;
  pointer-events: auto !important;
}

body.wallet-modal-open .header,
body.wallet-modal-open .panelInner{
  pointer-events: none !important;
}

/* ===== PAGE ===== */
.page{
  animation: fadeIn .20s ease;
}

@keyframes fadeIn{
  from{
    opacity: 0;
    transform: translateY(6px);
  }
  to{
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== MOBILE ===== */
@media (max-width: 900px){
  .layout{
    display: flex;
    flex-direction: column;
    position: relative;
  }
.panel.dragging{
  transition: none !important;
}
  #map{
    height: 100dvh;
  }

  .sheetHandle{
    display: block;
  }

  .panel{
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    width: 100%;
    height: 52dvh;
    border-top-left-radius: 28px;
    border-top-right-radius: 28px;
    overflow: hidden;
    border-top: 1px solid rgba(255,255,255,.65);
    box-shadow: 0 -18px 48px rgba(15,23,42,.10);
  }

  .panel.sheet-mid{
    height: 52dvh;
  }

  .panel.sheet-full{
    height: 88dvh;
  }

  .panel.sheet-compact{
    height: 34dvh;
  }

  body.wallet-modal-open .panel{
    transform: translateY(170%) !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  .header{
    padding-top: max(16px, env(safe-area-inset-top));
  }

  .tabs{
    overflow-x: auto;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar{
    display: none;
  }

  .tabBtn{
    min-width: max-content;
    flex: 1 0 auto;
    padding-left: 14px;
    padding-right: 14px;
  }

  .zoneInfo{
    grid-template-columns: 1fr 1fr;
  }

  .zoneBuyRow{
    grid-template-columns: 1fr;
  }

  .zoneBuyRow .btnPrimary,
  .zoneBuyRow .zoneInput{
    width: 100%;
  }

  .rewardTop{
    align-items: flex-start;
  }

  .rewardTop .btnPrimary{
    flex: 0 0 auto;
  }
}

/* ===== SMALL MOBILE ===== */
@media (max-width: 520px){
  .header{
    padding-left: 14px;
    padding-right: 14px;
  }

  .panelInner{
    padding: 10px 12px 18px;
  }

  .brandText b{
    font-size: 16px;
  }

  .brandText span{
    font-size: 11px;
  }

  .zoneInfo{
    grid-template-columns: 1fr;
  }

  .rewardTitle{
    font-size: 16px;
  }

  .zoneTitle{
    font-size: 18px;
  }

  .profileCard,
  .rewardCard,
  .zoneCard{
    padding: 13px;
  }

  .btnPrimary{
    font-size: 13px;
  }
}

/* ===== DESKTOP ===== */
@media (min-width: 901px){
  .layout{
    display: grid;
    grid-template-columns: 1fr var(--panel-width);
    width: 100vw;
    height: 100vh;
  }

  #map{
    height: 100vh;
    min-height: 100vh;
  }

  .panel{
    height: 100vh;
    border-top: none;
    border-left: 1px solid rgba(255,255,255,.55);
    border-top-left-radius: 28px;
    border-bottom-left-radius: 28px;
    box-shadow: -18px 0 48px rgba(15,23,42,.08);
  }

  body.wallet-modal-open .panel{
    transform: translateX(115%);
  }

  .panelInner{
    padding: 14px 16px 22px;
  }

  .zoneInfo{
    grid-template-columns: 1fr 1fr;
  }
}