/* ============================================================
   ОСНОВНЫЕ СТИЛИ
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: #0a0a1a;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    touch-action: none;
}

#gameContainer {
    position: relative;
    width: 420px;
    height: 100vh;
    max-height: 800px;
    background: #080818;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 0 60px rgba(0, 200, 255, 0.1), inset 0 0 60px rgba(0, 100, 200, 0.05);
    touch-action: none;
}

#gameContainer canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ============================================================
   СТАРТОВЫЙ ЭКРАН
   ============================================================ */
#startScreen {
    padding-top: 60px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(8, 8, 24, 0.95);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

#startScreen h1 {
    font-size: 28px;
    color: #fff;
    text-shadow: 0 0 40px rgba(0, 200, 255, 0.3);
    margin-bottom: 5px;
    text-align: center;
}

#startScreen p {
    color: rgba(255,255,255,0.5);
    font-size: 14px;
    margin-bottom: 20px;
}

#heroSelection {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
    width: 100%;
    max-width: 340px;
}

.hero-card {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 15px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.hero-card:hover {
    transform: translateY(-2px);
    border-color: rgba(0, 200, 255, 0.3);
}

.hero-card.selected {
    border-color: #00ccff;
    box-shadow: 0 0 40px rgba(0, 200, 255, 0.2);
    background: rgba(0, 200, 255, 0.05);
}

.hero-card[data-hero="FireBall"].selected {
    border-color: #ff4400;
    box-shadow: 0 0 40px rgba(255, 68, 0, 0.2);
    background: rgba(255, 68, 0, 0.05);
}

.hero-card[data-hero="LightningBall"].selected {
    border-color: #00ddff;
    box-shadow: 0 0 40px rgba(0, 200, 255, 0.2);
    background: rgba(0, 200, 255, 0.05);
}

.hero-card[data-hero="WindBall"].selected {
    border-color: #ccccdd;
    box-shadow: 0 0 40px rgba(200, 200, 255, 0.2);
    background: rgba(200, 200, 255, 0.05);
}

.hero-card .hero-icon {
    font-size: 36px;
    margin-bottom: 6px;
}

.hero-card .hero-name {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 2px;
}

.hero-card .hero-desc {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
}

.hero-card .hero-color {
    width: 30px;
    height: 3px;
    border-radius: 2px;
    margin: 6px auto 0;
}

.btn {
    padding: 14px 40px;
    border: 2px solid #00ccff;
    border-radius: 30px;
    background: transparent;
    color: #00ccff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
    text-shadow: 0 0 20px rgba(0, 200, 255, 0.2);
    box-shadow: 0 0 30px rgba(0, 200, 255, 0.05);
    margin: 5px;
    min-width: 200px;
}

.btn:active {
    transform: scale(0.95);
    background: #00ccff;
    color: #050510;
}

.btn-red {
    border-color: #ff0055;
    color: #ff0055;
    text-shadow: 0 0 20px rgba(255, 0, 85, 0.2);
    box-shadow: 0 0 30px rgba(255, 0, 85, 0.05);
}

.btn-red:active {
    background: #ff0055;
    color: #fff;
}

.btn-back {
    border-color: rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.5);
    min-width: 150px;
    font-size: 14px;
}

.btn-back:active {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

/* ============================================================
   ПОИСК
   ============================================================ */
#searchScreen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(8, 8, 24, 0.95);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#searchScreen h2 {
    color: #00ccff;
    font-size: 24px;
    margin: 15px 0;
}

#searchScreen p {
    color: rgba(255,255,255,0.5);
    font-size: 14px;
    margin-bottom: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(0, 200, 255, 0.1);
    border-top: 4px solid #00ccff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================================
   HP БАРЫ (актуальная панель описана ниже в «ВЕРХНЯЯ ПАНЕЛЬ»)
   ============================================================ */

/* ============================================================
   КНОПКА МЕНЮ (СДАТЬСЯ) — слева вверху под миникартой
   ============================================================ */
/* ============================================================
   ВЕРХНЯЯ ПАНЕЛЬ: моё ХП слева, таймер в центре, соперник справа.
   Правый верхний угол свободен для золота/магазина.
   ============================================================ */
#topHP {
    pointer-events: none;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start; /* правый блок прижат к рамке имени, не к краю экрана */
    gap: 6px;
    padding: 8px 10px 0;
    position: relative;
    z-index: 45;
}
#hudMySide {
    flex: 0 0 44%;
    max-width: 44%;
    background: rgba(12,18,40,.78);
    border: 1px solid #2c3a6a;
    border-radius: 12px;
    padding: 7px 10px;
}
/* золотая шкала опыта — над шкалой ХП */
#xpBar {
    height: 3px;
    background: #222;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 3px;
}
#xpFill {
    display: block;
    height: 100%;
    background: #ffd94a;
    width: 0%;
    transition: width .3s;
}
#hudMySide .name {
    font-size: 12px;
    font-weight: bold;
    color: #9fe8ff;
    text-shadow: 0 1px 3px #000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}
#hudMySide .bar-bg {
    height: 10px;
    background: #222;
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid #000;
}
#hudMySide .bar-fill {
    height: 100%;
    background: linear-gradient(#4cd964, #2aa845);
    width: 100%;
    transition: width .2s;
}
#hudMySide .hp-text {
    font-size: 10px;
    color: #cfe0ff;
    text-align: center;
    margin-top: 2px;
    text-shadow: 0 1px 2px #000;
}
#hudStats {
    margin-top: 4px;
    font-size: 10px;
    color: #aab8e0;
    text-align: center;
    text-shadow: 0 1px 2px #000;
}
/* правая колонка: ник соперника → ряд (таймер + сдача) */
#hudRight {
    flex: 0 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}
#hudTimerRow {
    display: flex;
    align-items: stretch;
    gap: 6px;
}
#hudTimer {
    font-size: 13px;
    font-weight: 900;
    color: #eaf0ff;
    background: rgba(12,18,40,.78);
    border: 1px solid #2c3a6a;
    border-radius: 10px;
    padding: 7px 9px;
    text-shadow: 0 1px 3px #000;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
}
#surrenderBtn {
    position: static;
    width: 38px;
    border-radius: 10px;
    border: 1px solid #3a4a7a;
    background: rgba(12,18,40,.78);
    color: #ffffff;
    font-size: 17px;
    line-height: 1;
    z-index: 50;
    padding: 0;
    cursor: pointer;
    pointer-events: auto; /* #topHP имеет pointer-events:none — иначе клик уходит в PIXI-канвас */
}
#surrenderBtn:active { background: rgba(40,55,110,.85); }

/* вторая строка: миникарта → магазин → золото */
#hudRow2 {
    pointer-events: none;
    width: 44%;
    margin: 8px 0 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative; /* над PIXI-канвасом, иначе кнопки не кликабельны */
    z-index: 45;
}
#hudRow2 #minimap {
    position: static;
    flex: 0 0 auto;
    pointer-events: none;
}
#hudRow2 #shopBtn {
    pointer-events: auto;
    position: static;
    flex: 0 0 auto;
}
#hudRow2 #goldBar {
    position: static;
    margin-left: auto; /* правый край золота = правый край рамки имени */
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center; /* золото по центру своей рамки */
    gap: 4px;
    white-space: nowrap;
    font-size: 11px;
    padding: 5px 6px;
}
#hudOpponent {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(12,18,40,.78);
    border: 1px solid #2c3a6a;
    border-radius: 12px;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: bold;
    color: #ffb0a0;
    text-shadow: 0 1px 3px #000;
    white-space: nowrap;
    margin-bottom: 6px;
    max-width: 100%;
}
#hudOpponent #oppHeroIcon { font-size: 16px; }
#hudOpponent #opponentName {
    overflow: hidden;
    text-overflow: ellipsis;
}
#hudMySide, #hudOpponent { position: relative; }
/* оверлей респауна: рамка мутнеет, в центре — таймер до возрождения */
.respawn-overlay {
    position: absolute;
    inset: 0;
    background: rgba(8,12,28,.72);
    border-radius: inherit;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 900;
    color: #ffb0b0;
    text-shadow: 0 1px 4px #000;
    z-index: 6;
    pointer-events: none;
}
.respawn-overlay.visible { display: flex; }

/* (старые абсолютные правила золота/магазина удалены —
   они живут во второй строке hudRow2: миникарта → магазин → золото) */

/* визуал рамок золота и магазина (позиция задаётся в hudRow2) */
#goldBar {
    padding: 5px 10px;
    border-radius: 10px;
    border: 1px solid #6a5a1a;
    background: rgba(40,34,10,.7);
    color: #ffd94a;
    font-size: 13px;
    font-weight: bold;
}
#shopBtn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid #3a4a7a;
    background: rgba(20,28,60,.7);
    color: #cfe0ff;
    font-size: 15px;
    line-height: 1;
    padding: 0;
}
#shopBtn:active { background: rgba(40,55,110,.85); }

/* Уровень теперь в скобках после ника; чип удалён */

/* Счётчик онлайна на главном экране */

/* Кнопка рейтинга над заголовком */
#leaderboardBtn {
    display: block;
    margin: 0 auto 6px;
    padding: 5px 14px;
    border-radius: 16px;
    border: 1px solid #6a5a1a;
    background: rgba(40,34,10,.7);
    color: #ffd94a;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
}
#leaderboardBtn:active { background: rgba(70,60,20,.85); }

/* Панель рейтинга игроков */
#leaderboardPanel {
    position: absolute;
    inset: 0;
    z-index: 1100;
    background: rgba(8,8,24,.96);
    display: none;
    flex-direction: column;
    padding: 16px;
    overflow: hidden;
}
#lbHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    font-weight: bold;
    color: #ffd94a;
    margin-bottom: 12px;
}
#lbClose {
    background: none;
    border: none;
    color: #8899cc;
    font-size: 16px;
    cursor: pointer;
}
#leaderboardList {
    overflow-y: auto;
    flex: 1;
}
.lb-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    margin-bottom: 5px;
    border-radius: 10px;
    border: 1px solid #2a3560;
    background: rgba(20,28,60,.5);
}
.lb-row.me { border-color: #ffd94a; background: rgba(60,50,10,.5); }
.lb-place {
    width: 26px;
    font-size: 12px;
    font-weight: 900;
    color: #ffd94a;
    text-align: center;
    flex-shrink: 0;
}
.lb-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #2a3560;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: bold;
    color: #cfe0ff;
    overflow: hidden;
}
.lb-avatar img { width: 100%; height: 100%; object-fit: cover; }
.lb-info { flex: 1; min-width: 0; }
.lb-name {
    font-size: 12px;
    font-weight: bold;
    color: #dfe8ff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lb-rankname { font-size: 10px; color: #8899cc; }
.lb-rating {
    font-size: 13px;
    font-weight: 900;
    color: #ffd94a;
    text-align: right;
    flex-shrink: 0;
}
.lb-wl { font-size: 9px; color: #8899aa; text-align: right; }
#onlineCounter {
    display: none;
    margin: 4px auto 10px;
    padding: 6px 16px;
    width: fit-content;
    border-radius: 20px;
    border: 1px solid rgba(0, 255, 100, 0.25);
    background: rgba(0, 40, 15, 0.5);
    color: #4aff8a;
    font-size: 13px;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(0, 255, 100, 0.3);
}

/* Панель магазина */
#shopPanel {
    position: absolute;
    top: 150px;
    right: 6px;
    width: 240px;
    max-height: 55%;
    z-index: 55;
    background: rgba(12,16,36,.96);
    border: 1px solid #3a4a7a;
    border-radius: 12px;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
#shopHeader {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 10px; font-size: 13px; font-weight: bold; color: #cfe0ff;
    border-bottom: 1px solid #2a3560;
}
#shopClose { background:none; border:none; color:#8899cc; font-size:14px; cursor:pointer; }
#shopSlots { display:flex; gap:4px; padding:8px 10px 2px; }
#shopSlots .slot {
    width: 26px; height: 26px; border-radius: 6px;
    border: 1px dashed #3a4a7a; background: rgba(20,28,60,.6);
    display:flex; align-items:center; justify-content:center;
    font-size: 9px; color:#8899cc; text-align:center; overflow:hidden;
}
#shopSlots .slot.filled { border-style: solid; border-color: #6a7ab0; }
#shopList { touch-action: pan-y; overflow-y: auto; padding: 6px; }
.shop-item {
    padding: 6px 8px; margin-bottom: 5px; border-radius: 8px;
    border: 1px solid #2a3560; background: rgba(20,28,60,.5);
    color: #dfe8ff; font-size: 11px; cursor: pointer;
}
.shop-item:hover { border-color: #5a6ab0; }
.shop-item .nm { font-weight: bold; font-size: 12px; }
.shop-item .bonus { color: #7fd48a; }
.shop-item .cost { color: #ffd94a; }
.shop-item.poor { opacity: .45; cursor: default; }
.shop-item.owned { border-color: #4a7a5a; }

/* ============================================================
   ПРОКАЧКА СКИЛЛОВ: кнопки «+» и ранги, ульта
   ============================================================ */
.skill-wrap { position: relative; display: inline-block; }
.skill-up {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid #4a7a5a;
    background: rgba(30,70,40,.9);
    color: #b8e986;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    z-index: 5;
    display: none; /* появляется, когда есть очко навыка */
    padding: 0;
}
.skill-up.visible { display: block; }
.skill-rank {
    position: absolute;
    top: -6px;
    right: -4px;
    z-index: 5;
    font-size: 10px;
    font-weight: bold;
    color: #ffd94a;
    text-shadow: 0 1px 2px #000;
}
.ult-btn { border-color: #7a4a9a !important; }
.ult-btn .label { color: #d0aaff !important; }
.skill-wrap.ult.locked { opacity: .4; }
.action-btn.unlearned { opacity: .45; }
.action-btn.unlearned .label { color: #8899aa !important; }

/* ============================================================
   МИНИКАРТА
   ============================================================ */
#minimap {
    position: absolute;
    top: 75px;
    left: 10px;
    z-index: 50;
    pointer-events: none;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 200, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    width: 55px;
    height: 55px;
}

#minimap canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ============================================================
   УПРАВЛЕНИЕ
   ============================================================ */
#controls {
    position: absolute;
    bottom: 15px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 15px;
    z-index: 200;
    gap: 10px;
    pointer-events: none; /* полоса прозрачна для кликов — тапы идут в игру */
}

#joystick {
    pointer-events: auto; /* джойстик ловит касания */
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 200, 255, 0.08), rgba(0, 100, 200, 0.15));
    border: 2px solid rgba(0, 200, 255, 0.2);
    position: relative;
    flex-shrink: 0;
    touch-action: none;
    box-shadow: 0 0 40px rgba(0, 200, 255, 0.05), inset 0 0 40px rgba(0, 200, 255, 0.05);
}

#joystickDot {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 200, 255, 0.4), rgba(0, 100, 200, 0.2));
    border: 2px solid rgba(0, 200, 255, 0.3);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: none;
    touch-action: none;
    box-shadow: 0 0 30px rgba(0, 200, 255, 0.15);
    pointer-events: none;
}

#actionBtns {
    /* кнопки по дуге вокруг Атаки (схема владельца):
       контейнер 210×265, атака в правом нижнем углу,
       между границами кнопок ~10px зазора */
    pointer-events: auto;
    position: relative;
    width: 210px;
    height: 265px;
    flex-shrink: 0;
}

.action-btn {
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.15s ease;
    border: 2px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.05);
    color: #fff;
    font-size: 8px;
    font-weight: 600;
    text-shadow: 0 0 20px rgba(255,255,255,0.1);
}

.action-btn:active {
    transform: scale(0.9);
}

.action-btn .icon {
    font-size: 18px;
    line-height: 1;
    margin-bottom: 1px;
}

.action-btn .label {
    font-size: 7px;
    opacity: 0.7;
    line-height: 1.1;
}

#attackBtn {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 76px;
    height: 76px;
    background: radial-gradient(circle, rgba(255, 100, 50, 0.25), rgba(200, 50, 0, 0.15));
    border-color: rgba(255, 100, 50, 0.35);
    box-shadow: 0 0 40px rgba(255, 100, 50, 0.1);
}

#attackBtn .icon {
    font-size: 26px;
}

#attackBtn:active {
    background: radial-gradient(circle, rgba(255, 100, 50, 0.4), rgba(200, 50, 0, 0.25));
    border-color: rgba(255, 100, 50, 0.6);
    box-shadow: 0 0 60px rgba(255, 100, 50, 0.3);
}

/* Взрыв (оранжевый) — слева от атаки, у самого низа */
#wrap1 { position: absolute; left: 68px; bottom: 0; }
#skill1 {
    width: 48px;
    height: 48px;
}

#skill1 .icon {
    font-size: 17px;
}

/* Щит (синий) — над взрывом */
#wrap2 { position: absolute; left: 82px; top: 137px; }
#skill2 {
    width: 44px;
    height: 44px;
}

/* Целевой скилл (розовый) — над атакой */
#wrap3 { position: absolute; right: 0; bottom: 94px; }
#skill3 {
    width: 52px;
    height: 52px;
}

#skill3 .icon {
    font-size: 15px;
}

/* Ульт (жёлтый) — над розовым */
#wrap4 { position: absolute; right: 0; bottom: 164px; }
#skill4 {
    width: 50px;
    height: 50px;
}

#skill4 .icon {
    font-size: 17px;
}

#skill2 .icon {
    font-size: 14px;
}

/* Активное состояние щита */
#skill2.active {
    border-color: #00ff00;
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.3);
    animation: shieldPulse 0.5s ease-in-out infinite alternate;
}

@keyframes shieldPulse {
    0% { box-shadow: 0 0 20px rgba(0, 255, 200, 0.2); }
    100% { box-shadow: 0 0 50px rgba(0, 255, 200, 0.5); }
}

/* ============================================================
   GAME OVER
   ============================================================ */
#gameOver {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 1000;
    padding: 30px;
}

#gameOver.show {
    display: flex;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

#gameOver h1 {
    font-size: 36px;
    margin-bottom: 10px;
    text-shadow: 0 0 60px currentColor;
}

#gameOver #resultTitle.win {
    color: #00ff88;
}

#gameOver #resultTitle.lose {
    color: #ff4400;
}

#gameOver p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 16px;
    margin-bottom: 25px;
}

/* ============================================================
   АДАПТАЦИЯ
   ============================================================ */
@media (max-width: 440px) {
    #gameContainer {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    #joystick {
        width: 115px;
        height: 115px;
    }
    #joystickDot {
        width: 42px;
        height: 42px;
    }
    #actionBtns {
        transform: scale(0.9);
        transform-origin: bottom right;
    }

}

@media (max-height: 700px) {
    #gameContainer {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    #joystick {
        width: 100px;
        height: 100px;
    }
    #joystickDot {
        width: 36px;
        height: 36px;
    }
    #actionBtns {
        transform: scale(0.82);
        transform-origin: bottom right;
    }

}

/* Золотые шары — в верхней полосе главного экрана */
#goldBallsBar {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 14px;
    border: 1px solid #6a5a1a;
    background: rgba(40,34,10,.75);
    color: #ffd94a;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(255,217,74,.3);
}
.gb-icon {
    display: inline-block;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff3b0, #ffd94a 45%, #c9962a 80%, #8a6400);
    box-shadow: 0 0 8px rgba(255,217,74,.6), inset 0 -2px 3px rgba(120,80,0,.6);
}

/* ============================================================
   ВЕРХНЯЯ ПОЛОСА ГЛАВНОГО ЭКРАНА: рейтинг → профиль → шары
   ============================================================ */
#startTopBar {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
#leaderboardBtn {
    display: inline-block;
    margin: 0;
    padding: 6px 12px;
    border-radius: 16px;
    border: 1px solid #6a5a1a;
    background: rgba(40,34,10,.7);
    color: #ffd94a;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    white-space: nowrap;
}
#leaderboardBtn:active { background: rgba(70,60,20,.85); }
#goldBallsBar {
    position: static;
    display: flex;
    padding: 6px 12px;
    border-radius: 14px;
    border: 1px solid #6a5a1a;
    background: rgba(40,34,10,.75);
    color: #ffd94a;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(255,217,74,.3);
    white-space: nowrap;
}
#profileBar {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 14px;
    border: 1px solid #4a5a8a;
    background: rgba(16,24,52,.75);
    font-size: 13px;
    font-weight: bold;
    white-space: nowrap;
}
#profileBar #pbEmblem { font-size: 15px; }
#profileBar #pbRating { color: #ffd94a; }
#profileBar #pbWL { color: #9fe8ff; }
/* ============================================================
   КНОПКА ЗВАНИЯ (центр верхней полосы) + ЛЕСТНИЦА ЗВАНИЙ
   ============================================================ */
#rankBtn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 14px;
    border: 1px solid #4a5a8a;
    background: rgba(16,24,52,.78);
    color: #dfe8ff;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    white-space: nowrap;
    text-shadow: 0 1px 3px #000;
}
#rankBtn:hover { border-color: #ffd94a; }
#rankBtn #rankBtnEmblem { font-size: 16px; }

#ranksPanel {
    position: absolute;
    top: 64px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    max-height: 60%;
    overflow-y: auto;
    z-index: 850;
    background: rgba(10,14,32,.97);
    border: 1px solid #4a5a8a;
    border-radius: 14px;
    padding: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
.ranks-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    margin-bottom: 4px;
    border-radius: 10px;
    border: 1px solid #2a3560;
    background: rgba(20,28,60,.5);
}
.ranks-row.current {
    border-color: #ffd94a;
    background: rgba(60,50,10,.5);
}
.ranks-row .r-emblem { font-size: 20px; width: 26px; text-align: center; flex-shrink: 0; }
.ranks-row .r-name { flex: 1; font-size: 12px; font-weight: bold; color: #dfe8ff; }
.ranks-row .r-range { font-size: 10px; color: #8899cc; white-space: nowrap; }
.ranks-row.current .r-range { color: #ffd94a; }
/* Очки и счёт в кнопке звания */
#rankBtnStats {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 4px;
    padding-left: 8px;
    border-left: 1px solid #4a5a8a;
    font-size: 12px;
}
#rankBtnRating { color: #ffd94a; }
.wl .win-num { color: #4aff8a; }
.wl .lose-num { color: #ff6655; }

/* Клик мимо лестницы званий закрывает её (перехват на body) */
body.ranks-open #ranksPanel { display: block; }

/* ============================================================
   ЭКРАН ВОЗВРАТА В МАТЧ после отключения
   ============================================================ */
#rejoinOverlay {
    position: absolute;
    inset: 0;
    z-index: 1200;
    background: rgba(5,8,20,.9);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
}
#rejoinBox {
    background: #141c3c;
    border: 1px solid #4a5a8a;
    border-radius: 18px;
    padding: 26px 28px;
    max-width: 330px;
    text-align: center;
    color: #dfe8ff;
}
#rejoinTitle { font-size: 17px; font-weight: bold; margin-bottom: 10px; color: #ffd94a; }
#rejoinText { font-size: 13px; line-height: 1.6; margin-bottom: 20px; color: #cfe0ff; }
#rejoinBtn {
    width: 100%;
    padding: 13px 20px;
    border-radius: 14px;
    border: 2px solid #00ccff;
    background: rgba(0, 204, 255, 0.12);
    color: #00ccff;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all .15s ease;
}
#rejoinBtn:active { background: #00ccff; color: #050510; }
