/* =========================================================================
   Испорченный телефон. Светлая «бумажная» тема: белые карточки на тёплом фоне,
   один яркий акцент. Анимации — только transform и opacity, чтобы телефон
   не пересчитывал раскладку на каждом кадре.
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
    --bg: #f5f3ee;
    --paper: #ffffff;
    --ink: #1d1b26;
    --ink-2: #4a4756;
    --muted: #8a8794;
    --line: #e7e3da;
    --line-2: #d8d3c7;
    --accent: #5b5bf0;
    --accent-ink: #ffffff;
    --accent-soft: #ecebff;
    --good: #2f9e44;
    --good-soft: #e6f7ea;
    --warn: #e8590c;
    --danger: #e03131;
    --yellow: #ffd43b;
    --radius: 22px;
    --radius-sm: 14px;
    --shadow: 0 1px 2px rgba(29, 27, 38, .04), 0 8px 28px rgba(29, 27, 38, .07);
    --shadow-lift: 0 2px 4px rgba(29, 27, 38, .06), 0 16px 40px rgba(29, 27, 38, .12);
    --ease: cubic-bezier(.2, .8, .2, 1);
    --spring: cubic-bezier(.34, 1.56, .64, 1);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --font: "Nunito", ui-rounded, "Segoe UI", Roboto, -apple-system, Arial, sans-serif;
}

html, body { margin: 0; padding: 0; }

body {
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--ink);
    background-color: var(--bg);
    /* Едва заметная точечная сетка — как лист блокнота. */
    background-image: radial-gradient(rgba(29, 27, 38, .07) 1px, transparent 1.2px);
    background-size: 22px 22px;
    font: 600 16px/1.45 var(--font);
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: var(--accent); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- каркас ---------- */
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 10px;
    padding: calc(10px + var(--safe-top)) 16px 10px;
    background: rgba(245, 243, 238, .82);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
    background: var(--accent); color: #fff; transform: rotate(-8deg);
    box-shadow: 0 6px 16px rgba(91, 91, 240, .35);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-weight: 900; font-size: 17px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.me-chip {
    display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 999px;
    background: var(--paper); box-shadow: var(--shadow); font-size: 14px; max-width: 46vw;
}
.me-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stage {
    position: relative; flex: 1; width: 100%; max-width: 1180px; margin: 0 auto;
    padding: 8px 16px calc(24px + var(--safe-bottom));
    display: flex; flex-direction: column;
}

.screen { flex: 1; display: flex; flex-direction: column; animation: screen-in .5s var(--ease) both; }
.screen.is-leaving { animation: screen-out .22s ease-in both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes screen-out { to { opacity: 0; transform: translateY(-8px) scale(.99); } }

/* ---------- базовые элементы ---------- */
.card {
    background: var(--paper); border-radius: var(--radius); padding: 22px;
    box-shadow: var(--shadow); border: 1px solid rgba(29, 27, 38, .04);
}
.card.narrow { width: 100%; max-width: 440px; margin: auto; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; }

.title { font-size: 28px; line-height: 1.15; font-weight: 900; letter-spacing: -.02em; margin: 6px 0 8px; }
.subtitle { font-size: 19px; font-weight: 800; margin: 0; letter-spacing: -.01em; }
.label { display: block; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.tiny { font-size: 13px; }
p { margin: 0 0 16px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 18px; border-radius: 14px; border: 0;
    font-weight: 800; font-size: 15px; text-decoration: none; white-space: nowrap;
    background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-2);
    transition: transform .18s var(--ease), box-shadow .2s, background-color .2s, opacity .2s;
    user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.big { min-height: 54px; font-size: 17px; border-radius: 16px; padding: 0 22px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px rgba(91, 91, 240, .32); }
.btn.dark { background: var(--ink); color: #fff; box-shadow: none; }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-2); }
@media (hover: hover) {
    .btn:hover { transform: translateY(-1px); }
    .btn.primary:hover { box-shadow: 0 10px 24px rgba(91, 91, 240, .4); }
    .btn.ghost:hover { background: rgba(29, 27, 38, .04); }
}
.card .btn.big { width: 100%; }

.icon-btn {
    width: 44px; height: 44px; border-radius: 14px; border: 0; display: grid; place-items: center;
    background: var(--paper); box-shadow: var(--shadow); color: var(--ink-2); text-decoration: none;
    transition: transform .18s var(--ease), background-color .2s, color .2s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.small { width: 36px; height: 36px; border-radius: 11px; }
.icon-btn.ghost { background: transparent; box-shadow: none; }
@media (hover: hover) { .icon-btn:hover { color: var(--accent); } }

.link-btn { border: 0; background: none; color: var(--accent); font-size: 14px; font-weight: 700; margin-left: 8px; padding: 0; vertical-align: middle; }

.input {
    width: 100%; border: 1.5px solid var(--line-2); border-radius: 14px; background: #fcfbf8;
    padding: 12px 14px; outline: none; transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 4px var(--accent-soft); }
.input.big { font-size: 18px; padding: 14px 16px; text-align: center; font-weight: 700; }
.code-input { text-transform: uppercase; letter-spacing: .35em; font-weight: 900; font-size: 22px !important; }
.code-input::placeholder { letter-spacing: .2em; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 20px 0 14px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.join-row { display: flex; gap: 10px; }
.join-row .input { flex: 1; min-width: 0; }
.card .join-row .btn.big { width: auto; flex: none; }

.dots { display: inline-flex; gap: 4px; vertical-align: middle; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: dot 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.loader { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; transition: opacity .3s; }
.loader .dots i { width: 9px; height: 9px; }
.loader.is-hidden { opacity: 0; }

/* ---------- приветствие ---------- */
.hero-doodle { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 4px 0 14px; flex-wrap: wrap; }
.bubble-doodle {
    padding: 6px 12px; border-radius: 14px 14px 14px 4px; font-size: 14px; font-weight: 800;
    background: var(--accent-soft); color: var(--accent); animation: float 4s ease-in-out infinite;
}
.bubble-doodle.b2 { background: #fff4d6; color: #b07d00; animation-delay: .5s; }
.bubble-doodle.b3 { background: #ffe8ec; color: #d6336c; animation-delay: 1s; }
.arrow-doodle { color: var(--line-2); font-weight: 900; }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-4px) rotate(2deg); } }
.hero-emoji { font-size: 46px; line-height: 1; margin-bottom: 6px; animation: pop .6s var(--spring) both; }

/* ---------- лобби ---------- */
.lobby { width: 100%; max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.lobby-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.code-value {
    border: 0; background: none; padding: 0; font-size: 38px; font-weight: 900; letter-spacing: .14em;
    color: var(--ink); line-height: 1.1; transition: color .2s, transform .2s var(--ease);
}
.code-value:active { transform: scale(.96); }
@media (hover: hover) { .code-value:hover { color: var(--accent); } }
.lobby-actions { display: flex; gap: 10px; }
.count { color: var(--muted); font-weight: 700; margin-left: 4px; }

.players { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.player {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 14px 8px 12px; border-radius: 18px; background: #faf9f6; border: 1px solid var(--line);
    animation: pop .45s var(--spring) both;
}
.player.is-me { border-color: var(--accent); background: var(--accent-soft); }
.player.is-off { opacity: .55; }
.player-name { font-size: 14px; font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .crown { position: absolute; top: 6px; left: 8px; color: #f59f00; }
.player .crown svg { width: 16px; height: 16px; fill: #ffd43b; }
.kick {
    position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 9px; border: 0;
    display: grid; place-items: center; background: transparent; color: var(--muted); opacity: .0;
    transition: opacity .2s, background-color .2s, color .2s;
}
.kick svg { width: 15px; height: 15px; }
.player:hover .kick, .kick:focus-visible { opacity: 1; }
@media (hover: none) { .kick { opacity: .7; } }
.kick:hover { background: #ffe3e3; color: var(--danger); }
.player.slot { border-style: dashed; background: transparent; color: var(--line-2); justify-content: center; min-height: 104px; animation: none; }

.avatar {
    position: relative; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
    color: #fff; font-weight: 900; font-size: 21px; background: var(--c, var(--accent));
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12); flex: none; overflow: visible;
}
/* Фото кладём поверх круга абсолютно: в grid-контейнере height:100% у картинки
   не работает, и вертикальное фото растягивало строку и вылезало из рамки. */
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar .silhouette { width: 72%; height: 72%; margin-top: 18%; fill: rgba(255, 255, 255, .92); stroke: none; }
.avatar { overflow: visible; }
.avatar .clip { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; display: grid; place-items: center; }
.avatar.sm { width: 30px; height: 30px; font-size: 13px; }
.avatar.xs { width: 26px; height: 26px; font-size: 12px; }
.avatar .online { position: absolute; right: 0; bottom: 0; width: 13px; height: 13px; border-radius: 50%; background: #bbb; border: 2.5px solid #fff; }
.avatar .online.on { background: #40c057; }
.avatar.sm .online { width: 10px; height: 10px; border-width: 2px; }

.plan { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.plan li {
    display: flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 12px; font-size: 14px; font-weight: 800;
    background: #faf9f6; border: 1px solid var(--line); animation: pop .35s var(--spring) both;
}
.plan li svg { width: 16px; height: 16px; }
.plan li small { color: var(--muted); font-weight: 700; }
.plan li.k-write { color: var(--accent); }
.plan li.k-draw { color: #d6336c; }
.plan li.k-describe { color: #0c8599; }
.rule-time { font-weight: 900; white-space: nowrap; }
.rule-time.k-write { color: var(--accent); }
.rule-time.k-draw { color: #d6336c; }
.rule-time.k-describe { color: #0c8599; }
.plan.compact li { padding: 5px 9px; font-size: 13px; }

.lobby-footer {
    position: sticky; bottom: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 12px 0 calc(4px + var(--safe-bottom)); background: linear-gradient(to top, var(--bg) 70%, rgba(245, 243, 238, 0));
}
.waiting-host { flex: 1; text-align: center; margin: 0; display: flex; gap: 8px; align-items: center; justify-content: center; }

/* ---------- игра ---------- */
.play { width: 100%; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.hud {
    position: relative; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px;
    padding: 10px 14px 14px; background: var(--paper); border-radius: 18px; box-shadow: var(--shadow);
}
.hud-round { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.hud-round > span:first-child { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.hud-kind { font-size: 17px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-ready { display: flex; align-items: center; }
.hud-ready .avatar { margin-left: -8px; border: 2px solid #fff; transition: transform .3s var(--spring), opacity .3s, filter .3s; }
.hud-ready .avatar:first-child { margin-left: 0; }
.hud-ready .avatar.wait { filter: grayscale(1); opacity: .35; }
.hud-ready .avatar.done { animation: pop .45s var(--spring); }
.hud-ready .more { margin-left: 6px; font-size: 13px; color: var(--muted); font-weight: 800; }
.hud-timer {
    min-width: 72px; height: 40px; padding: 0 12px; border-radius: 12px; display: grid; place-items: center;
    background: var(--ink); color: #fff; font-weight: 900; font-size: 18px; font-variant-numeric: tabular-nums;
    transition: background-color .3s;
}
.hud-timer.is-low { background: var(--danger); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.07); } }
.timebar { position: absolute; left: 14px; right: 14px; bottom: 6px; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.timebar i { display: block; height: 100%; width: 100%; background: var(--accent); border-radius: 4px; transform-origin: left; will-change: transform; }
.hud-timer.is-low ~ .timebar i { background: var(--danger); }

.task { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 720px; margin: 0 auto; animation: screen-in .45s var(--ease) both; }
.prompt-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.prompt-label svg { width: 17px; height: 17px; color: var(--accent); }
.frame { border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #fff; aspect-ratio: 4 / 3; }
.frame canvas { display: block; width: 100%; height: 100%; }
.prompt-drawing { padding: 14px; }
/* Рисунок и поле ответа должны помещаться на экран без прокрутки. */
.prompt-drawing .frame { width: min(100%, max(240px, calc((100dvh - 350px) * 4 / 3))); margin: 0 auto; }
.textarea-wrap { position: relative; }
.text-input { resize: none; font-size: 19px; font-weight: 700; line-height: 1.4; min-height: 110px; padding-right: 52px; }
.dice { position: absolute; right: 8px; top: 8px; box-shadow: none; background: #f3f1ec; }
.dice:active svg { transform: rotate(90deg); }
.dice svg { transition: transform .3s var(--spring); }
.write-card .row-between { margin-top: 12px; }

/* рисовалка */
.draw { max-width: none; }
.draw-prompt {
    display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; justify-content: center; text-align: center;
    padding: 12px 16px; background: var(--paper); border-radius: 16px; box-shadow: var(--shadow);
}
.draw-prompt .prompt-label { margin: 0; }
.draw-phrase { font-size: 20px; font-weight: 900; line-height: 1.25; letter-spacing: -.01em; }
.draw-layout {
    display: grid; gap: 10px; justify-content: center;
    grid-template-columns: minmax(0, var(--board-w));
    grid-template-areas: "board" "palette" "tools";
    --board-w: min(100%, calc((100dvh - 330px) * 4 / 3));
}
.board {
    grid-area: board; position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: 16px; overflow: hidden;
    background: #fff; box-shadow: var(--shadow-lift); border: 1px solid var(--line);
    touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
    transition: opacity .3s, filter .3s;
}
.board canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; transform-origin: 0 0; }
.board.is-panning .board-live { cursor: grabbing; }
.board.is-panning .board-cursor { opacity: 0; }
.board[data-zoom]:not([data-zoom="100%"]):after { content: attr(data-zoom); position: absolute; right: 12px; top: 12px; padding: 4px 9px; border-radius: 20px; background: rgba(29,27,38,.65); color: white; font-size: 11px; font-weight: 800; pointer-events: none; }
.board-live { cursor: crosshair; touch-action: none; }
.board.has-cursor .board-live { cursor: none; }
.board-cursor {
    position: absolute; left: 0; top: 0; border-radius: 50%; pointer-events: none; opacity: 0;
    border: 1.5px solid rgba(29, 27, 38, .7); box-shadow: 0 0 0 1px rgba(255, 255, 255, .8); transition: opacity .15s;
}
.board.has-cursor .board-cursor { opacity: 1; }
.board.is-disabled { filter: saturate(.6); opacity: .7; pointer-events: none; }

.tools { grid-area: tools; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.tool-group { display: flex; gap: 4px; padding: 4px; background: var(--paper); border-radius: 14px; box-shadow: var(--shadow); }
.tool {
    width: 42px; height: 42px; border: 0; border-radius: 11px; background: transparent; color: var(--ink-2);
    display: grid; place-items: center; transition: background-color .2s, color .2s, transform .15s var(--ease);
}
.tool:active { transform: scale(.9); }
.tool.is-active { background: var(--accent-soft); color: var(--accent); }
@media (hover: hover) { .tool:hover { background: #f3f1ec; } .tool.is-active:hover { background: var(--accent-soft); } }
.tool:disabled { opacity: .3; pointer-events: none; }
.tool.size i { display: block; width: var(--d); height: var(--d); border-radius: 50%; background: currentColor; }

.palette { grid-area: palette; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding: 8px; background: var(--paper); border-radius: 14px; box-shadow: var(--shadow); }
.swatch {
    width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--c); padding: 0;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); transition: transform .18s var(--spring), box-shadow .2s;
}
.swatch.is-active { transform: scale(1.15); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12), 0 0 0 3px #fff, 0 0 0 5px var(--c); }
.swatch:active { transform: scale(.9); }
.swatch.custom { position: relative; overflow: hidden; background: conic-gradient(#ff6b6b, #ffd43b, #51cf66, #22b8cf, #5c7cfa, #cc5de8, #ff6b6b); }
.swatch.custom input { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); opacity: 0; cursor: pointer; border: 0; padding: 0; }
.swatch.custom.is-active { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--c, var(--accent)); }

/* Фигуры: кнопка с уголком-меткой и выезжающее меню. На телефоне панель
   инструментов внизу — меню выезжает вверх, на ПК колонка слева — вправо. */
.shape-pick { position: relative; display: flex; }
#shape-btn { position: relative; }
#shape-btn::after {
    content: ""; position: absolute; right: 5px; bottom: 5px; width: 0; height: 0;
    border-style: solid; border-width: 0 0 5px 5px; border-color: transparent transparent currentColor transparent; opacity: .45;
}
.shape-pick.is-open #shape-btn:not(.is-active) { background: #f3f1ec; }
.shape-menu {
    position: absolute; z-index: 25; left: -4px; bottom: calc(100% + 12px);
    display: flex; gap: 4px; padding: 4px; background: var(--paper); border-radius: 14px;
    box-shadow: var(--shadow-lift), 0 0 0 1px rgba(29, 27, 38, .05);
    transform-origin: 22px 100%; opacity: 0; visibility: hidden; pointer-events: none;
    transform: translateY(6px) scale(.92);
    transition: opacity .16s ease, transform .22s var(--ease), visibility 0s linear .22s;
}
.shape-menu .tool { opacity: 0; transform: scale(.5); transition: opacity .15s, transform .15s var(--ease), background-color .2s, color .2s; }
.shape-pick.is-open .shape-menu {
    opacity: 1; visibility: visible; pointer-events: auto; transform: none;
    transition: opacity .18s ease, transform .32s var(--spring), visibility 0s;
}
.shape-pick.is-open .shape-menu .tool { opacity: 1; transform: none; transition: opacity .2s, transform .3s var(--spring), background-color .2s, color .2s; }
.shape-pick.is-open .shape-menu .tool:nth-child(2) { transition-delay: .03s; }
.shape-pick.is-open .shape-menu .tool:nth-child(3) { transition-delay: .06s; }
.shape-pick.is-open .shape-menu .tool:nth-child(4) { transition-delay: .09s; }
.shape-pick.is-open .shape-menu .tool:active { transform: scale(.9); transition-delay: 0s; }

/* Непрозрачность: шахматка под градиентом «прозрачно → цвет», ручка показывает
   итоговый цвет. По умолчанию дорожка горизонтальная, на ПК — вертикальная. */
.opacity {
    --v: 1; --c: #1f1f24; --thumb: 20px;
    flex: 1 0 100%; display: flex; align-items: center; gap: 10px; min-height: 30px; padding: 0 4px 0 6px;
    cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; outline: none;
    transition: opacity .2s;
}
.opacity.is-idle { opacity: .4; }
.opacity-track {
    position: relative; flex: 1; height: 12px; border-radius: 99px;
    background:
        linear-gradient(to right, rgba(255, 255, 255, 0), var(--c)),
        repeating-conic-gradient(#e4e0d7 0 25%, #fff 0 50%) 0 0 / 8px 8px;
    box-shadow: inset 0 0 0 1px rgba(29, 27, 38, .1);
}
.opacity-thumb {
    position: absolute; top: calc(50% - var(--thumb) / 2); left: calc(var(--v) * (100% - var(--thumb)));
    width: var(--thumb); height: var(--thumb); border-radius: 50%; overflow: hidden;
    background: repeating-conic-gradient(#e4e0d7 0 25%, #fff 0 50%) 0 0 / 6px 6px;
    box-shadow: 0 0 0 3px #fff, 0 0 0 4px rgba(29, 27, 38, .12), 0 3px 8px rgba(29, 27, 38, .25);
    transition: transform .15s var(--ease);
}
.opacity-thumb::after { content: ""; position: absolute; inset: 0; background: var(--c); opacity: calc(.05 + var(--v) * .95); }
.opacity.is-dragging .opacity-thumb { transform: scale(1.15); }
.opacity:focus-visible .opacity-thumb { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--accent), 0 3px 8px rgba(29, 27, 38, .25); }
.opacity-value { min-width: 34px; text-align: right; font-size: 12px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }

.draw-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; max-width: var(--board-w-px, 100%); margin: 0 auto; }
.draw-footer .btn { min-width: 180px; }
.hotkeys { display: none; }

@media (max-width: 719px) {
    .stage { padding-left: 10px; padding-right: 10px; }
    .draw-layout { --board-w: min(100%, calc((100dvh - 360px) * 4 / 3)); }
    .draw-footer .btn { flex: 1; }
    .tool { width: 38px; height: 38px; }
    .swatch { width: 28px; height: 28px; }
    .palette { gap: 5px; padding: 6px; }
    .draw-phrase { font-size: 18px; }
    .hud { padding: 8px 12px 13px; }
    .hud-ready .avatar:nth-child(n+6) { display: none; }
}

/* ПК: инструменты слева, палитра справа, доска — по центру и как можно крупнее. */
@media (min-width: 900px) and (pointer: fine), (min-width: 1000px) {
    .draw-layout {
        grid-template-columns: auto minmax(0, var(--board-w)) auto;
        grid-template-areas: "tools board palette";
        align-items: start;
        --board-w: min(820px, calc(100vw - 280px), calc((100dvh - 270px) * 4 / 3));
    }
    .tools { flex-direction: column; flex-wrap: nowrap; }
    .tool-group { flex-direction: column; }
    .palette { display: grid; grid-template-columns: repeat(2, 30px); gap: 8px; padding: 10px; align-content: start; }
    .swatch.custom { grid-column: 1 / -1; justify-self: center; }
    .shape-menu { left: calc(100% + 12px); top: -4px; bottom: auto; transform-origin: 0 22px; transform: translateX(-6px) scale(.92); }
    .opacity { grid-column: 1 / -1; flex-direction: column; gap: 8px; padding: 10px 0 0; margin-top: 2px; border-top: 1px solid var(--line); }
    .opacity-track {
        /* Колонка палитры не длиннее доски: высота доски минус ~300px на цвета. */
        flex: none; width: 12px; height: clamp(90px, calc(min(100dvh - 270px, (100vw - 280px) * .75, 615px) - 300px), 240px);
        background:
            linear-gradient(to top, rgba(255, 255, 255, 0), var(--c)),
            repeating-conic-gradient(#e4e0d7 0 25%, #fff 0 50%) 0 0 / 8px 8px;
    }
    .opacity-thumb { top: auto; left: calc(50% - var(--thumb) / 2); bottom: calc(var(--v) * (100% - var(--thumb))); }
    .opacity-value { min-width: 0; text-align: center; }
    .hotkeys { display: inline; }
    .draw-footer { max-width: calc(var(--board-w) + 230px); }
}

.submitted {
    position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px;
    background: rgba(245, 243, 238, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    animation: fade-in .3s ease both;
}
.submitted-card { width: 100%; max-width: 380px; padding: 26px 22px 20px; animation: pop .5s var(--spring) both; }
.submitted-card .subtitle { margin-top: 4px; }
.submitted-card p { margin: 4px 0 14px; }

/* Кольцевой таймер: полоска убывает вместе с раундом, в последние 10 секунд краснеет. */
.wait-ring { position: relative; width: 132px; height: 132px; margin: 0 auto 10px; }
.wait-ring > svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring-track { fill: none; stroke: var(--line); stroke-width: 8; }
.ring-bar {
    fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round;
    stroke-dasharray: 326.73; stroke-dashoffset: 0; transition: stroke .3s;
    filter: drop-shadow(0 3px 6px rgba(91, 91, 240, .35));
}
.wait-ring.is-low .ring-bar { stroke: var(--danger); filter: drop-shadow(0 3px 6px rgba(224, 49, 49, .35)); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-time { font-size: 30px; font-weight: 900; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.wait-ring.is-low .ring-time { color: var(--danger); }
.ring-label { margin-top: 4px; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ring-badge {
    position: absolute; right: 4px; top: 6px; width: 32px; height: 32px; border-radius: 50%;
    display: grid; place-items: center; background: var(--good); color: #fff;
    box-shadow: 0 0 0 4px #fff, 0 6px 14px rgba(47, 158, 68, .35); animation: pop .5s .1s var(--spring) both;
}
.ring-badge svg { width: 18px; height: 18px; stroke-width: 3; stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw-tick .5s .35s var(--ease) forwards; }

.wait-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 34vh; max-height: 34dvh; overflow: auto; text-align: left; }
.wait-list li {
    display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 13px;
    background: #faf9f6; border: 1px solid var(--line); transition: background-color .35s, border-color .35s;
}
.wait-list li.is-done { background: var(--good-soft); border-color: rgba(47, 158, 68, .2); }
.wait-list .who { flex: 1; min-width: 0; font-weight: 800; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wait-list .state { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.wait-list .is-done .state { color: var(--good); }
.wait-list .state svg { width: 15px; height: 15px; stroke-width: 3; }
.wait-list .is-done .state svg { animation: pop .4s var(--spring) both; }
.wait-list .dots i { width: 4px; height: 4px; }
@keyframes draw-tick { to { stroke-dashoffset: 0; } }
.spectate { flex: 1; display: grid; place-items: center; }

/* ---------- заставка раунда ---------- */
.intro {
    position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px;
    background: rgba(245, 243, 238, .75); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    animation: fade-in .25s ease both;
}
.intro.is-leaving { animation: fade-out .3s ease both; }
.intro-card { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.intro-round { font-size: 14px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); animation: rise .5s var(--ease) both; }
.intro-icon {
    width: 96px; height: 96px; border-radius: 30px; display: grid; place-items: center; margin: 10px 0;
    background: var(--accent); color: #fff; box-shadow: 0 18px 40px rgba(91, 91, 240, .35);
    animation: intro-pop .7s var(--spring) .05s both;
}
.intro-icon svg { width: 46px; height: 46px; }
.intro-icon.k-draw { background: #f06595; box-shadow: 0 18px 40px rgba(240, 101, 149, .35); }
.intro-icon.k-describe { background: #15aabf; box-shadow: 0 18px 40px rgba(21, 170, 191, .35); }
.intro-title { font-size: 34px; font-weight: 900; letter-spacing: -.02em; animation: rise .5s var(--ease) .12s both; }
.intro-sub { color: var(--ink-2); max-width: 420px; animation: rise .5s var(--ease) .2s both; }
@keyframes intro-pop { from { opacity: 0; transform: scale(.4) rotate(-20deg); } to { opacity: 1; transform: none; } }

/* ---------- показ ---------- */
.reveal { width: 100%; max-width: 640px; margin: 0 auto; flex: 1; display: flex; flex-direction: column; }
.reveal-wait { margin: auto; }
.feed-wrap { display: flex; flex-direction: column; flex: 1; gap: 10px; }
.feed-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 0 4px; }
.feed { display: flex; flex-direction: column; gap: 14px; padding: 8px 2px 20px; flex: 1; }
.msg { display: flex; gap: 10px; align-items: flex-start; animation: msg-in .45s var(--ease) both; }
.msg .avatar { margin-top: 18px; }
.msg-body { min-width: 0; flex: 1; display: flex; flex-direction: column; align-items: flex-start; }
.msg-name { font-size: 13px; font-weight: 900; margin: 0 0 4px 4px; color: var(--c, var(--muted)); }
.bubble {
    max-width: 100%; padding: 11px 15px; border-radius: 6px 20px 20px 20px; background: var(--paper);
    box-shadow: var(--shadow); border: 1px solid rgba(29, 27, 38, .05);
    font-size: 18px; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere;
}
.bubble.typing { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.bubble.typing .dots { color: var(--ink); }
.bubble.drawing { padding: 8px; width: min(100%, 460px); }
.bubble.drawing .frame { border: 0; border-radius: 13px; }
.caret::after { content: ""; display: inline-block; width: 2px; height: 1.05em; margin-left: 2px; vertical-align: -2px; background: var(--accent); animation: blink .8s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.missed-tag { margin: 6px 0 0 4px; padding: 2px 9px; border-radius: 8px; font-size: 12px; font-weight: 800; background: #fff0e6; color: var(--warn); animation: fade-in .4s ease both; }
@keyframes msg-in { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }

.compare { margin-top: 6px; padding: 18px; border-radius: var(--radius); background: var(--ink); color: #fff; animation: pop .6s var(--spring) both; }
.compare .label { color: rgba(255, 255, 255, .55); }
.compare .from, .compare .to { font-size: 18px; font-weight: 800; margin: 4px 0 12px; }
.compare .to { margin-bottom: 0; color: var(--yellow); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate3d(var(--dx), 105vh, 0) rotate(var(--r)); } }

.feed-controls {
    position: sticky; bottom: 0; display: flex; gap: 10px; flex-wrap: wrap; padding: 12px 0 calc(4px + var(--safe-bottom));
    background: linear-gradient(to top, var(--bg) 70%, rgba(245, 243, 238, 0));
}

.gallery-head { margin: 8px 0 18px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.story-card { display: flex; flex-direction: column; gap: 10px; animation: pop .5s var(--spring) both; }
.story-card .owner { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.story-thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.story-thumbs canvas { width: 100%; aspect-ratio: 4 / 3; border-radius: 9px; border: 1px solid var(--line); display: block; background: #fff; }

/* Скачать рисунок: круглая кнопка в углу картинки. */
.bubble.drawing .frame, .story-thumbs .thumb { position: relative; }
.save-pic {
    position: absolute; right: 8px; bottom: 8px; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%;
    display: grid; place-items: center; color: var(--ink); background: rgba(255, 255, 255, .92); cursor: pointer;
    box-shadow: 0 0 0 1px rgba(29, 27, 38, .07), 0 4px 12px rgba(29, 27, 38, .16);
    animation: fade-in .35s ease both; transition: transform .15s var(--ease), background-color .2s, color .2s, opacity .2s;
}
.save-pic svg { width: 17px; height: 17px; stroke-width: 2.2; }
.save-pic:active { transform: scale(.88); }
.save-pic.is-busy { opacity: .55; pointer-events: none; }
.save-pic.is-done { background: var(--good); color: #fff; }
.save-pic.is-done svg { animation: pop .35s var(--spring) both; }
.save-pic:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) { .save-pic:hover { color: var(--accent); background: #fff; } .save-pic.is-done:hover { color: #fff; background: var(--good); } }
.story-thumbs .save-pic { right: 4px; bottom: 4px; width: 26px; height: 26px; }
.story-thumbs .save-pic svg { width: 14px; height: 14px; }
.story-line { font-size: 15px; line-height: 1.35; }
.story-line b { display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.story-actions { display: flex; gap: 8px; margin-top: auto; }
.story-actions .btn { flex: 1; min-height: 40px; }
.gallery-footer { position: sticky; bottom: 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 16px 0 calc(4px + var(--safe-bottom)); background: linear-gradient(to top, var(--bg) 70%, rgba(245, 243, 238, 0)); }
.reveal:has(.gallery-wrap:not([hidden])) { max-width: 1000px; }

/* ---------- модальные окна ---------- */
.modal { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(29, 27, 38, .35); animation: fade-in .25s ease both; }
.modal-card {
    position: relative; width: 100%; max-width: 480px; max-height: calc(100dvh - 32px); overflow: auto;
    background: var(--paper); border-radius: 24px; padding: 20px; box-shadow: 0 30px 80px rgba(29, 27, 38, .25);
    animation: modal-in .4s var(--spring) both;
}
.modal.is-leaving .modal-card { animation: modal-out .2s ease-in both; }
.modal.is-leaving .modal-backdrop { animation: fade-out .2s ease-in both; }
@keyframes modal-in { from { opacity: 0; transform: translateY(24px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes modal-out { to { opacity: 0; transform: translateY(12px) scale(.98); } }
@media (max-width: 560px) {
    .modal { align-items: flex-end; padding: 0; }
    .modal-card { border-radius: 24px 24px 0 0; max-height: 92dvh; padding-bottom: calc(20px + var(--safe-bottom)); }
    @keyframes modal-in { from { transform: translateY(100%); } to { transform: none; } }
    @keyframes modal-out { to { transform: translateY(100%); } }
}
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.ready-check-btn { flex: 0 0 52px; width: 52px; height: 52px; border: 1px solid var(--line); border-radius: 16px; color: var(--accent); background: var(--paper); }
.ready-check-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.ready-check-btn:disabled { opacity: .45; cursor: default; }
.readiness-modal { z-index: 90; }
.readiness-card { max-width: 410px; padding: 32px 26px calc(22px + var(--safe-bottom)); text-align: center; }
.readiness-card > .muted { font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.readiness-emblem { width: 62px; height: 62px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 22px; color: var(--accent); background: var(--accent-soft); animation: ready-emblem .6s var(--spring) both; }
.readiness-emblem svg { width: 30px; height: 30px; }
.readiness-people { display: flex; justify-content: center; flex-wrap: wrap; gap: 7px; margin: 24px 0; }
.readiness-person { display: inline-flex; align-items: center; gap: 5px; padding: 7px 10px; border-radius: 12px; font-size: 12px; color: var(--muted); background: var(--bg); overflow-wrap: anywhere; min-width: 0; }
.readiness-person svg { width: 14px; height: 14px; flex-shrink: 0; }
.readiness-person.yes { color: #237437; background: var(--good-soft); }
.readiness-person.no { color: #b62626; background: #fff0f0; }
.readiness-actions { display: flex; gap: 10px; }
.readiness-close { width: 100%; min-height: 50px; }
.readiness-actions .btn { flex: 1; min-height: 50px; border: 2px solid transparent; }
.ready-yes { color: white; background: #27853c; }
.ready-no { color: white; background: #ce3535; }
.readiness-actions .btn[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 3px var(--paper) inset; }
.readiness-clock { margin: 24px 0 10px; height: 3px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.readiness-clock i { display: block; height: 100%; background: var(--accent); transform-origin: left; transition: transform .1s linear; }
.all-ready .readiness-emblem { color: var(--good); background: var(--good-soft); }
.is-complete .readiness-emblem { animation: ready-emblem .5s var(--spring) both; }
@keyframes ready-emblem { from { opacity: 0; transform: scale(.6) rotate(-12deg); } to { opacity: 1; transform: none; } }
.share-pic { right: 50px; }
.share-pic.is-sent, .syndicate-share.is-sent { color: var(--good); background: var(--good-soft); }
.share-pic:disabled { opacity: .5; cursor: wait; }
.story-thumbs .share-pic { right: 34px; }
.story-actions { flex-wrap: wrap; }
.story-actions .syndicate-share { flex-basis: 100%; font-size: 12px; }
.feed-controls { flex-wrap: wrap; }
.gif-syndicate { width: 100%; margin-top: 14px; background: var(--accent-soft); color: var(--accent); }

.settings { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.setting { display: flex; flex-direction: column; gap: 8px; }
.setting-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.setting-head b { display: block; font-weight: 800; }
.setting-head small { display: block; color: var(--muted); font-size: 13px; font-weight: 600; }
.setting output { font-weight: 900; font-size: 18px; color: var(--accent); font-variant-numeric: tabular-nums; min-width: 56px; text-align: right; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: linear-gradient(to right, var(--accent) var(--p, 50%), var(--line) var(--p, 50%)); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 6px; background: linear-gradient(to right, var(--accent) var(--p, 50%), var(--line) var(--p, 50%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 2px 8px rgba(29, 27, 38, .25), 0 0 0 4px var(--accent) inset; transition: transform .15s; }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 2px 8px rgba(29, 27, 38, .25), 0 0 0 4px var(--accent) inset; }
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.15); }
.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segmented button { min-width: 48px; height: 38px; padding: 0 12px; border-radius: 11px; border: 1.5px solid var(--line-2); background: #fff; font-weight: 800; transition: all .2s; }
.segmented button.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.segmented button:disabled { opacity: .35; }
.settings-preview { margin-top: 18px; padding: 14px; border-radius: 16px; background: #faf9f6; border: 1px solid var(--line); }
.settings-preview .plan { margin: 8px 0; }

.gif-card { max-width: 420px; }
.gif-progress { margin: 18px 0 6px; display: flex; flex-direction: column; gap: 8px; }
.progress { height: 10px; border-radius: 10px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; width: 100%; background: var(--accent); border-radius: 10px; transform: scaleX(0); transform-origin: left; transition: transform .2s; }
.gif-preview { display: block; width: 100%; max-width: 340px; margin: 16px auto 0; border-radius: 16px; box-shadow: var(--shadow-lift); animation: pop .5s var(--spring) both; }
.gif-card .tiny.center { margin: 12px 0 0; }

/* ---------- тост ---------- */
.toast {
    position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); z-index: 90; max-width: calc(100% - 32px);
    padding: 12px 18px; border-radius: 14px; background: var(--ink); color: #fff; font-weight: 700; font-size: 15px;
    box-shadow: 0 12px 30px rgba(29, 27, 38, .3); pointer-events: none;
    opacity: 0; transform: translate(-50%, 16px) scale(.96); transition: opacity .25s, transform .35s var(--spring);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast.is-error { background: var(--danger); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* На узком экране в шапке остаётся только аватар — название игры важнее. */
@media (max-width: 420px) {
    .me-chip { padding: 4px; }
    .me-chip span:last-child { display: none; }
}
@media (max-width: 420px) {
    .hud { gap: 8px; }
    .hud-ready .avatar:nth-child(n+5) { display: none; }
    .hud-timer { min-width: 62px; font-size: 16px; }
}

.compare-head { display: flex; align-items: center; gap: 8px; }
.compare-head .avatar { box-shadow: 0 0 0 2px rgba(255, 255, 255, .25); }


/* Рисовалка: two games, one paper-and-ink visual language. */
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
button:focus-visible, a:focus-visible { outline:3px solid var(--accent); outline-offset:4px; }
.game-picker { display:grid; grid-template-columns:1fr 1fr; gap:12px; padding:12px; }
.game-choice { display:flex; align-items:center; flex-direction:column; justify-content:center; gap:6px; min-height:130px; padding:12px 8px; border:1.5px solid transparent; border-radius:18px; background:transparent; font-size:15px; font-weight:900; line-height:1.25; transition:background .22s, border-color .22s, transform .25s var(--spring); }
.game-choice img { width:76px; height:76px; object-fit:contain; transition:transform .3s var(--spring); }
.game-choice.is-selected { background:var(--accent-soft); border-color:#b9b6fc; }
.game-choice[data-mode=crocodile].is-selected { background:#eaf7ed; border-color:#a6dcb7; }
.game-choice:disabled { cursor:default; color:var(--ink); }
.game-choice:not(:disabled):hover img { transform:translateY(-4px) rotate(-4deg) scale(1.05); }
.game-choice:not(:disabled):active { transform:scale(.97); }
.rules-actions { display:flex; align-items:center; gap:10px; }
.rules-stage { position:relative; overflow:hidden; }
.rules-panel { display:flow-root; }
.lobby-rules { --rule-bg:var(--accent-soft); --rule-ink:var(--accent); }
.croc-rules { --rule-bg:#eaf7ed; --rule-ink:#2c8457; }
.rules-note { margin:0; padding-top:16px; border-top:1px solid var(--line); font-size:14px; line-height:1.6; color:var(--ink-2); }
.rule-step { display:flex; gap:14px; margin:18px 0; align-items:flex-start; }
.rule-step > span { display:grid; place-items:center; flex:none; width:32px; height:32px; background:var(--rule-bg); color:var(--rule-ink); border-radius:11px; font-size:12px; font-weight:900; font-variant-numeric:tabular-nums; }
.rule-step p { margin:0; font-size:14px; line-height:1.6; color:var(--ink-2); }
.rule-step b { display:block; color:var(--ink); font-size:15px; }
.wordpool-link { display:flex; justify-content:space-between; align-items:center; gap:10px; font-size:13px; font-weight:800; padding-top:16px; border-top:1px solid var(--line); text-decoration:none; }
.croc-settings { padding-top:20px; }
.croc-settings .segmented { margin-top:12px; }
#croc-dictionary-setting { margin-top:22px; }
.is-croc .croc-word-mask { display:flex; flex-wrap:wrap; gap:8px 22px; }
.croc-mask-word { display:inline-flex; flex-wrap:wrap; gap:6px; }
.croc-mask-char { display:inline-block; min-width:.65em; text-align:center; }
.croc-mask-char.is-revealed { animation:croc-letter-reveal .65s ease-out both; color:var(--accent); }
@keyframes croc-letter-reveal { from { opacity:0; transform:translateY(7px) scale(.8); filter:blur(3px); } to { opacity:1; transform:translateY(0) scale(1); filter:blur(0); } }
@media(prefers-reduced-motion:reduce) { .croc-mask-char.is-revealed { animation:none; } }
.play.is-croc { display:grid; grid-template-columns:minmax(0,1fr) 320px; gap:16px; align-content:start; align-items:start; }
.is-croc > .hud { grid-column:1/-1; grid-template-columns:1fr auto; width:100%; }
.is-croc .task { grid-column:1; min-width:0; }
.is-croc .draw-layout { grid-template-columns:minmax(0,var(--board-w)); grid-template-areas:"board" "palette" "tools"; --board-w:min(100%,max(320px,calc((100dvh - 390px)*4/3))); }
.is-croc .task:has(#tools[hidden]) .draw-layout { --board-w:min(100%,max(320px,calc((100dvh - 240px)*4/3))); }
.is-croc .tools { flex-direction:row; flex-wrap:wrap; gap:6px; }
.is-croc .tool-group { flex-direction:row; }
.is-croc .palette { display:flex; flex-wrap:wrap; flex-direction:row; gap:6px; padding:8px; }
.is-croc .swatch.custom { grid-column:auto; }
.is-croc .opacity { flex-direction:row; flex:1; padding:0 0 0 8px; margin:0; min-width:120px; border-top:0; border-left:1px solid var(--line); }
.is-croc .opacity-track { flex:1; width:auto; height:12px; background:linear-gradient(to right,rgba(255,255,255,0),var(--c)),repeating-conic-gradient(#e4e0d7 0 25%,#fff 0 50%) 0 0/8px 8px; }
.is-croc .opacity-thumb { bottom:auto; top:calc(50% - var(--thumb)/2); left:calc(var(--v) * (100% - var(--thumb))); }
.is-croc .shape-menu { left:50%; top:auto; bottom:calc(100% + 12px); transform:translateX(-50%) scale(.92); transform-origin:50% 100%; }
.is-croc .shape-pick.is-open .shape-menu { transform:translateX(-50%) scale(1); }
.is-croc .board.is-disabled { opacity:1; filter:none; }
.is-croc .draw-phrase { overflow-wrap:anywhere; }
.is-croc .draw-prompt { min-height:72px; }
.is-croc .draw-footer { max-width:100%; }
.croc-chat { grid-column:2; grid-row:2; position:sticky; top:76px; display:flex; flex-direction:column; gap:14px; min-width:0; width:100%; height:clamp(420px,calc(100dvh - 185px),760px); padding:18px; }
.croc-chat .subtitle { font-size:17px; }
.live-badge { font-size:10px; font-weight:900; color:var(--muted); white-space:nowrap; }
.live-badge.is-online { color:var(--good); }
.croc-scoreboard { display:flex; flex-wrap:wrap; gap:6px; max-height:120px; overflow-y:auto; flex-shrink:0; }
.score-chip { display:flex; gap:5px; align-items:center; padding:5px 8px; border-radius:10px; font-size:11px; background:#f5f3ee; transition:background .25s; max-width:100%; }
.score-chip > span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.score-chip b { font-variant-numeric:tabular-nums; }
.score-chip.guessed { background:var(--good-soft); color:var(--good); }
.score-chip.artist { background:var(--accent-soft); color:var(--accent); }
.score-chip.offline { opacity:.55; }
.score-dot { flex:none; width:7px; height:7px; border-radius:50%; }
.croc-messages { flex:1; min-height:100px; overflow-y:auto; overscroll-behavior:contain; display:flex; flex-direction:column; gap:9px; scrollbar-width:thin; }
.croc-messages:empty::before { content:"Здесь появятся ваши догадки. Смотрите на рисунок — и пробуйте!"; margin:auto 10px; text-align:center; color:var(--muted); font-size:14px; line-height:1.6; }
.chat-message { font-size:13px; line-height:1.5; overflow-wrap:anywhere; animation:rise .22s var(--ease) both; }
.chat-message.guess b { color:var(--accent); }
.chat-message.correct { padding:10px; border-radius:12px; background:var(--good-soft); color:#237839; }
.chat-message.system { font-size:12px; padding:10px; background:#f5f3ee; border-radius:12px; }
.chat-points { margin-left:8px; white-space:nowrap; }
.croc-guess { display:flex; gap:8px; }
.croc-guess .input { min-width:0; flex:1; font-size:14px; text-transform:uppercase; }
.croc-guess .btn { padding:0 14px; font-size:22px; }
.croc-hint { margin:0; font-size:11px; line-height:1.5; }
.croc-results { grid-column:1/-1; width:100%; max-width:600px; margin:20px auto; text-align:center; animation:screen-in .5s var(--ease) both; }
.croc-results .title { margin:14px 0 24px; }
.ranking-row { display:flex; align-items:center; gap:14px; text-align:left; padding:14px 4px; border-bottom:1px solid var(--line); }
.ranking-row .grow { overflow-wrap:anywhere; }
.ranking-row b { white-space:nowrap; color:var(--accent); }
.ranking-place { display:grid; place-items:center; width:32px; height:32px; border-radius:10px; background:var(--accent-soft); color:var(--accent); }
.croc-results .btn { margin-top:24px; }
.croc-results p { margin-top:20px; }
.pool-shell { width:100%; max-width:900px; padding:16px 24px calc(32px + var(--safe-bottom)); margin:0 auto; }
.pool-top-label { margin-left:auto; font-size:13px; color:var(--muted); }
.pool-hero { display:flex; gap:24px; align-items:center; justify-content:space-between; padding:32px 4px; }
.pool-hero h1 { font-weight:900; font-size:clamp(30px,4.4vw,48px); line-height:1.08; letter-spacing:-.035em; margin:12px 0 18px; }
.pool-hero p { max-width:430px; margin:0; line-height:1.6; }
.pool-hero img { object-fit:contain; flex-shrink:0; transform:rotate(5deg); animation:screen-in .6s var(--ease); }
.pool-compose, .pool-login, .pool-library { margin-bottom:18px; }
.pool-add { display:flex; gap:12px; margin:18px 0 12px; }
.pool-add input { flex:1; min-width:0; text-transform:uppercase; }
.pool-login input { text-transform:none; }
.pool-compose p { margin:0; }
.pool-count { padding:6px 12px; border-radius:12px; background:var(--accent-soft); color:var(--accent); font-weight:900; }
.pool-search { margin:20px 0 8px; width:100%; }
.pool-word { display:flex; align-items:center; justify-content:space-between; gap:16px; min-height:58px; padding:10px 0; border-bottom:1px solid var(--line); animation:rise .2s var(--ease); }
.pool-word > span { overflow-wrap:anywhere; font-size:14px; }
.pool-word-actions { display:flex; gap:8px; flex-shrink:0; }
.pool-word-actions .icon-btn { font-size:22px; }
.pool-pages { display:flex; align-items:center; justify-content:space-between; gap:10px; padding-top:20px; }
.pool-pages .btn { min-height:40px; font-size:13px; }
.pool-empty { padding:36px 0; text-align:center; }
.pool-footer { text-align:center; line-height:1.6; padding:8px 20px; }
#pool-edit-form .input { width:100%; margin-top:18px; }
#pool-delete-text { margin-top:18px; overflow-wrap:anywhere; }
@media(min-width:1400px) { .stage:has(.is-croc) { max-width:1320px; } .play.is-croc { grid-template-columns:minmax(0,1fr) 340px; } }
@media(max-width:1000px) and (min-width:761px) { .play.is-croc { grid-template-columns:minmax(0,1fr) 290px; gap:12px; } .is-croc .tools .tool { width:36px; height:36px; } .croc-chat { padding:14px; } }
@media(max-width:760px) {
    .play.is-croc { display:flex; gap:12px; }
    .croc-chat { position:static; height:340px; padding:16px; }
    .is-croc .draw-layout, .is-croc .task:has(#tools[hidden]) .draw-layout { --board-w:100%; }
    .is-croc .draw-prompt { min-height:58px; padding:12px; }
    .is-croc .draw-phrase { font-size:18px; }
    .is-croc .draw-footer { display:none; }
    .is-croc .croc-scoreboard { max-height:68px; }
    .croc-messages { min-height:85px; }
    .is-croc .board.is-disabled .board-live { touch-action:pan-y; }
    .pool-shell { padding:8px 16px 24px; }
    .pool-hero { gap:8px; padding:24px 0; }
    .pool-hero img { width:110px; height:110px; }
    .pool-hero .label { font-size:10px; }
    .pool-hero p { font-size:13px; }
    .pool-top-label { display:none; }
}
@media(max-width:420px) {
    .game-choice { font-size:13px; min-height:120px; }
    .game-choice img { width:66px; height:66px; }
    .game-picker { gap:8px; padding:9px; }
    .rules-actions { gap:4px; }
    .rules-actions .tiny { font-size:11px; }
    .pool-hero img { width:85px; height:85px; }
    .pool-hero h1 { font-size:30px; }
    .pool-add { flex-direction:column; }
    .pool-word { gap:8px; }
    .pool-word-actions { gap:4px; }
}
