/* Тёмно-янтарная тема «Пивоварки». Фиксированная (не зависит от темы Telegram):
   почти чёрный фон + янтарно-золотые надписи и акценты под цвет пива. */
:root {
  --bg: #0a0908;            /* почти чёрный, тёплый */
  --panel: #17130c;         /* очень тёмно-серый/коричневый (шапка, меню) */
  --panel-2: #201a10;       /* полоски, разделители */
  --gold: #f5b642;          /* основной янтарный */
  --gold-bright: #ffd479;   /* яркий — крупные числа */
  --gold-deep: #d98a1f;     /* насыщенный — градиенты */
  --dim: #9a8560;           /* приглушённые подписи */
  --text: #f3e7cf;          /* мягкий светлый текст */
  --danger: #e5734b;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app { height: 100%; }
.hidden { display: none !important; }
.muted { color: var(--dim); font-size: 14px; }
.center { text-align: center; }
.error { color: var(--danger); font-size: 14px; margin-top: 8px; }

/* Полноэкранные экраны (загрузка, регистрация) */
.fullscreen {
  height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; padding: 24px; text-align: center;
}
.fullscreen h1 { color: var(--gold); font-size: 22px; }
.loader { font-size: 56px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: .7; } 50% { transform: scale(1.15); opacity: 1; } }

/* Поля и кнопки */
input[type="text"] {
  width: 100%; max-width: 320px;
  padding: 14px 16px; font-size: 16px;
  border-radius: 12px;
  border: 1px solid var(--panel-2);
  background: var(--panel); color: var(--text);
  text-align: center;
}
input[type="text"]:focus { outline: none; border-color: var(--gold); }

.btn-primary {
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-deep) 100%);
  color: #201400;
  border: none; border-radius: 14px;
  padding: 16px 24px; font-size: 17px; font-weight: 800;
  cursor: pointer; width: 100%; max-width: 320px;
  box-shadow: 0 6px 18px rgba(245, 182, 66, 0.22);
  transition: transform .08s ease, opacity .2s ease;
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: .45; box-shadow: none; }

/* ---- Основной интерфейс ---- */
#main { height: 100%; display: flex; flex-direction: column; }

.topbar {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 16px; background: var(--panel);
  border-bottom: 1px solid var(--panel-2);
}
.brewery-name {
  font-weight: 700; font-size: 15px; color: var(--gold);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Три баланса в одну строку: пиво / PWR / GRAM */
.balances { display: flex; justify-content: space-between; gap: 8px; }
.bal {
  flex: 1; min-width: 0;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  background: var(--bg); border: 1px solid var(--panel-2);
  border-radius: 10px; padding: 6px 4px;
}
.bal-ic { font-size: 14px; }
.bal-ic-img { width: 18px; height: 18px; object-fit: contain; }
.bal b { font-size: 15px; font-weight: 800; color: var(--gold-bright); }
.bal-u { font-size: 11px; color: var(--dim); }

/* Кружка на экране профиля */
.prof-emoji { display: block; width: 72px; height: 72px; object-fit: contain; margin: 6px auto 4px; }

/* Область экранов */
.screen {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; align-items: center;
}

/* Экран пивоварни */
/* Чан по центру, боковые панели — АБСОЛЮТНО по краям (как в играх: кнопки прижаты
   к краям экрана и не сжимают арт). Чан центрируется независимо от того, сколько
   кнопок на панелях и есть ли они вообще. */
/* Ряд занимает ВСЮ ширину экрана (как шапка с балансами и нижнее меню) — иначе
   панели прижимались бы к невидимому узкому контейнеру и висели далеко от краёв. */
.vat-row {
  position: relative; display: flex; justify-content: center;
  width: 100%; margin-top: 6px;
}
/* Панели выровнены по ВЕРХУ чана, а не по центру его высоты. */
.side-rail {
  position: absolute; top: 4px;
  display: flex; flex-direction: column; gap: 8px; z-index: 2;
}
.side-rail-left { left: 0; align-items: flex-start; }
.side-rail-right { right: 0; align-items: flex-end; }

/* Кнопка-«пилюля»: круглая иконка + короткая подпись. Компактная — она вспомогательная,
   и не должна спорить с чаном и кнопкой «Разлить». */
.rail-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 9px 3px 3px; border-radius: 999px; cursor: pointer;
  background: linear-gradient(180deg, #2b2011 0%, #191208 100%);
  border: 1px solid var(--gold-deep);
  box-shadow: 0 2px 7px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 213, 128, .1);
  color: var(--gold-bright);
}
.rail-btn:active { transform: scale(0.95); }
.rail-ic {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 11.5px;
  background: radial-gradient(circle at 32% 26%, #6b4c15 0%, #2c1f09 100%);
  border: 1px solid #7a5717;
}
.rail-label {
  font-size: 9px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
  white-space: nowrap;
}
/* На узких экранах (iPhone SE и подобные) подписи убираем, чтобы «пилюли» не налезли
   на чан — остаются круглые иконки, как в большинстве игр. */
@media (max-width: 350px) {
  .rail-btn { padding: 4px; }
  .rail-label { display: none; }
}

.vat-wrap { margin-top: 6px; }
.vat {
  width: 131px; height: 190px;
  object-fit: contain;
  filter: drop-shadow(0 10px 26px rgba(245, 182, 66, 0.18));
  animation: bob 3.5s ease-in-out infinite;
  /* Мини-заглушка: крошечный размытый чан, виден сразу, пока грузится полный webp. */
  background: url("data:image/webp;base64,UklGRmQEAABXRUJQVlA4WAoAAAAQAAAAHQAAKwAAQUxQSPIBAAABkKxt21k7X5Latoa2bdu2O22PwLN21GuP6s5s27Ztm2vl/7/3HeRPVvYZRMQESLznl1567dXLgwPEF098X+I98VvWCWQTo+jhFZbCktALypzkbSl0XrOqGc4RGfnqWC/fdwSByDP83vYwAwWgX66uOEuulsK+iPgi9Ra8VSUJJ0lmbV5FEV986bo9QwLGqkttaAF+zqstnswgESoAVXW4lfzYQJqHmlVAASiS63+eLdLJqsKhuUDxq/rwjCua2/fmb2jhVuRsePgrNa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AuCta6o3b4PtLBNdXS0HA5VyGLiiMGntZRFVdnHkEIcwdneLG6NNxuCxHKYHiDbvsD4/eOxC2QU6P2uA3iuxbdz3urZ+xf7jAAA=") center/contain no-repeat;
}
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.batch { text-align: center; margin-top: 12px; }
.batch-label { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.batch-amount { font-size: 42px; font-weight: 800; line-height: 1.1; color: var(--gold-bright); }
.batch-amount .unit { font-size: 20px; color: var(--dim); font-weight: 600; }
.rate { color: var(--gold); font-weight: 600; margin-top: 4px; font-size: 15px; }

.cycle { width: 100%; max-width: 320px; margin-top: 18px; }
.progress { height: 10px; background: var(--panel-2); border-radius: 6px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold));
  border-radius: 6px; transition: width .5s linear;
}
.cycle-timer { text-align: center; margin-top: 8px; color: var(--dim); font-size: 14px; }

/* Кнопка «Разлить» — сразу под таймером */
.btn-collect { margin-top: 16px; }

/* Новости — блоки-карточки (клик открывает модалку с полным текстом) */
.news { width: 100%; max-width: 340px; margin-top: 22px; display: flex; flex-direction: column; gap: 8px; }
.news-card {
  background: var(--panel); border: 1px solid var(--panel-2); border-radius: 12px;
  padding: 10px 12px; cursor: pointer; text-align: left;
}
.news-card:active { transform: scale(0.99); }
.news-date { font-size: 10px; color: var(--dim); display: flex; align-items: center; gap: 6px; }
/* Непрочитанная новость: золотая рамка + бейдж «новое» */
.news-card.news-unread { border-color: var(--gold-deep); background: #1b1409; }
.news-badge {
  font-size: 9px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: #221803; background: var(--gold); border-radius: 6px; padding: 1px 5px;
}
.news-title { font-weight: 700; color: var(--gold); font-size: 14px; margin: 2px 0; }
.news-preview {
  color: var(--text); font-size: 12px; opacity: .75;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Всплывающее окно (модалка) */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, .72);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  position: relative; width: 100%; max-width: 340px; max-height: 80%;
  overflow-y: auto; background: var(--panel);
  border: 1px solid var(--panel-2); border-radius: 16px; padding: 20px 18px;
}
.modal-close {
  position: absolute; top: 10px; right: 10px;
  width: 30px; height: 30px; border: none; border-radius: 8px;
  background: var(--panel-2); color: var(--gold); font-size: 15px; cursor: pointer;
}
.modal-date { font-size: 11px; color: var(--dim); }
.modal-title { color: var(--gold); font-size: 18px; margin: 6px 24px 10px 0; }
.modal-body { color: var(--text); font-size: 14px; line-height: 1.5; white-space: pre-wrap; }

/* Задания */
.subtabs {
  display: flex; gap: 6px; width: 100%; max-width: 360px; margin-top: 14px;
  background: var(--panel); border: 1px solid var(--panel-2); border-radius: 12px; padding: 4px;
}
.subtab {
  flex: 1; background: none; border: none; color: var(--dim);
  font-size: 12px; font-weight: 600; padding: 8px 4px; border-radius: 9px; cursor: pointer;
}
.subtab.active { background: var(--panel-2); color: var(--gold); }
.tasks { width: 100%; max-width: 360px; margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.tasks-empty { text-align: center; margin-top: 24px; }
.task-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--panel); border: 1px solid var(--panel-2); border-radius: 12px; padding: 12px;
}
.task-main { min-width: 0; }
.task-title { font-weight: 700; color: var(--text); font-size: 14px; }
.task-reward { color: var(--gold); font-size: 12px; margin-top: 3px; }
.task-progress { color: var(--dim); font-size: 11px; margin-top: 3px; }
.task-side { flex: 0 0 auto; }
.task-status { color: var(--dim); font-size: 13px; }
.task-status.ok { color: #57c977; }

/* Всплывающее уведомление (тост) */
.toast {
  position: fixed; left: 50%; bottom: 78px; transform: translateX(-50%) translateY(20px);
  background: linear-gradient(180deg, var(--gold), var(--gold-deep)); color: #201400;
  font-weight: 700; font-size: 13px; padding: 10px 16px; border-radius: 12px;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  z-index: 200; max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Заглушки и профиль */
.stub { margin: auto; text-align: center; }
.stub h2 { color: var(--gold); }
.stub-emoji { font-size: 56px; margin-bottom: 10px; }
h2 { color: var(--gold); }
.profile-list { width: 100%; max-width: 340px; margin-top: 18px; list-style: none; }
.profile-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 4px; border-bottom: 1px solid var(--panel-2);
}
.profile-list li span { color: var(--dim); }
.profile-list li b { color: var(--gold-bright); }
.li-ic { width: 18px; height: 18px; object-fit: contain; vertical-align: middle; margin-right: 5px; }

/* Кошелёк TON в профиле */
.wallet-block {
  width: 100%; max-width: 340px; margin-top: 24px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.wallet-title { color: var(--gold); font-weight: 700; font-size: 15px; align-self: flex-start; }
.wallet-note { font-size: 12px; text-align: center; line-height: 1.4; }
#ton-connect-btn { min-height: 40px; }
#wallet-status { font-size: 12px; }
.deposit-row { display: flex; gap: 8px; width: 100%; margin-top: 4px; }
.deposit-row input { flex: 1; font-size: 14px; padding: 10px 12px; }
.deposit-row .btn-sm:disabled { opacity: .5; cursor: default; }
.deposit-note { font-size: 11px; text-align: left; line-height: 1.4; margin-top: 4px; }
.deposit-copy { display: flex; gap: 8px; width: 100%; }
.btn-mini {
  flex: 1; background: var(--panel-2); color: var(--gold);
  border: 1px solid var(--panel-2); border-radius: 8px;
  padding: 8px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.btn-mini:active { transform: scale(0.97); }

/* Экран рефералов */
.ref-link { display: flex; gap: 8px; width: 100%; max-width: 340px; margin-top: 16px; }
.ref-link input { flex: 1; font-size: 12px; padding: 11px 10px; text-align: left; }
.btn-sm {
  background: var(--panel-2); color: var(--gold);
  border: 1px solid var(--panel-2); border-radius: 10px;
  padding: 0 14px; font-weight: 700; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.btn-sm:active { transform: scale(0.96); }
#ref-share-btn { margin-top: 12px; }
.ref-note {
  font-size: 12px; color: var(--gold);
  background: rgba(245, 182, 66, 0.08); border: 1px solid var(--panel-2);
  border-radius: 10px; padding: 8px 10px; margin-top: 10px;
  text-align: center; max-width: 340px;
}
.ref-total { margin-top: 18px; font-size: 15px; }
.ref-total b { color: var(--gold-bright); }
.ref-levels { margin-top: 12px; }
.ref-table-title {
  align-self: flex-start; margin-top: 22px; color: var(--dim);
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
}
.ref-table { width: 100%; max-width: 360px; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.ref-table th {
  text-align: left; color: var(--dim); font-weight: 600;
  padding: 6px 4px; border-bottom: 1px solid var(--panel-2); font-size: 11px;
}
.ref-table td { padding: 8px 4px; border-bottom: 1px solid var(--panel-2); }
.ref-table td:nth-child(2), .ref-table th:nth-child(2) { color: var(--gold-bright); }
.ref-table .ok { color: #57c977; }
.ref-table .pending { color: var(--dim); font-size: 12px; }

/* Нижнее меню */
.bottom-nav {
  display: flex; background: var(--panel);
  border-top: 1px solid var(--panel-2);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-btn {
  flex: 1; min-width: 0; background: none; border: none; color: var(--dim);
  font-size: 9.5px; padding: 8px 1px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.nav-btn span { font-size: 19px; filter: grayscale(0.4); }
.nav-btn.active { color: var(--gold); }
.nav-btn.active span { filter: none; }

/* Прыжок баланса при розливе */
.bump { animation: bump .4s ease; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(1); } }

/* Плашка «нажми Start в боте» (для открывших Mini App минуя Start) */
.start-banner {
  display: flex; align-items: center; gap: 10px;
  margin: 8px 12px 0; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--gold-deep);
  border-radius: 12px;
}
.start-banner-txt { flex: 1; font-size: 13px; line-height: 1.3; color: var(--text); }
.start-banner-txt b { color: var(--gold-bright); }
.start-banner .btn-sm { flex-shrink: 0; }

/* ---- Фишки уровней на главной ---- */
.branch-chips { display: flex; gap: 8px; justify-content: center; margin-top: 4px; }
.chip {
  font-size: 12.5px; font-weight: 700; color: var(--gold);
  background: #1e160b; border: 1px solid #3a2c15; border-radius: 9px; padding: 6px 10px;
  font-variant-numeric: tabular-nums;
}
.chip small { color: var(--dim); font-weight: 600; }

/* ---- Магазин: линейка уровней ---- */
.branch-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 2px 2px; }
.branch-title { font-size: 15px; font-weight: 700; color: var(--text); }
.branch-now { font-size: 12.5px; color: var(--dim); text-align: right; }
.branch-now b { color: var(--gold); font-weight: 800; }
.shop-max { text-align: center; color: var(--gold-bright); font-weight: 700; padding: 8px; }

.ladder { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.lvl-row {
  display: flex; align-items: center; gap: 10px; border-radius: 11px; padding: 9px 11px;
  border: 1px solid var(--panel-2); background: #140f09; font-variant-numeric: tabular-nums;
}
.lr-lvl { flex: none; width: 54px; font-size: 12px; font-weight: 700; color: var(--dim); }
.lr-val { flex: 1; font-size: 14px; color: var(--text); }
.lr-right { flex: none; font-size: 12.5px; color: var(--dim); }

.lvl-row.done { opacity: .55; }
.lvl-row.done .lr-lvl, .lvl-row.done .lr-right { color: #7bd88f; }
.lvl-row.cur { opacity: .9; border-color: #3a4a2e; background: #141a0f; }

.lvl-row.active {
  padding: 12px; border: 1px solid var(--gold-deep);
  background: linear-gradient(180deg, #241a0b 0%, #191207 100%);
  box-shadow: 0 8px 20px -12px #000;
}
.lvl-row.active .lr-lvl { color: var(--gold-bright); font-weight: 800; }
.lr-grow { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.lr-line { font-size: 15px; font-weight: 700; color: var(--text); display: flex; gap: 8px; align-items: center; }
.lr-line b { color: var(--gold-bright); }
.lr-sub { font-size: 12px; color: var(--dim); }
.lr-sub b { color: var(--gold); }
.delta {
  font-size: 11px; font-weight: 800; color: #7bd88f;
  background: #132015; border: 1px solid #244a2c; border-radius: 6px; padding: 1px 6px;
}
.lvl-row.locked { opacity: .42; }
.lr-lock { flex: none; font-size: 13px; }

.buy-btn {
  border: none; border-radius: 11px; cursor: pointer; font-family: inherit;
  font-weight: 800; color: #231600; font-size: 14px; padding: 11px 15px; flex: none;
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
  box-shadow: 0 5px 13px rgba(245, 182, 66, .20); transition: transform .08s ease, filter .15s ease;
}
.buy-btn:hover { filter: brightness(1.06); }
.buy-btn:active { transform: scale(.97); }
.buy-btn.off { background: #241d12; color: #6f6244; box-shadow: none; border: 1px solid var(--panel-2); cursor: default; }
