/* Балда — оформление.
   Цвета: тёмно-синий (шапки, второй игрок), оранжевый (главные действия, первый игрок),
   светло-серый фон, белые карточки. Шрифты: Nunito Sans (интерфейс), Roboto Slab (буквы на плитках). */
@font-face {
  font-family: 'Nunito Sans';
  src: url('../assets/fonts/nunito-sans-cyrillic-wght-normal.woff2') format('woff2');
  font-weight: 200 1000; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Nunito Sans';
  src: url('../assets/fonts/nunito-sans-latin-wght-normal.woff2') format('woff2');
  font-weight: 200 1000; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Roboto Slab';
  src: url('../assets/fonts/roboto-slab-cyrillic-wght-normal.woff2') format('woff2');
  font-weight: 100 900; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Roboto Slab';
  src: url('../assets/fonts/roboto-slab-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 900; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --navy: #204882;          /* шапки экранов */
  --navy-2: #2A5797;
  --brand: #204882;         /* кнопки, переключатели, второй игрок */
  --orange: #EC6331;        /* главное действие, первый игрок */
  --orange-2: #F27A48;
  --icon-a: #3062A2;
  --icon-b: #234C88;
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --surface-2: #EEF1F5;
  --ink: #121826;
  --muted: #6C727F;
  --line: #E5E7EB;
  --tile: #FFFFFF;
  --tile-ink: #121826;
  --tile-empty: #E7EBF1;
  --tile-shadow: 0 1px 0 #D5DCE6, 0 4px 10px rgba(18, 24, 38, .06);
  --p1: var(--orange);
  --p1-soft: #FDEBE3;
  --p1-deep: #C94A1E;
  --p2: var(--brand);
  --p2-soft: #E3EAF5;
  --p2-deep: #15335F;
  --ok: #12A06B;
  --ok-soft: #DDF4EA;
  --bad: #E5484D;
  --bad-soft: #FDE4E4;
  --gold: #F5A524;
  --on-band: #FFFFFF;
  --on-band-muted: rgba(255, 255, 255, .74);
  --band-glass: rgba(255, 255, 255, .14);
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 18px rgba(16, 24, 40, .06);
  --font: 'Nunito Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Nunito Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --tile-font: 'Roboto Slab', Georgia, 'Times New Roman', serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ad-h: 0px;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --navy: #183766;
  --navy-2: #1E4379;
  --brand: #4F80D8;
  --orange: #F06D3C;
  --orange-2: #F5865A;
  --icon-a: #3C6FBD;
  --icon-b: #27508F;
  --bg: #0C1322;
  --surface: #151F34;
  --surface-2: #1D2942;
  --ink: #EEF2F8;
  --muted: #95A1B6;
  --line: #25324C;
  --tile: #213052;
  --tile-ink: #F3F6FB;
  --tile-empty: #121B2E;
  --tile-shadow: 0 1px 0 #080D18, 0 4px 10px rgba(0, 0, 0, .3);
  --p1-soft: #3A2117;
  --p1-deep: #B4441B;
  --p2-soft: #1A2B4E;
  --p2-deep: #2C59A8;
  --ok: #2CC489;
  --ok-soft: #0F3626;
  --bad: #FF5C61;
  --bad-soft: #431B20;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body {
  font-family: var(--font);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
input, textarea { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
a { color: var(--brand); }
h1, h2, h3 { font-family: var(--display); font-weight: 800; margin: 0; letter-spacing: -.01em; }

#app { height: 100%; }
.screen {
  min-height: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 12px) 18px calc(var(--safe-bottom) + 24px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: screen-in .22s ease-out;
}
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- синяя шапка экрана ---------- */
.topbar { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.topbar h2 { font-size: 20px; flex: 1; }
.screen > .topbar:first-child,
.screen > .hero:first-child {
  margin: calc(-12px - var(--safe-top)) -18px 4px;
  padding: calc(var(--safe-top) + 10px) 16px 16px;
  background: var(--navy);
  color: var(--on-band);
  border-radius: 0 0 28px 28px;
}
.screen > .topbar:first-child h2 { color: var(--on-band); }
.screen > .topbar:first-child .icon-btn,
.hero .icon-btn { background: var(--band-glass); box-shadow: none; color: var(--on-band); }

.icon-btn {
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--surface); box-shadow: var(--shadow); color: var(--ink);
  flex: none;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:active { transform: scale(.94); }

/* ---------- главный экран: шапка с логотипом ---------- */
.hero { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 14px; }
.screen > .hero:first-child {
  padding-bottom: 22px;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(255, 255, 255, .10), transparent 55%),
    linear-gradient(180deg, var(--navy-2), var(--navy) 75%);
}
.hero::after {
  content: 'Б'; position: absolute; right: -26px; top: 26px; pointer-events: none;
  font: 700 230px/1 var(--tile-font); color: rgba(255, 255, 255, .05); transform: rotate(12deg);
}
.hero > * { position: relative; z-index: 1; }
.hero .profile-chip { background: var(--band-glass); color: var(--on-band); box-shadow: none; }
.hero .profile-chip .hint { color: var(--on-band-muted); }
.hero .tagline { color: var(--on-band-muted); }
.hero .menu-card.primary { box-shadow: 0 14px 28px -12px rgba(0, 0, 0, .55); }

.logo { display: flex; justify-content: center; gap: 7px; padding: 8px 0 2px; }
.logo span {
  width: 52px; height: 58px; border-radius: 14px;
  display: grid; place-items: center;
  font: 700 33px/1 var(--tile-font);
  background: var(--tile); color: var(--tile-ink);
  box-shadow: var(--tile-shadow);
  animation: logo-in .5s cubic-bezier(.2, 1.4, .4, 1) both;
}
.hero .logo span { background: #fff; color: #1B3D70; box-shadow: 0 3px 0 rgba(6, 18, 42, .35), 0 10px 22px rgba(6, 18, 42, .25); }
:root[data-theme='dark'] .hero .logo span { background: #E9EEF6; }
.logo span:nth-child(1) { transform: rotate(-4deg); animation-delay: .00s; }
.logo span:nth-child(2) { transform: translateY(4px) rotate(2deg); background: var(--orange) !important; color: #fff !important; animation-delay: .05s; }
.logo span:nth-child(3) { transform: rotate(-1deg); animation-delay: .10s; }
.logo span:nth-child(4) { transform: translateY(3px) rotate(3deg); background: #3467B3 !important; color: #fff !important; animation-delay: .15s; }
.logo span:nth-child(5) { transform: rotate(-3deg); animation-delay: .20s; }
.hero .logo span:nth-child(4) { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .28), 0 3px 0 rgba(6, 18, 42, .35), 0 10px 22px rgba(6, 18, 42, .25); }
@keyframes logo-in { from { opacity: 0; translate: 0 -14px; } to { opacity: 1; translate: 0 0; } }
.tagline { text-align: center; color: var(--muted); font-weight: 700; margin-top: -4px; }

/* ---------- карточки меню ---------- */
.menu { display: flex; flex-direction: column; gap: 12px; }
.menu-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.menu-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); color: var(--ink);
  text-align: left; width: 100%;
  transition: transform .12s ease;
}
.menu-card:active { transform: scale(.98); }
.menu-card .mc-icon {
  width: 50px; height: 50px; border-radius: 15px; flex: none;
  display: grid; place-items: center; font-size: 24px;
  background: linear-gradient(160deg, var(--icon-a), var(--icon-b)); color: #fff;
  box-shadow: 0 8px 16px -8px rgba(32, 72, 130, .7);
}
.menu-card .mc-icon svg { width: 24px; height: 24px; }
.menu-card .mc-text { flex: 1; min-width: 0; }
.menu-card .mc-title { font-weight: 800; font-size: 17.5px; }
.menu-card .mc-sub { color: var(--muted); font-size: 14px; font-weight: 600; }
.menu-card .mc-go { color: var(--muted); opacity: .6; flex: none; }
.menu-card .mc-go svg { width: 20px; height: 20px; display: block; }
.menu-card.primary { background: linear-gradient(135deg, var(--orange-2), var(--orange)); color: #fff; box-shadow: 0 12px 26px -12px rgba(236, 99, 49, .8); }
.menu-card.primary .mc-icon { background: rgba(255, 255, 255, .2); box-shadow: none; }
.menu-card.primary .mc-sub, .menu-card.primary .mc-go { color: rgba(255, 255, 255, .88); opacity: 1; }
.menu-card.blue { background: linear-gradient(135deg, var(--navy-2), var(--navy)); color: #fff; }
.menu-card.blue .mc-icon { background: rgba(255, 255, 255, .16); box-shadow: none; }
.menu-card.blue .mc-sub { color: rgba(255, 255, 255, .85); }
.menu-card.small { flex-direction: column; align-items: flex-start; gap: 12px; }
.menu-card.small .mc-icon { width: 46px; height: 46px; border-radius: 14px; }

/* ссылки внизу главного экрана — «таблетки» */
.links { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.link-btn {
  min-height: 40px; padding: 0 16px; border-radius: 999px;
  font-weight: 700; font-size: 14.5px; color: var(--ink);
  background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line);
}
.link-btn:active { background: var(--surface-2); }
.link-btn.gold { color: var(--orange); background: var(--p1-soft); box-shadow: none; }

/* ---------- профиль ---------- */
.profile-chip {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 5px 14px 5px 5px; border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow); font-weight: 800;
}
.profile-chip > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 22px;
}
.avatar.sm { width: 34px; height: 34px; font-size: 19px; }
.avatar.lg { width: 64px; height: 64px; font-size: 34px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.status-dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px; border-radius: 999px;
  font-weight: 800; font-size: 16px; color: var(--ink);
  background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line);
  transition: transform .1s ease, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.primary { background: var(--orange); color: #fff; box-shadow: 0 10px 20px -10px rgba(236, 99, 49, .9); }
.btn.blue { background: var(--brand); color: #fff; box-shadow: 0 10px 20px -10px rgba(32, 72, 130, .9); }
.btn.ok { background: var(--ok); color: #fff; box-shadow: 0 10px 20px -10px rgba(18, 160, 107, .9); }
.btn.ghost { background: transparent; box-shadow: none; color: var(--muted); }
.btn.block { width: 100%; }
.row > .btn.grow { padding: 0 12px; font-size: 15px; white-space: nowrap; }
.btn.sm { min-height: 40px; padding: 0 16px; font-size: 14px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.field {
  width: 100%; min-height: 54px; padding: 0 16px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  font: 700 18px var(--font); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(32, 72, 130, .12); }
.field::placeholder { color: var(--muted); opacity: .8; }
.code-input { text-align: center; font: 700 38px var(--tile-font); letter-spacing: .35em; padding-left: .35em; }

.section { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.section h3 { font-size: 17px; }
.label { font-size: 15px; color: var(--ink); font-weight: 800; }
.hint { color: var(--muted); font-size: 14px; font-weight: 600; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }

.seg { display: flex; background: var(--surface-2); border-radius: 999px; padding: 4px; gap: 2px; }
.seg button { flex: 1; min-width: 0; min-height: 42px; border-radius: 999px; font-weight: 800; font-size: 15px; color: var(--muted); transition: background .15s, color .15s; }
.seg button.on { background: var(--brand); color: #fff; box-shadow: 0 6px 14px -8px rgba(32, 72, 130, .9); }

.switch-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch-row .grow b { display: block; font-size: 15.5px; font-weight: 800; }
.switch-row .grow span { color: var(--muted); font-size: 13.5px; font-weight: 600; }
.switch { width: 52px; height: 32px; border-radius: 99px; background: var(--line); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch.on { background: var(--brand); }
.switch.on::after { transform: translateX(20px); }

.avatar-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.avatar-grid button { aspect-ratio: 1; min-width: 0; border-radius: 50%; font-size: 20px; display: grid; place-items: center; border: 3px solid transparent; }
.avatar-grid button.on { border-color: var(--brand); }

/* ---------- код комнаты, QR ---------- */
.code-tiles { display: flex; justify-content: center; gap: 8px; }
.code-tiles span {
  width: 58px; height: 68px; border-radius: 16px; display: grid; place-items: center;
  font: 700 40px var(--tile-font); background: var(--tile); color: var(--tile-ink); box-shadow: var(--tile-shadow);
}
.qr-box { background: #fff; border-radius: 20px; padding: 14px; width: 200px; height: 200px; margin: 0 auto; box-shadow: var(--shadow); }
.qr-box svg { width: 100%; height: 100%; display: block; }
.waiting-dots::after { content: ''; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------- списки ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .li-sub { color: var(--muted); font-size: 13px; font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 18px; font-weight: 600; }

/* ---------- «Как играть»: шаги с номерами ---------- */
.steps { display: flex; flex-direction: column; gap: 10px; }
.step { display: flex; align-items: center; gap: 16px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.step-icon {
  position: relative; width: 52px; height: 52px; border-radius: 16px; flex: none;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(160deg, var(--icon-a), var(--icon-b));
  box-shadow: 0 8px 16px -8px rgba(32, 72, 130, .7);
}
.step-icon svg { width: 24px; height: 24px; }
.step-icon b {
  position: absolute; top: -7px; right: -7px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; background: var(--orange); color: #fff;
  font: 800 12.5px/1 var(--font); box-shadow: 0 0 0 3px var(--surface);
}
.step-title { font-weight: 800; font-size: 16.5px; }
.step-sub { color: var(--muted); font-size: 14px; font-weight: 600; }

/* ---------- экран игры ---------- */
.game {
  height: 100%; max-width: 560px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: calc(var(--safe-top) + 8px) 12px calc(var(--safe-bottom) + var(--ad-h) + 8px);
  gap: 8px;
}
.game .icon-btn { width: 42px; height: 42px; }

/* табло наверху: имена и счёт, второй игрок — зеркально справа */
.game-top { display: grid; grid-template-columns: 42px minmax(0, 1fr) minmax(0, 1fr) 42px; align-items: center; gap: 6px; }
.sb {
  position: relative; display: flex; align-items: center; gap: 8px; min-width: 0;
  min-height: 58px; padding: 10px 14px; border-radius: 18px;
  background: var(--surface); box-shadow: var(--shadow);
  transition: background .2s, color .2s, box-shadow .2s;
}
.sb.right { flex-direction: row-reverse; text-align: right; }
.sb-av { display: none; }
.sb .avatar { width: 30px; height: 30px; font-size: 17px; }
.sb-txt { flex: 1; min-width: 0; }
.sb-name { font-weight: 800; font-size: 14.5px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-name > span { display: inline-block; }
/* длинное имя — бегущая строка: плавно к концу, пауза, обратно */
.sb-name.mq { text-overflow: clip; -webkit-mask-image: linear-gradient(90deg, transparent, #000 5px, #000 calc(100% - 5px), transparent); mask-image: linear-gradient(90deg, transparent, #000 5px, #000 calc(100% - 5px), transparent); }
.sb-name.mq > span { animation: name-mq var(--mq-t, 5s) ease-in-out infinite alternate; }
@keyframes name-mq { 0%, 18% { transform: translateX(0); } 82%, 100% { transform: translateX(var(--mq)); } }
.sb-sub { font-size: 11.5px; color: var(--muted); font-weight: 700; display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; }
.sb.right .sb-sub { justify-content: flex-end; }
.sb .status-dot { flex: none; width: 8px; height: 8px; }
.sb-score { flex: none; font: 900 25px/1 var(--display); font-variant-numeric: tabular-nums; }
.sb.c1 .sb-score { color: var(--p1); }
.sb.c2 .sb-score { color: var(--p2); }
/* чей ход — вся карточка цвета игрока, тексты белые */
.sb.c1.active { background: var(--p1); box-shadow: 0 10px 22px -12px rgba(236, 99, 49, .95); }
.sb.c2.active { background: var(--p2); box-shadow: 0 10px 22px -12px rgba(32, 72, 130, .95); }
.sb.active, .sb.active .sb-score { color: #fff; }
.sb.active .sb-sub { color: rgba(255, 255, 255, .86); }
.sb.active .skip-mark { color: var(--bad); background: #fff; border-radius: 6px; padding: 0 5px; }
.sb.active .status-dot.on { box-shadow: 0 0 0 2px rgba(255, 255, 255, .7); }
/* на широких экранах в карточках помещаются и аватары */
@media (min-width: 440px) { .sb-av { display: block; } }

/* под именами: отсчёт времени хода по секундам */
.turn-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.turn-right { justify-self: end; display: flex; gap: 8px; }
.turn-timer { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 100px; }
.tt-time { font: 900 31px/1 var(--display); font-variant-numeric: tabular-nums; color: var(--ink); }
.tt-time.c1 { color: var(--p1); }
.tt-time.c2 { color: var(--p2); }
.tt-time.off { color: var(--muted); opacity: .55; font-size: 27px; }
.tt-time.low { color: var(--bad); animation: tick 1s ease-in-out infinite; }
@keyframes tick { 0%, 100% { transform: scale(1); } 12% { transform: scale(1.12); } }
.tt-bar { width: 88px; height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.tt-bar i { display: block; width: 0; height: 100%; border-radius: 4px; background: var(--muted); transition: width .25s linear; }
.tt-bar i.c1 { background: var(--p1); }
.tt-bar i.c2 { background: var(--p2); }
.tt-bar i.low { background: var(--bad); }
.emoji-float { position: absolute; right: 8px; top: -6px; font-size: 30px; animation: float-up 1.8s ease-out forwards; pointer-events: none; }
@keyframes float-up { 0% { opacity: 0; transform: translateY(16px) scale(.6); } 15% { opacity: 1; transform: translateY(0) scale(1.1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-26px) scale(1); } }

.status-line { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; }
.word-pill {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 18px; border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow);
  font-weight: 800; max-width: 100%;
}
.word-pill .wp-word { font: 700 20px var(--tile-font); letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.word-pill .wp-note { font-size: 13px; color: var(--muted); white-space: nowrap; }
.word-pill.ok { background: var(--ok-soft); color: var(--ok); }
.word-pill.ok .wp-note { color: var(--ok); }
.word-pill.bad .wp-note { color: var(--bad); }
.word-pill.info { color: var(--muted); font-weight: 700; font-size: 15px; }
.word-pill.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.board-wrap { flex: 1 1 auto; min-height: 120px; container-type: size; display: grid; place-items: center; }
.board {
  --gap: 6px;
  width: min(100cqw, 100cqh); height: min(100cqw, 100cqh);
  display: grid; gap: var(--gap);
  touch-action: none; position: relative;
}
.cell {
  border-radius: 12px; display: grid; place-items: center;
  background: var(--tile-empty);
  font: 700 1em/1 var(--tile-font); color: var(--tile-ink);
  position: relative; z-index: 1; transition: background .15s, transform .15s, color .15s;
}
.cell.filled { background: var(--tile); box-shadow: var(--tile-shadow); }
.cell.avail::after { content: ''; width: 18%; height: 18%; border-radius: 50%; background: var(--muted); opacity: .3; }
.cell.picked { background: var(--surface); box-shadow: inset 0 0 0 3px var(--p1); }
.cell.new { background: var(--p1-soft); box-shadow: inset 0 0 0 3px var(--p1); color: var(--p1); animation: pop .25s ease-out; }
.cell.path { background: var(--p1); color: #fff; box-shadow: 0 3px 0 var(--p1-deep); transform: translateY(-1px); }
.cell.path.c2 { background: var(--p2); box-shadow: 0 3px 0 var(--p2-deep); }
.cell .ord { position: absolute; top: 3px; left: 5px; font: 800 10px var(--font); opacity: .7; }
.cell.last::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 3px var(--hl, var(--p2)); animation: last-ring 2.6s ease-out forwards; pointer-events: none; }
@keyframes last-ring { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
.cell.flash { animation: flash 1.4s ease-out; }
.cell.disabled { opacity: .9; }
@keyframes pop { 0% { transform: scale(.7); } 70% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes flash { 0% { transform: scale(1); } 15% { transform: scale(1.12); } 30% { transform: scale(1); } }
.board svg.path-line { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; z-index: 0; }

.actions { display: grid; grid-template-columns: 1fr 1fr 1.6fr; gap: 8px; }
.actions .btn { min-height: 54px; padding: 0 10px; font-size: 15px; }
.actions.two { grid-template-columns: 1fr 1fr; }
/* «Пропуск» — время хода — «Убрать букву» */
.actions.timed { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 14px; }
.actions.timed .turn-timer { min-width: 84px; padding: 0 2px; }
.actions.timed .btn { white-space: nowrap; }
@media (max-width: 380px) {
  .actions.timed { gap: 8px; }
  .actions.timed .btn { padding: 0 6px; font-size: 14px; }
  .actions.timed .turn-timer { min-width: 72px; }
  .actions.timed .tt-time { font-size: 25px; }
  .actions.timed .tt-bar { width: 66px; }
}
.kb-timer { display: flex; justify-content: center; padding: 2px 0 8px; }
.kb-timer .tt-time { font-size: 22px; }
.kb-timer .tt-bar { display: none; }
.status-line { position: relative; }
.status-line:has(.status-emoji) { padding: 0 50px; }
.status-line .status-emoji { position: absolute; right: 0; top: 50%; transform: translateY(-50%); }

.keyboard { background: var(--surface); border-radius: 24px; box-shadow: var(--shadow); padding: 8px; animation: kb-in .18s ease-out; }
@keyframes kb-in { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.kb-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.key {
  height: clamp(46px, 6.6vh, 62px); border-radius: 12px;
  background: var(--surface-2); color: var(--ink); font: 700 clamp(22px, 3.2vh, 29px)/1 var(--tile-font);
  display: grid; place-items: center; text-transform: uppercase;
}
.key:active, .key.on { background: var(--orange); color: #fff; }
.key:active { transform: translateY(1px); }
.key.remove, .key.hide { display: grid; place-items: center; }
.key.remove { grid-column: 5 / span 2; font: 800 16px var(--font); text-transform: none; }
.key.hide { grid-column: 7; color: var(--muted); }
.key.hide svg { width: 24px; height: 24px; }
.key.wide { grid-column: span 3; font: 800 17px var(--font); text-transform: none; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); color: var(--muted); border-radius: 999px; }
.game.kb-open .recent { display: none; }

/* последние слова под карточками игроков */
.recent { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: -2px; }
.recent-col {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  min-height: 52px; padding: 0 14px; text-align: left; overflow: hidden;
  color: var(--muted); font: 700 12.5px/1.32 var(--font); letter-spacing: .05em; text-transform: uppercase;
}
.recent-col.right { align-items: flex-end; text-align: right; }
.recent-col span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .5; }
.recent-col span:first-child { opacity: .85; }
.recent-col span:nth-child(2) { opacity: .65; }
.recent-col span:nth-child(n+4) { opacity: .38; }
.chip-btn {
  min-height: 44px; padding: 0 18px; border-radius: 999px; flex: none;
  background: var(--brand); color: #fff; font-weight: 800; white-space: nowrap;
  box-shadow: 0 10px 20px -10px rgba(32, 72, 130, .9);
}
.skip-mark { color: var(--bad); }
.word-item { display: flex; flex-direction: column; }
.word-chip.open { background: var(--surface-2); }
.word-def { font-size: 14px; font-weight: 600; line-height: 1.4; padding: 0 8px; text-transform: none; letter-spacing: 0; }
.word-def:not(:empty) { padding: 4px 8px 12px; }
.words-cols.stacked { grid-template-columns: 1fr; }
.wc-head.c1 span:first-child { color: var(--p1); }
.wc-head.c2 span:first-child { color: var(--p2); }
.emoji-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.emoji-grid button { font-size: 34px; height: 66px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.modal .btn { min-height: 56px; }

/* ---------- нижние листы, модальные окна, тосты ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(10, 18, 34, .5); z-index: 50; animation: fade .18s; display: flex; align-items: flex-end; justify-content: center; }
.backdrop.center { align-items: center; padding: 20px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%; max-width: 560px; max-height: 88vh; overflow: auto;
  background: var(--bg); border-radius: 28px 28px 0 0;
  /* лёгкая рамка и тень сверху — чтобы лист не сливался с экраном игры такого же цвета */
  border: 1px solid color-mix(in srgb, var(--line) 65%, transparent); border-bottom: none;
  box-shadow: 0 -8px 28px rgba(10, 18, 34, .14);
  padding: 14px 18px calc(var(--safe-bottom) + 18px);
  animation: sheet-in .24s cubic-bezier(.2, .9, .3, 1);
  display: flex; flex-direction: column; gap: 14px;
}
.close-x {
  position: absolute; top: 14px; right: 22px; z-index: 3; /* справа тот же отступ, что у заголовка слева (padding окна) */
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink);
}
.close-x svg { width: 20px; height: 20px; }
.close-x:active { transform: scale(.92); }
.sheet > .close-x { position: sticky; top: 0; right: auto; align-self: flex-end; flex: none; margin: 0 0 -54px 0; box-shadow: 0 0 0 4px var(--bg); }
.sheet > h2 { padding-right: 58px; min-height: 40px; display: flex; align-items: center; }
.sheet > .result-title { padding: 0 58px; }
.modal { position: relative; }
@keyframes sheet-in { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal { width: 100%; max-width: 420px; background: var(--surface); border-radius: 26px; padding: 22px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 24px 60px rgba(10, 18, 34, .3); animation: modal-in .22s cubic-bezier(.2, 1.2, .4, 1); }
@keyframes modal-in { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h2, .sheet h2 { font-size: 21px; }

/* окошко слова и статья Викисловаря поверх игры */
.wd-word { font: 700 30px/1.1 var(--tile-font); letter-spacing: .04em; padding-right: 58px; overflow-wrap: anywhere; }
.word-card .hint { margin-top: -8px; }
.wd-def { font-size: 16px; font-weight: 600; line-height: 1.45; min-height: 44px; }
.modal.wiki { max-width: 600px; height: min(82vh, 780px); padding: 0; gap: 0; overflow: hidden; }
.wiki-head { display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 0 72px 0 20px; border-bottom: 1px solid var(--line); flex: none; }
.wiki-head span { color: var(--muted); font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wiki-frame { flex: 1; width: 100%; min-height: 0; border: 0; background: #fff; display: block; }
.wiki-note { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; padding: 28px; text-align: center; }

.toast-wrap { position: fixed; left: 0; right: 0; top: calc(var(--safe-top) + 10px); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 100; pointer-events: none; padding: 0 14px; }
.toast {
  pointer-events: auto; max-width: 480px; width: fit-content;
  background: var(--ink); color: var(--bg); border-radius: 16px; padding: 12px 16px;
  font-weight: 700; font-size: 15px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  animation: toast-in .22s ease-out; display: flex; align-items: center; gap: 12px;
}
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
.toast .t-btn { background: rgba(255, 255, 255, .2); padding: 6px 12px; border-radius: 999px; font-weight: 800; white-space: nowrap; }
@keyframes toast-in { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }
/* в партии сообщения появляются внизу, над кнопками, чтобы не закрывать имена и время */
/* в партии — сверху, под карточками игроков: поле остаётся свободным, можно сразу вводить следующее слово */
body.in-game .toast-wrap { top: calc(var(--safe-top) + 74px); }
.toast .t-x { flex: none; width: 28px; height: 28px; margin: -4px -8px -4px -4px; border-radius: 50%; display: grid; place-items: center; background: rgba(127, 127, 127, .16); color: inherit; }
.toast .t-x svg { width: 15px; height: 15px; }
.toast.bad .t-x, .toast.ok .t-x { background: rgba(255, 255, 255, .22); }

/* ---------- итог партии ---------- */
.result-title { font: 900 30px var(--display); text-align: center; }
.result-score { display: flex; justify-content: center; align-items: center; gap: 18px; font: 900 46px var(--display); }
.result-score .c1 { color: var(--p1); }
.result-score .c2 { color: var(--p2); }
.words-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.words-col { background: var(--surface); border-radius: 18px; padding: 10px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); }
.words-col .wc-head { font-weight: 800; font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; }
.word-chip { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; border-radius: 10px; font-weight: 800; text-transform: uppercase; font-size: 14px; letter-spacing: .03em; }
.word-chip:active { background: var(--surface-2); }
.word-chip small { color: var(--muted); font-size: 12px; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 85; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- реклама (тестовая заглушка) ---------- */
.mock-strip {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(56px + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: repeating-linear-gradient(45deg, #EEF1F5, #EEF1F5 10px, #E6EAF0 10px, #E6EAF0 20px);
  color: #6C727F; display: grid; place-items: center; font-weight: 800; font-size: 13px;
  border-top: 1px solid var(--line);
}
:root[data-theme='dark'] .mock-strip { background: repeating-linear-gradient(45deg, #141D30, #141D30 10px, #182238 10px, #182238 20px); color: #8592A8; }
.mock-full { position: fixed; inset: 0; z-index: 90; background: #0B1220; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 30px; text-align: center; }
.mock-full .mock-x { position: absolute; top: calc(var(--safe-top) + 14px); right: 14px; min-width: 44px; height: 44px; padding: 0 14px; border-radius: 22px; background: rgba(255, 255, 255, .15); font-weight: 800; }
.mock-full .mock-card { width: min(320px, 90%); aspect-ratio: 4/5; border-radius: 24px; background: linear-gradient(160deg, #2F62AD, #183766); display: grid; place-items: center; padding: 20px; font: 800 22px var(--display); }

/* ---------- магазин ---------- */
.plan { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); border: 2px solid transparent; text-align: left; width: 100%; color: var(--ink); }
.plan.best { border-color: var(--orange); }
.plan .pl-icon { font-size: 28px; }
.plan .pl-title { font-weight: 800; }
.plan .pl-sub { font-size: 13px; color: var(--muted); font-weight: 600; }
.plan .pl-price { margin-left: auto; font: 900 18px var(--display); white-space: nowrap; }
.status-card { border-radius: var(--radius); padding: 16px; background: var(--p1-soft); color: #A2431B; font-weight: 800; }
:root[data-theme='dark'] .status-card { color: #FFB08F; }
.test-note { font-size: 13px; font-weight: 700; color: #8A5A00; background: #FFF3D1; border-radius: 14px; padding: 10px 12px; }
:root[data-theme='dark'] .test-note { background: #3A3012; color: #FFD889; }

/* ---------- правила ---------- */
.rules p, .rules li { font-size: 15.5px; font-weight: 500; }
.rules p { margin: 0; }
.rules ul { padding-left: 20px; margin: 6px 0; }
.rules li { margin: 4px 0; }
.rules b { font-weight: 800; }
.mini-board { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; width: 210px; margin: 6px auto; }
.mini-board i { aspect-ratio: 1; border-radius: 8px; background: var(--tile-empty); display: grid; place-items: center; font: 700 19px var(--tile-font); font-style: normal; }
.mini-board i.f { background: var(--tile); box-shadow: inset 0 0 0 1.5px var(--line), 0 2px 0 var(--line); }
.mini-board i.p { background: var(--p1); color: #fff; }

.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--orange); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.thinking { display: inline-flex; gap: 4px; }
.thinking i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: bounce 1s infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; }
.thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

@media (max-height: 720px) {
  .game.kb-open .status-line { display: none; }
  .recent-col { min-height: 34px; }
  .recent-col span:nth-child(n+4) { display: none; }
  .actions .btn { min-height: 48px; }
  .sb { padding: 8px 11px; min-height: 52px; }
  .sb-score { font-size: 23px; }
  .tt-time { font-size: 27px; }
  .hero { gap: 10px; }
  .logo span { width: 46px; height: 52px; font-size: 29px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* заставка «Победа/Поражение» на весь экран — на секунду перед рекламой и итогами */
.end-splash { position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  color: #fff; text-align: center; padding: 30px; animation: es-in .25s ease-out; transition: opacity .25s; }
.end-splash.win { background: linear-gradient(160deg, #2F62AD, #183766); }
.end-splash.lose { background: linear-gradient(160deg, #4A5568, #1F2633); }
.end-splash.draw { background: linear-gradient(160deg, #6B5BA8, #2E2560); }
.end-splash .es-title { font: 900 46px var(--display); letter-spacing: .5px; }
.end-splash .es-score { font: 800 30px var(--display); opacity: .95; }
.end-splash .es-sub { font-size: 16px; opacity: .8; }
.end-splash.out { opacity: 0; }
@keyframes es-in { from { opacity: 0; transform: scale(1.04); } to { opacity: 1; transform: none; } }
