/* ============================================================
   МУЛЬТИПЛЕЕРНЫЙ ОБМЕННИК — MOBILE-FIRST + GPU-OPTIMIZED
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    overflow: hidden;
    background: #05070f;
}

body.exchange-page {
    margin: 0 !important;
    padding: 0 !important;
    color: #eef2ff;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow: hidden !important;
    overscroll-behavior: none;
}

body.exchange-page > .container,
body.exchange-page > main,
body.exchange-page > .wrapper,
body.exchange-page > .site-wrapper {
    padding: 0 !important; margin: 0 !important;
    max-width: none !important; width: 100% !important;
}
body.exchange-page .navbar-custom,
body.exchange-page > nav.navbar-custom,
body.exchange-page > header { display: none !important; }

/* ============ КОРНЕВОЙ КОНТЕЙНЕР ============ */
.exchange-wrapper-full {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background:
      radial-gradient(ellipse 80% 60% at 50% -10%, #0e1a3a 0%, transparent 60%),
      radial-gradient(ellipse 70% 60% at 90% 100%, #1a0e2e 0%, transparent 60%),
      #05070f;
    z-index: 9999;
}

/* ============ КНОПКА «НАЗАД» ============ */
.exchange-back-btn {
    position: absolute;
    top: 10px; left: 10px;
    z-index: 10000;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    min-height: 40px;
    background: linear-gradient(180deg, rgba(15,28,58,.92), rgba(8,16,36,.88));
    border: 1px solid rgba(212,168,83,.35);
    color: #ffd47a;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 700;
    font-size: 12px;
    transition: transform .15s;
}
.exchange-back-btn:active { transform: scale(.95); }

/* ============ TOPBAR ============ */
.exchange-topbar {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px 8px;
    padding-left: 70px; /* место под кнопку Назад */
    background: linear-gradient(180deg, rgba(15,25,50,.94), rgba(10,18,38,.88));
    border-bottom: 1px solid rgba(120,180,255,.14);
    z-index: 50;
}
.exchange-title h1 {
    font-size: 1rem;
    margin: 0;
    font-weight: 800;
    background: linear-gradient(90deg, #ffd47a, #d4a853 50%, #ffba5c);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    padding-left: 0 !important;
}

/* KPI — горизонтальный скролл на мобилке */
.exchange-kpis {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
}
.exchange-kpis::-webkit-scrollbar { display: none; }
.kpi-box {
    flex: 0 0 auto;
    background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.01));
    border: 1px solid rgba(120,180,255,.15);
    border-radius: 9px;
    padding: 5px 10px;
    min-width: 74px;
    text-align: center;
}
.kpi-box .label {
    display: block;
    font-size: 8.5px;
    color: rgba(255,255,255,.4);
    text-transform: uppercase;
    letter-spacing: .6px;
    margin-bottom: 1px;
}
.kpi-box .value {
    font-size: 12px;
    font-weight: 700;
    color: #ffd47a;
    font-variant-numeric: tabular-nums;
}

/* ============ VIEWPORT ============ */
.exchange-viewport {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    overflow: hidden;
    touch-action: none;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    /* Фон — статичные слои, БЕЗ анимации */
    background:
      radial-gradient(circle at 50% 50%, rgba(60,140,255,.05) 0%, transparent 60%),
      repeating-linear-gradient(0deg, rgba(120,180,255,.028) 0 1px, transparent 1px 80px),
      repeating-linear-gradient(90deg, rgba(120,180,255,.028) 0 1px, transparent 1px 80px),
      radial-gradient(ellipse 80% 60% at 50% -10%, #0d2247 0%, transparent 60%),
      linear-gradient(180deg, #0a1e3a 0%, #061428 45%, #02060f 100%);
    contain: strict;
}
.exchange-viewport.dragging { cursor: grabbing; }

/* ============ FIELD ============ */
#field {
    position: absolute;
    left: 0; top: 0;
    width: 2000px; height: 2000px;
    will-change: transform;
    transform-origin: 0 0;
    transform: translate3d(0,0,0);
    /* Статичный фон БЕЗ анимаций */
    background:
      radial-gradient(circle at 50% 50%, rgba(60,140,255,.05) 0%, transparent 60%),
      repeating-linear-gradient(0deg, rgba(120,180,255,.028) 0 1px, transparent 1px 80px),
      repeating-linear-gradient(90deg, rgba(120,180,255,.028) 0 1px, transparent 1px 80px),
      radial-gradient(ellipse 80% 60% at 50% -10%, #0d2247 0%, transparent 60%),
      linear-gradient(180deg, #0a1e3a 0%, #061428 45%, #02060f 100%);
    z-index: 1;
    pointer-events: none;
    contain: layout style paint;
}

/* Звёзды генерируются в JS только под видимую область */
#field .starfield {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}
#field .starfield .star {
    position: absolute;
    border-radius: 50%;
    transform: translate3d(-50%, -50%, 0);
    animation-name: starTwinkle;
    animation-iteration-count: infinite;
    animation-direction: alternate;
    animation-timing-function: ease-in-out;
    will-change: opacity;
}
@keyframes starTwinkle {
    0%   { opacity: 1; }
    100% { opacity: var(--min-op, 0.3); }
}

/* ============ ORDER PANEL ============
   MOBILE-FIRST: bottom-sheet, свернут по умолчанию
   ============ */
#orderPanel {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    background: linear-gradient(180deg, rgba(15,28,58,.97), rgba(8,16,36,.98));
    border-top: 1px solid rgba(120,180,255,.22);
    border-radius: 18px 18px 0 0;
    padding: 10px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    z-index: 30;
    transform: translate3d(0, calc(100% - 56px), 0);
    transition: transform .3s cubic-bezier(.34,1.2,.64,1);
    max-height: 78vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    will-change: transform;
}
#orderPanel.open { transform: translate3d(0, 0, 0); }

/* Ручка-«потяни вверх» */
#orderPanel::before {
    content: '';
    position: absolute;
    top: 6px; left: 50%;
    transform: translateX(-50%);
    width: 40px; height: 4px;
    border-radius: 2px;
    background: rgba(120,180,255,.35);
}
#orderPanel h3 {
    font-size: 11px;
    margin: 6px 0 10px;
    color: #8db4e0;
    font-weight: 600;
    letter-spacing: .4px;
    text-transform: uppercase;
    text-align: center;
}
.sideToggle { display: flex; gap: 8px; margin-bottom: 12px; }
.sideToggle button {
    flex: 1;
    padding: 11px 6px;
    min-height: 42px;
    border: 1px solid rgba(120,180,255,.18);
    background: rgba(0,0,0,.25);
    color: #6a98c0;
    border-radius: 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    transition: all .15s;
}
.sideToggle button.active.buy {
    background: linear-gradient(180deg, rgba(74,222,160,.22), rgba(74,222,160,.10));
    border-color: rgba(74,222,160,.7);
    color: #4adea0;
    box-shadow: 0 0 16px rgba(74,222,160,.25);
}
.sideToggle button.active.sell {
    background: linear-gradient(180deg, rgba(255,120,180,.22), rgba(255,120,180,.10));
    border-color: rgba(255,120,180,.7);
    color: #ff78b4;
    box-shadow: 0 0 16px rgba(255,120,180,.25);
}
.inputRow { margin-bottom: 10px; }
.inputRow label {
    display: block;
    font-size: 11px;
    color: #8db4e0;
    margin-bottom: 5px;
}
.inputRow input {
    width: 100%;
    padding: 11px 12px;
    min-height: 44px;
    background: rgba(0,0,0,.4);
    border: 1px solid rgba(120,180,255,.2);
    border-radius: 10px;
    color: #eef2ff;
    font-size: 15px; /* ≥16px на iOS предотвращает зум, но 15 ок с maximum-scale */
    font-weight: 600;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.inputRow input:focus {
    border-color: rgba(120,180,255,.6);
    box-shadow: 0 0 0 3px rgba(80,140,255,.15);
}
.feeHint {
    font-size: 11px;
    color: #8db4e0;
    margin: 10px 0 6px;
    padding: 8px 12px;
    background: linear-gradient(180deg, rgba(255,215,0,.06), rgba(255,215,0,.02));
    border: 1px dashed rgba(255,215,0,.25);
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.feeHint b { color: #ffd47a; font-size: 13px; font-variant-numeric: tabular-nums; }

#createBtn {
    width: 100%;
    padding: 14px;
    min-height: 48px;
    background: linear-gradient(180deg, #6ae0ff 0%, #2a90d0 100%);
    color: #001a30;
    border: none;
    border-radius: 11px;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    margin-top: 6px;
    box-shadow: 0 4px 18px rgba(106,224,255,.35);
    transition: transform .12s, opacity .12s;
    -webkit-tap-highlight-color: transparent;
}
#createBtn:active:not(:disabled) { transform: scale(.97); }
#createBtn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
#cancelBtn {
    width: 100%;
    padding: 12px;
    min-height: 44px;
    border-radius: 11px;
    font-weight: 700;
    cursor: pointer;
    background: linear-gradient(180deg, rgba(255,71,87,.3), rgba(255,71,87,.15));
    color: #ffb0b8;
    border: 1px solid rgba(255,71,87,.5);
}
#cancelBtn:active { background: rgba(255,71,87,.45); }

.applyRateBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 12px;
    min-height: 44px;
    background: linear-gradient(180deg, rgba(212,168,83,.22), rgba(212,168,83,.10));
    border: 1px solid rgba(212,168,83,.55);
    color: #ffd47a;
    border-radius: 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    min-width: 74px;
    -webkit-tap-highlight-color: transparent;
}
.applyRateBtn:active { transform: scale(.95); }
.applyRateBtn.flash { animation: applyRateFlash .4s ease-out; }
@keyframes applyRateFlash {
    0%   { background: rgba(212,168,83,.6); }
    100% { background: rgba(212,168,83,.22); }
}

/* Индикатор отклонения курса */
.rateDelta {
    margin-top: 6px;
    font-size: 11.5px;
    font-weight: 700;
    text-align: right;
    min-height: 16px;
    font-variant-numeric: tabular-nums;
}
.rateDelta.hidden { display: none; }
.rateDelta.up { color: #4adea0; }
.rateDelta.up::before { content: '▲ '; font-size: 9px; }
.rateDelta.down { color: #ff78b4; }
.rateDelta.down::before { content: '▼ '; font-size: 9px; }
.rateDelta.equal { color: #8db4e0; }
.rateDelta .deltaMarket {
    color: rgba(255,255,255,.4);
    font-weight: 500;
    margin-left: 4px;
    font-size: 10.5px;
}

/* ============ TOOLBAR ============ */
.exchange-toolbar {
    position: absolute;
    right: 10px;
    top: 10px;
    display: flex;
    gap: 4px;
    align-items: center;
    background: linear-gradient(180deg, rgba(15,28,58,.9), rgba(8,16,36,.85));
    padding: 5px 8px;
    border-radius: 12px;
    border: 1px solid rgba(212,168,83,.25);
    z-index: 40;
}
.exchange-toolbar button {
    width: 38px; height: 38px;
    border-radius: 9px;
    border: none;
    background: rgba(212,168,83,.12);
    color: #ffd47a;
    font-size: 16px;
    cursor: pointer;
    transition: background .12s, transform .1s;
    -webkit-tap-highlight-color: transparent;
}
.exchange-toolbar button:active { transform: scale(.9); background: rgba(212,168,83,.3); }
.zoomLabel {
    color: #ffd47a;
    font-size: 12px;
    min-width: 44px;
    text-align: center;
    font-weight: 600;
}

/* ============ ПУЗЫРИ — GPU-friendly ============ */
.bubble {
    position: absolute;
    top: 0; left: 0;
    transform: translate3d(-50%, -50%, 0);
    pointer-events: none;
    z-index: 10;
    /* left/top выставляются в JS, но translate делает композитинг */
    will-change: transform;
    backface-visibility: hidden;
}
.bubble .bubbleInner {
    position: relative;
    width: 100%; height: 100%;
    border-radius: 50%;
    animation: bubbleFloat 4s ease-in-out infinite;
}
@keyframes bubbleFloat {
    0%, 100% { transform: translateY(0) scale(1); }
    50%      { transform: translateY(-5px) scale(1.02); }
}
.bubble.buy .bubbleInner {
    background:
      radial-gradient(circle at 32% 26%, rgba(255,255,255,.98) 0%, rgba(255,255,255,.35) 6%, transparent 20%),
      radial-gradient(circle at 50% 50%, rgba(74,222,160,.20) 38%, rgba(74,222,160,.62) 72%, rgba(24,170,110,.85) 100%);
    border: 1.5px solid rgba(160,255,215,.85);
    box-shadow:
      inset 0 0 20px rgba(74,222,160,.6),
      0 0 24px rgba(74,222,160,.55);
}
.bubble.sell .bubbleInner {
    background:
      radial-gradient(circle at 32% 26%, rgba(255,255,255,.98) 0%, rgba(255,255,255,.35) 6%, transparent 20%),
      radial-gradient(circle at 50% 50%, rgba(255,120,180,.20) 38%, rgba(255,120,180,.62) 72%, rgba(200,50,120,.85) 100%);
    border: 1.5px solid rgba(255,190,225,.85);
    box-shadow:
      inset 0 0 20px rgba(255,120,180,.6),
      0 0 24px rgba(255,120,180,.55);
}
.bubble.player .bubbleInner {
    animation: bubbleFloat 3s ease-in-out infinite, playerGlow 2s ease-in-out infinite;
}
@keyframes playerGlow {
    0%, 100% { box-shadow: inset 0 0 20px rgba(74,222,160,.6), 0 0 26px rgba(255,255,255,.6); }
    50%      { box-shadow: inset 0 0 26px rgba(74,222,160,.8), 0 0 44px rgba(255,255,255,.9); }
}
.bubble .shine {
    position: absolute;
    top: 11%; left: 17%;
    width: 32%; height: 22%;
    background: radial-gradient(ellipse, rgba(255,255,255,.95), transparent 70%);
    border-radius: 50%;
    transform: rotate(-25deg);
}
.bubble .shine2 {
    position: absolute;
    bottom: 17%; right: 21%;
    width: 14%; height: 10%;
    background: radial-gradient(ellipse, rgba(255,255,255,.6), transparent 70%);
    border-radius: 50%;
}
.bubble .flag {
    position: absolute;
    bottom: 100%; left: 50%;
    transform: translate3d(-50%, 0, 0);
    margin-bottom: 12px;
    padding: 7px 12px;
    border-radius: 14px;
    min-width: 118px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.25;
    white-space: nowrap;
    text-align: center;
    font-family: 'Inter', system-ui, sans-serif;
    box-shadow: 0 0 0 2px rgba(0,0,0,.55), 0 4px 14px rgba(0,0,0,.55);
    text-shadow: 0 1px 0 rgba(255,255,255,.35), 0 -1px 0 rgba(0,0,0,.35);
    animation: flagIn .3s cubic-bezier(.34,1.56,.64,1);
    z-index: 6;
    pointer-events: none;
}
@keyframes flagIn {
    from { transform: translate3d(-50%, 6px, 0) scale(.85); opacity: 0; }
    to   { transform: translate3d(-50%, 0, 0) scale(1); opacity: 1; }
}
.bubble .flag::after {
    content: '';
    position: absolute;
    top: 100%; left: 50%;
    transform: translateX(-50%);
    width: 0; height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 7px solid currentColor;
}
.bubble .flag .flagAmount {
    display: block;
    font-size: 13px;
    line-height: 1.15;
    font-weight: 900;
}
.bubble .flag .flagPrice {
    display: block;
    font-size: 12px;
    line-height: 1.15;
    font-weight: 900;
    margin-top: 2px;
    padding-top: 3px;
    border-top: 1px solid rgba(0,0,0,.18);
    font-variant-numeric: tabular-nums;
}
.bubble.buy .flag {
    background: linear-gradient(180deg, #5cecb0 0%, #22a978 100%);
    color: #002a17;
    border: 1.5px solid rgba(160,255,215,.95);
}
.bubble.sell .flag {
    background: linear-gradient(180deg, #ff9cc8 0%, #d12d84 100%);
    color: #3a0018;
    border: 1.5px solid rgba(255,190,225,.95);
}
.bubble.player .flag {
    border-width: 2px;
    animation: flagIn .3s cubic-bezier(.34,1.56,.64,1),
               flagPulse 1.6s ease-in-out infinite;
}
@keyframes flagPulse {
    0%, 100% { transform: translate3d(-50%, 0, 0) scale(1); }
    50%      { transform: translate3d(-50%, 0, 0) scale(1.05); }
}
.bubble.player::after {
    content: '';
    position: absolute;
    inset: -12px;
    border: 2px dashed rgba(255,255,255,.35);
    border-radius: 50%;
    animation: spin 14s linear infinite;
    pointer-events: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Кнопка обмена */
.exchangeBtn {
    position: absolute;
    transform: translate3d(-50%, -50%, 0);
    padding: 12px 22px;
    min-height: 44px;
    background: linear-gradient(180deg, #ffffff, #c8ecff);
    color: #002b4d;
    border: none;
    border-radius: 26px;
    font-weight: 800;
    font-size: 13px;
    cursor: pointer;
    z-index: 20;
    pointer-events: auto;
    white-space: nowrap;
    box-shadow: 0 8px 26px rgba(255,255,255,.35), 0 4px 12px rgba(0,0,0,.4);
    animation: pulseExchange 1.6s ease-in-out infinite;
    -webkit-tap-highlight-color: transparent;
}
@keyframes pulseExchange {
    0%, 100% { transform: translate3d(-50%, -50%, 0) scale(1); }
    50%      { transform: translate3d(-50%, -50%, 0) scale(1.05); }
}
.exchangeBtn:active { transform: translate3d(-50%, -50%, 0) scale(.94); }

/* Эффекты */
.pop {
    position: absolute;
    transform: translate3d(-50%,-50%,0);
    pointer-events: none;
    z-index: 100;
}
.pop .ring {
    position: absolute; inset: 0;
    border: 3px solid #fff;
    border-radius: 50%;
    animation: popRing .8s ease-out forwards;
    box-shadow: 0 0 24px rgba(255,255,255,.7);
}
@keyframes popRing {
    0%   { transform: scale(1); opacity: 1; }
    100% { transform: scale(2.4); opacity: 0; }
}
.spark-fly {
    position: absolute;
    width: 5px; height: 5px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 100;
}

/* ============ МОДАЛКА ============ */
#confirmModal {
    position: fixed;
    inset: 0;
    background: rgba(2,8,20,.82);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
    overflow-y: auto;
}
#confirmModal.show { display: flex; animation: fadeIn .18s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modalBox {
    background: linear-gradient(180deg, #122a52 0%, #081426 100%);
    border: 1px solid rgba(120,180,255,.3);
    border-radius: 20px;
    padding: 22px 20px;
    width: 100%;
    max-width: 400px;
    margin: auto;
    box-shadow: 0 24px 60px rgba(0,0,0,.6);
    animation: modalIn .22s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modalIn {
    from { transform: scale(.94); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}
.modalBox h3 {
    font-size: 15px;
    margin-bottom: 14px;
    color: #8ad0ff;
    font-weight: 700;
}
.dealRow {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(120,180,255,.10);
    font-size: 12.5px;
    gap: 12px;
}
.dealRow:last-of-type { border-bottom: none; }
.dealRow .k { color: #8db4e0; }
.dealRow .v { font-weight: 700; color: #eef2ff; text-align: right; }
.modalBtns { display: flex; gap: 10px; margin-top: 18px; }
.modalBtns button {
    flex: 1;
    padding: 13px;
    min-height: 46px;
    border-radius: 11px;
    border: none;
    font-weight: 800;
    font-size: 13px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.modalBtns button:active { transform: scale(.97); }
.modalBtns .confirm {
    background: linear-gradient(180deg, #6ae0ff, #2a90d0);
    color: #001a30;
    box-shadow: 0 6px 20px rgba(106,224,255,.4);
}
.modalBtns .cancel {
    background: rgba(120,180,255,.12);
    color: #8ad0ff;
    border: 1px solid rgba(120,180,255,.25);
}
.dealDelta-up   { color: #4adea0; font-weight: 700; }
.dealDelta-down { color: #ff78b4; font-weight: 700; }
.dealDelta-equal { color: #8db4e0; font-weight: 600; }

/* ============ TOAST ============ */
#toast {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translate3d(-50%, 20px, 0);
    background: linear-gradient(180deg, #6ae0ff, #2a90d0);
    color: #001a30;
    padding: 12px 22px;
    border-radius: 26px;
    font-weight: 800;
    font-size: 13px;
    opacity: 0;
    transition: all .3s cubic-bezier(.34,1.56,.64,1);
    pointer-events: none;
    z-index: 200;
    box-shadow: 0 10px 28px rgba(106,224,255,.4);
    max-width: calc(100vw - 32px);
    text-align: center;
}
#toast.show { opacity: 1; transform: translate3d(-50%, 0, 0); }

/* ============ ГЛУБОКИЕ ПУЗЫРИ (декор) ============ */
#field .deep-bubbles {
    position: absolute; inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}
#field .deep-bubbles .db {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 25%,
        rgba(255,255,255,.7) 0%, rgba(255,255,255,.15) 8%, transparent 22%),
        radial-gradient(circle at 50% 50%,
        rgba(150,220,255,.10) 40%, rgba(150,220,255,.22) 75%, transparent 100%);
    border: 1px solid rgba(180,220,255,.22);
    animation: deepBubbleFloat linear infinite;
    opacity: .45;
    will-change: transform, opacity;
}
@keyframes deepBubbleFloat {
    0%   { transform: translate3d(0, 0, 0) scale(1); opacity: 0; }
    10%  { opacity: .45; }
    90%  { opacity: .45; }
    100% { transform: translate3d(20px, -110vh, 0) scale(1.1); opacity: 0; }
}

/* ============ TABLET / DESKTOP ============ */
@media (min-width: 769px) {
    .exchange-topbar {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 12px 20px;
        padding-left: 130px;
    }
    .exchange-title h1 { font-size: 1.15rem; }
    .exchange-kpis { overflow: visible; }
    .kpi-box { min-width: 86px; padding: 7px 13px; }
    .kpi-box .value { font-size: 13.5px; }

    #orderPanel {
        left: auto; right: 16px; bottom: auto; top: 16px;
        width: 280px;
        border-radius: 16px;
        border: 1px solid rgba(120,180,255,.18);
        transform: none !important;
        max-height: none;
        padding: 16px;
        box-shadow: 0 12px 40px rgba(0,0,0,.5);
        backdrop-filter: blur(14px);
    }
    #orderPanel::before { display: none; }
    #orderPanel h3 { font-size: 13px; text-align: left; }

    .exchange-toolbar {
        left: 16px; right: auto; top: auto; bottom: 16px;
        padding: 6px 10px;
        backdrop-filter: blur(14px);
    }
    .exchange-back-btn {
        padding: 8px 14px;
        min-height: auto;
        font-size: 13px;
    }
    #toast { bottom: 40px; font-size: 14px; }
}

/* Только для устройств с hover — убираем «залипание» на тач */
@media (hover: hover) {
    .exchange-back-btn:hover {
        background: linear-gradient(180deg, rgba(212,168,83,.28), rgba(212,168,83,.16));
        color: #fff;
        transform: translateX(-2px);
    }
    #createBtn:hover:not(:disabled) {
        transform: translateY(-2px);
        box-shadow: 0 6px 24px rgba(106,224,255,.5);
    }
    .exchange-toolbar button:hover { background: rgba(212,168,83,.28); }
    .exchangeBtn:hover { background: linear-gradient(180deg, #ffffff, #e0f4ff); }
    .applyRateBtn:hover {
        background: linear-gradient(180deg, rgba(212,168,83,.35), rgba(212,168,83,.18));
        color: #fff;
    }
    .sideToggle button:hover { color: #a8c8e8; }
}

/* Убираем backdrop-filter на мобильных — тяжёлый для GPU */
@media (max-width: 768px) {
    .exchange-viewport::before { display: none; }
}

/* Уважаем настройки пользователя */
@media (prefers-reduced-motion: reduce) {
    .bubble .bubbleInner,
    .bubble.player .bubbleInner,
    .bubble.player .flag,
    .bubble.player::after,
    .exchangeBtn,
    #field .deep-bubbles .db {
        animation: none !important;
    }
}

/* ============ ПОДСВЕТКА СОВМЕСТИМЫХ ПУЗЫРЕЙ ============ */
.bubble.matched .bubbleInner {
    animation: bubbleFloat 3s ease-in-out infinite, matchedGlow 1.6s ease-in-out infinite;
}
@keyframes matchedGlow {
    0%, 100% {
        box-shadow:
            inset 0 0 24px currentColor,
            0 0 24px rgba(255,215,0,.55),
            0 0 40px rgba(255,215,0,.25);
    }
    50% {
        box-shadow:
            inset 0 0 30px currentColor,
            0 0 40px rgba(255,215,0,.95),
            0 0 70px rgba(255,215,0,.5);
    }
}

/* Золотая пунктирная обводка вокруг совместимого пузыря */
.bubble.matched::before {
    content: '';
    position: absolute;
    inset: -8px;
    border: 2px dashed rgba(255,215,0,.75);
    border-radius: 50%;
    animation: matchedSpin 8s linear infinite;
    pointer-events: none;
}
@keyframes matchedSpin {
    to { transform: rotate(360deg); }
}

/* Бейдж "Сделка" над совместимым пузырём */
.bubble.matched .matchBadge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(180deg, #ffd700, #e6a800);
    color: #2a1e00;
    font-size: 10px;
    font-weight: 800;
    padding: 3px 7px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(255,215,0,.6);
    letter-spacing: .3px;
    z-index: 11;
    animation: matchBadgePulse 1.4s ease-in-out infinite;
    white-space: nowrap;
    pointer-events: none;
}
@keyframes matchBadgePulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.12); }
}

/* Недоступные — притушены, но кликабельны */
.bubble:not(.matched):not(.player) .bubbleInner {
    opacity: .55;
    filter: saturate(.6);
}
.bubble:not(.matched):not(.player):hover .bubbleInner {
    opacity: .85;
    filter: saturate(1);
    transition: opacity .2s, filter .2s;
}

/* Свой пузырь — не трогаем */
.bubble.player .bubbleInner { opacity: 1; filter: none; }