[hidden] { display: none !important; }
:root {
  --ink: #3b2c2e;
  --cream: #fff7ea;
  --paper: #fffdf8;
  --peach: #ffb896;
  --mint: #a8e2c4;
  --lilac: #cdb9ff;
  --butter: #ffe08a;
  --coral: #ff8f8f;
  --sky: #9fd5ff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f6dccb; font-family: "Nunito", system-ui, sans-serif; color: var(--ink);
  -webkit-user-select: none; user-select: none; touch-action: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  background: radial-gradient(120% 90% at 50% 15%, #fff1e3 0%, #fbd9cc 55%, #f0c6d0 100%); }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }

/* «наклейка»: белая кайма + контур + мягкая тень, как у персонажей */
.sticker { background: var(--paper); border: 2.5px solid var(--ink); box-shadow: 0 0 0 3px #fff, 0 4px 0 3px rgba(59, 44, 46, .18); }

/* ---------- подписи над головами ---------- */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
.tag { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); white-space: nowrap; font-weight: 800; font-size: 12px;
  padding: 2px 8px; border-radius: 999px; background: rgba(255, 253, 248, .92); border: 2px solid var(--ink); }
.tag.me { background: var(--butter); }
.bubble { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); max-width: 190px; padding: 7px 11px; border-radius: 16px;
  background: #fff; border: 2.5px solid var(--ink); font-weight: 700; font-size: 14px; line-height: 1.25; text-align: center; word-wrap: break-word;
  box-shadow: 0 3px 0 rgba(59, 44, 46, .15); animation: pop .35s cubic-bezier(.34, 1.56, .64, 1); }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -9px; width: 12px; height: 12px; background: #fff;
  border-right: 2.5px solid var(--ink); border-bottom: 2.5px solid var(--ink); transform: translateX(-50%) rotate(45deg); }
.bubble.out { animation: fade .4s forwards; }
.emo { position: absolute; left: 0; top: 0; font-size: 34px; transform: translate(-50%, -100%); animation: floatUp 1.6s ease-out forwards; }
@keyframes pop { from { transform: translate(-50%, -80%) scale(.4); opacity: 0; } }
@keyframes fade { to { opacity: 0; transform: translate(-50%, -120%); } }
@keyframes floatUp { 0% { opacity: 0; margin-top: 10px; transform: translate(-50%, -100%) scale(.5); } 15% { opacity: 1; transform: translate(-50%, -100%) scale(1.15); }
  100% { opacity: 0; margin-top: -70px; transform: translate(-50%, -100%) scale(1); } }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
#hud > * { pointer-events: auto; }
.top { position: absolute; left: 12px; right: 12px; top: calc(10px + env(safe-area-inset-top)); display: flex; justify-content: space-between; align-items: center; gap: 10px; pointer-events: none; }
.top > * { pointer-events: auto; }
.place { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px; border-radius: 999px; font-size: 15px; }
.place .dot { width: 9px; height: 9px; border-radius: 50%; background: #3ccf7d; box-shadow: 0 0 0 3px rgba(60, 207, 125, .25); }
#online { background: var(--mint); border: 2px solid var(--ink); border-radius: 999px; padding: 0 8px; font-weight: 900; font-size: 13px; }
#online::before { content: "👤 "; }
.round { width: 46px; height: 46px; border-radius: 50%; font-size: 21px; display: grid; place-items: center; flex: none; transition: transform .15s; }
.round:active, .big:active, .emotes button:active { transform: scale(.9); }

#log { position: absolute; left: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); width: min(70vw, 320px); display: flex; flex-direction: column; gap: 3px; pointer-events: none; }
#log div { font-size: 13px; font-weight: 700; background: rgba(255, 253, 248, .82); padding: 3px 9px; border-radius: 10px; align-self: flex-start; animation: logIn .3s; transition: opacity 1s; }
#log b { font-weight: 900; }
@keyframes logIn { from { opacity: 0; transform: translateY(6px); } }

.bar { position: absolute; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; gap: 10px; align-items: center; }
.bar input { flex: 1; min-width: 0; height: 48px; border-radius: 999px; padding: 0 18px; outline: none; font-weight: 700; font-size: 16px; }
.bar input::placeholder { color: #b39a90; }
.send { background: var(--peach); font-size: 19px; }
.emotes { position: absolute; left: 12px; bottom: calc(74px + env(safe-area-inset-bottom)); display: flex; gap: 6px; padding: 6px; border-radius: 22px;
  background: var(--paper); border: 2.5px solid var(--ink); box-shadow: 0 0 0 3px #fff, 0 4px 0 3px rgba(59, 44, 46, .18); animation: pop2 .3s cubic-bezier(.34, 1.56, .64, 1); }
.emotes button { width: 44px; height: 44px; font-size: 26px; border-radius: 14px; transition: transform .15s; }
.emotes button:hover { background: var(--cream); }
@keyframes pop2 { from { transform: scale(.6) translateY(20px); opacity: 0; } }

/* ---------- экраны ---------- */
.screen { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; }
#loading { background: radial-gradient(120% 90% at 50% 15%, #fff1e3 0%, #fbd9cc 60%, #f0c6d0 100%); text-align: center; transition: opacity .5s; }
#loading.hide { opacity: 0; pointer-events: none; }
.logo { font-size: 84px; animation: bob 1.2s ease-in-out infinite; }
.ltxt { font-weight: 900; font-size: 20px; margin: 6px 0 14px; }
.lbar { width: 180px; height: 12px; border-radius: 999px; border: 2.5px solid var(--ink); background: #fff; overflow: hidden; margin: 0 auto; }
.lbar i { display: block; height: 100%; width: 0; background: var(--peach); transition: width .3s; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(8deg); } }

#pick { background: rgba(240, 198, 208, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); padding: 16px; }
.pick-box { width: min(520px, 100%); text-align: center; }
.pick-box h1 { font-weight: 900; font-size: 30px; margin: 0; }
.pick-box p { margin: 4px 0 14px; font-weight: 700; opacity: .7; }
.chars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.char { border-radius: 20px; padding: 10px 4px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), background .2s; }
.char img { height: min(28vw, 150px); filter: drop-shadow(0 4px 0 rgba(59, 44, 46, .15)); transition: transform .3s cubic-bezier(.34, 1.56, .64, 1); }
.char span { font-weight: 900; }
.char.on { background: var(--butter); transform: translateY(-4px); }
.char.on img { transform: scale(1.08) rotate(-3deg); }
.big { height: 56px; padding: 0 34px; border-radius: 999px; background: var(--peach); font-weight: 900; font-size: 18px; transition: transform .15s, opacity .2s; }
.big[disabled] { opacity: .5; }

#toast { position: fixed; z-index: 20; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; font-weight: 800; padding: 8px 16px; border-radius: 999px; transition: .3s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
