/* Кирпичный Магнат: Тап-Империя — mobile-first, тёмная кирпичная тема */
:root {
  --bg: #1a1412;
  --panel: #2a201c;
  --panel2: #342821;
  --brick: #c2562e;
  --brick-light: #e07b4f;
  --gold: #f5b942;
  --green: #6fcf67;
  --text: #f5ece4;
  --dim: #b5a195;
  --danger: #e06c5a;
}

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

html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
}

/* ——— Шапка ——— */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
}

.accounts { display: flex; gap: 8px; flex: 1; min-width: 0; }

.account {
  background: var(--panel);
  border-radius: 12px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.acc-label { font-size: 11px; color: var(--dim); font-weight: 700; letter-spacing: 0.5px; }
.acc-value { font-size: 17px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account.rs .acc-value { color: var(--gold); }
.account.ls .acc-value { color: var(--green); }

.header-buttons { display: flex; gap: 6px; }
.header-buttons button {
  background: var(--panel);
  border: none;
  color: var(--text);
  font-size: 18px;
  border-radius: 12px;
  width: 44px;
  height: 44px;
}

/* ——— Кирилл и баббл ——— */
#kirill-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 14px 6px;
  min-height: 64px;
}

#kirill-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--brick-light);
  flex-shrink: 0;
}

.speech {
  background: #fff4ea;
  color: #2a1a12;
  padding: 8px 12px;
  border-radius: 14px;
  border-bottom-left-radius: 3px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  max-width: calc(100% - 80px);
  transition: opacity 0.25s, transform 0.25s;
}

.speech.hidden { opacity: 0; transform: translateY(4px); }

/* ——— Вкладки-страницы ——— */
#main { flex: 1; overflow: hidden; position: relative; }

.tab { display: none; height: 100%; overflow-y: auto; padding: 10px 14px 18px; -webkit-overflow-scrolling: touch; }
.tab.active { display: block; }

.tab h2 { margin: 4px 0 12px; font-size: 20px; }

/* Завод */
#tab-factory.active { display: flex; flex-direction: column; align-items: center; }

#passive-rate { color: var(--dim); font-size: 14px; font-weight: 600; padding: 4px 0; }

#tap-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

#tap-zone {
  background: none;
  border: none;
  padding: 0;
  width: min(76vw, 340px);
  touch-action: manipulation;
  transition: transform 0.06s;
}

#tap-zone:active { transform: scale(0.93); }
#tap-zone svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 6px 14px #00000066); }

#tap-hint { color: var(--dim); font-size: 13px; margin-top: 10px; }

/* Карточка заказа */
#order-slot { width: 100%; }

.order-card {
  background: var(--panel2);
  border: 1px solid var(--brick);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 8px;
  animation: pop 0.2s;
}

.order-head { font-size: 14px; }
.order-text { color: var(--dim); font-size: 13px; margin: 4px 0; }
.order-deal { font-size: 14px; margin: 4px 0 8px; }

.order-btns { display: flex; gap: 8px; }

#order-accept, #order-decline {
  border: none;
  border-radius: 10px;
  padding: 10px 0;
  font-size: 15px;
  font-weight: 700;
  min-height: 44px;
}

#order-accept { flex: 2; background: var(--green); color: #11320e; }
#order-decline { flex: 1; background: var(--panel); color: var(--dim); }

.order-progress {
  height: 14px;
  background: #00000055;
  border-radius: 7px;
  overflow: hidden;
  margin: 8px 0 6px;
}

.order-progress i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--brick-light));
  border-radius: 7px;
  transition: width 0.08s;
}

.order-nums { font-size: 13px; color: var(--dim); }

/* ——— Бизнес ——— */
.upg-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 10px;
}

.upg-ico { font-size: 28px; flex-shrink: 0; }
.upg-body { flex: 1; min-width: 0; }
.upg-name { font-weight: 700; font-size: 14px; }
.upg-lvl { color: var(--gold); font-size: 12px; font-weight: 800; margin-left: 4px; }
.upg-desc { color: var(--dim); font-size: 12px; line-height: 1.3; margin-top: 2px; }

.buy-btn {
  background: linear-gradient(180deg, var(--brick-light), var(--brick));
  color: #fff4ea;
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 800;
  min-width: 86px;
  min-height: 44px;
  white-space: nowrap;
  flex-shrink: 0;
}

.buy-btn:disabled { background: var(--panel2); color: var(--dim); }

.buy-btn.gold {
  background: linear-gradient(180deg, #ffd76e, var(--gold));
  color: #3a2a06;
  animation: glow 1.4s infinite;
}

/* ——— Банк ——— */
.bank-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 17px;
  padding: 12px 2px;
}

.bank-row b { font-size: 19px; }

.bank-btns { display: flex; gap: 8px; }

.wd-btn {
  flex: 1;
  background: linear-gradient(180deg, var(--brick-light), var(--brick));
  border: none;
  color: #fff4ea;
  border-radius: 10px;
  padding: 12px 4px;
  font-size: 14px;
  font-weight: 800;
  min-height: 48px;
}

.wd-btn:disabled { background: var(--panel2); color: var(--dim); }

.bank-note { color: var(--dim); font-size: 12.5px; line-height: 1.35; }

#grey-btn {
  width: 100%;
  background: #181210;
  border: 2px dashed #6b564a;
  color: var(--dim);
  border-radius: 12px;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  min-height: 48px;
}

#grey-btn:disabled { opacity: 0.5; }

#bank-result { min-height: 26px; padding: 10px 2px; color: var(--dim); font-size: 14px; }
#bank-result b { color: var(--green); }

#reset-btn {
  display: block;
  margin: 28px auto 8px;
  background: none;
  border: none;
  color: var(--danger);
  font-size: 13px;
  opacity: 0.7;
  text-decoration: underline;
}

/* ——— Магазин ——— */
.shop-note { color: var(--dim); font-size: 13px; margin: -6px 0 12px; }

#shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.joy-card {
  background: var(--panel);
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
}

.joy-img {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.joy-emoji { font-size: 46px; }

.joy-img img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.joy-name { font-weight: 700; font-size: 13.5px; margin: 8px 0 2px; }
.joy-flavor { color: var(--dim); font-size: 12px; line-height: 1.3; flex: 1; margin-bottom: 8px; }

.joy-card .buy-btn { width: 100%; }

.joy-card.bought .joy-img { outline: 2px solid var(--green); outline-offset: -2px; }

.bought-mark { color: var(--green); font-weight: 800; font-size: 14px; padding: 10px 0 4px; text-align: center; }

.joy-card.chest { grid-column: 1 / -1; border: 1px solid #6b564a; }
.joy-card.chest.unlocked { border: 2px solid var(--gold); box-shadow: 0 0 18px #f5b94244; }
.joy-card.chest .joy-img { aspect-ratio: 16 / 7; }
.joy-card.chest .joy-emoji { font-size: 56px; }

/* ——— Нижняя навигация ——— */
#tabbar {
  display: flex;
  background: #14100e;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid #00000066;
}

#tabbar button {
  flex: 1;
  background: none;
  border: none;
  color: var(--dim);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 0 10px;
  position: relative;
  min-height: 56px;
}

#tabbar button.active { color: var(--brick-light); }

.tab-ico { display: block; font-size: 22px; margin-bottom: 2px; }

#tabbar button.dot::after {
  content: '';
  position: absolute;
  top: 7px;
  right: 22%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid #14100e;
}

/* ——— Оверлеи ——— */
.overlay {
  position: fixed;
  inset: 0;
  background: #000000b8;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: fadeIn 0.16s;
  padding: 16px;
}

.modal {
  background: var(--panel);
  border-radius: 18px;
  padding: 18px;
  width: min(88vw, 380px);
  max-height: 86dvh;
  overflow-y: auto;
  text-align: center;
  animation: pop 0.22s;
}

.modal h2, .modal h3 { margin: 12px 0 6px; }
.modal .joy-img { max-width: 290px; margin: 0 auto; }
.modal-line { color: var(--text); font-size: 15px; line-height: 1.4; margin: 8px 0; }
.finale-title { color: var(--gold); }

.code-box {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 1px;
  background: #00000077;
  border: 2px dashed var(--gold);
  color: var(--gold);
  padding: 14px 10px;
  border-radius: 12px;
  margin: 12px 0;
  user-select: text;
  -webkit-user-select: text;
  word-break: break-all;
}

.primary {
  background: linear-gradient(180deg, var(--brick-light), var(--brick));
  color: #fff4ea;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 16px;
  font-weight: 800;
  width: 100%;
  margin-top: 10px;
  min-height: 50px;
}

/* ——— Эффекты ——— */
#fx-root span { will-change: transform, opacity; }

.fx-float {
  position: fixed;
  z-index: 40;
  font-weight: 800;
  font-size: 18px;
  color: var(--gold);
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
  animation: floatUp 0.9s ease-out forwards;
}

@keyframes floatUp {
  to { transform: translate(var(--fx-dx, 0), -95px); opacity: 0; }
}

.fx-brick {
  position: fixed;
  z-index: 39;
  font-size: 17px;
  pointer-events: none;
  animation: brickFly 0.7s ease-in forwards;
}

@keyframes brickFly {
  25% { opacity: 1; }
  to { transform: translate(var(--fx-dx, 0), var(--fx-dy, -60px)) rotate(var(--fx-rot, 90deg)); opacity: 0; }
}

.fx-confetto {
  position: fixed;
  top: -3vh;
  width: 8px;
  height: 13px;
  border-radius: 2px;
  z-index: 60;
  pointer-events: none;
  animation: confFall 2.2s linear forwards;
}

@keyframes confFall {
  to { transform: translate(var(--fx-dx, 0), 110vh) rotate(640deg); }
}

@keyframes fadeIn { from { opacity: 0; } }

@keyframes pop {
  from { transform: scale(0.92); opacity: 0; }
}

/* свечение вместо scale: не двигает bounding box (стабильные клики) */
@keyframes glow {
  0%, 100% { box-shadow: 0 0 4px #f5b94233; }
  50% { box-shadow: 0 0 22px #f5b942aa; }
}
