/* Стилі плагіна town-map — мапа «Бобрового містечка» на головній */

/* ---------- верхній рядок ---------- */
.tm-top { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.tm-top .course-switch, .tm-top .review-card { margin: 0 !important; }
.tm-top .course-switch { align-self: flex-start; }
.tm-extras { margin-top: 4px; }

/* ---------- рамка й в'юпорт ---------- */
.tm { margin: 0 0 24px; min-width: 0; }
/* полотно ширше за колонку: не даємо йому розпирати сітку макета */
.tm-frame { width: 0; min-width: 100%; contain: inline-size; }
.tm-frame {
  position: relative; border-radius: var(--win-r, 28px); overflow: hidden; isolation: isolate;
  background: #9cc98a; box-shadow: var(--glass-edge), var(--glass-shadow);
}
.tm-view {
  height: min(512px, 72vh); min-height: 340px; overflow: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; cursor: grab;
  scrollbar-width: thin; scrollbar-color: rgba(59, 47, 42, .35) transparent; outline: none;
}
.tm-view:focus-visible { box-shadow: inset 0 0 0 3px var(--accent); }
.tm-view.dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.tm-view.dragging .tm-lot { pointer-events: none; }
.tm-canvas { position: relative; flex: none; overflow: hidden; }
.tm-bg { position: absolute; left: 0; top: 0; display: block; font-family: var(--font-round, inherit); }

/* ---------- палітра сцени (тема «Містечко» за замовчуванням) ---------- */
.tm-grass { fill: #9cc98a; }
.tm-grass2 { fill: #8cc07a; opacity: .55; }
.tm-tuft { fill: none; stroke: #6fa865; stroke-width: 1.4; stroke-linecap: round; }
.tm-bush { fill: #5e9e62; stroke: #3b2f2a; stroke-width: 1.6; }
.tm-berry { fill: #e8584f; }
.tm-shade { fill: #3b2f2a; opacity: .14; }
.tm-post { fill: #6b5a4e; }
.tm-lamp-head { fill: #3b2f2a; }
.tm-lamp-glow { fill: #ffe39a; opacity: 0; }
.tm-wood { fill: #a0673c; stroke: #3b2f2a; stroke-width: 1; }
.tm-picket { fill: #fff4e0; stroke: #8d7b6b; stroke-width: 1; }
.tm-rail { fill: #fff4e0; stroke: #8d7b6b; stroke-width: .8; }
.tm-bed { fill: #8a5a3a; stroke: #6d4529; stroke-width: 1.2; }
.tm-flower { stroke: rgba(59, 47, 42, .35); stroke-width: .6; }
.tm-plate { stroke: #3b2f2a; stroke-width: 1.6; }
.tm-plate-in { stroke: rgba(255, 255, 255, .7); stroke-width: 1.2; }
.tm-plate-t { fill: #fff; font-size: 11.5px; font-weight: 800; letter-spacing: .01em; }
.tm-sub-t { fill: #3b2f2a; font-size: 9.5px; font-weight: 700; opacity: .6; paint-order: stroke; stroke: #9cc98a; stroke-width: 3px; }
.tm-hedge { fill: #5e9e62; stroke: #3b2f2a; stroke-width: 1.6; }
.tm-paving { fill: #eadcc0; stroke: #c9b48f; stroke-width: 2; }
.tm-paving-ring { fill: none; stroke: #d9c7a4; stroke-width: 10; stroke-dasharray: 3 5; }
.tm-plaza-path { stroke: #d9c7a4; stroke-width: 12; stroke-linecap: round; }
.tm-basin { fill: #d9d0c4; stroke: #3b2f2a; stroke-width: 1.8; }
.tm-pool { fill: #8fd0ef; }
.tm-ripple { fill: none; stroke: #e3f4fc; stroke-width: 2; transform-box: fill-box; transform-origin: center; animation: tm-ripple 2.6s ease-out infinite; }
.tm-spray { fill: #e3f4fc; stroke: #8fd0ef; stroke-width: 1; }
.tm-jet { transform-box: fill-box; transform-origin: center; animation: tm-jet 1.3s ease-in-out infinite; }
.tm-bank { fill: none; stroke: #c9b48f; stroke-linecap: round; }
ellipse.tm-bank { fill: #c9b48f; stroke: none; }
.tm-river { fill: none; stroke: #8fd0ef; stroke-linecap: round; }
ellipse.tm-river { fill: #8fd0ef; stroke: none; }
.tm-river-hi { fill: none; stroke: #a7dcf4; stroke-linecap: round; }
.tm-glint { fill: none; stroke: #f4fbff; stroke-width: 2.4; stroke-linecap: round; opacity: .9; }
.tm-wave { fill: none; stroke: #e3f4fc; stroke-width: 2; stroke-dasharray: 10 22; stroke-linecap: round; animation: tm-wave 4s linear infinite; }
.tm-bshadow { fill: #3b2f2a; opacity: .14; }
.tm-deck { fill: #a0673c; stroke: #3b2f2a; stroke-width: 1.8; }
.tm-brail { fill: #c98a55; stroke: #3b2f2a; stroke-width: 1.2; }
.tm-bpost { fill: #83522d; stroke: #3b2f2a; stroke-width: 1; }
.tm-road-fill { fill: #d9c7a4; }
.tm-sidewalk { fill: none; stroke: #efe3c8; stroke-linejoin: round; }
.tm-road-edge { fill: none; stroke: #c9b48f; stroke-linejoin: round; }
.tm-road { fill: none; stroke: #d9c7a4; stroke-linejoin: round; }
.tm-lane { fill: none; stroke: #fff8ea; stroke-width: 2.4; stroke-dasharray: 12 12; stroke-linecap: round; }
.tm-sidewalk-f { fill: #efe3c8; }
.tm-road-edge-f { fill: #c9b48f; }
.tm-island { fill: #7fb069; stroke: #3b2f2a; stroke-width: 1.6; }
.tm-side-walk { fill: none; stroke: #efe3c8; stroke-linecap: round; }
.tm-side-road { fill: #d9c7a4; stroke: #d9c7a4; stroke-linecap: round; }
.tm-zebra { fill: #fffaf0; opacity: .95; }
.tm-hull { fill: #c4553a; stroke: #3b2f2a; stroke-width: 1.4; }
.tm-sail { fill: #fff4e0; stroke: #3b2f2a; stroke-width: 1.2; }
.tm-boat { transform: translate(var(--bx), var(--by)); animation: tm-boat 16s ease-in-out infinite alternate; }
.tm-board { fill: #a0673c; stroke: #3b2f2a; stroke-width: 2.2; }
.tm-board-in { fill: #fff4e0; stroke: #c98a55; stroke-width: 1.4; }
.tm-board-t { fill: #3b2f2a; font-size: 19px; font-weight: 800; }
.tm-board-s { fill: #c4553a; font-size: 12px; font-weight: 700; }

.tm-far { fill: #b9dca6; }
.tm-hill-far { fill: #a9d18e; }
.tm-hill { fill: #8cc07a; stroke: #6fa865; stroke-width: 2; }
.tm-curb { fill: none; stroke: rgba(201, 180, 143, .55); stroke-width: 1; stroke-dasharray: 18 3; }
.tm-lane.thin { stroke-width: 1.8; stroke-dasharray: 8 10; }
.tm-awning { fill: #fff4e0; stroke: #3b2f2a; stroke-width: 1.6; stroke-linejoin: round; }
.tm-stall0 .tm-awning-s, .tm-awning-s { fill: none; stroke: #e07a4f; stroke-width: 5; }
.tm-awning-e { fill: none; stroke: #3b2f2a; stroke-width: 1.4; }
.tm-fruit { stroke: #3b2f2a; stroke-width: 1; }
.tm-stone { fill: #d9d0c4; stroke: #3b2f2a; stroke-width: 1.6; }
.tm-roof { fill: #c4553a; stroke: #3b2f2a; stroke-width: 1.6; stroke-linejoin: round; }
/* фонові будинки: менші, приглушені, без підписів — щоб уроки читалися */
.tm-filler { opacity: .9; }
.tm-filler.far { opacity: .78; }
.tm-filler.plot { opacity: .6; }
.tm-hall { opacity: 1; }

/* ---------- ділянки ---------- */
.tm-lot {
  position: absolute; width: 116px; height: 116px; padding: 0; margin: 0; border: 0; background: none;
  cursor: pointer; color: var(--label); font: inherit; -webkit-tap-highlight-color: transparent; z-index: 2;
  border-radius: 18px;
}
.tm-lot:hover, .tm-lot:focus-visible { z-index: 6; }
.tm-lot:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tm-yard {
  position: absolute; left: 14px; right: 14px; bottom: 4px; height: 22px; border-radius: 10px;
  background: #b5dba0; transform: skewX(-30deg);
  box-shadow: inset 0 0 0 2px rgba(59, 47, 42, .14), 4px 4px 0 rgba(59, 47, 42, .12);
}
.tm-lot.site .tm-yard { background: #e6cf9f; }
.tm-lot.locked .tm-yard { background: transparent; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .55); border: 0; outline: 2px dashed rgba(59, 47, 42, .22); outline-offset: -2px; }
.tm-art { position: absolute; inset: 0; display: block; transition: transform .25s var(--ease, ease); transform-origin: 50% 90%; }
.tm-art svg { display: block; width: 100%; height: 100%; overflow: visible; }
.tm-lot.built .tm-art { filter: drop-shadow(5px 3px 0 rgba(59, 47, 42, .16)); }
.tm-lot.locked .tm-art { opacity: .78; }
.tm-lot:hover .tm-art, .tm-lot:focus-visible .tm-art { transform: translateY(-4px) scale(1.03); }
.tm-lot:active .tm-art { transform: scale(.97); }
.tm-no {
  position: absolute; left: 12px; top: 54px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 7px;
  background: rgba(255, 250, 241, .85); color: #7a6553; font-size: 11px; font-weight: 800; line-height: 22px; text-align: center;
  box-shadow: inset 0 0 0 1.5px rgba(90, 60, 30, .2);
}
.tm-tag {
  position: absolute; left: 50%; bottom: calc(100% - 6px); transform: translate(-50%, 6px) scale(.92);
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 11px 7px; border-radius: 12px;
  background: var(--glass-bg); color: var(--label); white-space: nowrap; pointer-events: none;
  box-shadow: var(--glass-edge), var(--glass-shadow); opacity: 0; transition: opacity .18s, transform .22s var(--ease, ease);
  font-size: 12px; line-height: 1.2;
}
.tm-tag b { font-weight: 800; font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px; }
.tm-tag b svg { width: 12px; height: 12px; }
.tm-tag small { color: var(--label2); font-size: 11px; }
.tm-stars { color: #f2b632; font-size: 13px; letter-spacing: 1px; }
.tm-stars i { font-style: normal; color: var(--label3); opacity: .6; }
.tm-lot:hover .tm-tag, .tm-lot:focus-visible .tm-tag { opacity: 1; transform: translate(-50%, 0) scale(1); }
.tm-lot.current .tm-tag { display: none; }
@media (hover: none) {
  /* на дотикових екранах — компактна підпис-зірочки під кожною будівлею */
  .tm-lot.built .tm-tag { opacity: 1; bottom: -14px; padding: 2px 7px 3px; transform: translate(-50%, 0) scale(.82); gap: 0; }
  .tm-lot.built .tm-tag small, .tm-lot.built .tm-tag b { display: none; }
  .tm-lot.built .tm-tag .tm-stars { font-size: 12px; }
}

/* будмайданчик: маркер «Будувати» */
.tm-pin {
  position: absolute; left: 50%; top: -8px; transform: translateX(-50%); z-index: 2;
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; min-height: 36px; border-radius: 999px;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 14px; white-space: nowrap;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .18), 0 10px 22px rgba(0, 0, 0, .18);
  animation: tm-pin 1.8s var(--ease, ease) infinite;
}
.tm-pin svg { width: 14px; height: 14px; }
.tm-pin::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; border: 2px solid var(--accent);
  animation: tm-ring 1.8s ease-out infinite;
}
.tm-pin::after {
  content: ""; position: absolute; left: 50%; bottom: -6px; width: 12px; height: 12px; margin-left: -6px;
  background: var(--accent); transform: rotate(45deg); border-radius: 2px; z-index: -1;
}
.tm-lot.current .tm-yard { box-shadow: 0 0 0 3px var(--accent), 4px 4px 0 rgba(59, 47, 42, .12); animation: tm-yard 1.8s ease-in-out infinite; }

/* ---------- Бобро біля будмайданчика ---------- */
.tm-fox { position: absolute; width: 52px; height: 58px; z-index: 7; pointer-events: none; }
.tm-fox .tm-fox-svg { width: 52px; height: 57px; display: block; filter: drop-shadow(2px 3px 0 rgba(59, 47, 42, .18)); animation: tm-hop 2.4s ease-in-out infinite; }
.tm-bubble {
  position: absolute; top: 2px; padding: 7px 11px; border-radius: 14px; width: max-content; max-width: 190px;
  background: var(--glass-bg); color: var(--label); font-size: 12.5px; line-height: 1.25; font-weight: 600;
  box-shadow: var(--glass-edge), var(--glass-shadow);
  animation: tm-bubble .5s var(--ease, ease) both .3s;
}
.tm-bubble b { color: var(--accent); }
/* бульбашка: під бобром над дорогою (північний ряд) або над ним (південний) */
.tm-fox.down .tm-bubble { top: 60px; left: -40px; border-top-left-radius: 4px; }
.tm-fox.up .tm-bubble { bottom: 60px; top: auto; left: -40px; border-bottom-left-radius: 4px; }
.tm-fox.done .tm-bubble { top: 2px; left: 54px; }

/* ---------- життя ---------- */
.tm-fg { position: absolute; left: 0; top: 0; display: block; pointer-events: none; z-index: 3; }
.tm-traffic { position: absolute; inset: 0; pointer-events: none; z-index: 1; overflow: hidden; }
.tm-car { position: absolute; left: 0; animation: tm-drive 60s linear infinite; }
.tm-car.w { animation-direction: reverse; }
.tm-car.w svg { transform: scaleX(-1); }
.tm-car svg { display: block; }
.tm-car-body { stroke: #3b2f2a; stroke-width: 1.2; }
.tm-car-glass { fill: #cfeaf7; stroke: #3b2f2a; stroke-width: .8; }
.tm-wheel { fill: #3b2f2a; stroke: #8d7b6b; stroke-width: 1.4; }
.tm-headlight { fill: #fff6c8; }
.tm-handle { fill: none; stroke: #6b5a4e; stroke-width: 2.4; stroke-linecap: round; }
.tm-walker { position: absolute; width: 12px; height: 24px; z-index: 4; pointer-events: none; animation: tm-walk 18s linear infinite; }
.tm-walker svg { display: block; overflow: visible; animation: tm-bob .5s ease-in-out infinite alternate; }
.tm-skin { fill: #f2c9a0; stroke: #3b2f2a; stroke-width: .7; }
.tm-skin-d { fill: #4a3a30; }
.tm-leg { transform-box: fill-box; transform-origin: 50% 0; animation: tm-leg .5s ease-in-out infinite alternate; }
.tm-leg-b { animation-direction: alternate-reverse; }
.tm-cloud { position: absolute; left: 0; z-index: 8; pointer-events: none; opacity: .9; animation: tm-cloud 200s linear infinite; }
.tm-cloud svg { display: block; width: 100%; height: auto; }
.tm-birds { position: absolute; left: 0; z-index: 8; pointer-events: none; animation: tm-fly 60s linear infinite; }
.tm-bird { fill: none; stroke: #3b2f2a; stroke-width: 1.8; stroke-linecap: round; transform-box: fill-box; transform-origin: center; animation: tm-flap .45s ease-in-out infinite alternate; }
.tm-bird.b2 { animation-delay: -.2s; }

/* ---------- стрілки ‹ › ---------- */
.tm-arrow {
  position: absolute; top: 50%; z-index: 9; width: 44px; height: 44px; margin-top: -22px; border: 0; border-radius: 50%;
  display: grid; place-items: center; padding: 0 0 3px; cursor: pointer; font: inherit; font-size: 30px; font-weight: 700; line-height: 1;
  background: var(--glass-bg); color: var(--label); box-shadow: var(--glass-edge), var(--glass-shadow);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); transition: opacity .2s, transform .2s var(--ease, ease);
}
.tm-arrow.l { left: 8px; }
.tm-arrow.r { right: 8px; }
.tm-arrow:hover { transform: scale(1.06); }
.tm-arrow:active { transform: scale(.94); }
.tm-frame.at-start .tm-arrow.l, .tm-frame.at-end .tm-arrow.r { opacity: 0; pointer-events: none; }

/* ---------- HUD ---------- */
.tm-hud {
  position: absolute; top: 10px; left: 10px; z-index: 9; width: 196px; padding: 10px 12px 12px; border-radius: 18px;
  background: var(--glass-bg); color: var(--label); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: var(--glass-edge), var(--glass-shadow);
}
.tm-hud-row { display: flex; align-items: center; gap: 9px; }
.tm-hud-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; color: #fff; background: var(--c); }
.tm-hud-ic svg { width: 18px; height: 18px; }
.tm-hud-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.tm-hud-txt small { font-size: 11px; color: var(--label2); }
.tm-hud-txt b { font-size: 14px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-hud-count { margin-top: 8px; font-size: 12.5px; color: var(--label2); }
.tm-hud-count b { color: var(--label); font-weight: 800; }
.tm-hud-bar { height: 7px; margin-top: 5px; border-radius: 99px; background: var(--fill2); overflow: hidden; }
.tm-hud-bar i { display: block; height: 100%; border-radius: inherit; background: var(--green); transition: width .8s var(--ease, ease); }
.tm-hud-go {
  margin-top: 9px; width: 100%; min-height: 44px; border: 0; border-radius: 13px; padding: 8px 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  background: var(--accent); color: #fff; font: inherit; font-size: 13.5px; font-weight: 800;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .15); transition: transform .2s var(--ease, ease);
}
.tm-hud-go svg { width: 16px; height: 16px; }
.tm-hud-go:hover { transform: translateY(-1px); }
.tm-hud-go:active { transform: scale(.97); }
.tm-hud-done { margin-top: 8px; font-weight: 800; color: var(--green); font-size: 13px; }

@media (max-width: 700px) {
  .tm-view { height: min(512px, 64vh); }
  .tm-hud { width: 168px; padding: 8px 10px 10px; top: 8px; left: 8px; border-radius: 16px; }
  .tm-hud-ic { width: 26px; height: 26px; border-radius: 8px; }
  .tm-hud-txt b { font-size: 13px; }
  .tm-hud-count { margin-top: 6px; font-size: 12px; }
  .tm-hud-go { font-size: 12.5px; }
  .tm-bubble { max-width: 150px; font-size: 12px; }
}

/* ---------- анімації ---------- */
@keyframes tm-drive { from { translate: -80px 0; } to { translate: var(--tw, 2000px) 0; } }
@keyframes tm-walk {
  0% { transform: translateX(0) scaleX(1); } 49.9% { transform: translateX(var(--d, 200px)) scaleX(1); }
  50% { transform: translateX(var(--d, 200px)) scaleX(-1); } 100% { transform: translateX(0) scaleX(-1); }
}
@keyframes tm-bob { from { transform: translateY(0); } to { transform: translateY(-1.2px); } }
@keyframes tm-leg { from { transform: rotate(-22deg); } to { transform: rotate(22deg); } }
@keyframes tm-cloud { from { translate: -220px 0; } to { translate: var(--tw, 2000px) 0; } }
@keyframes tm-fly { from { translate: -60px 0; } to { translate: var(--tw, 2000px) 0; } }
@keyframes tm-flap { from { transform: scaleY(1); } to { transform: scaleY(-.5); } }
@keyframes tm-pin { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-5px); } }
@keyframes tm-ring { 0% { opacity: .8; transform: scale(1); } 100% { opacity: 0; transform: scale(1.35, 1.7); } }
@keyframes tm-yard { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 45%, transparent), 4px 4px 0 rgba(59, 47, 42, .12); } }
@keyframes tm-hop { 0%, 70%, 100% { transform: translateY(0); } 80% { transform: translateY(-6px); } 90% { transform: translateY(0); } }
@keyframes tm-bubble { from { opacity: 0; transform: translateY(6px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes tm-ripple { 0% { transform: scale(.5); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }
@keyframes tm-jet { 50% { transform: scale(1.25) translateY(-1px); } }
@keyframes tm-wave { to { stroke-dashoffset: -64; } }
@keyframes tm-boat { from { transform: translate(var(--bx), var(--by)) rotate(-2deg); } to { transform: translate(calc(var(--bx) + 60px), var(--by)) rotate(2deg); } }

/* зменшений рух: усе завмирає (html.no-motion ядро вже вимикає анімації) */
@media (prefers-reduced-motion: reduce) {
  .tm *, .tm *::before, .tm *::after { animation: none !important; transition: none !important; }
}
html.no-motion .tm-bubble { opacity: 1; transform: none; }

@media (max-width: 700px) {
  .tm-arrow { font-size: 26px; }
  .tm-hud-go span { font-size: 12px; }
}

/* ================= Свято, вечір і ніч у місті ================= */
/* Святкові прикраси площі видно лише під час Зимового свята */
.tm-xmas { display: none; }
html[data-event="ny"] .tm-xmas { display: inline; }
.tm-garland-wire { fill: none; stroke: #3b5a3f; stroke-width: 1.6; }
.tm-bulb, .tm-ball { animation: tmTwinkle 1.4s steps(2) infinite; }
@keyframes tmTwinkle { 50% { opacity: .4; } }
.tm-tree-ny { transform-box: fill-box; transform-origin: 50% 100%; transition: transform .6s; }
.tm-tree-star { transform-box: fill-box; transform-origin: center; }
/* Нагорода «Святкова ялинка»: ялинка більша, зірка сяє */
html[data-ny-tree] .tm-tree-ny { transform: scale(1.35); }
html[data-ny-tree] .tm-tree-star { animation: tmStar 2.4s ease-in-out infinite; filter: drop-shadow(0 0 4px #ffd23f); }
@keyframes tmStar { 50% { transform: scale(1.25) rotate(20deg); } }
/* Сніжна земля під час свята */
html[data-event="ny"] .tm-grass { fill: #eef4f8; }
html[data-event="ny"] .tm-grass2 { fill: #ffffff; opacity: .8; }
html[data-event="ny"] .tm-tuft { stroke: #c9d6e2; }
html[data-event="ny"] .tm-far { fill: #e4edf3; }

/* Вечір: теплий відтінок; ніч: темніше, вікна й ліхтарі світяться.
   Тонування — на рамці (а не в контейнері, що гортається): так воно накриває весь екран, а не лише перший кадр панорами */
.tm-view { position: relative; }
.tm-frame::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; transition: background .8s; }
html[data-time="evening"] .tm-frame::after { background: linear-gradient(180deg, rgba(255, 140, 70, .16), rgba(255, 190, 120, .08)); }
html[data-time="night"] .tm-frame::after { background: rgba(18, 28, 64, .38); }
/* (без z-index: як і раніше, тонується фон сцени; ділянки, машинки й бобер лежать вище) */
html[data-time="evening"] .tm-view [fill="#9fd3f0"], html[data-time="night"] .tm-view [fill="#9fd3f0"] { fill: #ffd36b; }
html[data-time="night"] .tm-view [fill="#e3f4fc"] { fill: #fff2c2; }
html[data-time="night"] .tm-lamp-glow, html[data-time="evening"] .tm-lamp-glow { opacity: .6; filter: blur(2px); }
html[data-time="night"] .tm-bulb, html[data-time="night"] .tm-ball { filter: drop-shadow(0 0 3px currentColor); }
@media (prefers-reduced-motion: reduce) { .tm-bulb, .tm-ball, .tm-tree-star { animation: none !important; } }
html.no-motion .tm-bulb, html.no-motion .tm-ball, html.no-motion .tm-tree-star { animation: none !important; }

/* =====================================================================
   МІСТЕЧКО НА ВЕСЬ ЕКРАН (docs/design/screens/town-fullscreen.md)
   Лише сторінка learn: .layout.tf (оболонка shell(…, { full: true })).
   ===================================================================== */
/* Кольори арту над і під полотном (не токени: це кольори сцени) */
.layout.tf { --tm-far-c: #b9dca6; --tm-grass-c: #9cc98a; }
html[data-event="ny"] .layout.tf { --tm-far-c: #e4edf3; --tm-grass-c: #eef4f8; }

/* Без прокрутки документа і без «потягни, щоб оновити» */
html.tf-on, html.tf-on body { overflow: hidden; overscroll-behavior: none; height: 100%; }

.layout.tf {
  display: block; min-height: 0; padding: 0; gap: 0;
  --tf-dead-b: max(env(safe-area-inset-bottom, 0px), 16px);
  /* зона мапи: екран без накладок у стандартному стані (§6) */
  --tf-inset-t: calc(70px + env(safe-area-inset-top, 0px));
  --tf-inset-b: calc(146px + env(safe-area-inset-bottom, 0px));
  --tf-inset-l: 0px; --tf-inset-r: 0px;
}
.layout.tf .main.tf-main { padding: 0; display: block; }

/* ---------- скло накладок ---------- */
.tf-switch, .tf-stats, .tf-drawer, .tf-grip, .layout.tf .tf-rail, .layout.tf .tf-aside, .tf-aside-pill {
  background: var(--glass-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: var(--glass-edge), var(--glass-shadow); color: var(--label);
}
:is(.tf-drawer-toggle, .tf-hide, .tf-grip, .tf-aside-toggle, .tf-links button, .tf-switch):focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- мапа на весь екран ---------- */
.tm.tf-map { position: fixed; inset: 0; margin: 0; z-index: 0; }
.tf-map .tm-frame {
  width: 100%; min-width: 0; height: 100%; border-radius: 0; box-shadow: none; contain: none;
  background: linear-gradient(var(--tm-far-c) 0 50%, var(--tm-grass-c) 50% 100%);
}
.tf-map .tm-view { height: 100%; min-height: 0; overscroll-behavior: none; }
.tf-map .tm-view:focus-visible { box-shadow: inset 0 0 0 3px var(--accent); }
.tm-stage {
  display: flex; align-items: center; width: max-content; min-width: 100%; min-height: 100%; box-sizing: border-box;
  padding: var(--tf-inset-t) 0 var(--tf-inset-b);
}
.tf-map .tm-canvas { zoom: var(--tm-s, 1); }
.tf-zone { position: fixed; top: var(--tf-inset-t); bottom: var(--tf-inset-b); left: var(--tf-inset-l); right: var(--tf-inset-r); visibility: hidden; pointer-events: none; }
.tf-map .tm-arrow {
  width: 48px; height: 48px; margin-top: -24px; z-index: 9;
  top: calc(var(--tf-inset-t) + (100% - var(--tf-inset-t) - var(--tf-inset-b)) / 2);
  transition: opacity .2s, transform .2s var(--ease, ease), right .25s var(--ease, ease);
}
.tf-map .tm-arrow.l { left: calc(var(--tf-inset-l) + 8px); }
.tf-map .tm-arrow.r { right: calc(var(--tf-inset-r) + 8px); }

/* ---------- верхній рядок ---------- */
.tf-top {
  position: fixed; z-index: 20; top: calc(var(--gap) + env(safe-area-inset-top, 0px)); left: var(--gap); right: var(--gap);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none;
}
.tf-top > * { pointer-events: auto; }
.course-switch.tf-switch {
  margin: 0; height: 52px; min-width: 0; flex: 0 1 auto; max-width: 320px; gap: 8px;
  padding: 6px 10px 6px 6px; border-radius: 18px;
}
.tf-switch .cs-ic { width: 40px; height: 40px; border-radius: 12px; }
.tf-switch .cs-ic svg { width: 22px; height: 22px; }
.tf-switch .cs-txt { min-width: 0; overflow: hidden; line-height: 1.15; }
.tf-switch .cs-txt b { font-size: 16px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal; }
.tf-count { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.tf-switch .cs-txt small.tm-hud-count { margin: 0; font-size: 12px; font-weight: 600; color: var(--label2); text-transform: none; letter-spacing: 0; }
.tf-switch .cs-txt small.tm-hud-count b { font-size: inherit; letter-spacing: 0; }
.tf-done { display: none; align-items: center; gap: 3px; font-size: 12px; font-weight: 800; color: var(--green); }
.tf-done svg { width: 14px; height: 14px; }
.tf-bar { display: none; height: 4px; margin-top: 4px; border-radius: 99px; background: var(--fill2); overflow: hidden; }
.tf-bar i { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.tf-switch .cs-chev { margin-left: 2px; flex: none; }
@media (max-width: 379px) { .tf-switch .cs-chev { display: none; } }

.tf-stats { display: flex; align-items: center; height: 52px; padding: 0 10px; border-radius: 18px; flex: none; }
.tf-stats .stats { gap: 8px; }
.layout.tf .tf-stats .stat { background: none; box-shadow: none; padding: 0; gap: 4px; font-size: 15px; font-weight: 800; border-radius: 0; }
.tf-stats .stat .e { font-size: 18px; }

/* ---------- «Будувати» і «До будмайданчика» ---------- */
.tf-cta {
  position: fixed; z-index: 20; display: flex; gap: 8px; align-items: center; transform: translateX(-50%);
  left: calc(var(--tf-inset-l) + (100vw - var(--tf-inset-l) - var(--tf-inset-r)) / 2);
  bottom: calc(154px + env(safe-area-inset-bottom, 0px));
  transition: bottom .25s var(--ease, ease), left .25s var(--ease, ease);
}
.btn.tf-build {
  height: 56px; padding: 0 24px; border-radius: 999px; gap: 8px; display: inline-flex; align-items: center;
  font-size: 18px; font-weight: 800; white-space: nowrap;
}
.btn.tf-build svg { width: 18px; height: 18px; }
html[data-theme="town"] .btn.tf-build { background: var(--accent); color: #fff; border-radius: 999px; box-shadow: 0 4px 0 var(--accent-deep); }
html[data-theme="town"] .btn.tf-build:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--accent-deep); }
.btn.tf-build:focus-visible { outline: 3px solid var(--label); outline-offset: 3px; }
.tf-cta { opacity: 1; transition: opacity .15s, visibility 0s, bottom .25s var(--ease, ease), left .25s var(--ease, ease); }
.tf-cta.off { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .15s, visibility 0s .15s, bottom .25s var(--ease, ease), left .25s var(--ease, ease); }
@media (prefers-reduced-motion: reduce) { .tf-cta, .tf-cta.off { transition: none; } }
html.no-motion .tf-cta, html.no-motion .tf-cta.off { transition: none; }
.tf-drawer-open .tf-cta { visibility: hidden; }

/* ---------- нижній «док»: шторка + меню (≤ 1100) ---------- */
.tf-dock {
  position: fixed; z-index: 30; left: var(--gap); right: var(--gap); bottom: calc(var(--gap) + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; align-items: stretch; gap: 8px; pointer-events: none;
  transform: translateY(var(--tf-drag, 0px)); transition: transform .25s var(--ease, ease);
}
.tf-dock > * { pointer-events: auto; }
.tf-nav-hidden .tf-dock { transform: translateY(calc(100% + var(--gap) + env(safe-area-inset-bottom, 0px) + var(--tf-drag, 0px))); }
.layout.tf .tf-dock .mobile-nav { position: static; z-index: auto; min-height: 64px; touch-action: none; }

.tf-drawer {
  border-radius: 28px; display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(var(--tf-dragd, 0px)); transition: transform .25s var(--ease, ease);
}
.tf-drawer-head { position: relative; flex: none; height: 56px; padding: 0 4px 0 8px; display: flex; align-items: center; gap: 2px; touch-action: none; }
.tf-grabber { position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 99px; background: var(--fill2); pointer-events: none; }
.tf-drawer-toggle {
  flex: 1; min-width: 0; height: 48px; display: flex; align-items: center; gap: 6px; padding: 4px 6px 0; border-radius: 18px;
  color: var(--label); text-align: left; font: inherit;
}
.tf-chips { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; overflow: hidden; }
.tf-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 999px; flex: none;
  background: var(--fill); color: var(--label); font-size: 14px; font-weight: 800; white-space: nowrap;
}
.tf-chip svg { width: 16px; height: 16px; flex: none; }
.tf-chip.ready { background: #f2b632; color: #3b2a1e; }
.tf-chev { flex: none; width: 20px; height: 20px; margin-left: auto; color: var(--label2); transform: rotate(-90deg); transition: transform .25s var(--ease, ease); }
.tf-chev svg { width: 100%; height: 100%; }
.tf-drawer-open .tf-chev { transform: rotate(90deg); }
.tf-hide {
  flex: none; width: 52px; height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--label2); font: inherit; font-size: 12px; font-weight: 700; border-radius: 16px;
}
.tf-hide svg { width: 20px; height: 20px; }
.tf-drawer-open .tf-hide { display: none; }
.tf-drawer-body {
  max-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; visibility: hidden;
  transition: max-height .25s var(--ease, ease), visibility 0s .25s;
}
.tf-drawer-open .tf-drawer-body { max-height: var(--tf-body-max, 60vh); visibility: visible; transition: max-height .25s var(--ease, ease), visibility 0s; }
.tf-drawer.tf-nudge { animation: tf-nudge .9s var(--ease, ease) 1; }
@keyframes tf-fade { from { opacity: 0; } }
@keyframes tf-nudge { 0%, 50%, 100% { transform: translateY(0); } 25%, 75% { transform: translateY(-6px); } }

/* ---------- справи (шторка чи панель) ---------- */
.tf-tray { display: flex; flex-direction: column; gap: 10px; padding: 4px 12px 12px; }
.tf-tray > * { margin: 0 !important; }
.hub-tabs.tf-links { margin: 0; flex: none; }
.tf-links button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tf-links button svg { width: 20px; height: 20px; flex: none; color: var(--accent); }

/* ---------- повернення меню: «Меню» і смуга взмаху (≤ 700, лише коли сховане) ---------- */
.tf-grip {
  display: none; position: fixed; z-index: 31; left: 50%; bottom: calc(var(--gap) + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  height: 48px; padding: 0 18px; border-radius: 999px; align-items: center; gap: 6px; font: inherit; font-size: 14px; font-weight: 800;
  touch-action: none; /* взмах угору з «Меню» — той самий жест, що й зі смуги */
}
.tf-grip > svg { width: 18px; height: 18px; transform: rotate(-90deg); }
.tf-grip-gift { width: 22px; height: 22px; border-radius: 50%; background: #f2b632; color: #3b2a1e; display: grid; place-items: center; }
.tf-grip-gift svg { width: 14px; height: 14px; }
.tf-nav-hidden .tf-grip { display: inline-flex; animation: tf-fade .25s var(--ease, ease); }
.tf-band { display: none; position: fixed; left: 0; right: 0; bottom: var(--tf-dead-b); height: 64px; z-index: 25; touch-action: none; }
.tf-nav-hidden .tf-band { display: block; }
@media (hover: hover) and (pointer: fine) { .tf-band { pointer-events: none; } }

/* ---------- телефон (≤ 700) ---------- */
@media (max-width: 700px) {
  .layout.tf { --tf-body-max: calc(100dvh - 70px - env(safe-area-inset-top, 0px) - 82px - env(safe-area-inset-bottom, 0px) - 8px - 56px); }
  .tf-nav-hidden .tf-cta { bottom: calc(var(--tf-dead-b) + 72px); }
  .tf-switch .tf-done { display: none; }
}

/* ---------- рейка (≥ 701) ---------- */
@media (min-width: 701px) {
  .layout.tf .sidebar.tf-rail {
    position: fixed; z-index: 20; top: calc(var(--gap) + env(safe-area-inset-top, 0px)); left: calc(var(--gap) + env(safe-area-inset-left, 0px));
    width: 84px; height: auto; max-height: calc(100dvh - var(--gap) * 2); overflow-y: auto; padding: 12px 6px; border-radius: var(--win-r);
    display: flex; flex-direction: column; align-items: center; gap: 4px;
  }
  .layout.tf .tf-rail .logo { padding: 0 0 8px; justify-content: center; }
  .layout.tf .tf-rail .logo svg { width: 44px; height: 44px; }
  .layout.tf .tf-rail .nav-item {
    width: 72px; min-height: 64px; flex-direction: column; justify-content: center; align-items: center; gap: 4px; padding: 6px 2px;
    border-radius: 16px; font-size: 12px; font-weight: 800; color: var(--label2); text-align: center;
  }
  .layout.tf .tf-rail .nav-item .lbl { display: block; font-size: 12px; line-height: 1.1; }
  .layout.tf .tf-rail .nav-item .ic { font-size: 24px; }
  html[data-theme="town"] .layout.tf .tf-rail .nav-item.active { background: #bd5831; color: #fff; box-shadow: 0 3px 0 #94411f; }
  .layout.tf .tf-rail .nav-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
  .layout.tf .tf-rail .weather { margin-top: 8px; width: 72px; justify-content: center; padding: 10px 6px; }
  .layout.tf .tf-rail .weather .w-txt { display: none; }
  .course-switch.tf-switch { height: 56px; }
  .tf-stats { height: 56px; }
  .tf-bar { display: block; }
  .tf-done { display: inline-flex; }
}
@media (min-width: 701px) and (max-height: 520px) {
  .layout.tf .tf-rail .logo, .layout.tf .tf-rail .weather { display: none; }
}
@media (min-width: 701px) and (max-height: 360px) {
  .layout.tf .sidebar.tf-rail { gap: 0; }
  .layout.tf .tf-rail .nav-item { min-height: 60px; }
}

/* ---------- планшет (701–1100): рейка + шторка без меню ---------- */
@media (min-width: 701px) and (max-width: 1100px) {
  .layout.tf {
    --tf-inset-t: calc(80px + env(safe-area-inset-top, 0px)); --tf-inset-b: calc(88px + env(safe-area-inset-bottom, 0px));
    --tf-inset-l: calc(116px + env(safe-area-inset-left, 0px)); --tf-inset-r: calc(16px + env(safe-area-inset-right, 0px));
    --tf-body-max: calc(min(720px, 100dvh - 88px - env(safe-area-inset-top, 0px) - 16px - env(safe-area-inset-bottom, 0px)) - 56px);
  }
  .tf-top { left: var(--tf-inset-l); right: var(--tf-inset-r); }
  .tf-dock { left: var(--tf-inset-l); right: var(--tf-inset-r); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); align-items: center; }
  .tf-drawer { width: min(560px, 100%); }
  .tf-cta { bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- комп'ютер (≥ 1101): рейка + права панель, що згортається ---------- */
@media (min-width: 1101px) {
  .layout.tf { --tf-inset-t: 80px; --tf-inset-b: 16px; --tf-inset-l: calc(116px + env(safe-area-inset-left, 0px)); --tf-inset-r: 372px; }
  .layout.tf.tf-aside-collapsed { --tf-inset-r: 16px; }
  .tf-top { left: var(--tf-inset-l); right: var(--tf-inset-r); }
  .tf-cta { bottom: 32px; }
  .layout.tf .aside.tf-aside {
    position: fixed; z-index: 20; top: calc(var(--gap) + env(safe-area-inset-top, 0px)); right: calc(var(--gap) + env(safe-area-inset-right, 0px));
    width: 340px; height: auto; max-height: calc(100dvh - var(--gap) * 2); overflow-y: auto; overscroll-behavior: contain;
    border-radius: var(--win-r); padding: 12px; display: flex; flex-direction: column; gap: 12px;
    transition: transform .25s var(--ease, ease), opacity .25s;
  }
  .tf-aside-collapsed .aside.tf-aside { transform: translateX(calc(100% + var(--gap))); opacity: 0; pointer-events: none; }
  .tf-aside-head { position: sticky; top: -12px; z-index: 2; margin: -12px -12px 0; padding: 12px; display: flex; align-items: center; gap: 8px; background: var(--glass-bg); border-radius: var(--win-r) var(--win-r) 0 0; }
  .tf-aside-head > .stats { flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .tf-aside-head > .stats .stat { flex-direction: column; justify-content: center; gap: 4px; padding: 10px 4px; border-radius: 18px; font-size: 18px; font-weight: 700; }
  .tf-aside-head > .stats .stat .e { width: 24px; height: 24px; font-size: 24px; }
  .tf-aside-body { display: flex; flex-direction: column; gap: 12px; }
  .tf-aside-body > .tf-tray { padding: 0; }
  .tf-aside-toggle {
    flex: none; min-width: 48px; height: 48px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    color: var(--label); background: var(--fill); font: inherit;
  }
  .tf-aside-toggle > svg { width: 20px; height: 20px; flex: none; }
  .tf-aside-pill {
    display: none; position: fixed; z-index: 20; top: calc(var(--gap) + env(safe-area-inset-top, 0px)); right: calc(var(--gap) + env(safe-area-inset-right, 0px));
    height: 56px; padding: 0 4px 0 12px; border-radius: 18px; align-items: center; gap: 10px;
  }
  .tf-aside-collapsed .tf-aside-pill { display: flex; animation: tf-fade .25s var(--ease, ease); }
  .tf-aside-pill .stats { gap: 10px; }
  .layout.tf .tf-aside-pill .stat { background: none; box-shadow: none; padding: 0; gap: 4px; font-size: 15px; font-weight: 800; }
  .tf-aside-pill .stat .e { font-size: 18px; }
  .tf-aside-pill .tf-aside-toggle { padding: 0 6px 0 10px; }
  .tf-aside-pill .tf-aside-toggle > svg { transform: scaleX(-1); }
  .tf-aside-pill .tf-chips { flex: none; }
}

/* ---------- жест: елемент іде за пальцем; зменшений рух — без переходів ---------- */
.tf-dragging .tf-dock, .tf-dragging .tf-drawer { transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  .layout.tf *, .layout.tf { transition: none !important; }
  .tf-drawer.tf-nudge, .tf-nav-hidden .tf-grip, .tf-aside-collapsed .tf-aside-pill { animation: none !important; }
}
html.no-motion .layout.tf, html.no-motion .layout.tf * { transition: none !important; }
html.no-motion .tf-drawer.tf-nudge { animation: none !important; }
