/* ═══════════ Earth / Cosmic Farm — финальный UI ═══════════ */
:root {
  --e-bg: #005d9b;
  --e-card: rgba(255,255,255,0.92);
  --e-border: rgba(180,210,255,0.55);
  --e-orange: #FF8C42;
  --e-green: #A4D037;
  --e-blue: #4FC3F7;
  --e-text: #37474F;
  --e-muted: #78909C;
  --e-shadow: 0 4px 20px rgba(100,180,255,0.10);
}

#earth-app {
  font-family: -apple-system,'Segoe UI',Roboto,sans-serif;
  background: var(--e-bg);
  color: var(--e-text);
  min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  display: none;
}
#earth-app.active { display: block; }

/* ── Картинки с эмодзи-фолбэком ── */
.eimg { display: inline-block; object-fit: contain; vertical-align: middle; }
.eimg-broken { display: none !important; }
.eimg-emoji { display: none; align-items: center; justify-content: center; }
.e-logo      { width: 38px; height: 38px; font-size: 34px; }
.e-back-ico  { width: 16px; height: 16px; font-size: 14px; }
.e-res-ico   { width: 20px; height: 20px; font-size: 18px; }
.e-nav-ico   { width: 22px; height: 22px; font-size: 20px; }
.e-qa-ico    { width: 26px; height: 26px; font-size: 24px; }
.e-sec-ico   { width: 18px; height: 18px; font-size: 16px; }
.e-b-ico     { width: 36px; height: 36px; font-size: 30px; }
.e-item-ico  { width: 20px; height: 20px; font-size: 17px; }
.e-recipe-img{ width: 44px; height: 44px; font-size: 34px; }
.e-seed-img  { width: 38px; height: 38px; font-size: 30px; }
.e-build-img { width: 38px; height: 38px; font-size: 30px; }
.e-order-img { width: 22px; height: 22px; font-size: 19px; }
.e-energy-ico{ width: 22px; height: 22px; font-size: 19px; }
.cell-img    { width: 46px; height: 46px; font-size: 38px; }
.pen-img     { width: 30px; height: 30px; font-size: 26px; }
.e-season-ico{ width: 30px; height: 30px; font-size: 26px; }
.e-expand-ico{ width: 22px; height: 22px; font-size: 19px; }

/* ── База ── */
.e-card {
  background: var(--e-card);
  border: 1px solid var(--e-border);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--e-shadow);
  backdrop-filter: blur(6px);
}

.e-btn-primary {
  background: linear-gradient(135deg, var(--e-orange), #FFB347);
  color: #fff; border: none; border-radius: 12px;
  padding: 12px 16px; font-weight: 700; font-size: 14px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 3px 10px rgba(255,140,66,0.30);
  transition: transform .12s, box-shadow .12s;
}
.e-btn-primary:active { transform: scale(0.96); }

.e-btn-secondary {
  background: var(--e-green); color: #fff; border: none; border-radius: 12px;
  padding: 10px 14px; font-weight: 600; font-size: 13px; cursor: pointer;
  transition: transform .12s;
}
.e-btn-secondary:active { transform: scale(0.96); }
.e-btn-secondary.on { background: var(--e-orange); }

.e-btn-ghost {
  background: none; border: 1px solid var(--e-border); color: var(--e-text);
  border-radius: 10px; padding: 10px; font-weight: 600; width: 100%; cursor: pointer; margin-top: 10px;
}

.e-mini { padding: 7px 12px; font-size: 12px; border-radius: 10px; }
.disabled { opacity: 0.55; pointer-events: none; }

.e-orange { color: var(--e-orange); }
.e-green  { color: var(--e-green); }
.e-blue   { color: var(--e-blue); }
.e-muted  { color: var(--e-muted); font-size: 12px; }

/* ── Шапка: балансы слева, ресурсы справа ── */
#earth-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(240,249,255,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--e-border);
}
.e-topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
}
.e-top-left, .e-top-right {
  display: flex; flex-direction: column; gap: 6px;
}
.e-top-right { align-items: flex-end; }
.e-res {
  display: flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap;
  background: #fff; padding: 5px 10px; border-radius: 12px; border: 1px solid var(--e-border);
  box-shadow: 0 2px 6px rgba(100,180,255,0.08);
}
.e-res b { font-weight: 700; }
.e-res-cur { font-size: 10px; color: var(--e-muted); font-weight: 700; }
.e-bar { width: 56px; height: 7px; background: #E0F2FE; border-radius: 4px; overflow: hidden; }
.e-bar-fill { height: 100%; background: var(--e-green); transition: width .3s; }
.e-bar-fill.blue { background: var(--e-blue); }

/* ── Навигация ── */
#earth-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; background: rgba(255,255,255,0.96);
  border-top: 1px solid var(--e-border);
  padding-bottom: env(safe-area-inset-bottom);
}
#earth-nav button {
  flex: 1; background: none; border: none; color: var(--e-muted);
  font-size: 9px; padding: 7px 0 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: color .15s;
}
#earth-nav button.active { color: var(--e-orange); }
#earth-nav button.active .e-nav-ico { transform: translateY(-2px); }

/* ── Сезон / событие ── */
.e-season { display: flex; justify-content: space-between; align-items: center; }
.e-season-info { display: flex; align-items: center; gap: 10px; }
.e-season-name { font-weight: 700; font-size: 14px; }
.e-event-badge {
  display: flex; align-items: center; gap: 5px;
  background: linear-gradient(135deg, #FFE8D6, #FFF3E0);
  border: 1px solid #FFCC99; color: var(--e-orange);
  border-radius: 10px; padding: 5px 10px; font-size: 11px; font-weight: 700;
}

/* ── Быстрые действия ── */
.e-quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.e-qa {
  background: #fff; border: 1px solid var(--e-border); border-radius: 14px;
  padding: 10px 4px; cursor: pointer; font-size: 10px; font-weight: 600; color: var(--e-text);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  box-shadow: var(--e-shadow); transition: transform .12s;
}
.e-qa:active { transform: scale(0.95); }

/* ── Расширение клетки ── */
.e-expand { display: flex; justify-content: space-between; align-items: center; }
.e-expand-label { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }

/* ── Секции ── */
.e-section-title {
  font-weight: 700; font-size: 14px; margin: 14px 0 8px; color: #0369A1;
  display: flex; align-items: center; gap: 6px;
}
.e-sec-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; color: var(--e-text); }

/* ── Сетка фермы ── */
.farm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.farm-cell {
  position: relative; overflow: hidden; z-index: 1;
  border: 2px dashed var(--e-border); border-radius: 14px;
  aspect-ratio: 1; padding: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  text-align: center; background: #fff;
}
.cell-bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: 0.9; pointer-events: none;
}
.farm-cell > *:not(.cell-bg) { position: relative; z-index: 1; }

/* фолбэк-фоны по типам, если картинки ещё нет */
.farm-cell.type-field      { background: #F5EFDD; }
.farm-cell.type-greenhouse { background: #E6F4EA; }
.farm-cell.type-orchard    { background: #EBF3E0; }
.farm-cell.type-animal     { background: #F6EBDD; }
.farm-cell.type-fish       { background: #E0F1F7; }

.farm-cell.status-growing { border-style: solid; border-color: var(--e-blue); }
.farm-cell.status-ready   { border-style: solid; border-color: var(--e-green); box-shadow: 0 0 14px rgba(164,208,55,0.4); }
.farm-cell.status-dead    { border-style: solid; border-color: #ef5350; opacity: 0.75; }

.cell-content { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; }
.cell-empty-plus { font-size: 26px; font-weight: 300; color: var(--e-muted); opacity: 0.7; }
.cell-sub { font-size: 10px; }
.cell-icon { line-height: 1; margin-bottom: 3px; display: flex; align-items: center; justify-content: center; }
.cell-icon.pulse { animation: pulse 1.2s infinite; }
.cell-name { font-size: 10px; font-weight: 700; color: var(--e-text); line-height: 1.15; }
.cell-progress { width: 85%; height: 5px; background: rgba(255,255,255,0.7); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.cell-progress-fill { height: 100%; background: var(--e-blue); transition: width .5s; }
.cell-timer { font-size: 9px; color: var(--e-muted); margin-top: 3px; }
.cell-btn { position: relative; z-index: 2; padding: 6px 4px; font-size: 11px; border-radius: 8px; width: 100%; margin-top: 4px; }
.cell-btn.harvest { background: linear-gradient(135deg, var(--e-green), #BEE36A); }

/* ── Постройки ── */
.e-buildings { display: flex; flex-direction: column; gap: 8px; }
.e-building {
  display: flex; align-items: center; gap: 10px;
  background: #fff; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--e-border);
}
.e-building.working { background: #FFF6EC; border-color: #FFCC99; }
.e-building.building { background: #F0F7FF; }
.e-b-body { flex: 1; min-width: 0; }
.e-b-name { font-size: 13px; font-weight: 600; }
.e-b-status { display: flex; align-items: center; gap: 6px; }
.claim-btn { white-space: nowrap; }

/* ── Склад ── */
.e-storage { display: flex; flex-direction: column; gap: 12px; }
.e-storage-head { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 6px; font-size: 13px; }
.e-storage-title { display: flex; align-items: center; gap: 6px; }
.e-storage-bar { height: 6px; background: #E0F2FE; border-radius: 3px; overflow: hidden; margin-bottom: 10px; }
.e-storage-bar-fill { height: 100%; background: var(--e-green); transition: width .3s; }
.e-storage-bar-fill.full { background: var(--e-orange); }
.e-storage-items { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.e-item {
  display: flex; align-items: center; gap: 5px;
  background: #F0F9FF; padding: 5px 9px; border-radius: 10px; font-size: 12px;
  border: 1px solid var(--e-border);
}
.e-item-qty { font-weight: 700; color: var(--e-orange); }

/* ── Рецепты: новые карточки ── */
.e-recipe-list { display: flex; flex-direction: column; gap: 8px; }
.e-recipe {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, #FFFFFF 0%, #F6FBFF 100%);
  padding: 12px; border-radius: 16px;
  border: 1px solid var(--e-border); cursor: pointer;
  box-shadow: 0 2px 8px rgba(100,180,255,0.07);
  transition: transform .12s, box-shadow .12s;
  position: relative; overflow: hidden;
}
.e-recipe:active { transform: scale(0.98); }
.e-recipe.disabled { opacity: 0.55; filter: saturate(0.6); }
.e-recipe-img {
  width: 44px; height: 44px; font-size: 34px; flex-shrink: 0;
  background: #EFF8FF; border-radius: 12px; padding: 5px;
  display: flex; align-items: center; justify-content: center;
}
.e-recipe-body { flex: 1; min-width: 0; }
.e-recipe-name { font-size: 13px; font-weight: 700; }
.e-recipe-sub { font-size: 11px; color: var(--e-muted); margin-top: 3px; line-height: 1.35; }
.e-recipe-work {
  position: absolute; inset: 0; z-index: 1;
  background: rgba(255, 246, 236, 0.5); backdrop-filter: blur(2px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.e-recipe-work-timer { font-size: 15px; font-weight: 800; color: var(--e-orange); }
.e-recipe-work-label { font-size: 10px; color: var(--e-muted); }
.e-recipe-claim {
  background: linear-gradient(135deg, var(--e-green), #BEE36A);
  color: #fff; border: none; border-radius: 10px;
  padding: 8px 16px; font-weight: 700; font-size: 13px; cursor: pointer;
  animation: pulse 1.2s infinite;
}
.e-pack-icons { display: flex; align-items: center; gap: 3px; }
.e-pack-arrow { color: var(--e-muted); font-size: 12px; }

/* ── Количество ── */
.e-qty-picker { display: flex; align-items: center; gap: 10px; margin: 12px 0; justify-content: center; }
.e-qty-picker button {
  width: 34px; height: 34px; border-radius: 10px;
  border: 1px solid var(--e-border); background: #fff; font-weight: 700; cursor: pointer; font-size: 16px;
}
.e-qty-picker input {
  border: 1px solid var(--e-border); border-radius: 10px; padding: 8px;
  font-size: 15px; font-weight: 700; text-align: center;
}

/* ── Заказы ── */
.e-orders-subtitle { font-weight: 700; color: #0369A1; margin: 14px 0 8px; font-size: 13px; }
.e-order { border-left-width: 4px; }
.e-order.type-urgent    { border-left: 4px solid var(--e-orange); }
.e-order.type-premium   { border-left: 4px solid #9C27B0; }
.e-order.type-scrap     { border-left: 4px solid #78909C; }
.e-order.type-quarterly { border-left: 4px solid #3F51B5; }
.e-order-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.e-order-body { display: flex; align-items: center; gap: 6px; margin: 8px 0; font-size: 13px; }
.e-order-foot { display: flex; justify-content: space-between; align-items: center; }
.e-order-wr { display: flex; align-items: center; gap: 4px; font-weight: 700; }
.e-order-have { font-weight: 700; margin-left: auto; font-size: 12px; }
.e-order-have.ok { color: var(--e-green); }
.e-order-have.no { color: #ef5350; }

/* ── Модалка: 90% × 90%, динамическая высота, поверх всего ── */
.e-modal { position: fixed; inset: 0; z-index: 300; }
.e-modal.hidden { display: none !important; }
.e-modal-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(12, 30, 50, 0.45); backdrop-filter: blur(3px);
  animation: eFadeIn .22s ease;
  padding: 5vh 5vw;
}
.e-modal-box {
  width: 90%; max-width: 480px;
  max-height: 90%; height: auto;           /* ← динамическая высота по контенту */
  background: #fff; border-radius: 20px;
  overflow-y: auto; padding: 18px 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  animation: eSlideUp .28s cubic-bezier(.2,.8,.3,1);
  position: relative;
}
@keyframes eFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes eSlideUp { from { transform: translateY(40px) scale(.96); opacity: .4; } to { transform: none; opacity: 1; } }
.e-modal-close {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%;
  background: #F0F9FF; border: 1px solid var(--e-border);
  font-size: 16px; font-weight: 700; color: var(--e-text); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.e-modal-close:active { transform: scale(0.92); }
.e-modal-title {
  font-weight: 700; font-size: 17px; margin: 2px 40px 14px 0; color: #0369A1;
  display: flex; align-items: center; gap: 8px;
}

/* ── Семена / стройка ── */
.e-seed-list, .e-build-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.e-seed, .e-build-item {
  display: flex; align-items: center; gap: 10px;
  background: #F0F9FF; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--e-border);
}
.e-seed { cursor: pointer; }
.e-build-item.disabled { opacity: 0.55; }

/* ── Фаза ── */
.phase-head { font-size: 14px; margin-bottom: 6px; }
.phase-bar { background: rgba(180,210,255,0.4); border-radius: 8px; height: 10px; overflow: hidden; margin-bottom: 6px; }
.phase-fill { height: 100%; background: linear-gradient(90deg, var(--e-green), #C8E76F); transition: width .5s; }
.phase-burst { animation: phasePulse 1.4s ease; }
@keyframes phasePulse {
  0% { box-shadow: 0 0 0 0 rgba(255,140,66,.5); }
  60% { box-shadow: 0 0 0 12px rgba(255,140,66,0); }
  100% { box-shadow: var(--e-shadow); }
}

/* ── Энергия ── */
.e-energy-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 0; border-bottom: 1px dashed var(--e-border); font-size: 13px;
}
.e-energy-row:last-child { border-bottom: none; }
.e-energy-label { display: flex; align-items: center; gap: 7px; }

/* ── Животные ── */
.pen-grid { display: flex; flex-direction: column; gap: 8px; }
/* ── Загоны: один столбик, содержимое не уезжает ── */
.pen-card { display: flex; flex-direction: column; gap: 6px; }
.pen-buy { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pen-buy select { flex: 1; min-width: 140px; }
.pen-buy .e-mini { white-space: nowrap; }

.pen-card { background: #fff; border: 1px solid var(--e-border); border-radius: 12px; padding: 10px; font-size: 13px; }
.pen-card.ready { border-color: var(--e-green); box-shadow: 0 0 10px rgba(164,208,55,0.3); }
.pen-head { font-weight: 600; margin-bottom: 7px; display: flex; align-items: center; gap: 7px; font-size: 12px; }
.pen-buy { display: flex; gap: 5px; }
.pen-buy select {
  flex: 1; min-width: 0; border: 1px solid var(--e-border); border-radius: 8px;
  padding: 6px; font-size: 11px; background: #fff; color: var(--e-text);
}

.e-timer { font-size: 12px; color: var(--e-muted); white-space: nowrap; }

@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }

/* ═══ Социум ═══ */
.es-subtabs { display: flex; gap: 8px; margin-bottom: 12px; }
.es-subtab {
  flex: 1; background: #fff; border: 1px solid var(--e-border); border-radius: 12px;
  padding: 9px 4px; font-size: 12px; font-weight: 600; color: var(--e-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.es-subtab.active { border-color: var(--e-orange); color: var(--e-orange); box-shadow: 0 2px 8px rgba(255,140,66,0.18); }

.es-kinds { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.es-chip {
  background: #fff; border: 1px solid var(--e-border); border-radius: 999px;
  padding: 6px 12px; font-size: 11px; font-weight: 600; color: var(--e-muted); cursor: pointer;
}
.es-chip.active { background: var(--e-orange); border-color: var(--e-orange); color: #fff; }

.es-lot {
  display: flex; align-items: center; gap: 10px;
  background: #fff; padding: 10px 12px; border-radius: 14px;
  border: 1px solid var(--e-border); margin-bottom: 8px;
}
.es-lot-done { opacity: 0.6; }

.e-lb-row {
  display: flex; align-items: center; gap: 10px;
  background: #fff; padding: 9px 12px; border-radius: 12px;
  border: 1px solid var(--e-border); margin-bottom: 6px; font-size: 13px;
}
.e-lb-row.me { border-color: var(--e-orange); background: #FFF6EC; }
.e-lb-rank { width: 28px; text-align: center; font-weight: 700; }
.e-lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.e-lb-val { font-weight: 700; }

.ach-card {
  display: flex; align-items: center; gap: 12px;
  background: #fff; padding: 11px 12px; border-radius: 14px;
  border: 1px solid var(--e-border); margin-bottom: 8px;
}
.ach-card.done { border-color: var(--e-green); background: #F4FBE8; }
.ach-badge { font-size: 24px; }
.ach-bar { height: 6px; background: #E0F2FE; border-radius: 3px; overflow: hidden; margin: 5px 0 3px; }
.ach-fill { height: 100%; background: linear-gradient(90deg, var(--e-green), #C8E76F); transition: width .4s; }

/* ═══ Туториал ═══ */
#etut-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(12, 30, 50, 0.55);
}
.etut-hole {
  position: absolute; border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(12, 30, 50, 0.55), 0 0 20px rgba(255, 255, 255, 0.6) inset;
  background: transparent; pointer-events: none;
  animation: etutPulse 1.6s infinite;
}
@keyframes etutPulse { 0%,100% { box-shadow: 0 0 0 9999px rgba(12,30,50,0.55); } 50% { box-shadow: 0 0 0 9999px rgba(12,30,50,0.45); } }
.etut-card {
  position: absolute; left: 16px; right: 16px; max-width: 440px; margin: 0 auto;
  background: #fff; border-radius: 18px; padding: 18px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.etut-center { top: 50%; transform: translateY(-50%); }
.etut-bottom { bottom: calc(90px + env(safe-area-inset-bottom)); }
.etut-title { font-weight: 800; font-size: 17px; color: #0369A1; margin-bottom: 8px; }
.etut-text { font-size: 13px; line-height: 1.5; color: var(--e-text); margin-bottom: 14px; }
.etut-foot { display: flex; justify-content: space-between; align-items: center; }
.etut-progress { font-size: 12px; color: var(--e-muted); font-weight: 700; }
.etut-skip { background: none; border: none; color: var(--e-muted); font-size: 12px; cursor: pointer; margin-right: 8px; }

/* Кнопка продажи системе на складе */
.e-sell-sys {
  background: var(--e-orange); color: #fff; border: none; border-radius: 7px;
  font-size: 11px; padding: 2px 6px; cursor: pointer; margin-left: 2px;
}

/* Анимация покупки */
@keyframes seedPop { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
.e-seed-bought { animation: seedPop .35s ease; }

/* ── Тосты Земли ── */
#earth-toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  z-index: 500; max-width: 90%;
  background: rgba(226, 226, 226, 0.95); color: #fff;
  padding: 11px 18px; border-radius: 14px;
  font-size: 13px; font-weight: 600; text-align: center;
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
}
#earth-toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}
#earth-toast.error { background: rgba(198, 40, 40, 0.95); }

/* ═══ z-шкала v2: модалка/тост/туториал живут в <body> ═══ */
#earth-header { z-index: 40 !important; }
#earth-nav    { z-index: 40 !important; }
.farm-cell    { z-index: 0; }
.e-modal      { z-index: 200000 !important; }
#etut-overlay { z-index: 210000 !important; }
#earth-toast  { z-index: 220000 !important; }

/* после переноса в body теряется шрифт #earth-app — возвращаем */
.e-modal, #earth-toast, #etut-overlay {
  font-family: -apple-system,'Segoe UI',Roboto,sans-serif;
  color: var(--e-text);
}

/* ── Карточки рецептов v2 (Заводы / Кухня) ── */
.e-rcard {
  position: relative !important; overflow: hidden !important;
  background: linear-gradient(135deg, #FFFFFF 0%, #F6FBFF 100%);
  border: 1px solid var(--e-border); border-radius: 16px;
  padding: 12px; cursor: pointer;
  box-shadow: 0 2px 8px rgba(100,180,255,0.07);
  transition: transform .12s, box-shadow .12s;
}
.e-rcard:active { transform: scale(0.98); }
.e-rcard.off { opacity: .6; }
.e-rcard.off .e-rc-icon { filter: grayscale(.6); }

.e-rc-main { display: flex; align-items: center; gap: 12px; }
.e-rc-icon {
  width: 48px; height: 48px; flex-shrink: 0;
  background: #EFF8FF; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
}
.e-rc-img { width: 40px; height: 40px; font-size: 32px; }
.e-rc-info { flex: 1; min-width: 0; }
.e-rc-name { font-size: 14px; font-weight: 700; line-height: 1.2; }
.e-rc-out { color: var(--e-green); font-size: 12px; font-weight: 800; white-space: nowrap; }
.e-rc-premium { color: #9C27B0; }

.e-rc-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.e-rc-badge {
  font-size: 10px; font-weight: 700; color: var(--e-muted);
  background: #F0F9FF; border: 1px solid var(--e-border);
  border-radius: 999px; padding: 2px 8px; white-space: nowrap;
}
.e-rc-badge.wr { color: var(--e-blue); }

.e-rc-max { text-align: center; font-size: 9px; color: var(--e-muted); line-height: 1.2; flex-shrink: 0; }
.e-rc-max b { font-size: 14px; color: var(--e-orange); display: block; }

.e-rc-inputs {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--e-border);
}
.e-rc-ing {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: #F0F9FF; border: 1px solid var(--e-border); color: var(--e-text);
}
.e-rc-ing b { font-weight: 800; }
.e-rc-ing.ok b { color: #7CB342; }
.e-rc-ing.no { background: #FFF1F0; border-color: #FFCDD2; }
.e-rc-ing.no b { color: #E53935; }
.e-rc-ing-ico { width: 16px; height: 16px; font-size: 14px; }
.e-rc-reason { margin-top: 8px; font-size: 11px; color: #E53935; font-weight: 600; }

.e-rcard .e-recipe-work { border-radius: 16px; } /* оверлей «в работе» поверх карточки */

/* ── Статус цеха на подвкладке ── */
.ws-status {
  font-size: 11px; font-weight: 600; color: var(--e-muted);
  background: #F0F9FF; border: 1px solid var(--e-border);
  border-radius: 10px; padding: 6px 10px; margin-bottom: 10px;
}
.ws-status.busy { color: var(--e-orange); background: #FFF6EC; border-color: #FFCC99; }
.ws-status.none { color: #90A4AE; border-style: dashed; }

/* ── Продажа системе: цена и итог ── */
.e-sys-price { text-align: center; font-size: 13px; margin-bottom: 6px; }
.e-sys-total {
  text-align: center; font-size: 15px; margin: 4px 0 12px;
  background: #F0F9FF; border: 1px solid var(--e-border);
  border-radius: 12px; padding: 10px;
}
.e-sys-total b { color: var(--e-orange); }

/* ── Заблокированная, но КЛИКАБЕЛЬНАЯ кнопка сбора (не .disabled!) ── */
.cell-btn.blocked {
  background: linear-gradient(135deg, #B0BEC5, #CFD8DC);
  box-shadow: none;
}

/* ── Замок фазы на недоступных постройках ── */
.e-phase-lock {
  font-size: 10px; font-weight: 700; color: #78909C;
  background: #ECEFF1; border: 1px dashed #B0BEC5;
  border-radius: 10px; padding: 4px 10px;
  text-align: center; line-height: 1.3; white-space: nowrap;
}

/* ── Карточка «в работе» — без всяких слоёв, таймер просто справа ── */
.e-rc-working {
  border-color: #FFCC99;
  background: linear-gradient(135deg, #FFF9F0, #FFF3E2);
  cursor: default;
}
.e-rc-workside {
  flex-shrink: 0; display: flex; flex-direction: column;
  align-items: center; gap: 3px;
}

/* ── Калькулятор заказа ── */
.e-calc-box { background: #F0F9FF; border: 1px solid var(--e-border); border-radius: 12px; padding: 10px 12px; margin-top: 4px; }
.e-calc-row { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; }
.e-calc-row.big { font-size: 14px; font-weight: 700; border-top: 1px dashed var(--e-border); margin-top: 6px; padding-top: 8px; }
.e-calc-row.big.ok b { color: #7CB342; }
.e-calc-row.big.no b { color: #E53935; }
.e-calc-sub { font-size: 11px; color: var(--e-muted); margin-top: 8px; }

/* ── Загоны: сетка ячеек по 3 в ряд ── */
.pen-cells {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.pen-cell {
  position: relative;
  aspect-ratio: 1;
  min-height: 96px;                 /* было 62 — поднимаем, чтобы текст читался */
  border: 2px dashed var(--e-border);
  border-radius: 12px;
  background: #fff;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  overflow: hidden;
}

/* Иконка животного внутри ячейки — крупнее, чем в шапке загона */
.pen-cell .pen-img {
  width: 40px;
  height: 40px;
  font-size: 32px;
}


/* Пустая ячейка */
.pen-plus { font-size: 30px; font-weight: 300; line-height: 1; }
.pen-plus-sub { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }

/* Пустая ячейка — пунктир, кликабельна */
.pen-cell.empty {
  cursor: pointer;
  color: var(--e-muted);
  transition: transform .12s, border-color .12s;
}
.pen-cell.empty:hover { border-color: var(--e-green); }
.pen-cell.empty:active { transform: scale(0.94); }
.pen-plus {
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
}
.pen-plus-sub {
  font-size: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* Состояния */
.pen-cell.growing {
  border-style: solid;
  border-color: var(--e-blue);
}
.pen-cell.ready {
  border-style: solid;
  border-color: var(--e-green);
  box-shadow: 0 0 12px rgba(164,208,55,0.45);
}
.pen-cell.hungry {
  border-style: solid;
  border-color: var(--e-orange);
  box-shadow: 0 0 10px rgba(255,140,66,0.35);
}

/* Кнопки и таймер — крупнее */
.pen-cell .e-mini {
  padding: 6px 8px;
  font-size: 11px;
  border-radius: 8px;
  width: 100%;
  white-space: nowrap;
}

.pen-cell .pen-wait {
  background: linear-gradient(135deg, #B0BEC5, #CFD8DC);
  box-shadow: none;
}
.pen-cell .e-timer {
  font-size: 11px;
}

/* ── Модалка выбора вида животного ── */
.pen-opt-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pen-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #F0F9FF;
  border: 1px solid var(--e-border);
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform .12s, border-color .12s;
  font-family: inherit;
  text-align: left;
}
.pen-opt:hover { border-color: var(--e-green); }
.pen-opt:active { transform: scale(0.97); }
.pen-opt-img {
  width: 38px;
  height: 38px;
  font-size: 30px;
}
.pen-opt-name {
  flex: 1;
  font-weight: 700;
  font-size: 14px;
  color: var(--e-text);
}
.pen-opt-price {
  font-weight: 700;
  color: var(--e-orange);
  font-size: 13px;
}

/* ── Модалка выбора вида: карточка с описанием ── */
.pen-opt { align-items: flex-start; }
.pen-opt-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.pen-opt-desc {
  font-size: 11px;
  color: var(--e-muted);
  line-height: 1.5;
  font-weight: 400;
}
.pen-opt-desc b { color: var(--e-text); }

/* ═══ Финальный z-index: шапка под модалкой ═══ */
#earth-header { z-index: 40 !important; }
#earth-nav    { z-index: 40 !important; }
.e-modal      { z-index: 250000 !important; }
#etut-overlay { z-index: 260000 !important; }
#earth-toast  { z-index: 270000 !important; }

/* Кнопка ❓ у достижений */
.ach-info {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%;
  background: #F0F9FF; border: 1px solid var(--e-border);
  color: #0369A1; font-weight: 800; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.ach-info:active { transform: scale(0.9); }

/* ═══ Инфо-кнопки ❓ ═══ */
.e-info-btn {
  width: 22px; height: 22px; font-size: 12px; border-radius: 50%;
  background: #F0F9FF; border: 1px solid var(--e-border);
  color: #0369A1; font-weight: 800; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; margin-left: 6px; flex-shrink: 0; vertical-align: middle;
  font-family: inherit; line-height: 1;
}
.e-info-btn:active { transform: scale(0.9); }
.e-info-mini {
  width: 17px; height: 17px; font-size: 10px; border-radius: 50%;
  background: #fff; border: 1px solid #FFCC99; color: var(--e-orange);
  font-weight: 800; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; padding: 0; line-height: 1;
  font-family: inherit; flex-shrink: 0;
}

/* ═══ Сворачиваемые секции ═══ */
.esec-head { cursor: pointer; user-select: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.esec-head:active { opacity: .8; }
.esec-arrow { font-size: 12px; color: var(--e-muted); transition: transform .2s; flex-shrink: 0; }
.esec-arrow.collapsed { transform: rotate(-90deg); }
.esec-body.collapsed { display: none !important; }
.pen-head.esec-head { margin-bottom: 0; }
.pen-head-l { display: flex; align-items: center; gap: 7px; min-width: 0; flex-wrap: wrap; }

/* ═══ Читаемость на грядках/теплицах/саду: белый текст на тёмной плашке ═══ */
.farm-cell .cell-name,
.farm-cell .cell-timer,
.farm-cell .cell-sub {
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.65);
  background: rgba(0,0,0,.30);
  border-radius: 7px;
  padding: 1px 7px;
}

/* Подпись «выполните действие» в туториале */
.etut-waiting { font-size: 12px; font-weight: 700; color: var(--e-orange); animation: pulse 1.2s infinite; }

/* ═══ Туториал: клики проходят сквозь затемнение, кроме карточки ═══ */
#etut-overlay { pointer-events: none; }
#etut-overlay .etut-card { pointer-events: auto; }

/* ═══ Блокировка прокрутки фона при открытой модалке ═══ */
body.e-modal-open {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

/* Скролл внутри модалки — плавный на iOS, без «протягивания» скролла на body */
.e-modal-box {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}