:root {
  --bark: #3e2a1a;
  --bark2: #5a3f27;
  --moss: #4b7a3a;
  --moss-d: #36592a;
  --gold: #e3a92f;
  --gold-d: #b97f14;
  --cream: #f7eed8;
  --paper: #fffaf0;
  --soil: #6b4a31;
  --ink: #2c2116;
  --muted: #7b6a55;
  --line: #e4d6b4;
  --bad: #b24a32;
  --r: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bark); }
body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(#f9f0da, #efe2bf 60%, #e6d6ac);
  min-height: 100vh;
  font: 16px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 17px; color: var(--bark2); margin: 18px 0 8px; letter-spacing: .2px; }
[hidden] { display: none !important; }

/* Шапка */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px calc(8px) 14px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: linear-gradient(var(--bark2), var(--bark));
  color: #fff3d6;
  box-shadow: 0 2px 10px #0004;
}
.logo { border-radius: 11px; box-shadow: 0 1px 4px #0006; }
.brand { flex: 1; min-width: 0; }
.brand h1 { font-size: 20px; line-height: 1.1; letter-spacing: .5px; }
.brand p { font-size: 12px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.coins {
  display: flex; align-items: center; gap: 6px;
  background: #00000040; border-radius: 999px; padding: 4px 12px 4px 6px;
  font-size: 18px; color: #ffe39a; font-variant-numeric: tabular-nums;
}
.coin {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff0b0, var(--gold) 55%, var(--gold-d));
  box-shadow: inset 0 0 0 2px #b97f1488, 0 1px 2px #0005;
  display: inline-block; flex: none;
}
.coin.s { width: 14px; height: 14px; vertical-align: -2px; box-shadow: inset 0 0 0 1.5px #b97f1488; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0;
  background: #ffffff1f; color: #fff3d6; font-size: 18px; flex: none;
}
.icon-btn.txt { font-size: 13px; font-weight: 700; }
.icon-btn:hover { background: #ffffff33; }
.sheet .icon-btn { background: #0000000f; color: var(--ink); }

/* Вкладки */
.tabs { display: flex; gap: 6px; max-width: 980px; margin: 12px auto 0; padding: 0 14px; }
.tabs button {
  flex: 1; position: relative; padding: 11px 8px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--paper); font-weight: 700; color: var(--muted);
}
.tabs button[aria-selected="true"] {
  background: linear-gradient(var(--moss), var(--moss-d)); border-color: var(--moss-d); color: #fff;
  box-shadow: 0 3px 0 #2a4620;
}
.dot { position: absolute; top: 6px; right: 14px; width: 11px; height: 11px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 2px #fff; animation: pulse 1.4s infinite; }

main { max-width: 980px; margin: 0 auto; padding: 0 14px 18px; }
.cols { display: grid; grid-template-columns: 1fr; gap: 0 22px; }
@media (min-width: 820px) { .cols { grid-template-columns: 1.15fr 1fr; } }
.h-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.h-row h2, .h-row h3 { margin-top: 18px; }
.sheet .h-row h3 { margin-top: 0; }

/* Кнопки */
.btn {
  border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 700; color: #fff;
  background: linear-gradient(var(--moss), var(--moss-d)); box-shadow: 0 3px 0 #2a4620;
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #2a4620; }
.btn.gold { background: linear-gradient(#f0bb44, var(--gold-d)); box-shadow: 0 3px 0 #8a5d0c; color: #3b2606; }
.btn.gold:active:not(:disabled) { box-shadow: 0 1px 0 #8a5d0c; }
.btn.small { padding: 6px 12px; font-size: 14px; margin-top: 14px; }
.btn.ghost { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 2px var(--line); }
.btn:disabled { filter: grayscale(.8) opacity(.55); cursor: not-allowed; }

/* Грядки */
.beds { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.bed {
  position: relative; aspect-ratio: 1; border-radius: var(--r); border: 0; padding: 6px;
  background:
    radial-gradient(circle at 30% 20%, #ffffff14, transparent 40%),
    repeating-linear-gradient(100deg, #00000010 0 3px, transparent 3px 9px),
    linear-gradient(#7a563a, var(--soil));
  box-shadow: inset 0 -5px 0 #00000026, 0 3px 0 #4a3220;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: #fff3d6; overflow: hidden;
}
.bed:active { transform: translateY(2px); }
.bed .plus { font-size: 34px; line-height: 1; opacity: .7; }
.bed .hint { font-size: 12px; opacity: .8; text-align: center; line-height: 1.15; }
.bed img { width: 58%; height: auto; transform-origin: 50% 90%; transition: transform .4s; filter: drop-shadow(0 3px 2px #0005); }
.bed.growing img { transform: scale(var(--g, .5)); filter: drop-shadow(0 3px 2px #0005) saturate(.8); }
.bed.ready { box-shadow: inset 0 -5px 0 #00000026, 0 3px 0 #4a3220, 0 0 0 3px var(--gold); }
.bed.ready img { animation: bob .9s ease-in-out infinite; }
.bed .label { font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px #000a; }
.bed .bar { position: absolute; left: 10px; right: 10px; bottom: 9px; height: 6px; border-radius: 4px; background: #0005; overflow: hidden; }
.bed .bar i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: linear-gradient(#b8e26a, #6fb43a); border-radius: 4px; }
.bed .tm { position: absolute; top: 6px; right: 8px; font-size: 11px; background: #0006; border-radius: 8px; padding: 0 6px; }
.bed .ok { position: absolute; top: 6px; left: 8px; font-size: 11px; font-weight: 800; background: var(--gold); color: #3b2606; border-radius: 8px; padding: 0 6px; }

/* Заказы */
.orders { display: grid; gap: 8px; }
.order {
  display: flex; align-items: center; gap: 10px; background: var(--paper);
  border: 2px solid var(--line); border-radius: var(--r); padding: 8px 10px;
}
.order.can { border-color: var(--moss); background: #f4fbe9; }
.order .who { font-size: 30px; line-height: 1; }
.order .mid { flex: 1; min-width: 0; }
.order .nm { font-size: 12px; color: var(--muted); }
.need { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.need span { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; font-size: 14px; }
.need span.lack { color: var(--bad); }
.need img { width: 26px; height: 26px; }
.order .rw { text-align: right; font-size: 12px; color: var(--muted); }
.order .rw b { display: block; font-size: 16px; color: var(--gold-d); }

/* Амбар */
.barn { display: grid; gap: 8px; }
.barn .empty { color: var(--muted); background: var(--paper); border: 2px dashed var(--line); border-radius: var(--r); padding: 18px; text-align: center; }
.item {
  display: flex; align-items: center; gap: 10px; background: var(--paper);
  border: 2px solid var(--line); border-radius: var(--r); padding: 6px 10px;
}
.item img { width: 42px; height: 42px; }
.item .nm { flex: 1; font-weight: 700; }
.item .nm small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.item .qty { font-weight: 800; font-size: 18px; color: var(--bark2); min-width: 32px; text-align: right; }
.item .btn { padding: 7px 12px; font-size: 14px; }

/* Окно выбора */
.sheet { position: fixed; inset: 0; z-index: 50; background: #1e130a99; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
@media (min-width: 700px) { .sheet { align-items: center; } }
.sheet-card {
  width: 100%; max-width: 520px; max-height: 86vh; overflow: auto; background: var(--cream);
  border-radius: 22px 22px 0 0; padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
  animation: up .2s;
}
@media (min-width: 700px) { .sheet-card { border-radius: 22px; } }
#sheet-body { display: grid; gap: 7px; margin-top: 10px; }
.pick {
  display: flex; align-items: center; gap: 10px; text-align: left; width: 100%;
  border: 2px solid var(--line); background: var(--paper); border-radius: 14px; padding: 6px 10px;
}
.pick:hover:not(:disabled) { border-color: var(--moss); }
.pick img { width: 44px; height: 44px; }
.pick .nm { flex: 1; font-weight: 700; }
.pick .nm small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.pick .pr { font-weight: 800; color: var(--gold-d); white-space: nowrap; }
.pick:disabled { opacity: .5; cursor: not-allowed; }
.pick.locked { filter: grayscale(1); }

/* Дача */
.scene {
  margin: 14px 0 0; border-radius: 22px; overflow: hidden; position: relative;
  background: linear-gradient(#bfe3f2 0%, #e8f4e0 55%, #b9db8a 100%);
  box-shadow: 0 3px 0 #00000022, inset 0 0 0 3px #ffffff88;
  aspect-ratio: 1.8;
}
.scene img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 64%; }
.card { background: var(--paper); border: 2px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin-top: 14px; }
.card.muted { color: var(--muted); font-size: 13px; }
.card.muted p { margin-bottom: 4px; }
.card h3 { font-size: 17px; color: var(--bark2); }
.card .sub { color: var(--muted); font-size: 14px; margin: 2px 0 8px; }
.card ul { margin: 4px 0 10px; padding-left: 18px; font-size: 14px; }
.card .btn { width: 100%; padding: 12px; }
.stages { display: flex; gap: 6px; margin-bottom: 8px; }
.stages i { flex: 1; height: 8px; border-radius: 4px; background: var(--line); }
.stages i.on { background: var(--moss); }
.stage-list { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.stage-list li { padding: 3px 0; color: var(--muted); }
.stage-list li.on { color: var(--moss-d); font-weight: 700; }
.stage-list li.on::before { content: "✓ "; }
.stage-list li.next { color: var(--ink); font-weight: 700; }
.stage-list li.next::before { content: "→ "; }

/* Подарок */
.daily {
  display: flex; align-items: center; gap: 12px; margin-top: 14px;
  background: linear-gradient(#fff2c4, #ffe79a); border: 2px solid var(--gold); border-radius: var(--r); padding: 10px 14px;
}
.daily .ic { font-size: 30px; }
.daily .tx { flex: 1; font-weight: 700; }
.daily .tx small { display: block; font-weight: 400; color: var(--bark2); }
.daily .btn { width: auto; padding: 9px 16px; }
.streak { display: flex; gap: 4px; margin: 8px 0; }
.streak i { flex: 1; height: 8px; border-radius: 4px; background: var(--line); }
.streak i.on { background: var(--gold); }

/* Об игре */
.about { margin-top: 28px; text-align: center; }
.about img { width: 100%; height: auto; border-radius: 18px; box-shadow: 0 3px 0 #00000022; aspect-ratio: 3 / 1; object-fit: cover; }
.about p { max-width: 640px; margin: 0 auto; color: var(--bark2); }
footer {
  max-width: 980px; margin: 0 auto; padding: 14px 14px calc(26px + env(safe-area-inset-bottom));
  display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: space-between; font-size: 12px; color: var(--muted);
}
footer a { color: var(--moss-d); }

/* Всплывашки */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 60; }
.toast { background: #2c2116ee; color: #fff3d6; padding: 8px 16px; border-radius: 999px; font-weight: 700; font-size: 15px; animation: toast 2.2s forwards; box-shadow: 0 3px 10px #0005; }
.toast.good { background: #36592aee; }
.toast.bad { background: #8a3220ee; }

@keyframes bob { 50% { transform: translateY(-5px) scale(1.06); } }
@keyframes pulse { 50% { transform: scale(1.35); } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes toast { 0% { transform: translateY(12px); opacity: 0; } 10%, 80% { transform: none; opacity: 1; } 100% { opacity: 0; transform: translateY(-8px); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
