@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@600;700;800;900&display=swap');

:root {
  --bgc: #5b12c9;
  --ink: #222;
  --ink-2: #6b6b6b;
  --line: #d4d4d4;
  --dark: #2b2b2b;
  --violet: #7c3aed;
  --violet-d: #4c1d95;

  --a0: #e8456b;
  --a1: #1e9bd7;
  --a2: #f2a516;
  --a3: #2db57a;
  --a4: #ff7a1a;
  --a5: #14b8a6;

  --ok: #2db57a;
  --bad: #e8456b;
  --gold: #f6c343;
  --silver: #c9ced8;
  --bronze: #d9894a;

  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --spring: cubic-bezier(.34, 1.56, .64, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { color-scheme: light; }
body {
  font-family: var(--font);
  font-weight: 700;
  color: #fff;
  background: var(--bgc);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; line-height: 1.15; font-weight: 900; }
a { color: inherit; }
.hidden { display: none !important; }
.ico { width: 1.2em; height: 1.2em; flex: none; }

/* ---------- фон: косые полосы и плавающие иконки ---------- */
.bg {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background-color: var(--bgc);
  transition: background-color .35s ease;
}
.bg::before {
  content: ''; position: absolute; inset: -50% -50% -50% -100%;
  background: repeating-linear-gradient(-35deg, transparent 0 160px, rgba(255,255,255,.055) 160px 320px);
  animation: drift 40s linear infinite;
}
.bg::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(120% 80% at 50% 120%, rgba(0,0,0,.28), transparent 60%);
}
@keyframes drift { to { transform: translateX(390.6px); } }
.bg .float { position: absolute; color: rgba(255,255,255,.07); animation: bob 9s ease-in-out infinite; }
.bg .float .ico { width: 100%; height: 100%; }
.bg .f0 { width: 140px; height: 140px; left: 6%; top: 14%; transform: rotate(-14deg); }
.bg .f1 { width: 110px; height: 110px; right: 8%; top: 20%; animation-delay: -2s; }
.bg .f2 { width: 160px; height: 160px; left: 12%; bottom: 8%; animation-delay: -4s; }
.bg .f3 { width: 120px; height: 120px; right: 12%; bottom: 14%; animation-delay: -6s; }
@keyframes bob { 0%, 100% { translate: 0 0; rotate: -8deg; } 50% { translate: 0 -22px; rotate: 6deg; } }

body.ok { --bgc: #1f9e66; }
body.bad { --bgc: #d93a5e; }

/* ---------- верхнее меню ---------- */
.nav {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 14px;
  background: rgba(0,0,0,.28);
  position: relative; z-index: 20;
}
.brand {
  font-weight: 900; font-size: 24px; letter-spacing: -.05em;
  color: #fff; text-decoration: none;
  display: inline-block; transform: rotate(-4deg);
  margin-right: 10px;
  text-shadow: 0 3px 0 rgba(0,0,0,.25);
}
.nb {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 800; color: #fff; text-decoration: none;
  padding: 8px 14px; border-radius: 4px;
  box-shadow: 0 3px 0 rgba(0,0,0,.35);
  transition: transform .06s, box-shadow .06s, filter .15s;
}
.nb:hover { filter: brightness(1.12); }
.nb:active { transform: translateY(3px); box-shadow: 0 0 0 rgba(0,0,0,.35); }
.nb.green { background: #0f7b4f; }
.nb.blue { background: #1f5fd1; }
.nb.pink { background: #d6336c; }
.nb.violet { background: var(--violet); }
.nb.active { outline: 2px solid #fff; outline-offset: 1px; }
.nav .spacer { flex: 1; }

/* ---------- логотип ---------- */
.logo {
  font-weight: 900;
  font-size: clamp(64px, 12vw, 112px);
  letter-spacing: -.06em;
  line-height: .9;
  transform: rotate(-4deg);
  text-shadow: 0 6px 0 rgba(0,0,0,.25);
  animation: logoIn .7s var(--spring) both;
}
.logo.md { font-size: 56px; }
.logo span { display: inline-block; animation: wiggle 3.2s ease-in-out infinite; transform-origin: 50% 80%; }
@keyframes logoIn { from { transform: rotate(-4deg) scale(.4); opacity: 0; } }
@keyframes wiggle { 0%, 86%, 100% { transform: rotate(0); } 90% { transform: rotate(-14deg); } 95% { transform: rotate(10deg); } }

/* ---------- экраны ---------- */
.screen { display: none; min-height: 100vh; min-height: 100dvh; flex-direction: column; }
.screen.active { display: flex; }
.center { align-items: center; justify-content: center; text-align: center; gap: 18px; padding: 24px 16px; }
.grow { flex: 1; display: flex; flex-direction: column; }
.screen.active .rise { animation: rise .45s var(--spring) both; }
.screen.active .rise:nth-child(2) { animation-delay: .06s; }
.screen.active .rise:nth-child(3) { animation-delay: .12s; }
.screen.active .rise:nth-child(4) { animation-delay: .18s; }
.screen.active .rise:nth-child(5) { animation-delay: .24s; }
@keyframes rise { from { transform: translateY(24px) scale(.96); opacity: 0; } }

/* ---------- карточки, поля ---------- */
.card {
  background: #fff; color: var(--ink);
  border-radius: 6px;
  padding: 14px;
  box-shadow: 0 5px 0 rgba(0,0,0,.22);
}
.join-card { width: 100%; max-width: 330px; display: flex; flex-direction: column; gap: 10px; }
.join-card .label { font-size: 13px; font-weight: 800; color: var(--ink); text-transform: uppercase; letter-spacing: .06em; }
.field {
  width: 100%;
  border: 2px solid #cfcfcf; border-radius: 4px;
  padding: 13px 12px;
  font: 800 18px var(--font); color: var(--ink);
  text-align: center;
  background: #fff;
  transition: border-color .15s;
}
.field::placeholder { color: #9a9a9a; }
.field:focus { outline: none; border-color: #333; }
.err { color: var(--bad); font-size: 14px; font-weight: 800; min-height: 1em; }
.linkbtn { background: none; border: 0; font: 700 14px var(--font); color: var(--ink-2); cursor: pointer; text-decoration: underline; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 4px;
  padding: 12px 20px;
  font: 800 16px var(--font);
  color: #fff; background: var(--dark);
  box-shadow: 0 4px 0 #000;
  cursor: pointer; text-decoration: none;
  transition: transform .06s, box-shadow .06s, filter .15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 #000; }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.white { background: #fff; color: var(--ink); box-shadow: 0 4px 0 #b9b9b9; }
.btn.violet { background: var(--violet); box-shadow: 0 4px 0 var(--violet-d); }
.btn.green { background: var(--ok); box-shadow: 0 4px 0 #1b7a50; }
.btn.red { background: var(--bad); box-shadow: 0 4px 0 #a82346; }
.btn.ghost { background: rgba(255,255,255,.16); box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.btn.light { background: #ececec; color: var(--ink); box-shadow: 0 3px 0 #c4c4c4; }
.btn.lg { font-size: 20px; padding: 16px 30px; }
.btn.sm { font-size: 13px; padding: 7px 12px; box-shadow: 0 3px 0 #000; }
.btn.sm.light { box-shadow: 0 3px 0 #c4c4c4; }
.btn.sm:active { transform: translateY(3px); }
.btn.block { width: 100%; }
.btn.icon { padding: 7px; }

/* ---------- плитки ответов ---------- */
.c0 { --c: var(--a0); --cd: #a82346; }
.c1 { --c: var(--a1); --cd: #13699a; }
.c2 { --c: var(--a2); --cd: #b07405; }
.c3 { --c: var(--a3); --cd: #1b7a50; }
.c4 { --c: var(--a4); --cd: #b8500a; }
.c5 { --c: var(--a5); --cd: #0b7c70; }

.tiles {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  width: 100%;
}
.tile {
  background: var(--c); color: #fff;
  border: 0; border-radius: 6px;
  box-shadow: 0 5px 0 var(--cd);
  display: flex; align-items: center; gap: 16px;
  padding: 16px 22px;
  min-height: 90px;
  font: 800 clamp(18px, 2.3vw, 30px) var(--font);
  text-align: left;
  text-shadow: 0 2px 0 rgba(0,0,0,.15);
  animation: tileIn .45s var(--spring) both;
  transition: opacity .3s, transform .3s, filter .3s;
  position: relative;
}
.tile .ico { width: 1.7em; height: 1.7em; filter: drop-shadow(0 2px 0 rgba(0,0,0,.18)); }
.tile .txt { flex: 1; overflow-wrap: anywhere; }
.tile:nth-child(2) { animation-delay: .07s; }
.tile:nth-child(3) { animation-delay: .14s; }
.tile:nth-child(4) { animation-delay: .21s; }
.tile:nth-child(5) { animation-delay: .28s; }
.tile:nth-child(6) { animation-delay: .35s; }
.tile.dim { opacity: .28; filter: saturate(.5); }
.tile .mark { width: 1.5em; height: 1.5em; flex: none; }
.tile.right { animation: tileIn .45s var(--spring) both, bump .5s .4s ease; }
@keyframes tileIn { from { transform: scale(.6) translateY(20px); opacity: 0; } }
@keyframes bump { 50% { transform: scale(1.04); } }

button.tile { cursor: pointer; }
button.tile:active { transform: translateY(5px); box-shadow: 0 0 0 var(--cd); }

/* ---------- таймер ---------- */
.timer {
  width: 104px; height: 104px; flex: none;
  border-radius: 50%;
  background: var(--violet);
  display: grid; place-items: center;
  font-weight: 900; font-size: 44px;
  box-shadow: 0 5px 0 rgba(0,0,0,.28);
  transition: background .3s;
}
.timer.hurry { background: var(--bad); animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.1); } }

/* ---------- лоадер ---------- */
.loader { width: 54px; height: 54px; position: relative; }
.loader::before, .loader::after {
  content: ''; position: absolute; inset: 0;
  border: 7px solid rgba(255,255,255,.25); border-top-color: #fff;
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
.loader::after { inset: 14px; border-width: 5px; animation-duration: .6s; animation-direction: reverse; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- плашки ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,.28);
  padding: 8px 14px; border-radius: 4px;
  font-weight: 800;
}
.pill.white { background: #fff; color: var(--ink); }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100;
  transform: translateX(-50%);
  background: var(--dark); color: #fff;
  padding: 12px 20px; border-radius: 4px;
  font-weight: 800;
  box-shadow: 0 4px 0 #000;
  animation: toastIn .35s var(--spring) both;
}
.toast.bad { background: var(--bad); box-shadow: 0 4px 0 #a82346; }
@keyframes toastIn { from { transform: translate(-50%, 30px); opacity: 0; } }

.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 90; }

@keyframes pop { from { transform: scale(.3); opacity: 0; } 70% { transform: scale(1.12); } }
@keyframes shake { 10%, 90% { transform: translateX(-3px); } 20%, 80% { transform: translateX(6px); } 30%, 50%, 70% { transform: translateX(-10px); } 40%, 60% { transform: translateX(10px); } }
@keyframes slideIn { from { transform: translateX(-40px); opacity: 0; } }

@media (max-width: 600px) {
  .tiles { gap: 8px; }
  .tile { padding: 12px 14px; min-height: 70px; gap: 10px; }
  .timer { width: 76px; height: 76px; font-size: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- переключатель языка ---------- */
.lang { position: relative; z-index: 40; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; color: var(--ink);
  border: 0; border-radius: 999px;
  padding: 6px 12px 6px 9px;
  font: 800 14px var(--font);
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,.25);
}
.lang-btn .ico { width: 18px; height: 18px; }
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: #fff; color: var(--ink);
  border-radius: 6px; padding: 6px; min-width: 170px;
  box-shadow: 0 6px 0 rgba(0,0,0,.2), 0 10px 30px rgba(0,0,0,.25);
  display: none; flex-direction: column;
  animation: pop .25s var(--spring) both;
}
.lang.open .lang-menu { display: flex; }
.lang-menu button {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 0; border-radius: 4px;
  padding: 9px 10px; font: 700 15px var(--font); color: var(--ink);
  cursor: pointer; text-align: left;
}
.lang-menu button:hover { background: #f0f0f0; }
.lang-menu button.on { background: #efe7ff; color: var(--violet); }
.lang-menu b { width: 26px; font-weight: 900; }
.lang.float { position: fixed; top: 12px; right: 12px; }

/* ---------- персонажи ---------- */
.ava { display: block; width: 48px; height: 48px; flex: none; overflow: visible; }
.ava.bounce { animation: avaBounce 1.6s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes avaBounce {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  15% { transform: translateY(0) scale(1.08, .9); }
  40% { transform: translateY(-14%) scale(.95, 1.06); }
  65% { transform: translateY(0) scale(1.05, .94); }
}

/* ---------- оверлей (QR на весь экран) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(20, 6, 48, .82);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fadeIn .2s ease both;
  cursor: zoom-out;
}
.overlay .card { cursor: default; animation: pop .35s var(--spring) both; }
@keyframes fadeIn { from { opacity: 0; } }

/* ---------- окно подтверждения ---------- */
.modal-ov { cursor: default; z-index: 95; }
.modal { max-width: 420px; width: 100%; display: flex; flex-direction: column; gap: 12px; padding: 22px; text-align: left; }
.modal h3 { font-size: 22px; }
.modal p { margin: 0; color: var(--ink-2); font-weight: 600; }
.modal-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-top: 6px; }

/* ---------- переключатель (вкл/выкл) ---------- */
.switch { display: flex; align-items: center; gap: 14px; padding: 10px 4px; cursor: pointer; text-align: left; }
.switch + .switch { border-top: 1px solid #eee; }
.switch .txt { flex: 1; display: flex; flex-direction: column; gap: 2px; font-weight: 800; color: var(--ink); }
.switch .txt small { font-weight: 600; color: var(--ink-2); font-size: 13px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .knob { flex: none; width: 50px; height: 30px; border-radius: 999px; background: #d6d6dc; position: relative; transition: background .2s; }
.switch .knob::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 0 rgba(0,0,0,.15); transition: transform .25s var(--spring); }
.switch input:checked + .knob { background: var(--ok); }
.switch input:checked + .knob::after { transform: translateX(20px); }
.switch input:focus-visible + .knob { outline: 3px solid var(--violet); outline-offset: 2px; }

/* ---------- полоса автоперехода ---------- */
.autobar { position: fixed; left: 0; top: 0; height: 6px; width: 100%; background: var(--a2); z-index: 50; transform-origin: left; box-shadow: 0 2px 0 rgba(0,0,0,.2); }
.autobar.run { animation: autobar linear forwards; }
@keyframes autobar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------- боковая панель справа (настройки, игроки) — не закрывает экран ---------- */
.overlay.drawer-ov { background: rgba(20, 6, 48, .25); backdrop-filter: none; justify-content: flex-end; align-items: stretch; padding: 0; }
.drawer-ov .settings-card { width: min(420px, 100vw); max-height: none; height: 100%; border-radius: 0; box-shadow: -6px 0 0 rgba(0,0,0,.18), -20px 0 40px rgba(0,0,0,.25); animation: drawerIn .3s cubic-bezier(.2,.9,.3,1) both; }
@keyframes drawerIn { from { transform: translateX(100%); } }

/* ---------- вход ведущего ---------- */
.login-ov { background: var(--bgc); backdrop-filter: none; cursor: default; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; align-items: stretch; gap: 12px; padding: 24px; text-align: center; }
.login-card .logo { color: var(--violet); text-shadow: 0 4px 0 #e6dbff; font-size: 52px; margin-bottom: 6px; }
.login-card h3 { font-size: 20px; }
.login-hint { margin: 0; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.login-card.shake { animation: shake .5s ease both; }

/* ---------- «ведущий отключился» у игроков ---------- */
.away-banner { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); z-index: 70; display: flex; align-items: center; gap: 10px; background: #fff; color: var(--ink); padding: 10px 16px; border-radius: 999px; font-weight: 800; font-size: 15px; box-shadow: 0 5px 0 rgba(0,0,0,.2), 0 10px 30px rgba(0,0,0,.25); max-width: calc(100% - 24px); animation: toastIn .35s var(--spring) both; }
.away-banner .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--a2); flex: none; animation: pulse .6s ease-in-out infinite alternate; }

/* ---------- «у тебя идёт игра» в списке квизов ---------- */
.resume-card { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: #fff; color: var(--ink); border-radius: 8px; padding: 14px 16px; box-shadow: 0 5px 0 rgba(0,0,0,.2); animation: rise .4s var(--spring) both; }
.resume-card .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 5px #d9f5e6; flex: none; }
.resume-card .txt { flex: 1; min-width: 200px; font-weight: 800; }
.resume-card .txt small { display: block; color: var(--ink-2); font-weight: 700; }
.nb.logout-btn { background: rgba(255,255,255,.16); border: 0; cursor: pointer; padding: 8px 10px; }

/* ---------- подтверждение удаления ---------- */
.modal.has-hero { text-align: center; align-items: center; }
.modal.has-hero .modal-btns { justify-content: center; width: 100%; }
.modal.has-hero .modal-btns .btn { flex: 1; }
.modal.danger h3 { color: #c2264b; }
.del-hero { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 4px; width: 100%; }
.del-icon { width: 78px; height: 78px; border-radius: 50%; background: #ffe3ea; color: var(--bad); display: grid; place-items: center; box-shadow: 0 0 0 8px #fff3f6; animation: pop .45s var(--spring) both, wobble 1.6s .5s ease-in-out infinite; }
.del-icon .ico { width: 38px; height: 38px; }
@keyframes wobble { 0%, 70%, 100% { transform: rotate(0); } 78% { transform: rotate(-12deg); } 86% { transform: rotate(10deg); } 94% { transform: rotate(-6deg); } }
.del-quiz { display: flex; align-items: center; gap: 12px; width: 100%; background: #f6f4fa; border-radius: 10px; padding: 8px 14px 8px 8px; text-align: left; }
.del-cover { width: 52px; height: 52px; border-radius: 8px; background: var(--c); color: #fff; display: grid; place-items: center; flex: none; box-shadow: 0 3px 0 var(--cd); }
.del-cover .ico { width: 28px; height: 28px; }
.del-name { font-weight: 900; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.del-name small { display: block; font-weight: 700; color: var(--ink-2); font-size: 13px; }

/* ---------- команды ---------- */
.t0 { --tc: #e8456b; --td: #a82346; } .t1 { --tc: #1e9bd7; --td: #13699a; }
.t2 { --tc: #f2a516; --td: #b07405; } .t3 { --tc: #2db57a; --td: #1b7a50; }
.team-tag { display: inline-flex; align-items: center; gap: .35em; background: var(--tc); color: #fff; font-weight: 900; padding: .3em .75em; border-radius: 999px; box-shadow: 0 3px 0 var(--td); white-space: nowrap; }
.team-tag .ico { width: 1.1em; height: 1.1em; }
.btn.t0, .btn.t1, .btn.t2, .btn.t3 { background: var(--tc); color: #fff; box-shadow: 0 4px 0 var(--td); }
