/* Общая визуальная система. Геометрия полей и цвета игровых фигур — в style.css. */
:root {
  --bg: #161618;
  --panel: #202023;
  --cell: #2c2c30;
  --cell-hover: #39393e;
  --text: #f5f5f7;
  --muted: #aaaab2;
  --accent: #0071e3;
  --accent-text: #72b7ff;
  --line: #3b3b40;
  --surface: #27272b;
  --surface-raised: #303035;
  --soft-blue: #16324e;
  --soft-mint: #203e38;
  --soft-peach: #493426;
  --soft-lilac: #353047;
  --ink-blue: #96caff;
  --ink-mint: #8bd8bf;
  --ink-peach: #f2ba91;
  --ink-lilac: #c5b4ed;
  --hero: #dceaff;
  --hero-ink: #142c4a;
  --hero-muted: #405875;
  --on-accent: #ffffff;
  --overlay: rgb(0 0 0 / .4);
  --frost: rgb(32 32 35 / .9);
  --app-shadow: rgb(0 0 0 / .2);
  --focus: rgb(0 113 227 / .3);
  --sunken: #1b1b1e;
  --board-light: #8e9c98;
  --board-dark: #526a61;
  --board-check: #9f5558;
  --piece-light: #ffffff;
  --piece-dark: #202a25;
}
:root[data-theme="light"] {
  --bg: #f5f5f7;
  --panel: #ffffff;
  --cell: #f0f0f3;
  --cell-hover: #e7e7ec;
  --text: #1d1d1f;
  --muted: #68686e;
  --accent: #0071e3;
  --accent-text: #0066cc;
  --line: #dedee3;
  --surface: #fafafb;
  --surface-raised: #ffffff;
  --soft-blue: #e7f1ff;
  --soft-mint: #e7f3ee;
  --soft-peach: #fff0e3;
  --soft-lilac: #efebfa;
  --ink-blue: #245e99;
  --ink-mint: #28654f;
  --ink-peach: #8a512b;
  --ink-lilac: #66518c;
  --hero: #eaf2ff;
  --hero-ink: #142c4a;
  --hero-muted: #405875;
  --overlay: rgb(25 30 40 / .28);
  --frost: rgb(255 255 255 / .9);
  --app-shadow: rgb(30 40 60 / .08);
  --sunken: #ececf0;
  --board-light: #ecede7;
  --board-dark: #a3b6a8;
  --board-check: #edaaa7;
}
/* Фиолетовая тема — прежняя тёмная сайта (до нового оформления): тёмно-синий фон
   и фиолетовые кнопки. */
:root[data-theme="purple"] {
  --bg: #1e1e2e;
  --panel: #2a2a3d;
  --cell: #313146;
  --cell-hover: #3a3a54;
  --text: #f2f2f7;
  --muted: #9a9ab0;
  --accent: #7c5cff;
  --accent-text: #a48bff;
  --line: #3d3d58;
  --surface: #262638;
  --surface-raised: #33334b;
  --soft-blue: #22304f;
  --soft-mint: #1f3a3a;
  --soft-peach: #43303a;
  --soft-lilac: #3a3163;
  --ink-lilac: #cbb9ff;
  --hero: #e4dcff;
  --hero-ink: #23164d;
  --hero-muted: #574a80;
  --overlay: rgb(10 8 25 / .5);
  --frost: rgb(42 42 61 / .9);
  --app-shadow: rgb(0 0 0 / .35);
  --focus: rgb(124 92 255 / .35);
  --sunken: #1a1a28;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
  letter-spacing: -.015em;
}
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { letter-spacing: -.035em; }
.app {
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: 0 16px 64px var(--app-shadow);
  padding: 30px 28px;
  max-width: 420px;
}
.app > h1 { font-size: 22px; font-weight: 650; margin-bottom: 24px; letter-spacing: -.045em; }
.app.wide { max-width: 500px; }
.primary-btn, .secondary-btn, .reset-btn {
  border-radius: 14px;
  font-weight: 600;
  letter-spacing: -.015em;
  min-height: 46px;
  box-shadow: none;
}
.primary-btn { color: var(--on-accent); }
.secondary-btn { background: var(--cell); }
.primary-btn:disabled, .secondary-btn:disabled { opacity: .5; }
button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent-text);
  outline-offset: 3px;
}
input:not([type=range]):not([type=checkbox]):not([type=radio]), textarea, select {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 46px;
  box-shadow: none;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.name-input { text-align: left; }
.hint, .btn-sub { line-height: 1.5; }
.fs-btn, .info-btn, .bell-btn, .acct-btn, .upd-btn {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .025em; margin: 0 0 10px; }
.entry-intro { text-align: left; }
.entry-intro h2 { font-size: 42px; font-weight: 650; line-height: 1.06; margin: 0 0 18px; }
.entry-intro .games-line { font-size: 15px; line-height: 1.6; color: var(--muted); max-width: 320px; margin: 0 0 12px; text-align: left; }
#entryCatalogBtn { width: auto; padding: 8px 0; background: transparent; color: var(--accent-text); font-size: 15px; text-align: left; }
#entryCatalogBtn span { margin-left: 8px; }
.entry-block { border: 1px solid var(--line); background: var(--surface); padding: 18px; border-radius: 20px; margin: 0; }
.entry-title { text-align: left; text-transform: none; font-size: 15px; font-weight: 600; color: var(--text); }
.entry-reassurance { font-size: 12px; line-height: 1.5; }
.signup-entry { font-size: 13px; }
.signup-link { border: 0; outline: none; box-shadow: none; background: transparent; color: var(--accent-text); }
.play-art { position: relative; height: 196px; width: 290px; max-width: 100%; margin: 18px 0; }
.art-tile { position: absolute; display: grid; place-items: center; width: 100px; height: 110px; border-radius: 22px; font-size: 66px; font-weight: 500; line-height: 1; box-shadow: 0 12px 26px var(--app-shadow); border: 1px solid var(--glass-8); }
.art-cross { left: 6px; top: 18px; color: var(--ink-blue); background: var(--soft-blue); transform: rotate(-13deg); }
.art-knight { left: 87px; top: 3px; color: var(--ink-mint); background: var(--soft-mint); transform: rotate(8deg); }
.art-ring { left: 145px; top: 72px; color: var(--ink-lilac); background: var(--soft-lilac); transform: rotate(15deg); }
.art-ace { left: 59px; top: 79px; color: var(--ink-peach); background: var(--soft-peach); transform: rotate(-7deg); font-family: Georgia, serif; font-size: 42px; gap: 0; padding: 12px; }
.art-ace > span { font-size: 25px; }
#menu { gap: 16px; }
#menu .profile { margin-bottom: 2px; }
#menu .profile-name { font-size: 15px; font-weight: 500; }
#menu .home-main { min-height: 124px; padding: 24px; border-radius: 22px; background: var(--hero); color: var(--hero-ink); border: 1px solid var(--glass-4); font-size: 24px; justify-content: center; overflow: hidden; }
#menu .home-main .btn-sub { font-size: 13px; color: var(--hero-muted); opacity: 1; max-width: 220px; }
.home-arrow { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--on-accent); color: var(--hero-ink); font-size: 22px; right: 20px; }
#menu .tile { border: 1px solid var(--line); background: var(--surface); border-radius: 18px; min-height: 82px; padding: 16px; font-size: 15px; box-shadow: none; }
#menu .tile-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--soft-blue); color: var(--ink-blue); flex-shrink: 0; }
#menu #joinRoomBtn .tile-ico { background: var(--soft-mint); color: var(--ink-mint); }
.tile-ico svg, .mobile-nav svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
#menu .home-solo { border-radius: 18px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); font-size: 15px; }
.profile-card, .room-row, .friend-row, .history-row { border-radius: 16px; }
.avatar, .profile-card .avatar { background: var(--soft-blue); color: var(--ink-blue); box-shadow: none; font-weight: 600; }
.player-row, .room-choice { background: var(--surface); border: 1px solid var(--line); }
.room-code { letter-spacing: .08em; }
#roomScreen .bs-heading { font-size: 14px; font-weight: 600; }
#roomScreen .lobby-actions { padding: 10px; background: var(--surface); border-radius: 16px; }
#roomScreen #lobbyReadyBtn { border-radius: 12px; }
#roomHostControls .primary-btn { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
#roomHostControls .primary-btn .btn-sub { color: var(--muted); }
#roomHostControls .primary-btn:disabled { opacity: .45; }
.modal { background: var(--overlay); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.modal-box { border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 24px 80px var(--app-shadow); padding: 24px; }
.info-head { align-items: center; gap: 12px; margin-bottom: 16px; }
.info-head h2 { font-size: 26px; margin: 0; font-weight: 650; text-align: left; }
.info-close, .chat-close { border: 0; background: var(--cell); color: var(--muted); border-radius: 50%; width: 36px; height: 36px; flex-shrink: 0; }
.discovery-box { max-width: 850px; }
.discovery-filters { gap: 10px; margin-bottom: 16px; }
.discovery-filters input { min-width: 0; }
.discovery-filters select, .discovery-filters input[type=search], .lobby-actions select { background: var(--surface); border-color: var(--line); }
.catalog-list { gap: 14px; }
.catalog-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px; }
.catalog-head { gap: 12px; }
.catalog-head h3 { flex: 1; font-size: 18px; font-weight: 650; line-height: 1.2; }
.catalog-icon { width: 46px; height: 46px; flex: 0 0 46px; display: grid; place-items: center; border-radius: 13px; background: var(--soft-blue); color: var(--ink-blue); font-size: 25px; font-weight: 600; letter-spacing: -.065em; }
[data-game=ck] .catalog-icon, [data-game=nd] .catalog-icon, [data-game=bk] .catalog-icon, [data-game=cr] .catalog-icon { background: var(--soft-mint); color: var(--ink-mint); }
[data-game=pk] .catalog-icon, [data-game=bj] .catalog-icon, [data-game=dk] .catalog-icon, [data-game=un] .catalog-icon { background: var(--soft-peach); color: var(--ink-peach); font-size: 20px; }
[data-game=mf] .catalog-icon, [data-game=sp] .catalog-icon, [data-game=ph] .catalog-icon, [data-game=qp] .catalog-icon { background: var(--soft-lilac); color: var(--ink-lilac); }
.catalog-star { color: var(--muted); border-radius: 50%; }
.catalog-star[aria-pressed=true] { color: var(--accent-text); background: var(--soft-blue); }
.catalog-card p { font-size: 14px; line-height: 1.5; }
.catalog-card .hint { font-size: 12px; }
.catalog-actions { gap: 8px; }
.catalog-actions > button { font-size: 13px; min-height: 42px; padding: 10px; }
.round-hint { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.cb-cell { background: var(--board-light); }
.cb-cell.dark { background: var(--board-dark); }
.cb-cell.check { background: var(--board-check); }
.cb-cell.last-move { box-shadow: inset 0 0 0 2px var(--accent-text); }
.ch-piece { font-family: "DejaVu Sans", "Segoe UI Symbol", "Apple Symbols", sans-serif; font-size: clamp(32px, calc(9vw / var(--kk-vz, 1)), 44px); font-weight: 400; line-height: 1; }
.ch-piece.w { color: var(--piece-light); -webkit-text-stroke: .7px var(--piece-dark); text-shadow: 0 1px 2px var(--app-shadow); }
.ch-piece.b { color: var(--piece-dark); -webkit-text-stroke: .5px var(--piece-light); text-shadow: 0 1px 2px var(--app-shadow); }
.seg { background: var(--cell); border-radius: 12px; padding: 4px; }
.seg button { border-radius: 9px; }
.seg button.on { background: var(--panel); color: var(--accent-text); box-shadow: 0 1px 4px var(--app-shadow); }
.chat-panel { border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 12px 45px var(--app-shadow); }
.chat-toggle { box-shadow: 0 4px 18px var(--app-shadow); }
@media (hover: hover) {
  #menu .tile:hover, #menu .home-solo:hover, .catalog-card:hover { border-color: var(--muted); }
  #menu .home-main:hover { filter: brightness(.98); }
}
@media (min-width: 900px) and (min-height: 650px) {
  .app:has(#menu:not(.hidden)), .app:has(#nameScreen:not(.hidden)) { max-width: 840px; padding: 30px 40px; }
  .app:has(#nameScreen:not(.hidden)) { height: min(780px, calc(calc(100dvh / var(--kk-vz, 1)) - 48px)); }
  #nameScreen { display: grid; grid-template-columns: 1.05fr 1fr; grid-template-rows: auto auto auto; gap: 16px 40px; align-content: center; }
  .entry-intro { grid-column: 1; grid-row: 1 / 5; align-self: center; }
  #nameScreen > .entry-block, #nameScreen > .signup-entry, #nameScreen > .name-hint { grid-column: 2; }
  #nameScreen .name-hint:empty { display: none; }
  #menu { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: max-content; gap: 16px 24px; align-content: start; }
  #menu > .profile, #menu > .home-main, #menu > .home-catalog, #menu > .menu-tiles, #menu > .home-links, #menu > .home-solo, #resumeRoomBtn, #tourBanner { grid-column: 1 / -1; }
  #menu .profile { margin: 0; }
  #menu .home-main { min-height: 130px; }
  #menu .menu-tiles { grid-template-columns: 1fr 1fr; gap: 16px; }
  #menu .home-solo { flex-direction: row; align-items: center; justify-content: space-between; }
}
@media (max-width: 600px), (pointer: coarse) and (max-height: 500px) {
  body { background: var(--bg); }
  .app, .app.wide, .app.chatgame, .app.rb-full { max-width: none; border: 0; border-radius: 0; box-shadow: none; background: var(--bg); padding: calc(56px + env(safe-area-inset-top, 0px)) 12px calc(12px + env(safe-area-inset-bottom, 0px)); }
  .app > h1 { font-size: 18px; font-weight: 650; }
  .app:has(#menu:not(.hidden)), .app:has(#nameScreen:not(.hidden)) { padding-left: 20px; padding-right: 20px; }
  #nameScreen, #menu { gap: 14px; }
  .entry-intro h2 { font-size: 36px; margin-bottom: 12px; }
  .entry-intro .eyebrow { margin-top: 6px; margin-bottom: 10px; font-size: 11px; }
  .entry-intro .games-line { font-size: 14px; margin-bottom: 4px; }
  .entry-intro .play-art { display: none; }
  #entryCatalogBtn { min-height: 40px; font-size: 14px; }
  .entry-block { padding: 16px; background: var(--panel); }
  .entry-switch { background: var(--cell); border: 1px solid var(--line); padding: 3px; border-radius: 13px; }
  .entry-switch button { min-height: 40px; font-size: 13px; font-weight: 600; }
  .entry-switch button[aria-pressed=true] { background: var(--panel); color: var(--text); box-shadow: 0 1px 5px var(--app-shadow); }
  #menu .home-main { min-height: 112px; padding: 20px; font-size: 23px; }
  #menu .home-main .btn-sub { max-width: 210px; font-size: 12px; }
  .home-arrow { width: 32px; height: 32px; right: 14px; }
  #menu .tile { min-height: 76px; padding: 14px; background: var(--panel); }
  #menu .home-solo { background: var(--panel); padding: 14px 16px; }
  .home-action-text .btn-sub, .home-solo .btn-sub { font-size: 12px; }
  .mobile-nav { z-index: 19; background: var(--frost); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: 1px solid var(--line); padding-top: 5px; }
  .mobile-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10px; font-weight: 500; border-radius: 0; }
  .mobile-nav button[aria-current=page] { background: transparent; color: var(--accent-text); }
  .mobile-nav svg { width: 23px; height: 23px; }
  .modal { padding: 10px; }
  .modal-box { padding: 20px 16px; border-radius: 24px; max-height: calc(var(--mobile-height, calc(100dvh / var(--kk-vz, 1))) - 20px); }
  .info-head h2 { font-size: 24px; }
  .discovery-filters { top: -20px; padding: 10px 0; }
  .catalog-card { padding: 14px; border-radius: 18px; background: var(--surface); }
  .catalog-head h3 { font-size: 16px; }
  .catalog-icon { width: 40px; height: 40px; flex-basis: 40px; font-size: 24px; border-radius: 12px; }
  .catalog-card .hint { font-size: 12px; margin: 8px 0; }
  .catalog-choose { background: transparent; color: var(--accent-text); border-top: 1px solid var(--line); border-radius: 0; text-align: left; padding: 10px 0 0; font-size: 13px; min-height: 40px; }
  .catalog-actions { margin-top: 12px; }
  .room-choice { background: var(--panel); border-radius: 20px; padding: 14px; }
  #roomScreen .player-row { flex: 0 0 220px; max-width: 260px; flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
  #roomScreen .player-row .player-name { flex: 1 0 calc(100% - 42px); }
  .room-choice select { background: var(--surface); border-color: var(--line); }
  .game-tools > summary { background: var(--cell); border: 1px solid var(--line); border-radius: 12px; font-size: 12px; }
  .game-tools[open] > .game-actions { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; }
  .round-hint { background: transparent; }
  .round-hint summary { background: transparent; font-size: 13px; }
  .mobile-card-confirm, .pk-actions, .nd-controls, .dk-actions { background: var(--bg); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .mobile-nav { background: var(--panel); backdrop-filter: none; }
  .modal { backdrop-filter: none; }
}

/* Главная: «Создать комнату» — главная кнопка, под ней две плитки и каталог.
   Всё влезает на экран телефона без прокрутки. */
#menu .menu-tiles { grid-template-columns: 1fr 1fr; }
#menu .menu-tiles .tile { flex-direction: column; align-items: flex-start; justify-content: center; gap: 8px; }
#menu .home-catalog { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; text-align: left; padding: 12px 16px; }
#menu .home-catalog .btn-sub { color: var(--muted); font-weight: 400; margin: 0; font-size: 12px; }
#mobileRecent { display: none !important; }
@media (max-width: 600px), (pointer: coarse) and (max-height: 500px) {
  #menu { gap: 10px; }
  #menu .home-main { min-height: 96px; padding: 18px 20px; }
  #menu .menu-tiles { max-height: none; min-height: 0; gap: 10px; }
  #menu .menu-tiles .tile { min-height: 84px; padding: 12px 14px; }
  #menu .tile-ico { width: 32px; height: 32px; }
  /* Задания дня и недели — рядом, в одну строку. */
}
@media (max-height: 700px) and (max-width: 600px) {
  #menu .home-main { min-height: 76px; padding: 14px 18px; font-size: 20px; }
  #menu .menu-tiles .tile { min-height: 70px; }
  #menu .profile-card { padding: 6px 10px; }
}
#menu .menu-tiles .tile { overflow-wrap: normal; word-break: keep-all; hyphens: none; }
@media (max-width: 380px) { #menu .menu-tiles .tile { font-size: 14px; } #menu .menu-tiles .tile .btn-sub { font-size: 11px; } }
/* Окно «Играть»: четыре способа плитками два на два. */
.play-box { max-width: 460px; }
.play-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 12px; }
.play-tiles .tile { flex-direction: column; align-items: flex-start; justify-content: center; gap: 8px; min-height: 104px; padding: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 18px; text-align: left; font-size: 15px; font-weight: 600; box-shadow: none; overflow-wrap: normal; word-break: keep-all; hyphens: none; }
.play-tiles .tile .btn-sub { color: var(--muted); font-weight: 400; font-size: 12px; }
.play-tiles .tile-ico { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--soft-blue); color: var(--ink-blue); flex-shrink: 0; }
.play-tiles #createRoomBtn .tile-ico { background: var(--hero); color: var(--hero-ink); }
.play-tiles #joinRoomBtn .tile-ico { background: var(--soft-mint); color: var(--ink-mint); }
.play-tiles .home-action-text { display: flex; flex-direction: column; gap: 2px; }
@media (max-width: 380px) { .play-tiles .tile { font-size: 14px; padding: 12px; } .play-tiles .tile .btn-sub { font-size: 11px; } }

/* Карточка ставки и итога: строка — значение. */
.stake-card { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 10px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); text-align: left; font-size: 14px; }
.stake-card dt { color: var(--muted); }
.stake-card dd { margin: 0; font-weight: 600; color: var(--text); }
.stake-card dd.minus { color: var(--red-text); }
.stake-card dd.plus { color: var(--win-text); }

/* Подсказка в партии: чей ход, что делать, как закончить. */
.turn-hint { position: relative; margin: 4px 0 8px; padding: 8px 34px 8px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); text-align: left; font-size: 13px; line-height: 1.4; flex-shrink: 0; }
.turn-hint.mine { border-color: var(--accent); }
.turn-hint p { margin: 0; }
.turn-hint-who { color: var(--text); }
.turn-hint.mine .turn-hint-who { color: var(--accent-text); }
.turn-hint-what { color: var(--text); }
.turn-hint-end { color: var(--muted); font-size: 12px; margin-top: 2px !important; }
.turn-hint-end .link-btn { padding: 0; margin: 0 0 0 4px; font-size: 12px; min-height: 0; }
.turn-hint-close { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 14px; cursor: pointer; }

/* Обучение на поле. */
.tutorial-field { margin: 10px 0; }
.learn-grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 4px; max-width: 320px; margin: 10px auto; }
.learn-cell { position: relative; aspect-ratio: 1; min-height: 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 22px; line-height: 1; cursor: pointer; }
.learn-grid[style*="--cols: 8"] .learn-cell { font-size: 16px; }
.learn-cell.light { background: var(--cell); }
.learn-cell.foe { background: var(--cell); opacity: .7; }
.learn-cell[data-label]::after { content: attr(data-label); position: absolute; bottom: 2px; right: 4px; font-size: 9px; color: var(--muted); }
.learn-cell.good, .learn-card.good, .learn-player.good { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.learn-cell.bad, .learn-card.bad, .learn-player.bad { animation: learn-shake .35s; border-color: var(--red-text); }
@keyframes learn-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) { .learn-cell.bad, .learn-card.bad, .learn-player.bad { animation: none; } }
.learn-info { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.learn-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.learn-card { min-width: 64px; min-height: 84px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font-size: 17px; font-weight: 600; cursor: pointer; }
.learn-card.red { color: var(--red-text); }
.learn-player { padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); cursor: pointer; }
.learn-form { display: flex; gap: 8px; }
.learn-form .name-input { flex: 1; margin: 0; }
.learn-form .primary-btn { width: auto; margin: 0; padding: 0 16px; }
.learn-canvas { display: block; width: 100%; max-width: 320px; margin: 0 auto; aspect-ratio: 14 / 9; border: 1px dashed var(--line); border-radius: 12px; background: var(--surface); touch-action: none; }
#tutorialFeedback.ok { color: var(--text); }
#tutorialFeedback.warn { color: var(--red-text); }

/* ---------- чат комнаты ---------- */
.chat-text { white-space: pre-wrap; }
.chat-row textarea { flex: 1; min-width: 0; resize: none; overflow-y: auto; max-height: 124px; background: var(--cell); border: none; border-radius: 10px; padding: 10px 12px; color: var(--text); font: inherit; font-size: 0.9rem; line-height: 1.35; }
.chat-row textarea::placeholder { color: var(--muted); }
.chat-row { align-items: flex-end; }
.chat-head { gap: 6px; }
.chat-head > span { flex: 1; }
.chat-grab { display: none; }
.chat-prefs { display: flex; flex-direction: column; gap: 8px; background: var(--cell); border-radius: 10px; padding: 10px 12px; font-size: 0.85rem; text-align: left; }
.chat-prefs label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.chat-new { align-self: center; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font: inherit; font-size: 0.8rem; font-weight: 600; padding: 6px 14px; margin-top: -4px; cursor: pointer; box-shadow: 0 4px 14px var(--app-shadow); }
.cg-body .chat-new { margin: 4px auto 0; }
.chat-quote { display: block; margin: 2px 0 4px; padding: 3px 8px; border-left: 3px solid var(--accent); border-radius: 4px; background: rgba(0, 0, 0, 0.18); font-size: 0.78rem; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-edited { display: block; font-size: 0.68rem; opacity: 0.65; text-align: right; }
.chat-msg.deleted .chat-text { font-style: italic; opacity: 0.6; }
.chat-msg.mention:not(.mine) { box-shadow: inset 3px 0 0 var(--gold-text); }
.chat-msg { transition: transform 0.15s ease; }
.chat-unhide { margin-left: 4px; font-size: inherit; min-height: 0; padding: 0; }
.chat-reply { display: flex; align-items: center; gap: 8px; background: var(--cell); border-left: 3px solid var(--accent); border-radius: 8px; padding: 4px 4px 4px 10px; font-size: 0.8rem; color: var(--muted); }
.chat-reply-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.react-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 4px; }
.react-quick button { border: 0; background: var(--cell-hover); border-radius: 10px; font-size: 1.6rem; line-height: 1; padding: 8px 0; cursor: pointer; }
.react-quick button.chosen { outline: 2px solid var(--accent); }
.react-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.react-action { flex: 1 1 auto; border: 0; background: var(--cell-hover); color: var(--text); border-radius: 999px; font: inherit; font-size: 0.8rem; padding: 7px 10px; cursor: pointer; }
.chat-quick { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
.chat-quick::-webkit-scrollbar { display: none; }
.chat-chip { flex-shrink: 0; }
.chat-chip.cooling { opacity: 0.55; transition: opacity 0.3s ease; }
.chat-chip { transition: opacity 0.3s ease; }
.chat-toast { position: fixed; right: 16px; bottom: 82px; z-index: 21; max-width: min(320px, calc(calc(100vw / var(--kk-vz, 1)) - 32px)); border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); font: inherit; font-size: 0.85rem; text-align: left; padding: 10px 14px; box-shadow: 0 10px 30px var(--app-shadow); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: kk-pop-in 0.18s ease-out; }
/* Окно (карточка игрока, жалоба) — поверх чата. */
body:has(.modal:not(.hidden)) .chat-panel { z-index: 19; }

/* Широкий экран: панель справа во всю высоту, рядом с игрой. */
@media (min-width: 1100px) and (pointer: fine) {
  .chat-panel { top: 16px; bottom: 16px; right: 16px; width: 360px; max-height: none; }
  .chat-panel:not(.hidden) ~ .chat-toast { display: none; }
}

/* Телефон: панель снизу. Ручка — раскрыть во весь экран или свернуть. */
@media (max-width: 600px), (pointer: coarse) and (max-height: 500px) {
  .chat-panel { left: 0; right: 0; width: auto; bottom: var(--keyboard-space, 0px); border-radius: 20px 20px 0 0; border-bottom: 0; padding: 4px 12px calc(10px + env(safe-area-inset-bottom, 0px)); max-height: min(calc(62dvh / var(--kk-vz, 1)), calc(var(--mobile-height, calc(100dvh / var(--kk-vz, 1))) - 60px)); }
  .chat-panel.tall { height: calc(var(--mobile-height, calc(100dvh / var(--kk-vz, 1))) - var(--keyboard-space, 0px) - 24px); max-height: none; }
  .chat-grab { display: block; align-self: center; width: 64px; height: 22px; min-height: 0; min-width: 0; border: 0; background: transparent; padding: 0; position: relative; cursor: grab; touch-action: none; }
  .chat-grab::before { content: ""; position: absolute; left: 14px; right: 14px; top: 9px; height: 5px; border-radius: 3px; background: var(--muted); opacity: 0.5; }
  .chat-head { touch-action: none; }
  .chat-row #chatSendBtn { min-width: 52px; min-height: 44px; font-size: 1rem; border-radius: 22px; }
  .chat-row textarea { font-size: 16px; } /* меньше 16px — телефон приближает страницу */
  .chat-toast { left: 16px; right: 72px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); max-width: none; }
  .chat-msg { touch-action: pan-y; }
}
.chat-panel > :not(.chat-log) { flex-shrink: 0; }
/* Открыто меню сообщения — быстрые фразы уступают ему место. */
.react-picker:not(.hidden) ~ .chat-quick { display: none; }

/* Баланс на главной — над «Играть». */
.home-balance { grid-column: 1 / -1; width: 100%; box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; margin: 0 0 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.home-balance-label { color: var(--muted); font-size: 14px; }
.home-balance-value { color: var(--gold-text); font-size: 18px; }
/* Новый аккаунт: монеты пока заморожены для ставок — строкой под балансом. */
.home-balance { flex-wrap: wrap; }
.home-balance-frozen { flex-basis: 100%; color: var(--muted); font-size: 13px; text-align: left; }
