/* Палитра — art/ART_BIBLE.md. Скругления концентрические: вложенный радиус = внешний − отступ. */
:root {
  --linen: #F3E9D2;
  --panel: #E9DCBE;
  --accent: #C8413A;
  --accent-dark: #A8322C;
  --ink: #3B2A1E;
  --select: #F2B233;

  --r-card: 28px;
  --pad-card: 18px;
  --r-card-inner: calc(var(--r-card) - var(--pad-card));
  --r-pill: 20px;
  --r-booster: 18px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--linen); color: var(--ink);
  font: 500 16px/1.3 -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Экраны: виден только тот, что в body[data-screen]. */
body:not([data-screen="menu"]) #menu, body:not([data-screen="dacha"]) #dacha,
body:not([data-screen="map"]) #map, body:not([data-screen="app"]) #app { display: none !important; }
.screen { position: fixed; inset: 0; overflow: hidden; }

#app {
  height: 100dvh; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  /* Ячейка лотка: ширина лица плитки; места хватает на 5 ячеек («+1 ячейка»). */
  --slot-gap: 8px;
  --slot-w: min(60px, calc((100vw - 28px - 4 * var(--slot-gap)) / 5));
}
.side { display: flex; flex-direction: column; }

.hud {
  display: flex; justify-content: center; align-items: center; gap: 4px;
  padding: 10px 6px 4px;
}
.pill {
  background: var(--panel); border-radius: var(--r-pill);
  padding: 6px 9px; font-weight: 700; font-size: 13px; white-space: nowrap;
}
.pill .sep { margin: 0 4px; opacity: .5; }
@media (max-width: 374px) { .pill { font-size: 12px; padding: 6px 7px; } }
.menu-btn { border: 0; color: var(--ink); cursor: pointer; padding: 4px 7px; line-height: 0; touch-action: manipulation; }
.menu-btn svg, .round svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 400px) { .hud { gap: 3px; } .hud .pill { font-size: 12px; padding: 6px 6px; } }
/* Кот Пряник в шапке: реакции на ходы. */
.cat { width: 38px; height: 38px; object-fit: contain; margin: -6px 0 -6px 2px; transform-origin: 50% 90%; }
.cat.bounce { animation: cat-bounce 500ms ease-out; }
@keyframes cat-bounce { 0% { transform: scale(1); } 30% { transform: scale(1.25) translateY(-4px); } 100% { transform: scale(1); } }

.tray { display: flex; justify-content: center; gap: var(--slot-gap); padding: 6px 14px 4px; }
#app.classic .tray { display: none; }
.slot {
  width: var(--slot-w); height: calc(var(--slot-w) * 4 / 3);
  border-radius: calc(var(--slot-w) * .12);
  background: rgba(59, 42, 30, .10); box-shadow: inset 0 2px 5px rgba(59, 42, 30, .22);
}

#field { flex: 1; min-height: 0; min-width: 0; position: relative; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }

.boosters {
  display: flex; justify-content: center; gap: 14px;
  padding: 4px 14px 10px;
}
.booster {
  position: relative; width: 88px; height: 62px;
  border: 0; border-radius: var(--r-booster); padding: 4px;
  background: var(--accent); color: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-family: inherit; font-weight: 700; font-size: 12px; line-height: 1.1;
  box-shadow: 0 4px 0 var(--accent-dark);
  touch-action: manipulation;
}
.booster:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-dark); }
.booster svg { width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.booster .cnt {
  position: absolute; top: -6px; right: -6px; min-width: 24px; height: 24px; padding: 0 6px;
  border-radius: 12px; background: var(--select); color: var(--ink); font-size: 13px; line-height: 24px;
}

/* Альбом: слева колонка «уровень · время · плитки · очки» и лоток столбиком, справа бустеры столбиком,
   поле — вся высота между ними. */
@media (orientation: landscape) {
  #app {
    flex-direction: row;
    --slot-gap: 6px;
    --slot-w: min(72px, calc((100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 16px - 4 * var(--slot-gap)) / 5 * 3 / 4));
  }
  .side { flex-direction: row; }
  .hud { flex-direction: column; flex-wrap: nowrap; align-items: stretch; justify-content: center; width: 120px; padding: 8px 4px 8px 10px; }
  .hud .pill { text-align: center; padding: 6px 8px; }
  .hud .pill .sep { display: block; height: 0; overflow: hidden; margin: 0; }
  .hud .menu-btn { align-self: flex-start; }
  .hud .cat { width: 56px; height: 56px; margin: 4px auto 0; }
  .tray { flex-direction: column; padding: 8px 6px; }
  .boosters { flex-direction: column; gap: 12px; padding: 8px 12px 8px 4px; }
  .booster { width: 76px; height: 56px; font-size: 10px; }
  .booster svg { width: 24px; height: 24px; }
  .booster .cnt { min-width: 20px; height: 20px; line-height: 20px; font-size: 12px; top: -5px; right: -5px; }
}

#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
#combo {
  position: fixed; z-index: 6; pointer-events: none; transform: translate(-50%, -50%);
  font-weight: 900; font-size: 22px; color: var(--select); white-space: nowrap; opacity: 0;
  text-shadow: 0 2px 0 var(--accent-dark), 0 0 8px rgba(59, 42, 30, .35);
}
#combo.show { animation: combo 900ms ease-out; }
@keyframes combo {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  30% { transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  #combo.show { animation: combo-fade 900ms linear; }
  @keyframes combo-fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
}

.modal {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(59, 42, 30, .45); padding: 16px; z-index: 10;
}
.modal[hidden] { display: none; }
.card {
  width: min(360px, 100%); background: var(--linen); border-radius: var(--r-card);
  padding: var(--pad-card); text-align: center; box-shadow: 0 12px 40px rgba(59, 42, 30, .35);
}
.card h2 { margin: 4px 0 10px; font-size: 22px; }
.card p { margin: 0 0 14px; }
.actions { display: flex; flex-direction: column; gap: 8px; }
.btn {
  border: 0; border-radius: var(--r-card-inner); padding: 14px; cursor: pointer;
  background: var(--panel); color: var(--ink); font-family: inherit; font-weight: 700; font-size: 16px; line-height: 1;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }
.stats { display: flex; justify-content: space-around; margin: 0 0 16px; }
.stats dt { font-size: 13px; opacity: .7; }
.stats dd { margin: 2px 0 0; font-size: 22px; font-weight: 800; }

/* ——— Мета: валюты, меню, дача, карта уровней ——— */
.ico { display: inline-block; width: 18px; height: 18px; vertical-align: -4px; margin-right: 4px; background: center / contain no-repeat; }
.ico.coin { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='10' fill='%23E3A62A' stroke='%23A8741A' stroke-width='2'/%3E%3Ccircle cx='12' cy='12' r='5.5' fill='none' stroke='%23FBE3A6' stroke-width='2'/%3E%3C/svg%3E"); }
.ico.shovel { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg transform='rotate(-45 12 12)' fill='%23806040' stroke='%23806040' stroke-linecap='round'%3E%3Cpath d='M12 2v11' stroke-width='2.2'/%3E%3Cpath d='M9.5 2h5' stroke-width='2.2'/%3E%3Cpath d='M8 12.5h8v4.5q-4 6-8 0z' fill='%238A9BA8' stroke='%235E6B75' stroke-width='1.2'/%3E%3C/g%3E%3C/svg%3E"); }
.pill.cur { display: inline-flex; align-items: center; font-size: 15px; }
.pill.big { font-size: 20px; padding: 8px 14px; }
.pill.big .ico { width: 24px; height: 24px; }

.topbar {
  position: absolute; left: 0; right: 0; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 10px calc(12px + env(safe-area-inset-left));
}
.grow { flex: 1; }
.bar-title { margin: 0; font-size: 20px; }
.round {
  width: 42px; height: 42px; border-radius: 21px; border: 0; background: var(--panel); color: var(--ink);
  display: flex; align-items: center; justify-content: center; cursor: pointer; touch-action: manipulation;
  box-shadow: 0 2px 6px rgba(59, 42, 30, .25);
}
.scene-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 30% 50%; }

#menu .menu-card {
  position: absolute; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(360px, calc(100% - 32px)); background: rgba(243, 233, 210, .94); border-radius: var(--r-card);
  padding: var(--pad-card); box-shadow: 0 12px 40px rgba(59, 42, 30, .35); display: flex; flex-direction: column; gap: 10px;
}
#menu h1 { margin: 0 0 4px; text-align: center; font-size: 28px; color: var(--accent-dark); }
.menu-row { display: flex; gap: 10px; }
.menu-row .btn { flex: 1; position: relative; }
.menu-row[hidden] { display: none; }
.btn.big { padding: 18px; font-size: 20px; }
.btn.small { padding: 10px 14px; font-size: 15px; }
.btn.primary { box-shadow: 0 4px 0 var(--accent-dark); }
.btn:active { transform: translateY(2px); }
.dot { position: absolute; top: 6px; right: 8px; width: 12px; height: 12px; border-radius: 6px; background: var(--accent); }
.dot[hidden] { display: none; }
@media (orientation: landscape) and (max-height: 500px) {
  #menu .menu-card { left: auto; right: calc(20px + env(safe-area-inset-right)); transform: none; bottom: 16px; top: 64px; justify-content: center; }
}

#scene { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
/* Вокруг «вся дача» — та же сцена cover, размытая и чуть затемнённая (картинку ставит js/ui/scene.js). */
.scene-blur {
  position: absolute; inset: -40px; background: center / cover no-repeat;
  filter: blur(16px) brightness(.78);
}
.before-btn { border: 0; color: var(--ink); height: 42px; padding: 0 16px; font-family: inherit; font-size: 15px; cursor: pointer; touch-action: none; box-shadow: 0 2px 6px rgba(59, 42, 30, .25); -webkit-touch-callout: none; }
.before-btn[hidden] { display: none; }
.before-btn:active { background: var(--select); }
.dacha-cat {
  position: absolute; z-index: 2; right: calc(12px + env(safe-area-inset-right)); bottom: calc(120px + env(safe-area-inset-bottom));
  width: 84px; height: 84px; object-fit: contain; pointer-events: none; transform-origin: 50% 90%;
  filter: drop-shadow(0 4px 8px rgba(59, 42, 30, .35)); animation: cat-bounce 500ms ease-out;
}
.dacha-cat[hidden] { display: none; }
.dacha-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 12px 16px calc(18px + env(safe-area-inset-bottom)); pointer-events: none;
}
.dacha-bottom > * { pointer-events: auto; }
.task-label {
  background: rgba(243, 233, 210, .94); border-radius: var(--r-pill); padding: 8px 16px; font-weight: 800;
  box-shadow: 0 4px 14px rgba(59, 42, 30, .3); text-align: center;
  border: 0; color: var(--ink); font-family: inherit; font-size: 16px; min-height: 44px; cursor: pointer; touch-action: manipulation;
}
.task-label:empty { display: none; }
#dPlay { width: min(320px, 100%); }
@media (orientation: landscape) and (max-height: 500px) {
  .dacha-bottom { flex-direction: row; justify-content: center; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  #dPlay { width: auto; padding: 12px 22px; font-size: 17px; }
  .dacha-cat { bottom: calc(70px + env(safe-area-inset-bottom)); width: 64px; height: 64px; }
}
.toast {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 15; max-width: min(320px, 90%);
  pointer-events: none; /* тост поверх окна не должен съедать касание по кнопке под ним */
  background: rgba(59, 42, 30, .9); color: #fff; border-radius: 16px; padding: 12px 16px; text-align: center; font-weight: 700;
}
.toast[hidden] { display: none; }

#map { background: var(--linen); }
.level-grid {
  position: absolute; inset: calc(64px + env(safe-area-inset-top)) 0 0; overflow-y: auto; padding: 8px 16px 24px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 10px; align-content: start;
  max-width: 560px; margin: 0 auto;
}
.lv {
  aspect-ratio: 3 / 4; border: 0; border-radius: 12px; font-family: inherit; font-weight: 800; font-size: 22px; line-height: 1; cursor: pointer;
  background: #F7F0DC; color: var(--ink); box-shadow: -4px 4px 0 #E2D3AE, 0 6px 10px rgba(59, 42, 30, .2);
  touch-action: manipulation; position: relative;
}
.lv.done::after { content: '✓'; position: absolute; right: 5px; bottom: 4px; font-size: 13px; color: #4F9B3A; }
.lv.cur { background: var(--select); }
.lv:disabled { opacity: .45; cursor: default; box-shadow: -4px 4px 0 #E2D3AE; }

/* ——— Окна ——— */
.card.wide { width: min(460px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; }
.card-cat { width: 96px; height: 96px; object-fit: contain; margin: -64px auto -6px; display: block; }
.reward { display: flex; justify-content: center; gap: 10px; margin: 0 0 16px; }
.note { font-size: 13px; opacity: .7; }
.toggles { display: flex; flex-direction: column; gap: 10px; margin: 0 0 10px; text-align: left; }
.toggle { display: flex; align-items: center; gap: 12px; background: var(--panel); border-radius: var(--r-card-inner); padding: 12px 14px; cursor: pointer; }
.toggle span { flex: 1; font-weight: 700; font-size: 15px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i { width: 46px; height: 28px; border-radius: 14px; background: #BFB095; position: relative; flex: none; transition: background .15s; }
.toggle i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 11px; background: #fff; transition: transform .15s; }
.toggle input:checked + i { background: #4F9B3A; }
.toggle input:checked + i::after { transform: translateX(18px); }
.howto { text-align: left; padding-left: 22px; margin: 0 0 14px; }
.howto li { margin-bottom: 10px; }
.days { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 14px; }
.day { background: var(--panel); border-radius: 12px; padding: 8px 4px; font-size: 12px; font-weight: 700; line-height: 1.2; }
.day b { display: block; font-size: 11px; opacity: .65; margin-bottom: 4px; }
.day.today { background: var(--select); }
.day.taken { opacity: .5; }
.day.chest { grid-column: span 2; }

/* Бабушка: реплика снизу (в альбоме — слева внизу), поле остаётся видно. */
.guide {
  position: fixed; z-index: 12; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(400px, calc(100% - 20px)); display: flex; align-items: flex-end; gap: 6px; pointer-events: none;
}
.guide[hidden] { display: none; }
.guide img { width: 84px; height: 84px; object-fit: contain; flex: none; filter: drop-shadow(0 4px 8px rgba(59, 42, 30, .35)); }
.guide .bubble {
  flex: 1; background: #fff; border-radius: 18px 18px 18px 4px; padding: 12px 14px; pointer-events: auto;
  box-shadow: 0 8px 24px rgba(59, 42, 30, .3); display: flex; flex-direction: column; gap: 8px;
}
.guide p { margin: 0; font-size: 15px; }
.guide .btn { align-self: flex-end; }
@media (orientation: landscape) and (max-height: 500px) {
  .guide { left: calc(130px + env(safe-area-inset-left)); transform: none; bottom: 10px; width: min(420px, 55%); }
}

/* ——— Фаза 3: реклама за награду, магазин, вход ——— */
/* Кнопка rewarded: значок «видео» — сразу видно, что это реклама (п. 4.5.1). */
.btn.rv { display: flex; align-items: center; justify-content: center; gap: 8px; line-height: 1.15; }
.btn.rv::before {
  content: ''; flex: none; width: 20px; height: 20px; border-radius: 6px; background: currentColor;
  --rv-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M0 6a6 6 0 0 1 6-6h8a6 6 0 0 1 6 6v8a6 6 0 0 1-6 6H6a6 6 0 0 1-6-6zm8 0v8l6-4z' fill-rule='evenodd'/%3E%3C/svg%3E");
  -webkit-mask: var(--rv-icon) center / contain no-repeat;
  mask: var(--rv-icon) center / contain no-repeat;
}
.btn[hidden] { display: none; }
/* Платформа без рекламы (Telegram): кнопок «за просмотр рекламы» нет. */
.btn.no-ads { display: none; }
#winModal .btn.rv { width: 100%; margin: 0 0 10px; }
.btn.login { width: 100%; margin: 0 0 12px; line-height: 1.25; background: #FFDB4D; }

.shop { display: flex; flex-direction: column; gap: 8px; margin: 0 0 12px; text-align: left; }
.shop-item { display: flex; align-items: center; gap: 12px; background: var(--panel); border-radius: var(--r-card-inner); padding: 10px 10px 10px 14px; }
.shop-item div { flex: 1; }
.shop-item b { display: block; font-size: 16px; }
.shop-item span { font-size: 13px; opacity: .75; }
.shop-item .btn { flex: none; min-width: 96px; padding: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.shop-item .btn img { width: 18px; height: 18px; }
/* Низкий альбом (телефон): товары в две колонки — окно целиком влезает по высоте, «Закрыть» видно (п. 1.10.1). */
@media (orientation: landscape) and (max-height: 500px) {
  #shopModal .card.wide { width: min(720px, 100%); padding: 12px 18px; }
  #shopModal h2 { margin: 0 0 8px; font-size: 20px; }
  .shop { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 8px; }
  .shop-item { padding: 8px 8px 8px 12px; }
  .shop-item b { font-size: 15px; }
  .shop-item span { font-size: 12px; }
  .shop-item .btn { min-width: 84px; padding: 10px; }
  #shopModal .note { margin: 0 0 8px; font-size: 12px; }
  #shopModal .btn.primary#shopClose { padding: 11px; }
}
/* Низкий альбом: настройки — переключатели в ряд, кнопки в ряд; окно победы — «Дальше» и «На дачу» в ряд.
   Иначе с кнопкой входа и кнопкой rewarded окна выше экрана 390 px. */
@media (orientation: landscape) and (max-height: 500px) {
  #settingsModal .card { width: min(720px, 100%); padding: 12px 18px; }
  #settingsModal h2, #winModal h2 { margin: 0 0 8px; font-size: 20px; }
  #settingsModal .toggles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 8px; }
  #settingsModal .toggle { padding: 10px 12px; }
  #settingsModal .toggle span { font-size: 13px; }
  #settingsModal .note { margin: 0 0 8px; }
  #settingsModal .btn.login { margin: 0 0 8px; padding: 11px; }
  #settingsModal .actions, #winModal .actions { flex-direction: row; }
  #settingsModal .actions .btn, #winModal .actions .btn { flex: 1; padding: 12px; }
  #winModal .card { width: min(440px, 100%); }
  #winModal .card-cat { width: 72px; height: 72px; margin-top: -44px; }
  #winModal .stats { margin: 0 0 8px; }
  #winModal .reward { margin: 0 0 8px; }
  #winModal .btn.rv { margin: 0 0 8px; padding: 11px; }
}
