:root {
  --ink: #2a1a10;
  --cream: #fff6e8;
  --clay: #d0683f;
  --amber: #f6b84a;
  --amber-ink: #3a2410;
  --glass: rgba(255, 246, 232, 0.86);
  --line: rgba(42, 26, 16, 0.12);
  --display: "Fredoka", "Nunito", system-ui, sans-serif;
  --body: "Nunito", system-ui, sans-serif;
  --hand: "Caveat", cursive;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  /* Палитра с утверждённых кадров */
  --cocoa: #3b1a12;
  --terra: #d6643c;
  --terra-deep: #b44d27;
  --pill: rgba(236, 196, 164, .55);
  --pill-ink: #7a3a20;
  --muted: #8a7466;
  --hand-body: "Delius", var(--body);
  /* Кнопка из глины: блик сверху, тень снизу, неровная форма */
  --clay-btn-shadow: inset 0 3px 1px rgba(255, 236, 214, .5), inset 0 -5px 2px rgba(110, 35, 10, .32), 0 2px 0 rgba(130, 45, 15, .35), 0 14px 26px rgba(160, 62, 22, .32);
  --cream-btn-shadow: inset 0 3px 1px rgba(255, 255, 255, .95), inset 0 -4px 2px rgba(150, 110, 80, .22), 0 2px 0 rgba(150, 110, 80, .18), 0 10px 20px rgba(120, 70, 40, .16);
  --blob: 44px 52px 46px 54px / 54px 44px 52px 46px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #d9c3a2; color: var(--ink); font: 15px/1.45 var(--body); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

.stage { position: fixed; inset: 0; overflow: hidden; }
#scene { position: absolute; inset: 0; transition: opacity 1.2s ease; }
#scene canvas { display: block; touch-action: none; }
body:not(.ready) #scene { opacity: 0; }

/* Вход: глиняные облака закрывают экран и расходятся, как занавес */
.clouds { position: absolute; inset: 0; z-index: 9; pointer-events: none; overflow: hidden; }
.veil { position: absolute; inset: 0; width: 100%; height: 100%; }
/* Без WebGL — тёплая заливка, которая просто исчезает */
.veil.flat { background: radial-gradient(120% 90% at 50% 40%, #fff3e4 0%, #f3cfb0 100%); transition: opacity 1.2s ease; }
body.ready .veil.flat { opacity: 0; }
.loader { position: absolute; z-index: 2; left: 50%; top: 50%; margin: 0; transform: translate(-50%, -50%); display: grid; justify-items: center; gap: 12px; padding: 20px 26px 18px;
  border-radius: 30px 36px 32px 38px / 36px 30px 38px 32px; background: url("assets/ui/tex-cream.jpg") center / 260px, #fbf1e3; box-shadow: var(--cream-btn-shadow);
  color: var(--pill-ink); font: 600 13px/1 var(--display); letter-spacing: .14em; text-transform: uppercase; transition: opacity .5s ease; }
.loader span { white-space: nowrap; }
.loader img { width: 64px; height: auto; animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(.92); opacity: .7; } }
body.ready .loader { opacity: 0; }

/* Затемнение сверху под заголовком — только на первом экране */
.shade {
  position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 1.4s ease;
  background: radial-gradient(120% 70% at 50% 18%, rgba(40, 22, 10, .5) 0%, rgba(40, 22, 10, .12) 55%, rgba(40, 22, 10, 0) 75%);
}
/* Тёмная подложка больше не нужна: текст стоит на светлой дымке */

/* ---------- Заголовки: плотный округлый шрифт, ровная матовая какао-заливка — без обводок, рельефа и теней ---------- */
.clay { font-family: var(--display); font-weight: 700; color: var(--cocoa); letter-spacing: -.025em; }
/* Буквы ложатся по одной, как комки глины — мягко, без сильной деформации */
.drop .w { display: inline-block; white-space: nowrap; }
.drop .ch { display: inline-block; opacity: 0; transform-origin: 50% 100%; }
.go .ch, .drop.go .ch { animation: plop .5s cubic-bezier(.3, 1.35, .5, 1) forwards; animation-delay: calc(var(--i) * 38ms + var(--d, 0ms)); }
@keyframes plop {
  0% { opacity: 0; transform: translateY(-.32em) scale(.94, 1.06); }
  55% { opacity: 1; transform: translateY(0) scale(1.05, .95); }
  100% { opacity: 1; transform: none; }
}
/* Строка по дуге, как «You're builder» на карточке */
.arc .ch { translate: 0 calc(var(--y, 0) * 1em); rotate: calc(var(--r, 0) * 1deg); }

/* ---------- Первый экран ---------- */
.hero { position: absolute; inset: 0; z-index: 5; pointer-events: none; color: var(--ink); }
.hero > * {
  opacity: 0; transform: translateY(14px);
  transition: opacity .9s var(--ease-out), transform 1.1s var(--ease-out);
}
body[data-phase="hero"] .hero > * { opacity: 1; transform: none; pointer-events: auto; }
body[data-phase="hero"] .hero > .hero-haze { pointer-events: none; }
body[data-phase="hero"] .hero > .hero-main { transition-delay: .15s; }
body[data-phase="play"] .hero > * { transition-duration: .5s; transform: translateY(-16px); }
body[data-phase="play"] .hero > .hero-haze { transform: translateX(12%); transition-duration: 1s; }

/* Тёплый свет за текстом справа: сцена не размыта, просто небо за заголовком чуть светлее */
.hero-haze {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 52% 72% at 80% 44%, rgba(255, 244, 228, .8) 0%, rgba(255, 244, 228, .5) 46%, rgba(255, 244, 228, 0) 78%),
    linear-gradient(180deg, rgba(255, 240, 222, .55) 0%, rgba(255, 240, 222, 0) 22%);
}
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.logo img { display: block; width: 52px; height: auto; filter: drop-shadow(0 4px 8px rgba(80, 30, 10, .25)); }
.logo .clay { font-size: 21px; line-height: .95; letter-spacing: 0; }
.hero .logo .clay { font-size: 23px; text-transform: uppercase; letter-spacing: .01em; }
.hero .logo { position: absolute; left: clamp(20px, 4vw, 56px); top: clamp(18px, 3.4vh, 36px); }
.hero-live {
  position: absolute; right: clamp(16px, 3vw, 40px); top: clamp(18px, 3.4vh, 36px); margin: 0;
  display: inline-flex; align-items: center; gap: 12px; padding: 10px 22px 10px 16px; border-radius: 999px;
  background: var(--pill); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: var(--pill-ink); font: 700 16px/1 var(--display); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45);
}
.hero-live img { width: 30px; height: auto; }
.hero-live .arrow { font-weight: 500; opacity: .8; }
.hero-live .flags:empty { display: none; }

.hero-main {
  position: absolute; right: clamp(20px, 5.5vw, 96px); top: 50%; translate: 0 -48%; width: min(600px, 42vw);
  display: flex; flex-direction: column; align-items: flex-start;
}
.hero h1 { margin: 0; font-size: clamp(52px, 6.4vw, 108px); line-height: .92; text-wrap: balance; }
.hero-sub { margin: clamp(14px, 2.2vh, 24px) 0 0; max-width: 30em; font: 400 clamp(17px, 1.45vw, 22px)/1.4 var(--hand-body); color: #4a2a1c; }
.hero-back { margin: 14px 0 0; font: 600 23px/1.15 var(--hand); color: var(--clay); }
.hero-back:empty, .hero-event:empty { display: none; }
.hero-event { margin: 8px 0 0; font: 600 14px/1.2 var(--display); color: var(--clay); }
.hero-cta { margin-top: clamp(22px, 3.4vh, 36px); display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.start, .cta {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 14px; border: 0; border-radius: var(--blob);
  padding: 20px 34px 22px 38px; color: #fff6ec; font: 600 22px/1 var(--display); letter-spacing: .01em; text-shadow: 0 1px 0 rgba(120, 40, 10, .35);
  background: url("assets/ui/tex-terra.jpg") center / 260px, var(--terra); box-shadow: var(--clay-btn-shadow);
  transition: transform .25s var(--ease-out), box-shadow .25s ease, opacity .4s ease, filter .2s;
}
.cta { padding: 15px 28px 17px; font-size: 18px; }
.start span, .cta span { transition: transform .25s var(--ease-out); }
.start:hover, .cta:hover { transform: translateY(-2px) scale(1.02); filter: brightness(1.05); }
.start:hover span, .cta:hover span { transform: translateX(4px); }
.start:active, .cta:active { transform: translateY(1px) scale(.98); box-shadow: inset 0 2px 1px rgba(255, 236, 214, .4), inset 0 -2px 2px rgba(110, 35, 10, .3), 0 6px 14px rgba(160, 62, 22, .3); }
body[data-phase="hero"] .start:disabled { opacity: .55; cursor: progress; transform: none; }
.start:focus-visible, .cta:focus-visible { outline: 3px solid var(--cocoa); outline-offset: 4px; }
.ghost-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px; border: 0; border-radius: var(--blob);
  padding: 15px 28px 17px; color: var(--pill-ink); font: 600 18px/1 var(--display);
  background: url("assets/ui/tex-cream.jpg") center / 260px, #fbf1e3; box-shadow: var(--cream-btn-shadow);
  transition: transform .25s var(--ease-out);
}
.ghost-pill span { color: var(--terra); }
.ghost-pill:hover { transform: translateY(-2px); }
.hero-count { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px 12px; margin: 0; }
.hero-count img { grid-row: span 2; width: 46px; height: auto; filter: drop-shadow(0 4px 6px rgba(120, 40, 10, .25)); }
.hero-count p { margin: 0; font: 600 16px/1 var(--display); color: var(--muted); }
.hero-count b { color: var(--cocoa); font-size: 19px; font-weight: 700; }
.hero-count .slash { color: var(--muted); }
.count-bar { display: block; width: 240px; height: 10px; border-radius: 10px; background: rgba(214, 100, 60, .16); overflow: hidden; box-shadow: inset 0 1px 2px rgba(110, 40, 10, .15); }
.count-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: url("assets/ui/tex-terra.jpg") center / 120px, var(--terra); box-shadow: inset 0 2px 0 rgba(255, 220, 190, .45); transition: width 1.2s var(--ease-out); }

.live { width: 8px; height: 8px; border-radius: 50%; background: #3cc46a; box-shadow: 0 0 0 0 rgba(60,196,106,.5); animation: pulse 2s infinite; flex: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(60,196,106,0); } 100% { box-shadow: 0 0 0 0 rgba(60,196,106,0); } }

/* ---------- В игре: маленькая шапка ---------- */
.bar {
  position: absolute; inset: 20px 24px auto; z-index: 4; display: flex; justify-content: space-between; align-items: center;
  pointer-events: none; opacity: 0; transform: translateY(-10px); transition: opacity .8s ease .6s, transform .8s var(--ease-out) .6s;
}
body[data-phase="play"] .bar { opacity: 1; transform: none; }
body[data-phase="play"] .bar > * { pointer-events: auto; }
.logo.small { padding: 6px 14px 6px 8px; border-radius: 999px; background: var(--glass); backdrop-filter: blur(10px); box-shadow: 0 6px 20px rgba(40, 20, 8, .16); }
.logo.small img { width: 34px; }
.logo.small .clay { font-size: 17px; }
.presence {
  display: flex; align-items: center; gap: 9px; margin: 0; padding: 7px 14px 7px 12px; border-radius: 999px;
  background: var(--glass); backdrop-filter: blur(10px); font: 600 13px/1 var(--display); box-shadow: 0 6px 20px rgba(40, 20, 8, .18);
}
.flags { display: flex; }
.flags .flag { width: 22px; height: 22px; margin-left: -4px; border-radius: 50%; background: var(--cream); border: 2px solid var(--cream); overflow: hidden; }
.flags .flag:first-child { margin-left: 0; }
.flag { display: inline-grid; place-items: center; font-style: normal; font-size: 16px; line-height: 1; }
.flag img { width: 18px; height: 13px; border-radius: 2px; object-fit: cover; }

/* Справа сверху: кто здесь, подъём крыши, страны дня */
.bar-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.event, .tally {
  position: relative; display: flex; align-items: center; gap: 6px; margin: 0; padding: 6px 12px; border-radius: 999px; overflow: hidden;
  background: var(--glass); backdrop-filter: blur(10px); font: 600 12px/1 var(--display); font-variant-numeric: tabular-nums;
  box-shadow: 0 6px 20px rgba(40, 20, 8, .14);
}
.event[hidden], .tally[hidden] { display: none; }
.event.on { background: var(--amber); color: var(--amber-ink); }
.event-bar { position: absolute; inset: 0 auto 0 0; width: calc(var(--p, 0) * 100%); background: rgba(255,255,255,.35); pointer-events: none; transition: width .6s var(--ease-out); }
.event span, .tally span { position: relative; }
.tally .flag { font-size: 14px; }
.tally b { font-weight: 700; margin-right: 4px; }
.hero-event { margin: 8px 0 0; font: 600 14px/1.2 var(--display); color: #ffe2b0; text-shadow: 0 2px 10px rgba(40, 20, 8, .6); }
.hero-event:empty { display: none; }

/* Подсказка управления: появляется после старта и по кнопке «?» */
.controls {
  position: absolute; left: 50%; top: 72px; z-index: 4; transform: translate(-50%, -6px);
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; max-width: min(760px, 92vw); padding: 10px 18px; border-radius: 20px;
  background: rgba(42, 26, 16, .62); backdrop-filter: blur(8px); color: #fff; font: 500 13px/1.2 var(--display);
  opacity: 0; pointer-events: none; transition: opacity .4s ease, transform .4s var(--ease-out);
}
.controls.show { opacity: 1; transform: translate(-50%, 0); }
.controls span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.controls b { font-weight: 700; color: var(--amber); }
.controls kbd { color: #fff; border-color: rgba(255,255,255,.35); }

/* Кнопки навигации справа внизу */
.nav {
  position: absolute; right: 24px; bottom: 28px; z-index: 4; display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
  opacity: 0; pointer-events: none; transition: opacity .8s ease .8s;
}
body[data-phase="play"] .nav { opacity: 1; pointer-events: auto; }
.nav button {
  width: 40px; height: 40px; border: 0; border-radius: 12px; display: grid; place-items: center;
  background: var(--glass); backdrop-filter: blur(10px); color: var(--ink); font: 600 20px/1 var(--display);
  box-shadow: 0 6px 18px rgba(40, 20, 8, .2); transition: transform .15s var(--ease-out), background .15s;
}
.nav button:hover { background: var(--cream); transform: scale(1.06); }
.nav button:active { transform: scale(.94); }
.nav button svg { width: 20px; height: 20px; }
.nav button[hidden] { display: none; }
.nav .nav-mine { width: auto; padding: 0 14px; background: var(--amber); color: var(--amber-ink); font-size: 14px; }

/* ---------- Низ по центру: что делать сейчас ---------- */
.bottom { position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 4; display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(620px, 92vw); }
.hud {
  display: flex; align-items: center; gap: 14px; padding: 10px 10px 10px 18px; border-radius: 999px;
  background: var(--cream); box-shadow: 0 10px 30px rgba(40, 20, 8, .35);
  animation: rise .3s var(--ease-out);
}
.hud[hidden] { display: none; }
.hud:has(.ring:not([hidden])) { padding-left: 10px; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.hud b { display: block; font: 600 17px/1.2 var(--display); }
.hud small { display: block; font-size: 12px; color: rgba(42,26,16,.6); }
.hud small[hidden] { display: none; }
.ring {
  --p: 0; width: 38px; height: 38px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--clay) calc(var(--p) * 360deg), rgba(42,26,16,.12) 0);
  -webkit-mask: radial-gradient(circle, transparent 12px, #000 13px); mask: radial-gradient(circle, transparent 12px, #000 13px);
}
.ring[hidden] { display: none; }
.hud-go {
  border: 0; border-radius: 20px 24px 21px 25px / 25px 20px 24px 21px; padding: 11px 17px 12px; flex: none;
  background: url("assets/ui/tex-terra.jpg") center / 200px, var(--terra); color: #fff6ec; font: 600 14px/1 var(--display);
  box-shadow: inset 0 2px 1px rgba(255, 236, 214, .5), inset 0 -3px 1px rgba(110, 35, 10, .3), 0 6px 14px rgba(160, 62, 22, .28);
  transition: transform .2s var(--ease-out);
}
.hud-go:hover { transform: scale(1.04); }
.hud-go[hidden], .hud-x[hidden] { display: none; }
.hud-x {
  width: 30px; height: 30px; border: 0; border-radius: 50%; flex: none;
  background: rgba(42,26,16,.08); font: 600 18px/1 var(--display); color: rgba(42,26,16,.6);
}
.hud-x:hover { background: rgba(42,26,16,.16); color: var(--ink); }

/* Зов: помочь соседу, позвать друга */
.call {
  display: flex; align-items: center; gap: 10px; max-width: 100%; padding: 8px 8px 8px 16px; border-radius: 999px;
  background: var(--ink); color: var(--cream); font: 600 14px/1.25 var(--display); box-shadow: 0 10px 30px rgba(0,0,0,.3);
  animation: rise .3s var(--ease-out);
}
.call[hidden] { display: none; }
.call .hud-x { background: rgba(255,255,255,.12); color: rgba(255,246,232,.8); }
.call .hud-x:hover { background: rgba(255,255,255,.22); color: #fff; }
.call .flag { margin-right: 2px; }

/* Праздник: ряд или корпус готов, подъём крыши начался */
.cheer {
  position: absolute; left: 50%; top: 120px; z-index: 6; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px;
  max-width: min(560px, 92vw); padding: 16px 26px 14px; border-radius: 22px; text-align: center;
  background: var(--amber); color: var(--amber-ink); box-shadow: 0 18px 50px rgba(120, 60, 0, .45); animation: pop .45s var(--ease-out);
}
.cheer[hidden] { display: none; }
.cheer b { font: 700 24px/1.1 var(--display); text-wrap: balance; }
.cheer span { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px; font: 600 14px/1.3 var(--display); }
.cheer .flag { font-size: 18px; }

/* ---------- Чат: компактный, сообщения сами тают ---------- */
.chat {
  position: absolute; left: 24px; bottom: 28px; z-index: 4; width: 280px; display: flex; flex-direction: column; gap: 8px;
  opacity: 0; pointer-events: none; transition: opacity .8s ease .8s;
}
body[data-phase="play"] .chat { opacity: 1; pointer-events: auto; }
#chat-log {
  list-style: none; margin: 0; padding: 0; max-height: 140px; overflow-y: auto; scrollbar-width: none;
  display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: #fff;
  text-shadow: 0 1px 6px rgba(30, 15, 5, .9);
}
#chat-log li { animation: fadeout 1s ease 14s forwards; }
.chat:focus-within #chat-log li, .chat:hover #chat-log li { animation: none; }
@keyframes fadeout { to { opacity: 0; } }
#chat-log .system { font-family: var(--hand); font-size: 18px; line-height: 1.1; color: #ffe2b0; }
#chat-form { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 14px; border-radius: 999px; background: rgba(255, 246, 232, .6); backdrop-filter: blur(10px); }
#chat-input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 7px 0; outline: none; }
#chat-input::placeholder { color: rgba(42,26,16,.6); }
#chat-form:focus-within { background: var(--cream); }
kbd { font: 600 11px/1 var(--display); padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line); color: rgba(42,26,16,.6); }
#chat-form:focus-within kbd { visibility: hidden; }

/* ---------- Метки в сцене ---------- */
.peer { position: relative; display: flex; align-items: flex-start; gap: 2px; pointer-events: none; }
.peer svg { filter: drop-shadow(0 2px 3px rgba(0,0,0,.3)); }
.peer span { display: inline-flex; align-items: center; gap: 5px; margin-top: 12px; padding: 3px 9px 3px 5px; border-radius: 999px; color: #fff; font: 600 12px/1.2 var(--display); white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.peer .flag { font-size: 14px; }
.peer .bubble {
  position: absolute; left: 18px; bottom: calc(100% - 4px); width: max-content; max-width: 220px;
  padding: 7px 11px; border-radius: 14px 14px 14px 4px; background: var(--cream); color: var(--ink);
  font: 500 13px/1.3 var(--body); font-style: normal; box-shadow: 0 6px 18px rgba(0,0,0,.2);
  opacity: 0; transform: translateY(4px); transition: opacity .2s, transform .2s;
}
.peer .bubble.show { opacity: 1; transform: none; }
.peer .bubble.typing::after { content: ""; display: inline-block; width: 2px; height: 1.05em; margin-left: 2px; vertical-align: -2px; background: var(--clay); animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
/* Своя метка: без стрелки — стрелка у меня и так есть, это мышь */
.peer.self svg { visibility: hidden; }
.station-chip {
  padding: 5px 11px; border-radius: 999px; background: var(--cream); color: var(--ink);
  font: 600 12px/1.2 var(--display); white-space: nowrap; pointer-events: none;
  box-shadow: 0 4px 14px rgba(40,20,8,.25); opacity: 0; transition: opacity .3s;
}
.station-chip[data-busy]:not([data-busy=""]) { opacity: .9; }
.station-chip[data-busy]:not([data-busy=""])::after { content: " · " attr(data-busy); color: var(--clay); }
.station-chip.helpable { pointer-events: auto; cursor: pointer; opacity: 1; }
.station-chip.helpable::before, .help-label::before { content: "Help"; display: inline-block; margin-right: 6px; padding: 2px 7px; border-radius: 999px; background: var(--amber); color: var(--amber-ink); }
.help-label {
  padding: 5px 11px 5px 6px; border: 0; border-radius: 999px; background: var(--cream); color: var(--ink); white-space: nowrap;
  font: 600 12px/1.2 var(--display); box-shadow: 0 4px 14px rgba(40,20,8,.3); pointer-events: auto; cursor: pointer; animation: bob 1.6s ease-in-out infinite;
}
.help-label.heavy { background: var(--amber); color: var(--amber-ink); }
.help-label.heavy::before { background: var(--ink); color: var(--cream); }
.clap-pop {
  width: 38px; height: 38px; border: 0; border-radius: 50%; display: grid; place-items: center; font-size: 19px; line-height: 1;
  background: var(--cream); box-shadow: 0 6px 18px rgba(40,20,8,.3); pointer-events: auto; cursor: pointer; animation: pop .4s var(--ease-out), bob 1.6s ease-in-out .4s infinite;
}
.clap-pop:hover { transform: scale(1.15); }
.clap-float { font-size: 22px; pointer-events: none; animation: floatup 1.4s ease-out forwards; }
@keyframes floatup { to { transform: translateY(-46px) scale(1.3); opacity: 0; } }

/* Подпись светящейся зоны — тоже кнопка */
.zone-label {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; pointer-events: auto;
  padding: 10px 18px 9px; border: 0; border-radius: 18px; background: var(--amber); color: var(--amber-ink);
  box-shadow: 0 10px 30px rgba(120, 60, 0, .4); animation: bob 1.6s ease-in-out infinite;
  transition: transform .25s var(--ease-out), box-shadow .25s ease;
}
.zone-label::after {
  content: ""; position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%);
  border-left: 9px solid transparent; border-right: 9px solid transparent; border-top: 10px solid var(--amber);
}
.zone-label b { font: 600 16px/1 var(--display); white-space: nowrap; }
.zone-label small { font: 600 11px/1 var(--display); opacity: 0; max-height: 0; transition: opacity .2s, max-height .2s; }
.zone-label.hot, .zone-label:hover { transform: scale(1.1); box-shadow: 0 14px 40px rgba(255, 170, 60, .6); }
.zone-label.hot small, .zone-label:hover small { opacity: .75; max-height: 14px; }
.zone-label[hidden] { display: none; }
.zone-label.cooling { background: var(--cream); color: var(--ink); animation: none; font-variant-numeric: tabular-nums; }
.zone-label.cooling::after { border-top-color: var(--cream); }
.zone-label.cooling small { opacity: .7; max-height: 14px; }
body:not([data-phase="play"]) .zone-label { display: none; }
@keyframes bob { 50% { translate: 0 -6px; } }

/* Подсказка в сцене: кольцо на нужной детали и рука с жестом */
.hint { position: relative; width: 0; height: 0; pointer-events: none; }
.hint-ring { position: absolute; left: -38px; top: -38px; width: 76px; height: 76px; border-radius: 50%; border: 3px solid rgba(255, 214, 140, .95); box-shadow: 0 0 22px rgba(255, 190, 90, .8), inset 0 0 18px rgba(255, 190, 90, .6); animation: ping 1.4s ease-out infinite; }
.hint-hand { position: absolute; left: 6px; top: 4px; font-size: 34px; line-height: 1; filter: drop-shadow(0 3px 6px rgba(60, 20, 5, .4)); }
.hint-label { position: absolute; left: 50%; top: -74px; translate: -50% 0; padding: 7px 13px 8px; border-radius: 16px 19px 17px 20px / 19px 16px 20px 17px; white-space: nowrap;
  background: url("assets/ui/tex-cream.jpg") center / 200px, #fbf1e3; color: var(--pill-ink); font: 700 15px/1 var(--display); box-shadow: var(--cream-btn-shadow); }
@keyframes ping { 0% { transform: scale(.7); opacity: 1; } 100% { transform: scale(1.35); opacity: 0; } }
.hint[data-g="tap"] .hint-hand, .hint[data-g="place"] .hint-hand { animation: tap .9s ease-in-out infinite; }
.hint[data-g="hold"] .hint-hand { animation: hold 1.6s ease-in-out infinite; }
.hint[data-g="hold"] .hint-ring { animation: fillring 1.6s ease-in-out infinite; }
.hint[data-g="scrub"] .hint-hand { animation: scrub .8s ease-in-out infinite alternate; }
.hint[data-g="drag"] .hint-hand { animation: dragup 1.3s ease-in-out infinite; }
@keyframes tap { 0%, 100% { transform: translateY(-10px); } 45% { transform: translateY(2px) scale(.92); } }
@keyframes hold { 0% { transform: translateY(-10px); } 25%, 80% { transform: translateY(2px) scale(.92); } 100% { transform: translateY(-10px); } }
@keyframes fillring { 0% { transform: scale(1.3); opacity: .2; } 80% { transform: scale(.85); opacity: 1; } 100% { transform: scale(.85); opacity: 0; } }
@keyframes scrub { from { transform: translateX(-26px) rotate(-12deg); } to { transform: translateX(22px) rotate(10deg); } }
@keyframes dragup { 0% { transform: translateY(20px); opacity: 0; } 20% { opacity: 1; } 80% { transform: translateY(-36px); opacity: 1; } 100% { transform: translateY(-40px); opacity: 0; } }

/* Карточка кирпича по клику: кто, откуда, когда */
.brick-card {
  position: relative; margin-bottom: 14px; width: max-content; min-width: 210px; max-width: 280px; pointer-events: auto;
  padding: 14px 16px 12px; border-radius: 16px; background: var(--cream); color: var(--ink);
  box-shadow: 0 14px 40px rgba(40, 20, 8, .38); animation: pop .3s var(--ease-out);
}
.brick-card::after {
  content: ""; position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%);
  border-left: 9px solid transparent; border-right: 9px solid transparent; border-top: 9px solid var(--cream);
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.96); } }
.bc-x { position: absolute; right: 8px; top: 8px; width: 26px; height: 26px; border: 0; border-radius: 50%; background: rgba(42,26,16,.07); color: rgba(42,26,16,.6); font: 600 16px/1 var(--display); }
.bc-x:hover { background: rgba(42,26,16,.14); }
.bc-mine { display: inline-block; margin-bottom: 6px; padding: 3px 8px; border-radius: 999px; background: var(--amber); color: var(--amber-ink); font: 700 11px/1.2 var(--display); letter-spacing: .04em; text-transform: uppercase; }
.bc-name { display: block; padding-right: 26px; font: 700 30px/1 var(--hand); color: color-mix(in oklab, var(--c, #7a3a1c) 45%, #3a1c0c); }
.brick-card q { display: block; margin-top: 3px; font: 600 21px/1.1 var(--hand); color: #7a3a1c; }
.bc-where { display: flex; align-items: center; gap: 7px; margin: 10px 0 0; font: 600 14px/1.2 var(--display); }
.bc-where .flag { font-size: 18px; }
.bc-when { margin: 4px 0 0; font: 500 13px/1.3 var(--body); color: rgba(42,26,16,.75); }
.bc-helpers { margin: 6px 0 0; font: 500 13px/1.35 var(--body); color: rgba(42,26,16,.8); }
.bc-helpers .flag { font-size: 13px; }
.bc-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.bc-row button { border: 0; border-radius: 999px; padding: 7px 12px; background: rgba(42,26,16,.07); font: 600 13px/1 var(--display); }
.bc-row button:hover:not(:disabled) { background: rgba(42,26,16,.14); }
.bc-row button:disabled { cursor: default; opacity: .75; }
.bc-row .bc-invite { background: var(--amber); color: var(--amber-ink); }
.bc-near { border: 0; padding: 0; background: none; margin-top: 6px; font: 600 13px/1.3 var(--display); color: var(--clay); text-decoration: underline; text-underline-offset: 3px; }
.brick-card small { display: block; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 12px; color: rgba(42,26,16,.6); }

.toast {
  position: absolute; top: 76px; left: 50%; transform: translateX(-50%); z-index: 7;
  padding: 11px 18px; border-radius: 999px; background: var(--ink); color: var(--cream);
  font: 600 15px/1.3 var(--display); box-shadow: 0 10px 30px rgba(0,0,0,.3); animation: rise .25s ease;
}
.toast[hidden] { display: none; }

/* Подпись кирпича */
.engrave { border: 0; padding: 0; border-radius: 22px; background: var(--cream); color: var(--ink); width: min(400px, 92vw); box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.engrave::backdrop { background: rgba(30, 18, 10, .55); backdrop-filter: blur(4px); }
.engrave form { padding: 26px; display: flex; flex-direction: column; gap: 12px; }
.engrave h2 { margin: 6px 0 0; font: 700 28px/1.05 var(--display); }
.engrave p { margin: 0 0 4px; color: rgba(42,26,16,.7); }
.engrave label { display: flex; flex-direction: column; gap: 5px; font: 600 13px/1 var(--display); }
.engrave label em { font-style: normal; font-weight: 500; opacity: .6; }
.engrave input { padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 16px; }
.engrave input:focus { outline: 2px solid var(--clay); outline-offset: 1px; }
.engrave .eg-error { margin: 0; color: #a3341a; font: 600 13px/1.3 var(--display); }
.engrave .eg-error[hidden] { display: none; }
.engrave .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.ghost { border: 0; background: transparent; padding: 12px 14px; font: 600 15px/1 var(--display); color: rgba(42,26,16,.7); }
.brick-preview {
  align-self: center; width: 180px; height: 72px; border-radius: 12px; display: grid; place-items: center;
  background: radial-gradient(circle at 30% 30%, #e07c52, #b8532f); box-shadow: inset 0 -6px 0 rgba(0,0,0,.12), 0 8px 18px rgba(120,50,20,.35);
  font: 700 30px/1 var(--hand); color: rgba(70,26,10,.75); text-shadow: 0 1px 0 rgba(255,220,190,.35);
}

/* Инструмент вместо курсора */
.tool { position: absolute; left: 0; top: 0; z-index: 8; pointer-events: none; width: 0; height: 0; }
.tool[hidden] { display: none; }
.tool-icon {
  position: absolute; left: -26px; top: -26px; width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; font-size: 30px; line-height: 1;
  background: var(--cream); box-shadow: 0 6px 18px rgba(40, 20, 8, .35);
  transform-origin: 60% 60%;
}
.tool-icon svg { width: 36px; height: 36px; }
.tool-ring {
  --p: 0; position: absolute; left: -33px; top: -33px; width: 66px; height: 66px; border-radius: 50%;
  background: conic-gradient(var(--amber) calc(var(--p) * 360deg), rgba(255,246,232,.35) 0);
  -webkit-mask: radial-gradient(circle, transparent 28px, #000 29px); mask: radial-gradient(circle, transparent 28px, #000 29px);
}
.tool.hit .tool-icon { animation: whack .22s ease-out; }
@keyframes whack { 40% { transform: rotate(-28deg) scale(.9); } 100% { transform: none; } }
.tool[data-tool="trowel"] .tool-icon, .tool[data-tool="saw"] .tool-icon, .tool[data-tool="sand"] .tool-icon, .tool[data-tool="mix"] .tool-icon { animation: wiggle .5s ease-in-out infinite; }
@keyframes wiggle { 50% { transform: rotate(10deg) translateX(3px); } }
.tool[data-tool="scoop"] .tool-icon, .tool[data-tool="lift"] .tool-icon { animation: nudge 1s ease-in-out infinite; }
.tool[data-tool="bucket"] .tool-icon { animation: tip 1.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(-5px); } }
@keyframes tip { 50% { transform: rotate(-35deg); } }

body[data-mode="carrying"] #scene canvas { cursor: grab; }

/* Награда: «You're builder #1,285» — пласт сливочной глины с неровным краем */
.reward {
  position: absolute; left: 50%; top: 50%; z-index: 8; translate: -50% -50%; width: min(460px, calc(100vw - 28px));
  display: flex; flex-direction: column; align-items: center; text-align: center; padding: 34px 30px 26px;
  border-radius: 38px 46px 40px 50px / 48px 38px 50px 42px;
  background: url("assets/ui/tex-cream.jpg") center / 300px, #fbf1e3;
  box-shadow: inset 0 3px 1px rgba(255, 255, 255, .9), inset 0 -6px 3px rgba(170, 130, 95, .18), 0 30px 70px rgba(70, 28, 8, .38);
  animation: pop .5s var(--ease-out);
}
.reward[hidden] { display: none; }
.reward-x { position: absolute; right: 14px; top: 12px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: rgba(120, 80, 50, .08); color: var(--muted); font: 600 18px/1 var(--display); }
.reward h2 { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 4px 0 0; font-size: clamp(46px, 11vw, 70px); line-height: 1; }
.reward h2 > span { display: block; white-space: nowrap; }
.reward h2 > .arc { font-size: .78em; margin-bottom: .08em; }
.reward-from, .reward-where { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; }
.reward-from { margin-top: 20px; font: 500 22px/1.2 var(--display); color: var(--muted); }
.reward-from b { color: var(--terra-deep); font-weight: 700; }
.reward-from svg { width: 26px; height: 26px; }
.reward-where { margin-top: 10px; font: 500 17px/1.3 var(--body); color: var(--muted); }
.reward-where svg { width: 22px; height: 22px; flex: none; }
.reward .cta, .reward .ghost-pill { align-self: stretch; margin-top: 22px; }
.reward .ghost-pill { margin-top: 14px; }
.reward-claps { display: flex; align-items: center; gap: 8px; margin: 18px 0 0; font: 500 17px/1 var(--display); color: var(--muted); }
.reward-claps[hidden] { display: none; }
.reward-claps b { color: var(--cocoa); font-weight: 700; }
.reward-claps img { width: 30px; height: auto; }
.bc-no { display: block; margin-bottom: 4px; font-size: 20px; color: var(--clay); text-shadow: 0 .03em 0 #8a3d1c; }

/* Средние экраны: чат поднимается над подсказкой, чтобы они не наезжали друг на друга */
@media (max-width: 1180px) {
  .chat { bottom: 96px; width: 240px; transition: bottom .3s var(--ease-out), opacity .8s ease .8s; }
  /* Зов над подсказкой — чат поднимается ещё выше */
  body:has(#call:not([hidden])) .chat { bottom: 160px; }
}

@media (max-width: 760px) {
  /* Телефон: заголовок сверху, сцена посередине, кнопка внизу под большим пальцем */
  .hero-haze { background: linear-gradient(180deg, rgba(255, 244, 228, .9) 0%, rgba(255, 244, 228, .62) 34%, rgba(255, 244, 228, 0) 56%, rgba(255, 244, 228, 0) 72%, rgba(255, 244, 228, .7) 100%); }
  .hero .logo { left: 16px; top: 14px; }
  .logo img { width: 40px; }
  .logo .clay, .hero .logo .clay { font-size: 17px; }
  .hero-live { right: 12px; top: 18px; padding: 7px 12px 7px 10px; font-size: 12px; }
  .hero-live .flags { display: none; }
  .hero-main { position: absolute; inset: 86px 16px 24px; translate: none; width: auto; right: 16px; }
  .hero h1 { font-size: clamp(44px, 13vw, 64px); }
  .hero-sub { font-size: 15px; margin-top: 12px; }
  .hero-cta { margin-top: auto; align-self: stretch; align-items: stretch; }
  .start { justify-content: center; padding: 18px 24px; font-size: 18px; }
  .hero-count { grid-template-columns: 40px 1fr; justify-content: stretch; }
  .hero-count img { width: 40px; }
  .hero-live img { width: 22px; }
  .hero-live .arrow { display: none; }
  .count-bar { width: 100%; }
  .bar { inset: 12px 12px auto; align-items: flex-start; }
  .tally { display: none; }
  .cheer { top: 96px; padding: 12px 18px; }
  .cheer b { font-size: 19px; }
  .call { font-size: 13px; }
  .logo.small span { display: none; }
  .controls { top: 60px; font-size: 12px; }
  /* На телефоне — только поле: сообщения и так видны у имён в мире */
  .chat { left: 12px; bottom: 96px; width: min(210px, calc(100vw - 84px)); }
  #chat-log, #chat-form kbd { display: none; }
  .nav { right: 12px; bottom: 96px; transition: bottom .3s var(--ease-out), opacity .8s ease .8s; }
  body:has(#call:not([hidden])) .chat, body:has(#call:not([hidden])) .nav { bottom: 168px; }
  .bottom { bottom: 18px; }
  .hud b { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .live, .zone-label, .tool-icon, .help-label, .clap-pop { animation: none !important; }
  .hero > * { transition-duration: .01s !important; filter: none; }
}
