/* Спільні стилі: панель, шапка, шторки, підказки. Модулі мають свої css/*.css */
:root {
  --ink: #0b2236;
  --muted: #4a5a68;
  --glass: rgba(255, 255, 255, 0.16);
  --glass-line: rgba(255, 255, 255, 0.28);
  --accent: #ffb547;
  --sea: #0b6e8a;
  --chip: #ece6d9;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #062033; overflow: hidden; }
body { font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; color: #fff; }
canvas#tank { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* Нижня панель: великі круглі кнопки для пальця дитини (≥ 60 px), підписи - тільки підказкою мишкою.
   Кнопки додають різні модулі (до 9-10): на вузькому екрані панель переноситься у два ряди. */
.bar {
  --btn: 64px;
  position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 3;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; padding: 8px;
  width: max-content; max-width: calc(100% - 24px);
  background: rgba(6, 46, 70, 0.32); border: 1px solid var(--glass-line);
  border-radius: calc(var(--btn) / 2 + 8px); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: opacity .5s, transform .5s;
}
button { font: inherit; border: 0; cursor: pointer; border-radius: 999px; padding: 10px 16px; white-space: nowrap;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.bar button {
  position: relative; width: var(--btn); height: var(--btn); padding: 0; flex: none;
  display: grid; place-items: center;
  color: #fff; background: rgba(255,255,255,0.2); box-shadow: inset 0 -3px 0 rgba(0,0,0,0.14);
  transition: transform .12s, background .2s;
}
.bar button .ico { font-size: calc(var(--btn) * 0.46); line-height: 1; }
.bar button.main {
  width: calc(var(--btn) * 1.2); height: calc(var(--btn) * 1.2);
  background: var(--accent); color: var(--ink); box-shadow: 0 4px 14px rgba(255,181,71,0.45), inset 0 -4px 0 rgba(0,0,0,0.12);
}
.bar button.main .ico { font-size: calc(var(--btn) * 0.62); font-weight: 700; }
.bar button:active { transform: scale(0.88); }
.bar button.boing { animation: boing .45s cubic-bezier(.3,1.6,.5,1); }
@keyframes boing { 0% { transform: scale(.85); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
.bar button.pulse { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.15); box-shadow: 0 0 0 10px rgba(255,255,255,0.35); } }
/* Підпис: читати дитині не треба, але мама з мишкою побачить підказку. */
.bar .lbl {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  padding: 5px 10px; border-radius: 10px; background: rgba(0,0,0,0.6); color: #fff; font-size: 13px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
@media (hover: hover) and (pointer: fine) { .bar button:hover .lbl { opacity: 1; } .bar button:hover { background: rgba(255,255,255,0.28); } .bar button.main:hover { background: #ffc46b; } }
.bar button:focus-visible, .parent-btn:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }
@media (max-width: 480px) { .bar { --btn: 60px; gap: 8px; padding: 7px; } }
@media (min-width: 700px) and (min-height: 600px) { .bar { --btn: 70px; gap: 12px; padding: 10px; } }

.hidden { display: none !important; }

.title {
  position: fixed; left: 16px; top: max(14px, env(safe-area-inset-top)); max-width: calc(100% - 190px); z-index: 2;
  padding: 8px 14px; border-radius: 16px; background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.title b { display: block; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title span { display: block; font-size: 13px; opacity: 0.85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.travellers { position: fixed; left: 16px; top: calc(max(14px, env(safe-area-inset-top)) + 64px); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
/* «Рибка мандрує»: кнопка для пальця дитини, не менше 56 px заввишки. */
.chip { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 6px 16px 6px 10px; background: rgba(0,0,0,0.3); color: #fff; font-size: 15px; }
.chip img { width: 52px; height: 36px; object-fit: contain; }
.news {
  position: fixed; right: 16px; top: calc(max(14px, env(safe-area-inset-top)) + 64px); max-width: min(320px, calc(100% - 32px));
  padding: 10px 14px; border-radius: 16px; background: rgba(255, 236, 140, 0.95); color: #3a2a00; font-size: 14px;
  display: grid; gap: 4px; opacity: 0; transform: translateY(-8px); transition: .4s; pointer-events: none;
}
.news.show { opacity: 1; transform: none; }
.sheet { position: fixed; inset: 0; z-index: 20; display: none; align-items: flex-end; justify-content: center; padding: 12px; background: rgba(2,14,24,0.45); }
.sheet.open { display: flex; }
.sheet-box {
  width: min(440px, 100%); max-height: calc(100dvh - 24px); overflow-y: auto; background: #fdfaf3; color: var(--ink); border-radius: 22px; padding: 18px;
  display: grid; gap: 8px; margin-bottom: max(0px, env(safe-area-inset-bottom));
}
.sheet-box h3 { margin: 0; font-size: 19px; }
.sheet-box p { margin: 0 0 6px; color: var(--muted); }
.sheet-box button { background: var(--chip); color: var(--ink); padding: 12px; min-height: 56px; white-space: normal; }
.sheet-box button.main { background: var(--sea); color: #fff; font-weight: 600; }
.sheet-box input { font: inherit; min-height: 52px; padding: 11px 14px; border-radius: 12px; border: 1px solid #d9d2c3; }
.sheet-img { width: 120px; max-height: 80px; object-fit: contain; justify-self: center; background: linear-gradient(#3fa9c9, #0d5a80); border-radius: 12px; padding: 6px; }

.toast {
  position: fixed; left: 50%; bottom: calc(max(14px, env(safe-area-inset-bottom)) + var(--bar-h, 80px) + 12px); transform: translateX(-50%);
  max-width: calc(100% - 32px); z-index: 100;
  padding: 10px 16px; border-radius: 999px; background: rgba(0,0,0,0.45);
  opacity: 0; transition: opacity .3s; pointer-events: none; text-align: center;
}
.toast.show { opacity: 1; }
/* Мушлі */
.shells {
  position: fixed; right: 80px; top: max(14px, env(safe-area-inset-top)); z-index: 4;
  height: 56px; padding: 0 16px; font-size: 17px; background: var(--glass); border: 1px solid var(--glass-line); color: #fff; font-weight: 600;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.shells.bump { animation: bump .5s; }
@keyframes bump { 30% { transform: scale(1.25); } }
.shell-fly { position: fixed; z-index: 6; pointer-events: none; font-weight: 700; color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.4); animation: fly 1.4s ease-out forwards; transform: translate(-50%, -50%); }
@keyframes fly { to { transform: translate(-50%, -160%); opacity: 0; } }

/* Вхід у зону «Для дорослих»: кутик угорі праворуч */
.parent-btn {
  position: fixed; right: 16px; top: max(14px, env(safe-area-inset-top)); z-index: 4;
  width: 56px; height: 56px; padding: 0; font-size: 26px; line-height: 1;
  background: var(--glass); border: 1px solid var(--glass-line); color: #fff;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: opacity .5s;
}

/* Замок «натисни й утримуй» */
.gate { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px;
  background: rgba(2,14,24,0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fadein .2s; }
.gate-box { width: min(340px, 100%); background: #fdfaf3; color: var(--ink); border-radius: 26px; padding: 22px 20px 16px;
  display: grid; justify-items: center; gap: 12px; text-align: center; }
.gate-title { font-size: 20px; font-weight: 700; }
.gate-hold { position: relative; width: 96px; height: 96px; flex: 0 0 auto; padding: 0; background: none; border-radius: 50%;
  display: grid; place-items: center; transition: transform .08s; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
.gate-hold svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.gate-hold span { font-size: 40px; font-weight: 800; width: 70px; height: 70px; border-radius: 50%; display: grid; place-items: center; background: #ffe7b8; }
.gate-hold.ready span { background: #bfe8c9; }
.gate-hold.nope { animation: nope .35s; }
@keyframes nope { 25% { translate: -6px 0; } 75% { translate: 6px 0; } }
.gate-digits { display: flex; gap: 10px; justify-content: center; }
.gate-ask { margin: 0; font-size: 18px; font-weight: 600; }
.gate-hold.holding span { background: #ffd27a; }
.gate-track { fill: none; stroke: #e8e1d2; stroke-width: 12; }
.gate-fill { fill: none; stroke: var(--sea); stroke-width: 12; stroke-linecap: round; }
.gate-hint { margin: 0; color: var(--muted); font-size: 16px; }
.gate-back { background: var(--chip); color: var(--ink); min-height: 56px; min-width: 160px; }
@keyframes fadein { from { opacity: 0; } }

/* Список рибок у зоні дорослих */
.fish-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.fish-pick button { display: grid; justify-items: center; gap: 4px; padding: 10px; border-radius: 16px; background: var(--chip); color: var(--ink); white-space: normal; }
.fish-pick img { width: 90px; height: 56px; object-fit: contain; background: linear-gradient(#3fa9c9, #0d5a80); border-radius: 10px; padding: 4px; }

/* Хто годує рибок: великі кнопки з личками, без поля для тексту */
.who-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.who-pick button { display: grid; justify-items: center; gap: 2px; min-height: 92px; padding: 8px 4px; border-radius: 18px; background: var(--chip); color: var(--ink); white-space: normal; }
.who-pick button span { font-size: 40px; line-height: 1.1; }
.who-pick button b { font-size: 15px; font-weight: 700; line-height: 1.15; }
.who-pick button:active { transform: scale(.96); }

/* Прибрані рибки: малюнок, ім'я, «Повернути» */
.removed-list { display: grid; gap: 8px; max-height: 52vh; overflow-y: auto; }
.removed-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px; border-radius: 16px; background: var(--chip); }
.removed-row img { width: 90px; height: 56px; object-fit: contain; background: linear-gradient(#3fa9c9, #0d5a80); border-radius: 10px; padding: 4px; }
.removed-row span { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.removed-row button { min-height: 56px; padding: 0 16px; }

/* Перший запуск: рука-підказка */
.onboard { position: fixed; inset: 0; z-index: 10; pointer-events: none; opacity: 0; transition: opacity .4s; }
.onboard.show { opacity: 1; }
.ob-hand { position: absolute; font-size: 78px; line-height: 1; transform: translate(-30%, -8%); filter: drop-shadow(0 6px 10px rgba(0,0,0,.35)); transition: transform .15s; }
.ob-hand.press { transform: translate(-30%, -8%) scale(.82); }
.ob-ring { position: absolute; width: 90px; height: 90px; margin: -45px 0 0 -45px; border-radius: 50%; border: 5px solid rgba(255,255,255,.9); opacity: 0; }
.ob-ring.go { animation: ring .9s ease-out; }
@keyframes ring { from { transform: scale(.2); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.ob-ok { position: absolute; left: 50%; transform: translateX(-50%); top: auto; bottom: calc(var(--bar-h, 120px) + max(28px, env(safe-area-inset-bottom))); pointer-events: auto;
  display: flex; align-items: center; gap: 8px; min-height: 60px; padding: 0 20px 0 14px; font-size: 17px;
  background: #fff; color: var(--ink); box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.ob-ok span { font-size: 32px; }
@media (prefers-reduced-motion: reduce) { .bar button.boing, .bar button.pulse { animation: none; } }

/* У студії внизу інструменти: підказки показуємо згори, під верхніми кнопками. */
body.studio-open .toast { top: calc(max(14px, env(safe-area-inset-top)) + 96px); bottom: auto; }
/* Пока відкрита листівка чи альбом, знайомство з акваріумом ховаємо, щоб не налазило. */
body:has(.soc-layer.open) .onboard, body:has(.soc-album.open) .onboard { display: none; }

/* Тихий акваріум: через 8 с без дотиків ховаємо все, крім самого акваріума. */
#bar, .title, .travellers, .shells, .parent-btn, .news, .moon, #care-root > * { transition: opacity .7s ease; }
body.calm #bar, body.calm .title, body.calm .travellers, body.calm .shells, body.calm .parent-btn,
body.calm .news, body.calm .moon, body.calm #care-root > * { opacity: 0 !important; pointer-events: none !important; }
/* Підказку («👵 Бабуся годує рибок») НЕ ховаємо: це живий момент саме для дитини, яка просто дивиться. */
/* Поки відкритий магазин чи прикрашання, підказка-знайомство не налазить. */
body.dc-shopping .onboard, body.dc-on .onboard { display: none; }

/* Замок до пошти: рибку видно, решта - після дорослого (js/account.js) */
.reglock { position: fixed; inset: 0; z-index: 9; display: flex; align-items: flex-end; justify-content: center; padding: 12px 12px max(12px, env(safe-area-inset-bottom)); background: linear-gradient(to top, rgba(2,14,24,0.6), rgba(2,14,24,0) 60%); }
.reglock-card { width: min(440px, 100%); background: #fdfaf3; color: var(--ink); border-radius: 22px; padding: 18px; display: grid; gap: 8px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,0.3); }
.reglock-card h3 { margin: 0; font-size: 21px; }
.reglock-card p { margin: 0 0 6px; color: var(--muted); font-size: 16px; }
.reglock-card button { background: var(--sea); color: #fff; font-weight: 600; padding: 12px; min-height: 56px; }

/* Талісман Абу на картці «поклич дорослого» і в шторках: без синьої підкладки, вона сама яскрава. */
.reglock-abu { width: 132px; height: auto; justify-self: center; margin: -62px 0 -2px; filter: drop-shadow(0 6px 10px rgba(2,14,24,0.3)); pointer-events: none; }
.sheet-img[src*="assets/abu/"] { background: none; padding: 0; width: 132px; max-height: 110px; }
