/* БУРМАЛДАGRADER — Material You, monochrome.
   Mobile: floating pill dock at the bottom. Desktop (>=900px): same nav in the top bar. */

@property --chance-deg {
  syntax: '<number>';
  inherits: true;
  initial-value: 0;
}

@view-transition { navigation: auto; }

:root {
  color-scheme: dark;
  --bg: #0e0e0e;
  --surface-1: #161616;
  --panel: #1c1c1c;
  --panel-2: #262626;
  --surface-4: #303030;
  --text: #f2f2f2;
  --muted: #a3a3a3;
  --border: #333333;
  --border-strong: #4a4a4a;
  --gold: #ffffff;            /* legacy name: the accent is now plain white/black */
  --gold-dim: #8f8f8f;
  --on-accent: #0e0e0e;
  --accent-soft: rgba(255, 255, 255, 0.12);
  --danger: #ff6b6b;
  --success: #7ddc9a;
  --scrim: rgba(0, 0, 0, 0.72);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);

  --r-xs: 8px;
  --r-s: 12px;
  --r-m: 16px;
  --r-l: 28px;
  --r-full: 999px;
  --ease: cubic-bezier(.2, 0, 0, 1);        /* M3 emphasized */
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --dock-h: 72px;
  --font: "Google Sans", "Product Sans", "Roboto Flex", Roboto, "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f7f7f7;
    --surface-1: #efefef;
    --panel: #ffffff;
    --panel-2: #f0f0f0;
    --surface-4: #e3e3e3;
    --text: #111111;
    --muted: #5f5f5f;
    --border: #dddddd;
    --border-strong: #bdbdbd;
    --gold: #111111;
    --gold-dim: #777777;
    --on-accent: #ffffff;
    --accent-soft: rgba(0, 0, 0, 0.08);
    --danger: #c62828;
    --success: #1e7d3a;
    --scrim: rgba(0, 0, 0, 0.45);
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
  }
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text); text-decoration: none; }

::selection { background: var(--text); color: var(--bg); }

/* ---------- page transitions ---------- */

/* Only the page content scales/slides. The top bar and the dock are their own
   groups with no animation, so they stay pinned (the dock's thumb would
   otherwise be dragged toward the centre by the whole-page scale). */
main.page { view-transition-name: page; }
.topbar { view-transition-name: topbar; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
::view-transition-old(page) { animation: vt-out .18s var(--ease) both; }
::view-transition-new(page) { animation: vt-in .32s var(--ease) both; }
::view-transition-group(topbar), ::view-transition-group(dock),
::view-transition-old(dock), ::view-transition-new(dock) { animation: none; }
::view-transition-old(dock) { display: none; }

@keyframes vt-out { to { opacity: 0; transform: scale(.985); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(14px) scale(.99); } }

.page > * { animation: rise-in .45s var(--ease) both; }
.page > *:nth-child(2) { animation-delay: .04s; }
.page > *:nth-child(3) { animation-delay: .08s; }
.upgrader-grid > *, .admin-wrap > *, .chat-wrap > * { animation: rise-in .5s var(--ease) both; }
.upgrader-grid > *:nth-child(2), .admin-wrap > *:nth-child(2), .chat-wrap > *:nth-child(2) { animation-delay: .05s; }
.upgrader-grid > *:nth-child(3), .admin-wrap > *:nth-child(3) { animation-delay: .1s; }
.upgrader-grid > *:nth-child(n+4), .admin-wrap > *:nth-child(n+4) { animation-delay: .15s; }

@keyframes rise-in { from { opacity: 0; transform: translateY(16px); } }

/* ---------- top app bar + nav ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
}

.logo {
  font-weight: 800;
  letter-spacing: .5px;
  font-size: 19px;
  color: var(--text);
  white-space: nowrap;
}
.logo b { font-weight: 400; opacity: .7; }

.nav-rail {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 auto;
  padding: 4px;
  background: var(--surface-1);
  border-radius: var(--r-full);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--r-full);
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  transition: color .25s var(--ease), background .35s var(--ease);
}
.nav-item:hover { color: var(--text); background: var(--accent-soft); }
.nav-item.active { color: var(--on-accent); background: var(--text); }
.nav-pill { display: flex; }
.dock-thumb { display: none; }
.ic { width: 22px; height: 22px; fill: currentColor; flex-shrink: 0; }
.nav-item .ic { width: 20px; height: 20px; transition: transform .4s var(--ease-spring); }
.nav-item:active .ic { transform: scale(.85); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-right form { margin: 0; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-full);
  background: var(--panel-2);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.chip small { font-weight: 400; color: var(--muted); }
.chip-ghost { background: transparent; border: 1px solid var(--border); }

.balance { color: var(--text); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  border-radius: var(--r-full);
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: color .2s, background .2s;
}
.icon-btn:hover { color: var(--text); background: var(--accent-soft); }

/* ---------- layout ---------- */

main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px 24px 40px;
}

h1 { font-size: 30px; font-weight: 500; letter-spacing: -.3px; margin: 8px 0 4px; }

.panel {
  background: var(--panel);
  border: none;
  border-radius: var(--r-l);
  padding: 22px;
  transition: background .3s var(--ease);
}

.panel h2 {
  font-size: 18px;
  font-weight: 500;
  margin: 0 0 4px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 16px;
}

.upgrader-grid {
  display: grid;
  grid-template-columns: 1fr 320px 1fr;
  gap: 16px;
  align-items: start;
}

/* ---------- item cards ---------- */

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 10px;
  min-height: 100px;
}

.item-card {
  position: relative;
  background: var(--panel-2);
  border: 2px solid transparent;
  border-radius: var(--r-m);
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .2s var(--ease), transform .35s var(--ease-spring), background .2s, border-radius .35s var(--ease);
}
.item-card:hover { background: var(--surface-4); transform: translateY(-3px); }
.item-card:active { transform: scale(.96); }
.item-card.selected {
  border-color: var(--text);
  border-radius: var(--r-l);
  background: var(--surface-4);
}

.showcase-star {
  position: absolute;
  top: 4px;
  right: 4px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  z-index: 1;
  transition: color .15s, transform .3s var(--ease-spring);
}
.showcase-star:hover { transform: scale(1.25); }
.showcase-star.active { color: var(--text); }

.item-card img {
  width: 100%;
  height: 72px;
  object-fit: contain;
  margin-bottom: 8px;
  transition: transform .4s var(--ease-spring);
}
.item-card:hover img { transform: scale(1.06) rotate(-2deg); }

.item-name {
  font-size: 12px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.value-total {
  margin-top: 14px;
  font-size: 14px;
  color: var(--muted);
}
.value-total span { color: var(--text); font-weight: 700; }

/* ---------- gauge ---------- */

.gauge-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 22px;
  background: var(--panel);
  border-radius: var(--r-l);
}

.gauge {
  position: relative;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gauge-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--text) 0deg, var(--text) calc(var(--chance-deg, 0) * 1deg), var(--panel-2) calc(var(--chance-deg, 0) * 1deg), var(--panel-2) 360deg);
  mask: radial-gradient(farthest-side, transparent calc(100% - 16px), #000 calc(100% - 15px));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 16px), #000 calc(100% - 15px));
  transition: --chance-deg .5s var(--ease);
}

.gauge-arrow {
  position: absolute;
  width: 4px;
  height: 94px;
  background: var(--text);
  top: 16px;
  left: calc(50% - 2px);
  transform-origin: bottom center;
  transform: rotate(0deg);
  transition: transform 3.2s cubic-bezier(.12,.82,.13,1);
  border-radius: 2px;
}

.gauge-center {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--panel-2);
  font-size: 30px;
  color: var(--text);
  z-index: 2;
}

.chance-label {
  font-size: 34px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ---------- buttons ---------- */

.btn-primary {
  position: relative;
  overflow: hidden;
  background: var(--text);
  color: var(--on-accent);
  border: none;
  font: inherit;
  font-weight: 600;
  border-radius: var(--r-full);
  padding: 12px 28px;
  cursor: pointer;
  font-size: 15px;
  transition: transform .3s var(--ease-spring), border-radius .3s var(--ease), opacity .2s, box-shadow .2s;
}
.btn-primary:hover:not(:disabled) { box-shadow: var(--shadow); }
.btn-primary:active:not(:disabled) { transform: scale(.95); border-radius: var(--r-s); }
.btn-primary:disabled { opacity: .38; cursor: not-allowed; }
.btn-upgrade { width: 100%; padding: 16px 28px; font-size: 17px; }

.btn-small {
  position: relative;
  overflow: hidden;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--r-full);
  padding: 7px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  transition: transform .3s var(--ease-spring), background .2s, border-color .2s, color .2s;
}
.btn-small:hover { background: var(--accent-soft); border-color: var(--text); }
.btn-small:active { transform: scale(.93); }
.btn-small:disabled { opacity: .4; }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); background: transparent; }
.badge-official { color: var(--success); font-size: 12px; }

/* ripple (added by ui.js) */
.ripple {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: currentColor;
  opacity: .22;
  transform: scale(0);
  animation: ripple .55s var(--ease) forwards;
}
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

.result-banner {
  width: 100%;
  text-align: center;
  padding: 12px;
  border-radius: var(--r-m);
  font-weight: 600;
  animation: pop-in .45s var(--ease-spring);
}
.result-banner.win { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.result-banner.lose { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.hidden { display: none; }
.case-reel-modal.hidden, .charm-equip-modal.hidden, .link-banner.hidden { display: none; }

@keyframes pop-in { from { opacity: 0; transform: scale(.85); } }

/* ---------- forms ---------- */

input, select, textarea { font: inherit; }

.auth-card input,
.inline-form input,
.inline-form select,
.admin-row input,
.admin-row select {
  background: var(--panel-2);
  border: 1px solid transparent;
  color: var(--text);
  border-radius: var(--r-s);
  padding: 10px 14px;
  outline: none;
  transition: border-color .2s, background .2s, border-radius .3s var(--ease);
}
.auth-card input:focus,
.inline-form input:focus,
.inline-form select:focus,
.admin-row input:focus,
.admin-row select:focus { border-color: var(--text); background: var(--surface-4); }
input[type="color"] { padding: 3px !important; width: 44px; height: 40px; cursor: pointer; }
input[type="range"] { accent-color: var(--text); }

.field-label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }

/* auth pages */
.auth-wrap {
  display: flex;
  justify-content: center;
  padding-top: 8vh;
}
.auth-card {
  background: var(--panel);
  border-radius: var(--r-l);
  padding: 32px 28px;
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: pop-in .5s var(--ease-spring);
}
.auth-logo { color: var(--text); font-weight: 800; text-align: center; margin-bottom: 6px; letter-spacing: .5px; }
.auth-card h1 { font-size: 26px; margin: 0 0 10px; text-align: center; }
.auth-card label { font-size: 13px; color: var(--muted); margin-top: 4px; }
.auth-card .btn-primary { margin-top: 10px; }
.auth-error { color: var(--danger); font-size: 13px; }
.auth-success { color: var(--success); font-size: 13px; }
.auth-switch { text-align: center; font-size: 13px; color: var(--muted); margin-top: 8px; }
.auth-switch a { text-decoration: underline; }

/* ---------- admin ---------- */

.admin-wrap { display: flex; flex-direction: column; gap: 16px; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.admin-list { display: flex; flex-direction: column; gap: 6px; }
.admin-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-2);
  border-radius: var(--r-m);
  padding: 8px 12px;
  transition: background .2s;
}
.admin-row:hover { background: var(--surface-4); }
.admin-row img { width: 38px; height: 38px; object-fit: contain; border-radius: var(--r-xs); }
.admin-row input, .admin-row select { background: var(--panel); padding: 7px 10px; }
.admin-row .name-input { flex: 1; }
.admin-row .price-input { width: 90px; }
.admin-row .url-input { flex: 1; }

/* custom text animation editor */
.anim-stage {
  height: 170px;
  margin-bottom: 14px;
  border-radius: var(--r-m);
  background:
    radial-gradient(circle at 50% 50%, var(--surface-4), var(--panel-2) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.anim-preview-text {
  display: inline-block;
  font-size: 38px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text);
}
.anim-frames {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.anim-frame {
  background: var(--panel-2);
  border-radius: var(--r-m);
  padding: 12px 14px;
  animation: pop-in .35s var(--ease-spring);
}
.anim-frame-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 14px; }
.anim-frame-head .btn-small { padding: 3px 9px; }
.anim-field {
  display: grid;
  grid-template-columns: 78px 1fr 42px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.anim-field output { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- chat ---------- */

.chat-wrap { display: flex; flex-direction: column; gap: 16px; }
.chat-panel { display: flex; flex-direction: column; }
.chat-messages {
  height: 380px;
  overflow-y: auto;
  background: var(--panel-2);
  border-radius: var(--r-m);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}
.chat-message { line-height: 1.45; word-break: break-word; animation: rise-in .3s var(--ease) both; }
.chat-username { color: var(--text); font-weight: 700; }
.chat-system { color: var(--success); font-style: italic; }

/* ---------- case reel ---------- */

.case-reel-modal {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  animation: fade-in .25s var(--ease);
}
.case-reel-viewport {
  position: relative;
  width: min(700px, 92vw);
  height: 140px;
  overflow: hidden;
  background: var(--panel);
  border-radius: var(--r-l);
  animation: pop-in .4s var(--ease-spring);
}
.case-reel-pointer {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--text);
  transform: translateX(-50%);
  z-index: 2;
  border-radius: 2px;
}
.case-reel-strip {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  display: flex;
  align-items: center;
  will-change: transform;
}
.case-reel-item {
  width: 110px;
  height: 110px;
  margin: 0 6px;
  flex-shrink: 0;
  background: var(--panel-2);
  border-radius: var(--r-m);
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}
.case-reel-item img { max-width: 100%; max-height: 70px; object-fit: contain; }
.case-reel-item.winning-item { border-color: var(--text); }

@keyframes fade-in { from { opacity: 0; } }

/* ---------- link banner ---------- */

.link-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--text);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
}
.link-banner a { color: var(--on-accent); text-decoration: underline; }
.link-banner #link-banner-countdown { font-weight: 400; opacity: .75; }
.link-banner button {
  background: none;
  border: none;
  color: var(--on-accent);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 0 0 6px;
  margin-left: auto;
}

/* ---------- quality / charms ---------- */

.quality-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 3px 8px;
  border-radius: var(--r-full);
  margin-top: 6px;
}

.item-charm-badge {
  position: absolute;
  bottom: 60px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--panel);
  border: 2px solid var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
}
.item-charm-badge img { width: 100%; height: 100%; object-fit: contain; }
.item-charm-badge .charm-emoji { font-size: 13px; line-height: 1; }

.charm-slot-btn {
  margin-top: 8px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-full);
  padding: 6px 8px;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, color .15s, transform .3s var(--ease-spring);
}
.charm-slot-btn:hover { border-color: var(--text); color: var(--text); }
.charm-slot-btn:active { transform: scale(.94); }
.charm-slot-btn.equipped { border-style: solid; color: var(--text); }
.charm-slot-btn .charm-slot-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: contain;
  flex-shrink: 0;
}
.charm-slot-btn .charm-slot-remove { margin-left: auto; color: var(--danger); font-weight: 700; }

/* bottom-sheet style modal */
.charm-equip-modal {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
  animation: fade-in .25s var(--ease);
}
.charm-equip-panel {
  width: min(640px, 100%);
  max-height: 82vh;
  background: var(--panel);
  border-radius: var(--r-l);
  padding: 20px;
  overflow-y: auto;
  animation: sheet-up .4s var(--ease);
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.charm-equip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 18px;
  font-weight: 500;
}
.charm-equip-close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--panel-2);
  border: none;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: transform .3s var(--ease-spring), background .2s;
}
.charm-equip-close:hover { transform: rotate(90deg); background: var(--surface-4); }
.charm-equip-grid .item-card.charm-equip-current { border-color: var(--text); }

/* ---------- quality win overlay ---------- */

.quality-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 200;
  opacity: 0;
}
.quality-overlay.active { opacity: 1; }

.quality-overlay-text {
  font-size: 46px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 0 0 24px currentColor;
}

.quality-overlay.anim-fly-in .quality-overlay-text { animation: quality-fly-in 1.6s ease-out forwards; }
@keyframes quality-fly-in {
  0% { transform: translateY(-160px) scale(.6); opacity: 0; }
  30% { transform: translateY(0) scale(1.1); opacity: 1; }
  45% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(20px) scale(1); }
}

.quality-overlay.anim-shake .quality-overlay-text { animation: quality-shake 1.4s ease-in-out forwards; }
@keyframes quality-shake {
  0% { opacity: 0; transform: scale(.9); }
  10% { opacity: 1; transform: scale(1.05); }
  15%, 25%, 35%, 45% { transform: translateX(-10px) scale(1.05); }
  20%, 30%, 40%, 50% { transform: translateX(10px) scale(1.05); }
  55% { transform: translateX(0) scale(1); }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

.quality-overlay.anim-glow-pulse .quality-overlay-text { animation: quality-glow 1.6s ease-in-out forwards; }
@keyframes quality-glow {
  0% { opacity: 0; text-shadow: 0 0 4px currentColor; transform: scale(.95); }
  20% { opacity: 1; }
  50% { text-shadow: 0 0 40px currentColor; transform: scale(1.05); }
  80% { opacity: 1; text-shadow: 0 0 10px currentColor; }
  100% { opacity: 0; transform: scale(1); }
}

.quality-overlay.anim-confetti .confetti-piece {
  position: absolute;
  top: -20px;
  width: 8px;
  height: 14px;
  opacity: 0;
  border-radius: 2px;
  animation: confetti-fall 1.8s ease-in forwards;
}
@keyframes confetti-fall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg); }
  100% { opacity: 0; transform: translateY(70vh) rotate(360deg); }
}
.quality-overlay.anim-confetti .quality-overlay-text { animation: quality-fly-in 1.6s ease-out forwards; }

/* ---------- котость ---------- */

.kotost-wrap { display: flex; flex-direction: column; gap: 16px; max-width: 760px; margin: 0 auto; }
.kotost-hero { display: flex; align-items: center; gap: 24px; }
.kotost-stage {
  position: relative;
  flex-shrink: 0;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--surface-4), var(--panel-2) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.kotost-art {
  width: 130px;
  height: 130px;
  transform: scale(var(--grow, .8));
  transition: transform .6s var(--ease-spring);
}
.kotost-body { fill: var(--text); animation: breathe 3.2s ease-in-out infinite; transform-origin: 60px 100px; }
.kotost-body .eye { fill: var(--panel); animation: blink 4.5s infinite; transform-box: fill-box; transform-origin: center; }
.kotost-body .mouth { fill: none; stroke: var(--panel); stroke-width: 3; stroke-linecap: round; }
@keyframes breathe { 50% { transform: scaleY(1.035) scaleX(.985); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
.kotost-art.bounce { animation: pet-bounce .6s var(--ease-spring); }
@keyframes pet-bounce { 30% { transform: scale(calc(var(--grow, .8) * 1.15)) rotate(-4deg); } 60% { transform: scale(calc(var(--grow, .8) * .95)) rotate(3deg); } }
.kotost-hero.hungry .kotost-body .mouth { d: path("M54 88 Q60 82 66 88"); }
.kotost-hero.hungry .kotost-body { animation: breathe 1.4s ease-in-out infinite; }
.kotost-hero.dead .kotost-body { fill: var(--border-strong); animation: none; }
.kotost-hero.dead .kotost-body .eye { animation: none; transform: scaleY(.15); }
.kotost-level {
  position: absolute;
  right: 6px;
  bottom: 10px;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border-radius: var(--r-full);
  background: var(--text);
  color: var(--on-accent);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 4px var(--panel);
}
.kotost-info { flex: 1; min-width: 0; }
.kotost-info h1 { margin: 0 0 2px; word-break: break-word; }
.kotost-info .hint { margin-bottom: 12px; }
.satiety { height: 10px; border-radius: var(--r-full); background: var(--panel-2); overflow: hidden; margin-bottom: 12px; }
.satiety-fill { height: 100%; width: 0; border-radius: inherit; background: var(--text); transition: width .8s var(--ease); }
.kotost-hero.hungry .satiety-fill { background: var(--danger); }
.kotost-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.kotost-chips .chip { height: 30px; font-size: 12px; font-weight: 500; }
.kotost-buttons { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.kotost-buttons .btn-primary { flex: 1; min-width: 140px; white-space: nowrap; }
.kotost-wrap .hidden { display: none; }
.kotost-buy { display: flex; gap: 8px; align-items: center; }
.kotost-buy input {
  width: 72px;
  background: var(--panel-2);
  border: 1px solid transparent;
  color: var(--text);
  border-radius: var(--r-s);
  padding: 9px 10px;
}
#kotost-message { margin-top: 12px; }
.tg-box { display: flex; flex-direction: column; gap: 10px; }
.tg-code {
  font: 700 28px/1 ui-monospace, "SF Mono", Consolas, monospace;
  letter-spacing: 4px;
  text-align: center;
  padding: 14px;
  border-radius: var(--r-m);
  background: var(--panel-2);
  user-select: all;
}

@media (max-width: 899px) {
  .kotost-hero { flex-direction: column; text-align: center; gap: 14px; }
  .kotost-chips { justify-content: center; }
  .kotost-buy { width: 100%; }
  .kotost-buy .btn-small { flex: 1; }
}

.settings-wrap { flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.icon-btn.active { color: var(--on-accent); background: var(--text); }
.kc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin: 10px 0 14px; }
.kc-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.kc-grid input {
  background: var(--panel-2); border: 1px solid transparent; color: var(--text);
  border-radius: var(--r-s); padding: 10px 14px; font: inherit;
}
.kc-grid select { background: var(--panel-2); border: 1px solid transparent; color: var(--text); border-radius: var(--r-s); padding: 10px 14px; font: inherit; }
.kc-case { display: flex; align-items: center; gap: 10px; }
.kc-case input[type="number"] { width: 80px; }
.bot-status { display: inline-flex; align-items: center; gap: 6px; }
.bot-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); }
.bot-dot.on { background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 22%, transparent); }

/* ---------- QR ---------- */

.qr-grant select, .qr-grant input, #qr-scan-box select, #qr-scan-box input {
  background: var(--panel-2); border: 1px solid transparent; color: var(--text);
  border-radius: var(--r-s); padding: 10px 14px; font: inherit;
}
.qr-grant h1 { word-break: break-word; }
.auth-card.hidden, .qr-video.hidden, #qr-scan-box.hidden, .qr-login-modal.hidden { display: none; }
.qr-img {
  display: block;
  width: min(240px, 100%);
  aspect-ratio: 1;
  margin: 4px auto;
  padding: 10px;
  background: #fff;
  border-radius: var(--r-m);
}
.qr-card { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.qr-video {
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--r-l);
  background: #000;
  display: block;
  margin: 0 auto 12px;
}
#qr-scan-box { display: flex; flex-direction: column; gap: 10px; max-width: 420px; margin: 0 auto; }
.auth-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 6px 0 2px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: transparent; color: var(--text); border: 1px solid var(--border-strong);
}
.btn-google svg { width: 18px; height: 18px; }
.qr-login-modal {
  position: fixed; inset: 0; z-index: 300; background: var(--scrim); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade-in .25s var(--ease);
}
.qr-login-panel {
  background: var(--panel); border-radius: var(--r-l); padding: 24px; width: min(360px, 100%);
  text-align: center; animation: pop-in .4s var(--ease-spring);
}
.qr-login-panel ol { text-align: left; color: var(--muted); font-size: 13px; padding-left: 20px; margin: 10px 0; }

/* ---------- daily bonus / referral ---------- */

.daily-card, .ga-card { margin-bottom: 16px; }
.daily-card.hidden, .ga-card.hidden, .ga-card .btn-primary.hidden { display: none; }
.ga-card { background: linear-gradient(135deg, var(--panel), var(--surface-4)); }
.ga-card .daily-head { margin-bottom: 0; }
.ga-prize { margin: 4px 0; font-size: 18px; font-weight: 700; word-break: break-word; }
.daily-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.daily-head .btn-primary { white-space: nowrap; }
.daily-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.daily-day {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 4px; border-radius: var(--r-m); background: var(--panel-2);
  font-size: 11px; color: var(--muted); transition: background .3s, color .3s, transform .3s var(--ease-spring);
}
.daily-day b { font-size: 15px; color: var(--text); }
.daily-day small { display: block; font-size: 9px; font-weight: 500; }
.daily-day.done { background: var(--text); color: var(--on-accent); }
.daily-day.done b { color: var(--on-accent); }
.daily-day.next { box-shadow: inset 0 0 0 2px var(--text); animation: day-pulse 1.6s ease-in-out infinite; }
@keyframes day-pulse { 50% { transform: scale(1.06); } }
.balance.bump { animation: pop-in .5s var(--ease-spring); }
.ref-link {
  display: flex; gap: 8px; width: 100%;
}
.ref-link input {
  flex: 1; min-width: 0; background: var(--panel-2); border: 1px solid transparent; color: var(--text);
  border-radius: var(--r-s); padding: 10px 12px; font: inherit; font-size: 13px;
}
.ref-stats { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
@media (max-width: 899px) {
  .daily-days { gap: 4px; }
  .daily-day { padding: 8px 2px; font-size: 9px; }
  .daily-day b { font-size: 13px; }
}

/* ---------- биржа ---------- */

.stocks-wrap { display: flex; flex-direction: column; gap: 12px; max-width: 900px; margin: 0 auto; }
.stock-summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.stock-summary-nums { display: flex; gap: 22px; }
.stock-summary-nums div { display: flex; flex-direction: column; }
.stock-summary-nums .hint { margin: 0; font-size: 12px; }
.stock-summary-nums b { font-size: 20px; font-variant-numeric: tabular-nums; }
.stock-list { display: flex; flex-direction: column; gap: 8px; }
.stock-card {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 12px 16px; border: none; border-radius: var(--r-l); background: var(--panel);
  color: var(--text); font: inherit; text-align: left; cursor: pointer;
  position: relative; overflow: hidden;
  transition: background .2s, transform .3s var(--ease-spring);
}
.stock-card:hover { background: var(--panel-2); }
.stock-card:active { transform: scale(.98); }
.stock-card img, #stk-portfolio img { width: 48px; height: 48px; border-radius: var(--r-s); object-fit: cover; background: var(--panel-2); flex-shrink: 0; }
.stock-card-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.stock-card-mid b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stock-card-mid .hint { margin: 0; font-size: 12px; }
.stock-card-right { display: flex; flex-direction: column; align-items: flex-end; min-width: 84px; font-variant-numeric: tabular-nums; }
.stock-chg { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.stock-chg.up { color: var(--success); }
.stock-chg.down { color: var(--danger); }
.stock-spark { width: 110px; height: 36px; flex-shrink: 0; }
.stock-spark path, .stock-chart .ln { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.stock-spark.up path, .stock-chart.up .ln { stroke: var(--success); }
.stock-spark.down path, .stock-chart.down .ln { stroke: var(--danger); }
.stock-chart { width: 100%; height: 200px; display: block; border-radius: var(--r-m); background: var(--panel-2); }
.stock-chart .area { stroke: none; opacity: .14; }
.stock-chart.up .area { fill: var(--success); }
.stock-chart.down .area { fill: var(--danger); }
.stock-sheet { max-width: 560px; }
.stock-head { display: flex; align-items: center; gap: 12px; }
.stock-head img { width: 44px; height: 44px; border-radius: var(--r-s); object-fit: cover; }
.stock-price-row { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.stock-price-row b { font-size: 32px; font-weight: 500; font-variant-numeric: tabular-nums; }
.stock-ranges { display: flex; gap: 6px; margin-bottom: 10px; }
.stock-ranges .btn-small.active { background: var(--text); color: var(--on-accent); border-color: var(--text); }
.stock-trade { display: flex; flex-direction: column; gap: 10px; }
.stock-qty { display: flex; gap: 6px; align-items: center; justify-content: center; }
.stock-qty input {
  width: 90px; text-align: center; background: var(--panel-2); border: 1px solid transparent;
  color: var(--text); border-radius: var(--r-s); padding: 9px; font: inherit; font-weight: 600;
}
.stock-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stock-buy { background: var(--success); color: #0b1f12; }
.stock-sell { background: var(--danger); color: #fff; }
#stk-portfolio-panel.hidden, #stk-sheet.hidden { display: none; }
@media (max-width: 899px) {
  .stock-card { padding: 10px 12px; gap: 10px; }
  .stock-spark { width: 64px; }
  .stock-summary-nums { gap: 14px; width: 100%; justify-content: space-between; }
  .stock-summary-nums b { font-size: 17px; }
}

/* ---------- заработать монеты ---------- */

/* the top bar must never be wider than the screen, whatever the balance */
.topbar { min-width: 0; max-width: 100vw; }
.topbar-right { min-width: 0; flex-shrink: 1; }
.logo { flex-shrink: 0; }
button.balance { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; justify-content: flex-start; }
button.balance .balance-plus { flex-shrink: 0; }
html { overflow-x: clip; }  /* clip, not hidden: hidden on html+body breaks the sticky top bar */
button.balance { border: none; font: inherit; font-weight: 600; cursor: pointer; color: var(--text); transition: background .2s, transform .3s var(--ease-spring); }
button.balance:hover { background: var(--surface-4); }
button.balance:active { transform: scale(.95); }
.balance-plus {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; margin-left: 4px; border-radius: 50%;
  background: var(--text); color: var(--on-accent); font-size: 13px; font-weight: 800; line-height: 1;
}
.earn-modal {
  position: fixed; inset: 0; z-index: 400; background: var(--scrim); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade-in .25s var(--ease);
}
.earn-modal.hidden { display: none; }
.earn-panel {
  width: min(560px, 100%); max-height: 86vh; overflow-y: auto; background: var(--panel);
  border-radius: var(--r-l); padding: 20px; animation: sheet-up .4s var(--ease);
}
.earn-task { background: var(--panel-2); border-radius: var(--r-m); padding: 14px; margin-bottom: 10px; }
.earn-task-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.earn-form { display: flex; flex-direction: column; gap: 8px; }
.earn-form input[type="text"] {
  background: var(--panel); border: 1px solid transparent; color: var(--text);
  border-radius: var(--r-s); padding: 10px 12px; font: inherit;
}
.earn-drop {
  display: flex; align-items: center; justify-content: center; padding: 14px;
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-m); cursor: pointer; color: var(--muted);
  transition: border-color .2s, color .2s;
}
.earn-drop:hover { border-color: var(--text); color: var(--text); }
.earn-previews { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.earn-previews:empty { display: none; }
.earn-previews img, .proof-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-xs); }
.earn-msg:empty { display: none; }
.earn-sub-title { font-size: 15px; font-weight: 500; margin: 16px 0 8px; }
.proof-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; margin: 8px 0; }
.proof-grid a { display: block; }
.earn-review { flex-direction: column; align-items: stretch; }
@media (max-width: 899px) {
  .earn-modal { align-items: flex-end; padding: 0; }
  .earn-panel { border-radius: var(--r-l) var(--r-l) 0 0; max-height: 90vh; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .balance-plus { width: 16px; height: 16px; font-size: 12px; }
}

.security-card { width: min(460px, 100%); }
.anon-toggle { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: var(--r-m); background: var(--panel-2); cursor: pointer; }
.anon-toggle input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--text); flex-shrink: 0; }
.security-card .admin-row { align-items: flex-start; }
.wait-icon { font-size: 44px; text-align: center; animation: pop-in .5s var(--ease-spring); }
.approve-panel { max-width: 400px; text-align: center; }

/* ---------- батлы ---------- */

.battle-create { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.battle-create select {
  flex: 1; min-width: 200px; background: var(--panel-2); border: 1px solid transparent; color: var(--text);
  border-radius: var(--r-s); padding: 10px 14px; font: inherit;
}
.battle-list { display: flex; flex-direction: column; gap: 8px; }
.battle-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-m); background: var(--panel-2); flex-wrap: wrap; }
.battle-row img { width: 46px; height: 46px; object-fit: contain; border-radius: var(--r-xs); }
.battle-arena { max-width: 640px; text-align: center; }
.battle-arena-head { font-size: 18px; font-weight: 600; margin-bottom: 14px; }
.battle-sides { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.battle-vs { font-weight: 900; font-size: 22px; color: var(--muted); }
.battle-side { background: var(--panel-2); border-radius: var(--r-l); padding: 14px 10px; border: 2px solid transparent; transition: border-color .3s, transform .4s var(--ease-spring), opacity .3s; }
.ba-name { font-weight: 700; margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ba-reel { height: 150px; display: flex; align-items: center; justify-content: center; }
.ba-reel img { max-width: 100%; max-height: 150px; object-fit: contain; }
.ba-drop { min-height: 44px; display: flex; flex-direction: column; font-size: 13px; }
.ba-drop span { color: var(--muted); }
.battle-side.landed .ba-reel img { animation: pop-in .4s var(--ease-spring); }
.battle-side.winner { border-color: var(--success); transform: scale(1.04); box-shadow: 0 0 30px color-mix(in srgb, var(--success) 35%, transparent); }
.battle-side.loser { opacity: .5; }
.battle-result { margin-top: 14px; font-size: 18px; min-height: 26px; }

/* ---------- сезон ---------- */

.season-card { margin-bottom: 16px; }
.season-card.hidden { display: none; }
.season-name { font-size: 22px; font-weight: 800; margin: 2px 0; }
.season-top { display: none; margin-top: 12px; }
.season-card.open .season-top { display: flex; }

/* ---------- аккаунты ---------- */

.acc-panel { max-width: 400px; }
.acc-list { display: flex; flex-direction: column; gap: 4px; }
.acc-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px;
  border: none; border-radius: var(--r-m); background: transparent; color: var(--text);
  font: inherit; text-align: left; cursor: pointer; transition: background .2s;
}
.acc-row:hover { background: var(--panel-2); }
.acc-row.current { background: var(--panel-2); }
.acc-row.loading { opacity: .5; }
.acc-avatar {
  width: 42px; height: 42px; flex-shrink: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-4); color: #fff; font-weight: 800; font-size: 18px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .4);
}
.acc-name { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.acc-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-name .hint { margin: 0; font-size: 12px; }
.acc-check { font-weight: 800; }
.acc-add { margin-top: 4px; }
.acc-add.hidden { display: none; }
.acc-add .acc-avatar { background: transparent; border: 1.5px dashed var(--border-strong); color: var(--muted); text-shadow: none; }
/* long-press on the dock shouldn't pop the browser's link menu or select text */
.nav-item, .dock-thumb { -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }

.toast {
  position: fixed;
  left: 50%;
  top: 76px;
  translate: -50% 0;
  z-index: 400;
  max-width: calc(100vw - 32px);
  padding: 14px 22px;
  border-radius: var(--r-full);
  font-weight: 600;
  box-shadow: var(--shadow);
  background: var(--text);
  color: var(--on-accent);
  animation: toast-in .5s var(--ease-spring);
  transition: opacity .4s, translate .4s var(--ease);
}
.toast.lose { background: var(--panel-2); color: var(--text); }
.toast.out { opacity: 0; translate: -50% -20px; }
@keyframes toast-in { from { translate: -50% -30px; opacity: 0; } }

.site-footer {
  margin-top: 28px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  animation: none !important;
}
.site-footer a { color: var(--muted); text-decoration: underline; }

/* ---------- scrollbar ---------- */

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ---------- desktop: menu stays in the top bar ---------- */

@media (min-width: 900px) and (max-width: 1100px) {
  .nav-label { display: none; }
  .nav-item { padding: 9px 12px; }
}

/* ---------- mobile: floating round dock ---------- */

@media (max-width: 899px) {
  .topbar {
    padding: 10px 14px;
    padding-top: max(10px, env(safe-area-inset-top));
    gap: 8px;
    /* backdrop-filter here would make the fixed dock position relative to the bar */
    background: var(--bg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .logo { font-size: clamp(14px, 4.4vw, 18px); margin-right: auto; }
  .topbar-right { gap: 6px; }
  .topbar-right .username { display: none; }
  .chip { height: 34px; padding: 0 12px; font-size: 13px; }

  .nav-rail {
    position: fixed;
    left: 50%;
    bottom: max(12px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 60;
    width: min(460px, calc(100vw - 24px));
    height: var(--dock-h);
    margin: 0;
    padding: 8px;
    justify-content: space-around;
    gap: 0;
    border-radius: var(--r-full);
    background: color-mix(in srgb, var(--panel) 88%, transparent);
    backdrop-filter: blur(22px) saturate(1.3);
    -webkit-backdrop-filter: blur(22px) saturate(1.3);
    box-shadow: var(--shadow), inset 0 0 0 1px var(--border);
    view-transition-name: dock;
    animation: dock-in .6s var(--ease-spring) both;
  }
  @keyframes dock-in { from { transform: translate(-50%, 120%); } }

  .nav-item {
    flex: 1;
    flex-direction: column;
    gap: 3px;
    padding: 4px 0;
    font-size: 11px;
    border-radius: var(--r-full);
    background: none !important;
    color: var(--muted);
    overflow: visible;
  }
  .nav-item:hover { color: var(--text); }
  .nav-pill {
    width: 56px;
    height: 32px;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-full);
    transition: background .35s var(--ease), width .35s var(--ease);
  }
  .nav-item.active { color: var(--text); font-weight: 700; }
  .nav-item .ic { width: 22px; height: 22px; }

  /* draggable thumb (ui.js): sits under the icons, the icon above it turns inverse */
  .dock-thumb {
    display: block;
    position: absolute;
    left: 0;
    top: 12px;
    width: 56px;
    height: 32px;
    z-index: 0;
    border-radius: var(--r-full);
    background: var(--text);
    touch-action: none;
    cursor: grab;
    transition: box-shadow .2s, scale .25s var(--ease-spring);
  }
  .dock-thumb:not(.placed) { opacity: 0; }
  /* arrived here through the dock: it stays put instead of sliding in again */
  .dock-nav .nav-rail { animation: none; }
  .dock-thumb.gliding { transition: translate .38s var(--ease-spring), box-shadow .2s, scale .25s var(--ease-spring); }
  .dock-thumb.grabbed {
    cursor: grabbing;
    scale: 1.12;
    box-shadow: 0 0 0 6px var(--accent-soft), var(--shadow);
  }
  .nav-item { z-index: 1; }
  .nav-item .nav-pill { transition: color .2s; }
  .nav-item.under-thumb .nav-pill { color: var(--on-accent); }
  .nav-item.under-thumb .ic { transform: scale(1.08); }
  /* let a press on the thumb reach it instead of the icon drawn above */
  .nav-item.under-thumb { pointer-events: none; }
  .nav-rail.leaving .dock-thumb { scale: .9; }
  .nav-label { white-space: nowrap; }

  body.has-nav main { padding-bottom: calc(var(--dock-h) + 36px + env(safe-area-inset-bottom)); }

  main { padding: 10px 12px 24px; }
  h1 { font-size: 26px; }
  .upgrader-grid { grid-template-columns: 1fr; gap: 12px; }
  .gauge-panel { order: -1; }
  .items-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .item-card img { height: 60px; }
  .panel, .gauge-panel { padding: 16px; border-radius: 24px; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form input,
  .inline-form select,
  .inline-form button { width: 100%; }
  .inline-form input[type="color"] { width: 100%; }
  .admin-row { flex-wrap: wrap; }
  .admin-row img { width: 30px; height: 30px; }
  .quality-overlay-text { font-size: 28px; }
  .anim-preview-text { font-size: 28px; }
  .link-banner { flex-wrap: wrap; text-align: center; font-size: 12px; }
  .chat-messages { height: 52vh; }
  .charm-equip-modal { align-items: flex-end; padding: 0; }
  /* main.page is its own stacking context (view transitions), so the dock stays on top
     of these sheets — leave room for it instead of letting it cover the buttons */
  .charm-equip-panel { border-radius: var(--r-l) var(--r-l) 0 0; max-height: 86vh; }
  body.has-nav .charm-equip-panel { padding-bottom: calc(var(--dock-h) + 28px + env(safe-area-inset-bottom)); }
  body.no-nav .charm-equip-panel { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .stock-btns .btn-primary { white-space: nowrap; font-size: 14px; padding: 13px 10px; }
}

/* admin + settings + logout icons next to the balance: make room on phones */
@media (max-width: 899px) {
  .topbar-right .icon-btn { width: 36px; height: 36px; }
  .topbar-right .icon-btn .ic { width: 20px; height: 20px; }
  .topbar-right { gap: 2px; }
}
@media (max-width: 420px) {
  .logo b { display: none; }
  .topbar-right .chip { padding: 0 10px; }
}

@media (max-width: 380px) {
  .nav-label { font-size: 10px; letter-spacing: -.2px; }
  .nav-pill { width: 46px; }
  .chip small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* ---------- партнёрка ---------- */

.partner-wrap { display: grid; gap: 16px; }
.partner-hero { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.partner-rates { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-top: 10px; }
.partner-rate {
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
  padding: 14px 16px; border-radius: var(--r-md, 16px); background: var(--accent-soft);
}
.partner-rate b { font-size: 26px; }
.partner-rate i { font-style: normal; font-size: 20px; color: var(--muted); margin: 0 4px; }
.partner-proof { border: 2px solid var(--text); }
.partner-phrase { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.partner-phrase code {
  font-size: 18px; font-weight: 700; padding: 8px 14px; border-radius: var(--r-full);
  background: var(--text); color: var(--bg); user-select: all; word-break: break-all;
}
.partner-videos { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 10px; }
.partner-video { display: flex; flex-direction: column; gap: 6px; }
.partner-video video { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: var(--r-xs, 8px); object-fit: contain; }
.partner-video a { text-align: center; text-decoration: none; margin-top: auto; }
.partner-form { display: grid; gap: 10px; }
.partner-link { display: block; text-decoration: none; color: inherit; border: 2px solid var(--text); }


.partner-form input:not([type="file"]), .partner-calc input {
  background: var(--panel-2); border: 1px solid transparent; color: var(--text);
  border-radius: var(--r-s); padding: 10px 14px; outline: none; transition: border-color .2s, background .2s;
}
.partner-form input:focus, .partner-calc input:focus { border-color: var(--text); background: var(--surface-4); }
.partner-calc { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.partner-calc b { font-size: 18px; }

/* seven/eight items in the mobile dock */
@media (max-width: 899px) {
  .nav-item { font-size: 10px; min-width: 0; }
  .nav-pill { width: min(56px, calc((100vw - 40px) / 8 - 2px)); }
  .nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
}

/* ---------- ИИ-админ ---------- */

.helper-wrap { display: grid; gap: 16px; }
.helper-head { display: flex; gap: 14px; align-items: center; }
.helper-ava {
  width: 56px; height: 56px; flex: none; display: grid; place-items: center; font-size: 30px;
  border-radius: var(--r-full); background: var(--text);
}
.helper-chat { display: flex; flex-direction: column; }
.helper-log {
  display: flex; flex-direction: column; gap: 10px; overflow-y: auto;
  height: min(60vh, 560px); padding: 4px 2px 10px;
}
.helper-msg { display: flex; flex-direction: column; gap: 4px; max-width: 82%; }
.helper-msg.me { align-self: flex-end; align-items: flex-end; }
.helper-msg.bot { align-self: flex-start; }
.helper-bubble {
  padding: 10px 14px; border-radius: 20px; background: var(--panel-2);
  white-space: pre-wrap; word-break: break-word; line-height: 1.4;
}
.helper-msg.me .helper-bubble { background: var(--text); color: var(--bg); border-bottom-right-radius: 6px; }
.helper-msg.bot .helper-bubble { border-bottom-left-radius: 6px; }
.helper-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.helper-action {
  font-size: 12px; padding: 4px 10px; border-radius: var(--r-full);
  border: 1px solid var(--border-strong); color: var(--text);
}
.helper-typing { display: flex; gap: 4px; }
.helper-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: hp-dot 1s infinite; }
.helper-typing i:nth-child(2) { animation-delay: .15s; }
.helper-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes hp-dot { 0%, 100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
.helper-form { display: flex; gap: 8px; margin-top: 8px; }
.helper-form input {
  flex: 1; min-width: 0; background: var(--panel-2); border: 1px solid transparent; color: var(--text);
  border-radius: var(--r-full); padding: 12px 16px; outline: none;
}
.helper-form input:focus { border-color: var(--text); }
.helper-form button { border-radius: var(--r-full); white-space: nowrap; }
.helper-prompt, #helper-admin input[type="password"] {
  width: 100%; box-sizing: border-box; background: var(--panel-2); border: 1px solid transparent; color: var(--text);
  border-radius: var(--r-s); padding: 10px 14px; font: inherit; outline: none; resize: vertical;
}

@media (max-width: 899px) {
  .helper-log { height: calc(100dvh - 380px); min-height: 220px; }
  .helper-head p { font-size: 12px; }
}

/* ---------- ИИ вылезает из нижнего меню и ржёт ---------- */

.ai-pop {
  position: fixed; left: 50%; bottom: 0; z-index: 59; /* under the dock (60): it climbs out from behind it */
  transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: min(340px, calc(100vw - 32px)); pointer-events: auto; cursor: pointer;
  animation: ai-pop-up .7s var(--ease-spring, cubic-bezier(.3,1.6,.5,1)) both;
}
@media (max-width: 899px) { .ai-pop { bottom: calc(var(--dock-h, 72px) + max(12px, env(safe-area-inset-bottom)) - 18px); } }
.ai-pop.out { animation: ai-pop-down .5s ease-in both; }
@keyframes ai-pop-up { from { transform: translate(-50%, 140%); } }
@keyframes ai-pop-down { to { transform: translate(-50%, 160%); opacity: 0; } }
.ai-pop-bubble {
  background: var(--text); color: var(--bg); font-weight: 700; padding: 12px 16px; border-radius: 20px;
  box-shadow: var(--shadow); line-height: 1.35; text-align: center; position: relative;
  animation: ai-pop-bubble .4s .45s both;
}
.ai-pop-bubble::after {
  content: ""; position: absolute; bottom: -8px; left: 50%; margin-left: -8px;
  border: 8px solid transparent; border-bottom: 0; border-top-color: var(--text);
}
@keyframes ai-pop-bubble { from { transform: scale(.4); opacity: 0; } }
.ai-pop-bot {
  position: relative; width: 92px; height: 78px; border-radius: 26px 26px 14px 14px; background: #111;
  border: 3px solid #fff; box-shadow: var(--shadow); animation: ai-pop-laugh .22s .6s infinite alternate ease-in-out;
}
.ai-pop-bot::before { /* antenna */
  content: ""; position: absolute; top: -16px; left: 50%; width: 4px; height: 13px; margin-left: -2px; background: #fff;
  border-radius: 2px; box-shadow: 0 -5px 0 2px #ff3b3b;
}
.ai-pop-eyes { display: flex; justify-content: center; gap: 18px; margin-top: 18px; }
.ai-pop-eyes i { width: 16px; height: 8px; border: 3px solid #fff; border-bottom: 0; border-radius: 16px 16px 0 0; } /* ^ ^ laughing eyes */
.ai-pop-mouth {
  width: 40px; height: 18px; margin: 9px auto 0; background: #fff; border-radius: 0 0 20px 20px;
  animation: ai-pop-mouth .22s .6s infinite alternate;
}
@keyframes ai-pop-mouth { to { height: 9px; } }
@keyframes ai-pop-laugh { from { transform: rotate(-7deg) translateY(0); } to { transform: rotate(7deg) translateY(-5px); } }
.ai-pop-ha {
  position: absolute; top: -6px; right: -34px; font-weight: 900; font-size: 18px; color: var(--text);
  animation: ai-pop-ha 1s .6s infinite;
}
.ai-pop-ha2 { right: auto; left: -34px; animation-delay: 1.1s; }
@keyframes ai-pop-ha { 0% { opacity: 0; transform: translateY(10px) scale(.6); } 40% { opacity: 1; } 100% { opacity: 0; transform: translateY(-18px) scale(1.2); } }
@media (prefers-reduced-motion: reduce) { .ai-pop, .ai-pop-bot, .ai-pop-mouth, .ai-pop-ha { animation: none; } }

.charm-sell-row { display: flex; gap: 6px; margin-top: 6px; }
.charm-sell-row .btn-small { flex: 1; padding: 7px 6px; font-size: 12px; }
