/* =====================================================================
   ONLINE FARM — базові стилі: токени, reset, кнопки, поля, тости
   ===================================================================== */
:root {
  /* 29.10.2026: Fredoka не має кирилиці (українські літери й цифри виходили різними шрифтами) — усе на Nunito */
  --font-display: "Nunito", system-ui, "Segoe UI", Roboto, sans-serif;
  --font-body: "Nunito", system-ui, "Segoe UI", Roboto, sans-serif;

  --ink: #3b2a1a;            /* основний текст — теплий темно-коричневий */
  --ink-soft: #7a6450;
  --cream: #fff9ec;
  --cream-2: #fff1d6;
  --paper-edge: #e8cfa2;

  --grass: #5fbf45;
  --grass-dark: #3a8f2e;
  --sky: #7fd0ff;

  --gold-1: #ffe066; --gold-2: #ffb81c; --gold-edge: #c9780a;
  --green-1: #8ee05c; --green-2: #45b336; --green-edge: #2b7d22;
  --blue-1: #7dd6ff; --blue-2: #2fa4f0; --blue-edge: #1a6fb0;
  --red-1: #ff8a7a; --red-2: #e5483a; --red-edge: #a42a20;

  --ok: #2f9e44;
  --err: #d6402f;

  --r-sm: 12px; --r-md: 18px; --r-lg: 26px;
  --shadow-1: 0 2px 0 rgba(0,0,0,.08), 0 6px 16px rgba(59,42,26,.14);
  --shadow-2: 0 4px 0 rgba(0,0,0,.08), 0 18px 40px rgba(59,42,26,.22);
  --ease-pop: cubic-bezier(.34,1.56,.64,1);

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--ink);
  background: #9fdc7c;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #2fa4f0; outline-offset: 2px; border-radius: 8px; }

/* ---------- Кнопки: «3D» з нижнім краєм, що натискається ---------- */
.btn {
  --b1: var(--gold-1); --b2: var(--gold-2); --edge: var(--gold-edge);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 54px; padding: 0 24px;
  border: 0; border-radius: var(--r-md);
  background: linear-gradient(180deg, var(--b1), var(--b2));
  box-shadow: 0 5px 0 var(--edge), 0 10px 18px rgba(0,0,0,.18), inset 0 2px 0 rgba(255,255,255,.55);
  font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; letter-spacing: .02em;
  color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.22);
  text-decoration: none; cursor: pointer; user-select: none;
  transition: transform .12s ease, box-shadow .12s ease, filter .15s ease;
  touch-action: manipulation;
}
.btn::after { /* відблиск */
  content: ""; position: absolute; left: 10px; right: 10px; top: 5px; height: 40%;
  border-radius: 12px 12px 30px 30px; background: linear-gradient(180deg, rgba(255,255,255,.45), rgba(255,255,255,0));
  pointer-events: none;
}
.btn:hover { filter: brightness(1.05) saturate(1.05); }
.btn:active, .btn.is-pressed { transform: translateY(4px); box-shadow: 0 1px 0 var(--edge), 0 4px 8px rgba(0,0,0,.18), inset 0 2px 0 rgba(255,255,255,.5); }
.btn[disabled], .btn.is-loading { cursor: default; filter: saturate(.6) brightness(.95); }
.btn-gold  { --b1: var(--gold-1);  --b2: var(--gold-2);  --edge: var(--gold-edge); color: #6b3b00; text-shadow: 0 1px 0 rgba(255,255,255,.5); }
.btn-green { --b1: var(--green-1); --b2: var(--green-2); --edge: var(--green-edge); }
.btn-blue  { --b1: var(--blue-1);  --b2: var(--blue-2);  --edge: var(--blue-edge); }
.btn-red   { --b1: var(--red-1);   --b2: var(--red-2);   --edge: var(--red-edge); }
.btn-block { width: 100%; }

.btn.is-loading .btn-label { opacity: 0; }
.btn.is-loading::before {
  content: ""; position: absolute; width: 24px; height: 24px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.55); border-top-color: currentColor;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Тости ---------- */
.toast-stack {
  position: fixed; z-index: 100; left: 50%; top: calc(12px + var(--safe-t));
  transform: translateX(-50%); width: min(92vw, 420px);
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--r-md);
  background: rgba(255,249,236,.96); box-shadow: var(--shadow-2);
  border: 2px solid var(--paper-edge);
  font-weight: 800; pointer-events: auto;
  animation: toast-in .35s var(--ease-pop) both;
}
.toast.out { animation: toast-out .25s ease forwards; }
.toast-ok { border-color: #9edb8a; }
.toast-err { border-color: #f2a196; }
.toast-ico { font-size: 1.3rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }

/* ---------- Сцена-фон ---------- */
.scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.scene-svg { width: 100%; height: 100%; }

/* Намальована ферма на передньому плані сцени входу (scene.php) */
.scene-props { position: absolute; left: 0; right: 0; bottom: 0; height: 40vh; }
.sp { position: absolute; height: auto; filter: drop-shadow(0 4px 4px rgba(0,0,0,.12)); }
.sp img { display: block; width: 100%; height: auto; }
.sp-tree1  { left: 0;    bottom: 22%; width: clamp(90px, 10vw, 170px); }
.sp-pine   { left: 17%;  bottom: 26%; width: clamp(50px, 5vw, 90px); }
.sp-barn   { left: 4%;   bottom: 12%; width: clamp(140px, 15vw, 260px); }
.sp-hay    { left: 21%;  bottom: 9%;  width: clamp(60px, 6vw, 110px); }
.sp-cow    { left: 25%;  bottom: 2%;  width: clamp(60px, 6vw, 110px); animation: sp-bob 1.6s ease-in-out infinite alternate; transform-origin: 50% 100%; }
.sp-fl1    { left: 7%;   bottom: 0;   width: clamp(70px, 7vw, 120px); }
.sp-fence1 { left: -1%;  bottom: 1%;  width: 26vw; }
.sp-tree2  { right: 1%;  bottom: 28%; width: clamp(80px, 8vw, 150px); }
.sp-house  { right: 3%;  bottom: 10%; width: clamp(170px, 19vw, 330px); }
.sp-mill   { right: 23%; bottom: 14%; width: clamp(80px, 8vw, 140px); }
.sp-blades { position: absolute; left: 47.86%; top: 37.5%; width: 90.71%; transform: translate(-50%, -50%); }
.sp-blades img { animation: sp-spin 10s linear infinite; }
.sp-bush   { right: 30%; bottom: 7%;  width: clamp(70px, 6vw, 110px); }
.sp-sheep  { right: 26%; bottom: 1%;  width: clamp(50px, 5vw, 90px); animation: sp-bob 1.9s ease-in-out infinite alternate; transform-origin: 50% 100%; }
.sp-chick  { right: 21%; bottom: 1%;  width: clamp(34px, 3.4vw, 60px); animation: sp-peck 2.6s ease-in-out infinite; transform-origin: 50% 100%; }
.sp-fl2    { right: 9%;  bottom: 0;   width: clamp(70px, 7vw, 120px); }
.sp-fence2 { right: -1%; bottom: 1%;  width: 26vw; }
@keyframes sp-spin { to { transform: rotate(360deg); } }
@keyframes sp-bob { from { transform: rotate(-2deg); } to { transform: translateY(-3px) rotate(2deg); } }
@keyframes sp-peck { 0%, 60%, 100% { transform: rotate(0); } 70%, 80% { transform: rotate(-24deg); } }
/* Телефон: картка займає майже весь екран — лишаємо небагато, щоб не було тісно */
@media (max-width: 699px) {
  .scene-props { height: 30vh; }
  .sp-pine, .sp-hay, .sp-mill, .sp-bush, .sp-chick, .sp-tree2, .sp-fl1, .sp-fl2 { display: none; }
  .sp-barn { left: -6%; width: 42vw; bottom: 6%; } .sp-house { right: -8%; width: 50vw; bottom: 5%; }
  .sp-cow { left: 30%; width: 18vw; } .sp-sheep { right: 30%; width: 14vw; }
  .sp-fence1, .sp-fence2 { width: 52vw; } .sp-tree1 { width: 26vw; bottom: 18%; }
}
.cloud { animation: drift 60s linear infinite alternate; }
.cloud.c2 { animation-duration: 80s; }
.cloud.c3 { animation-duration: 95s; animation-direction: alternate-reverse; }
@keyframes drift { from { transform: translateX(-60px); } to { transform: translateX(120px); } }

.big-emoji { font-size: 56px; line-height: 1; filter: drop-shadow(0 6px 6px rgba(0,0,0,.15)); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Перемикач мови ---------- */
.lang-switch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.lang-switch button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 0;
  min-height: 56px; padding: 4px; border-radius: 14px; border: 2px solid var(--paper-edge); background: #fff;
  font: inherit; font-size: .84rem; font-weight: 800; color: var(--ink); cursor: pointer; white-space: nowrap;
}
.lang-switch button span { font-size: 1.25rem; line-height: 1; }
.lang-switch button.on { background: linear-gradient(180deg, var(--green-1), var(--green-2)); border-color: #fff; color: #fff; box-shadow: 0 3px 0 var(--green-edge); text-shadow: 0 1px 0 rgba(0,0,0,.2); }
.lang-switch button:disabled { opacity: .6; }
.lang-switch.short { position: relative; z-index: 5; align-self: flex-end; display: flex; gap: 4px; margin: 0 0 6px; }
.lang-switch.short button { flex-direction: row; gap: 4px; min-height: 36px; padding: 0 10px; border-radius: 12px; font-size: .82rem; background: rgba(255,255,255,.85); }
.lang-switch.short button span { font-size: 1rem; }
.lang-switch.short button.on { background: linear-gradient(180deg, var(--green-1), var(--green-2)); }

/* ---------- BBCode у повідомленнях (HTML створює лише сервер: BBCode::render) ---------- */
.bb { overflow-wrap: anywhere; word-break: break-word; }
.bb strong { font-weight: 800; }
.bb .bb-u { text-decoration: underline; }
.bb-size-10 { font-size: .72em; } .bb-size-12 { font-size: .86em; } .bb-size-14 { font-size: 1em; } .bb-size-16 { font-size: 1.14em; }
.bb-size-18 { font-size: 1.28em; } .bb-size-20 { font-size: 1.42em; } .bb-size-24 { font-size: 1.7em; line-height: 1.2; }
.bb-quote { margin: 4px 0; padding: 6px 10px; border-left: 4px solid #e8b26a; border-radius: 8px; background: rgba(232,178,106,.16); font-style: italic; }
.bb-quote .bb-quote { background: rgba(232,178,106,.12); }
.bb-code { display: block; margin: 4px 0; padding: 8px 10px; border-radius: 8px; background: #2c2a26; color: #f6e6c4; font: 600 .86em/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; }
.bb-url { color: #1f74c4; font-weight: 800; text-decoration: underline; }

/* Емодзі в тексті → намальована іконка гри (iconize.js) — на всіх сторінках */
.inl-ico { display: inline-block; width: 1.25em; height: 1.25em; margin: 0 .05em; vertical-align: -.28em; object-fit: contain; pointer-events: none; }
.inl-txt { display: inline; }
