/* 5 Букв — оформление игры. Темы задаются через [data-theme]. */
:root {
  --font-ui: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-tile: 'Rubik', 'Manrope', system-ui, sans-serif;
  --r: 18px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

/* ---------- Темы ----------
   Три состояния буквы различаются и оттенком (тёплый / холодный / нейтральный), и яркостью,
   поэтому читаются и при дальтонизме. Контраст текста на плитках не ниже 4.5:1. */
[data-theme="aurora"] {
  --bg1: #0a0c1f; --bg2: #1b1147; --blob1: #6d4cff; --blob2: #14b8d6; --blob3: #ff4fa3;
  --panel: rgba(255,255,255,.07); --panel-b: rgba(255,255,255,.14); --sheet: #14163a;
  --text: #f4f5ff; --muted: #a9aeda;
  --tile-bg: rgba(255,255,255,.05); --tile-b: rgba(255,255,255,.18); --tile-bf: rgba(255,255,255,.6);
  --c-bg: #ffd43b; --c-t: #241a00; --p-bg: #4f9dff; --p-t: #00142e; --a-bg: #353a66; --a-t: #d2d6f7;
  --key: rgba(255,255,255,.13); --key-t: #f4f5ff;
  --accent: #7c5cff; --accent2: #22d3ee; --glow: rgba(124,92,255,.55); --danger: #ff6b8a; --ok: #34d399;
  --letter: rgba(255,255,255,.05); color-scheme: dark;
}
[data-theme="midnight"] {
  --bg1: #0e0e10; --bg2: #1c1c1f; --blob1: #26345f; --blob2: #163f3a; --blob3: #33264a;
  --panel: rgba(255,255,255,.06); --panel-b: rgba(255,255,255,.12); --sheet: #1f1f23;
  --text: #f5f5f7; --muted: #a1a1aa;
  --tile-bg: transparent; --tile-b: #45454b; --tile-bf: #9b9ba4;
  --c-bg: #ffd43b; --c-t: #241a00; --p-bg: #4f9dff; --p-t: #00142e; --a-bg: #3a3a40; --a-t: #d6d6db;
  --key: #3a3a40; --key-t: #ffffff;
  --accent: #4f8aff; --accent2: #20b2aa; --glow: rgba(79,138,255,.45); --danger: #ff6b6b; --ok: #3ddc97;
  --letter: rgba(255,255,255,.035); color-scheme: dark;
}
[data-theme="matcha"] {
  --bg1: #07130e; --bg2: #123226; --blob1: #2fbf71; --blob2: #c6f432; --blob3: #12877a;
  --panel: rgba(255,255,255,.06); --panel-b: rgba(255,255,255,.13); --sheet: #12261d;
  --text: #edfff5; --muted: #98c6ad;
  --tile-bg: rgba(255,255,255,.04); --tile-b: rgba(255,255,255,.18); --tile-bf: rgba(237,255,245,.62);
  --c-bg: #ffd43b; --c-t: #241a00; --p-bg: #5eb3ff; --p-t: #00182f; --a-bg: #2b4a3b; --a-t: #d3ecdf;
  --key: rgba(255,255,255,.11); --key-t: #edfff5;
  --accent: #2fbf71; --accent2: #c6f432; --glow: rgba(47,191,113,.5); --danger: #ff7a7a; --ok: #7dffb0;
  --letter: rgba(255,255,255,.04); color-scheme: dark;
}
[data-theme="sunset"] {
  --bg1: #ffe6d0; --bg2: #ffbfa8; --blob1: #ff7e5f; --blob2: #feb47b; --blob3: #ffd166;
  --panel: rgba(255,255,255,.6); --panel-b: rgba(255,255,255,.85); --sheet: #fff8f2;
  --text: #3e2119; --muted: #8a5a4c;
  --tile-bg: rgba(255,255,255,.6); --tile-b: #eaa48b; --tile-bf: #c4553a;
  --c-bg: #c2410c; --c-t: #ffffff; --p-bg: #4dabf7; --p-t: #06263f; --a-bg: #e3d3cc; --a-t: #5a3f37;
  --key: rgba(255,255,255,.85); --key-t: #5c3328;
  --accent: #e8590c; --accent2: #f59f00; --glow: rgba(232,89,12,.45); --danger: #c2255c; --ok: #0b7a53;
  --letter: rgba(120,50,30,.07); color-scheme: light;
}
[data-theme="candy"] {
  --bg1: #f6f3ff; --bg2: #dfe8ff; --blob1: #b79cff; --blob2: #8ab4ff; --blob3: #ffc6e6;
  --panel: rgba(255,255,255,.7); --panel-b: rgba(255,255,255,.95); --sheet: #ffffff;
  --text: #241f4a; --muted: #6a6592;
  --tile-bg: rgba(255,255,255,.8); --tile-b: #cbc4ee; --tile-bf: #6d58d6;
  --c-bg: #f59f00; --c-t: #2b1a00; --p-bg: #1971c2; --p-t: #ffffff; --a-bg: #dfe2f1; --a-t: #4a5074;
  --key: #ffffff; --key-t: #3d3480;
  --accent: #6d4cff; --accent2: #1c9ad6; --glow: rgba(109,76,255,.4); --danger: #d6336c; --ok: #12805c;
  --letter: rgba(90,70,200,.07); color-scheme: light;
}
[data-theme="contrast"] {
  --bg1: #000000; --bg2: #0d0d0d; --blob1: #222222; --blob2: #1a1a1a; --blob3: #222222;
  --panel: rgba(255,255,255,.08); --panel-b: rgba(255,255,255,.35); --sheet: #101010;
  --text: #ffffff; --muted: #c4c4c4;
  --tile-bg: transparent; --tile-b: #8a8a8a; --tile-bf: #ffffff;
  --c-bg: #ffe14d; --c-t: #000000; --p-bg: #2e8bff; --p-t: #000000; --a-bg: #2b2b2b; --a-t: #f0f0f0;
  --key: #2b2b2b; --key-t: #ffffff;
  --accent: #3db8ff; --accent2: #ffd60a; --glow: rgba(61,184,255,.4); --danger: #ff6b6b; --ok: #4ade80;
  --letter: rgba(255,255,255,.03); color-scheme: dark;
}

/* ---------- Основа ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-ui); color: var(--text); background: var(--bg1);
  overflow: hidden; overscroll-behavior: none; -webkit-font-smoothing: antialiased;
  user-select: none; -webkit-user-select: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
input { font: inherit; }
svg.i { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Фон ---------- */
.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: linear-gradient(160deg, var(--bg1), var(--bg2)); }
.bg .blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; will-change: transform; }
.bg .b1 { width: 52vmax; height: 52vmax; left: -14vmax; top: -16vmax; background: var(--blob1); animation: drift1 24s ease-in-out infinite alternate; }
.bg .b2 { width: 44vmax; height: 44vmax; right: -12vmax; top: 20vh; background: var(--blob2); animation: drift2 28s ease-in-out infinite alternate; opacity: .38; }
.bg .b3 { width: 40vmax; height: 40vmax; left: 10vw; bottom: -20vmax; background: var(--blob3); animation: drift3 32s ease-in-out infinite alternate; opacity: .34; }
body.cvd .tile[data-s="p"]::before, body.cvd .key[data-s="p"]::before { content: ''; position: absolute; top: 7%; right: 7%; width: 18%; height: 18%; max-width: 10px; max-height: 10px; border-radius: 50%; background: currentColor; opacity: .75; }
body.cvd .key { position: relative; }
body.cvd .tile[data-s="c"]::after { content: ''; position: absolute; left: 22%; right: 22%; bottom: 9%; height: 3px; border-radius: 3px; background: currentColor; opacity: .65; }
.bg .grain { position: absolute; inset: 0; background-image: radial-gradient(var(--letter) 1px, transparent 1px); background-size: 26px 26px; opacity: .8; }
.bg .fl { position: absolute; font: 800 var(--s, 60px) var(--font-tile); color: var(--letter); animation: floatUp var(--d, 30s) linear infinite; animation-delay: var(--dl, 0s); left: var(--x, 50%); bottom: -120px; }
@keyframes drift1 { to { transform: translate(14vmax, 10vmax) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-12vmax, -8vmax) scale(.9); } }
@keyframes drift3 { to { transform: translate(10vmax, -12vmax) scale(1.2); } }
@keyframes floatUp { from { transform: translateY(0) rotate(-8deg); } to { transform: translateY(-120vh) rotate(14deg); } }

/* ---------- Каркас ---------- */
#app {
  position: relative; z-index: 1; height: 100%; height: 100dvh; max-width: 520px; margin: 0 auto;
  display: flex; flex-direction: column; padding: max(10px, env(safe-area-inset-top)) 14px max(10px, env(safe-area-inset-bottom));
  gap: 8px;
}
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; flex: none;
  font: 800 24px var(--font-tile); color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 8px 22px -6px var(--glow); transform: rotate(-6deg); animation: logoWob 6s ease-in-out infinite;
}
@keyframes logoWob { 50% { transform: rotate(5deg) scale(1.05); } }
.brand h1 { margin: 0; font: 800 20px/1.1 var(--font-tile); letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; gap: 6px; flex: none; }
.ibtn {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--panel-b); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: transform .18s var(--ease), background .2s, box-shadow .2s;
}
.ibtn:hover { transform: translateY(-2px); box-shadow: 0 8px 18px -8px var(--glow); }
.ibtn:active { transform: scale(.92); }
.ibtn.off { opacity: .55; }
.ibtn[hidden] { display: none; }

/* HUD */
.hud { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--panel-b); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font-weight: 700; font-size: 14px; white-space: nowrap;
}
.chip.clickable { cursor: pointer; transition: transform .15s; }
.chip.clickable:active { transform: scale(.95); }
.chip .i { color: var(--accent2); }
#timer { font: 800 17px var(--font-tile); font-variant-numeric: tabular-nums; letter-spacing: .5px; min-width: 88px; justify-content: center; }
#timer.run { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border-color: transparent; box-shadow: 0 8px 22px -8px var(--glow); }
#timer.run .i { color: #fff; }
#timer.run .i { animation: tick 1s steps(2) infinite; }
@keyframes tick { 50% { transform: rotate(12deg); } }
.pips { display: inline-flex; gap: 4px; }
.pips i { width: 8px; height: 8px; border-radius: 50%; background: var(--tile-b); transition: background .3s, transform .3s var(--ease); }
.pips i.used { background: var(--accent2); transform: scale(1.2); }
.streak { color: #ff9f43; }

/* Поле */
.stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
#board { display: grid; gap: 8px; --tile: min(66px, calc((100vw - 28px - 32px) / 5), calc((100dvh - 330px) / var(--rows, 5) - 8px)); }
.row { display: grid; grid-template-columns: repeat(5, var(--tile)); gap: 8px; transition: opacity .4s; }
.row.future { opacity: .5; }
.row.shake { animation: shake .45s; }
@keyframes shake { 15%, 55% { transform: translateX(-9px); } 35%, 75% { transform: translateX(9px); } 95% { transform: translateX(-3px); } }
.tile {
  height: var(--tile); border-radius: calc(var(--tile) * .22); display: grid; place-items: center; position: relative;
  font: 800 calc(var(--tile) * .52) var(--font-tile); text-transform: uppercase; color: var(--text);
  background: var(--tile-bg); border: 2px solid var(--tile-b); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: border-color .15s, box-shadow .2s;
}
.tile.cur { border-color: var(--accent2); box-shadow: 0 0 0 4px rgba(127,127,127,.12), 0 0 20px -2px var(--glow); }
.tile.cur:not(.f)::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent2); box-shadow: 0 0 10px var(--accent2); animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .2; transform: scale(.6); } }
.tile.f { border-color: var(--tile-bf); }
.tile.pop { animation: pop .16s var(--ease); }
@keyframes pop { 50% { transform: scale(1.14); } }
.tile.flip { animation: flip var(--flip, .56s) ease-in-out; }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
.tile[data-s] { border-color: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
.tile[data-s="c"] { background: var(--c-bg); color: var(--c-t); box-shadow: 0 8px 20px -8px var(--c-bg); }
.tile[data-s="p"] { background: var(--p-bg); color: var(--p-t); box-shadow: 0 8px 20px -10px var(--p-bg); }
.tile[data-s="a"] { background: var(--a-bg); color: var(--a-t); }
.tile.bounce { animation: bounce .9s var(--ease); }
@keyframes bounce { 0%, 20% { transform: translateY(0); } 40% { transform: translateY(-22px); } 50% { transform: translateY(4px); } 60% { transform: translateY(-10px); } 80% { transform: translateY(2px); } 100% { transform: translateY(0); } }
.tile.drop { animation: drop .5s var(--ease) both; }
@keyframes drop { from { opacity: 0; transform: translateY(-14px) scale(.85); } }

/* Клавиатура */
#kb { display: flex; flex-direction: column; gap: 7px; padding-bottom: 2px; }
.kr { display: flex; gap: 5px; justify-content: center; }
.key {
  flex: 1 1 0; min-width: 0; height: 50px; border-radius: 11px; display: grid; place-items: center;
  font: 700 17px var(--font-tile); background: var(--key); color: var(--key-t); border: 1px solid var(--panel-b);
  transition: transform .1s, background .35s, color .35s, box-shadow .2s; touch-action: manipulation;
}
.key:hover { box-shadow: 0 6px 14px -8px var(--glow); }
.key:active, .key.press { transform: scale(.88); }
.key.wide { flex: 1.65 1 0; font-size: 12px; letter-spacing: .4px; }
.key[data-s="c"] { background: var(--c-bg); color: var(--c-t); border-color: transparent; }
.key[data-s="p"] { background: var(--p-bg); color: var(--p-t); border-color: transparent; }
.key[data-s="a"] { background: transparent; color: var(--muted); border: 1px dashed var(--panel-b); opacity: .55; box-shadow: none; }
.key.enter { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border-color: transparent; }

#playbar { display: none; gap: 10px; padding: 4px 0 6px; }
#playbar .btn { flex: 1; }
.over #kb { display: none; }
.over #playbar { display: flex; animation: rise .5s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(20px); } }

/* Кнопки */
.btn {
  height: 52px; padding: 0 22px; border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-weight: 800; font-size: 16px; letter-spacing: .2px; transition: transform .15s var(--ease), box-shadow .2s, filter .2s;
  background: var(--panel); border: 1px solid var(--panel-b); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.btn:active { transform: scale(.96); }
.btn.primary { color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--accent), var(--accent2)); box-shadow: 0 12px 28px -10px var(--glow); }
.btn.primary:hover { filter: brightness(1.08); transform: translateY(-2px); }
.btn.ghost { background: transparent; }
.btn.sm { height: 40px; font-size: 14px; padding: 0 16px; border-radius: 12px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.block { width: 100%; }

/* Футер */
.foot { text-align: center; font-size: 11px; color: var(--muted); min-height: 0; }
.foot-text { margin-bottom: 3px; }
.sign { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 11px; font-weight: 600; letter-spacing: .4px; color: var(--muted); opacity: .62; transition: opacity .25s; }
.sign:hover { opacity: 1; }
.sign i { width: 3px; height: 3px; border-radius: 50%; background: var(--accent2); opacity: .8; }
.sign a { color: inherit; text-decoration: none; background: linear-gradient(90deg, var(--accent), var(--accent2)) left bottom / 0 1px no-repeat; transition: background-size .3s var(--ease), color .2s; padding-bottom: 1px; }
.sign a:hover { color: var(--text); background-size: 100% 1px; }
@media (max-height: 640px) { .sign { font-size: 10px; } }

/* ---------- Модалки ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: none; align-items: flex-end; justify-content: center; padding: 0; }
.modal.open { display: flex; }
.modal .shade { position: absolute; inset: 0; background: rgba(5,6,20,.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade .25s; }
.sheet {
  position: relative; width: 100%; max-width: 480px; max-height: 92dvh; overflow: auto; background: var(--sheet); color: var(--text);
  border: 1px solid var(--panel-b); border-radius: 28px 28px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 60px -20px rgba(0,0,0,.5); animation: sheetIn .45s var(--ease); user-select: text; -webkit-user-select: text;
}
@media (min-width: 560px) {
  .modal { align-items: center; padding: 20px; }
  .sheet { border-radius: 28px; animation: sheetPop .45s var(--ease); }
}
@keyframes sheetIn { from { transform: translateY(60px); opacity: 0; } }
@keyframes sheetPop { from { transform: scale(.88) translateY(20px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.sheet h2 { margin: 0 0 4px; font: 800 24px var(--font-tile); }
.sheet .sub { margin: 0 0 16px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.sheet .close { position: absolute; right: 14px; top: 14px; width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--panel-b); }
.sheet .close:active { transform: scale(.9); }
.divider { height: 1px; background: var(--panel-b); margin: 16px 0; }

/* Вход */
.hero-tiles { display: flex; gap: 7px; justify-content: center; margin: 4px 0 18px; }
.hero-tiles span {
  width: 46px; height: 54px; border-radius: 14px; display: grid; place-items: center; font: 800 26px var(--font-tile); color: var(--p-t);
  background: var(--p-bg); animation: heroFlip 5s ease-in-out infinite; animation-delay: calc(var(--i) * .18s);
}
.hero-tiles span.c { background: var(--c-bg); color: var(--c-t); }
.hero-tiles span.a { background: var(--a-bg); color: var(--a-t); }
@keyframes heroFlip { 0%, 70%, 100% { transform: rotateX(0); } 80% { transform: rotateX(360deg); } }
.field { position: relative; margin-bottom: 10px; }
.field input {
  width: 100%; height: 54px; border-radius: 16px; padding: 0 16px; border: 1.5px solid var(--panel-b); background: var(--panel);
  color: var(--text); font-size: 16px; font-weight: 600; outline: none; transition: border-color .2s, box-shadow .2s; user-select: text; -webkit-user-select: text;
}
.field input::placeholder { color: var(--muted); font-weight: 500; }
.field input:focus { border-color: var(--accent2); box-shadow: 0 0 0 4px rgba(127,127,127,.12); }
.field .eye { position: absolute; right: 8px; top: 7px; width: 40px; height: 40px; display: grid; place-items: center; color: var(--muted); }
.msg { min-height: 20px; margin: 2px 2px 10px; font-size: 13px; font-weight: 600; color: var(--danger); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.hint { font-size: 12.5px; color: var(--muted); text-align: center; margin: 6px 0 0; line-height: 1.4; }
.linkbtn { color: var(--accent2); font-weight: 700; font-size: 14px; padding: 8px; }

/* Статистика */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.stat { text-align: center; padding: 12px 4px; border-radius: 16px; background: var(--panel); border: 1px solid var(--panel-b); }
.stat b { display: block; font: 800 22px var(--font-tile); }
.stat span { font-size: 11px; color: var(--muted); font-weight: 600; }
.dist { display: flex; flex-direction: column; gap: 6px; }
.dist .dr { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; }
.dist .dr .bar { height: 22px; min-width: 24px; border-radius: 8px; padding: 0 8px; display: flex; align-items: center; justify-content: flex-end; background: var(--a-bg); color: var(--a-t); font-size: 12px; transition: width .8s var(--ease); width: 24px; }
.dist .dr .bar.hit { background: linear-gradient(90deg, var(--accent), var(--accent2)); color: #fff; }

/* Рейтинг */
.lb { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.lbr { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 16px; background: var(--panel); border: 1px solid var(--panel-b); animation: rowIn .5s var(--ease) both; animation-delay: calc(var(--i) * 55ms); }
@keyframes rowIn { from { opacity: 0; transform: translateX(-16px); } }
.lbr.me { border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(127,127,127,.12), 0 8px 22px -12px var(--glow); }
.lbr .pos { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; font: 800 15px var(--font-tile); background: var(--a-bg); color: var(--a-t); }
.lbr:nth-child(1) .pos { background: linear-gradient(135deg, #ffd34e, #ff9f1c); color: #3a2500; }
.lbr:nth-child(2) .pos { background: linear-gradient(135deg, #e9edf5, #aab4c8); color: #26304a; }
.lbr:nth-child(3) .pos { background: linear-gradient(135deg, #f0a56a, #b8693a); color: #2e1707; }
.lbr .nm { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lbr .nm small { display: block; font-weight: 600; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.lbr .val { text-align: right; font: 800 17px var(--font-tile); }
.lbr .val small { display: block; font: 600 11px var(--font-ui); color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 26px 0; }

/* Справка */
.demo { display: flex; gap: 6px; margin: 8px 0; }
.demo .tile { --tile: 44px; width: 44px; }
.legend { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; font-size: 14px; }
.legend div { display: flex; align-items: center; gap: 10px; }
.legend .dot { width: 22px; height: 22px; border-radius: 7px; flex: none; }
.legend ul { margin: 0; padding-left: 18px; color: var(--muted); line-height: 1.6; }

/* Тема */
.themes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 8px; }
.theme-card { border-radius: 18px; padding: 10px; border: 2px solid transparent; background: linear-gradient(160deg, var(--bg1), var(--bg2)); color: var(--text); text-align: left; transition: transform .2s var(--ease), border-color .2s; }
.theme-card:hover { transform: translateY(-3px); }
.theme-card.active { border-color: var(--accent2); box-shadow: 0 10px 26px -12px var(--glow); }
.theme-card .mini { display: flex; gap: 4px; margin-bottom: 8px; }
.theme-card .mini i { flex: 1; height: 22px; border-radius: 6px; background: var(--tile-bg); border: 1.5px solid var(--tile-b); }
.theme-card .mini i.c { background: var(--c-bg); border-color: transparent; }
.theme-card .mini i.p { background: var(--p-bg); border-color: transparent; }
.theme-card .mini i.a { background: var(--a-bg); border-color: transparent; }
.theme-card b { font-size: 13px; }

/* Итог */
.res-word { display: flex; gap: 6px; justify-content: center; margin: 10px 0 14px; }
.res-word .tile { --tile: 48px; width: 48px; animation: drop .5s var(--ease) both; animation-delay: calc(var(--i) * 80ms); }
.res-title { text-align: center; }
.res-title h2 { font-size: 28px; }
.res-badges { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.badge { padding: 7px 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--panel-b); font-weight: 700; font-size: 13.5px; display: inline-flex; gap: 6px; align-items: center; }
.badge.rec { background: linear-gradient(135deg, #ffd34e, #ff9f1c); color: #3a2500; border-color: transparent; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.next-in { text-align: center; color: var(--muted); font-size: 13px; margin: 8px 0 0; }

/* Тосты */
#toasts { position: fixed; left: 0; right: 0; top: max(70px, calc(env(safe-area-inset-top) + 60px)); z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { padding: 11px 18px; border-radius: 14px; font-weight: 700; font-size: 14.5px; background: var(--text); color: var(--bg1); box-shadow: 0 14px 34px -10px rgba(0,0,0,.5); animation: toastIn .35s var(--ease); max-width: 90vw; text-align: center; }
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #05301f; }
.toast.out { opacity: 0; transform: translateY(-10px) scale(.95); transition: .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(.9); } }

#confetti { position: fixed; inset: 0; z-index: 50; pointer-events: none; }

/* Загрузка */
#boot { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: var(--bg1); transition: opacity .5s; }
#boot.done { opacity: 0; pointer-events: none; }
#boot .bl { display: flex; gap: 8px; }
#boot .bl i { width: 14px; height: 14px; border-radius: 5px; background: var(--accent2); animation: bl 1s ease-in-out infinite; animation-delay: calc(var(--i) * .12s); }
@keyframes bl { 50% { transform: translateY(-12px) rotate(90deg); background: var(--accent); } }

/* Полноэкранный режим / низкие экраны */
@media (max-height: 640px) { .brand p, .hud .pips { display: none; } .key { height: 44px; } #kb { gap: 5px; } }
@media (max-width: 440px) {
  .brand p { display: none; } .brand { gap: 8px; } .logo { width: 38px; height: 38px; font-size: 21px; border-radius: 12px; }
  .actions { gap: 4px; } .ibtn { width: 36px; height: 36px; border-radius: 12px; }
}
@media (max-width: 360px) { .key { font-size: 15px; } .kr { gap: 4px; } .brand h1 { font-size: 17px; } .ibtn { width: 36px; height: 36px; } }

/* Меньше анимаций */
body.calm .bg .blob, body.calm .bg .fl, body.calm .logo, body.calm .hero-tiles span { animation: none; }
body.calm .tile.cur::after { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .bg .blob, .bg .fl, .logo, .hero-tiles span, .tile.cur::after, .badge.rec { animation: none !important; }
}

/* ---------- Десктоп ---------- */
.play { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.side { display: none; }
.panel { background: var(--panel); border: 1px solid var(--panel-b); border-radius: 24px; padding: 20px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.panel h3 { margin: 0 0 14px; font: 800 17px var(--font-tile); display: flex; align-items: center; gap: 9px; }
.panel h3 .i { color: var(--accent2); }
.lb.mini { margin-top: 0; gap: 6px; }
.lb.mini .lbr { padding: 8px 10px; border-radius: 14px; }
.panel .stats { grid-template-columns: repeat(3, 1fr); margin: 0; }
.panel .legend { margin-top: 0; }

@media (min-width: 700px) and (min-height: 600px) {
  #app { max-width: 760px; padding-top: 18px; gap: 12px; }
  .logo { width: 52px; height: 52px; font-size: 29px; border-radius: 16px; }
  .brand h1 { font-size: 26px; } .brand p { font-size: 14px; }
  .ibtn { width: 48px; height: 48px; border-radius: 15px; } .ibtn .i { width: 22px; height: 22px; }
  .chip { height: 44px; font-size: 16px; padding: 0 18px; } #timer { font-size: 22px; min-width: 112px; }
  #board { gap: 10px; --tile: min(96px, calc((100dvh - 440px) / var(--rows, 5) - 10px)); }
  .row { gap: 10px; }
  #kb { max-width: 700px; width: 100%; margin: 0 auto; gap: 9px; }
  .kr { gap: 7px; } .key { height: 62px; font-size: 22px; border-radius: 14px; } .key.wide { font-size: 14px; }
  .btn { height: 58px; font-size: 18px; }
  #playbar { max-width: 700px; width: 100%; margin: 0 auto; }
  .sheet { max-width: 540px; padding: 30px 30px 30px; } .sheet h2 { font-size: 28px; }
  .res-word .tile { --tile: 60px; width: 60px; } .demo .tile { --tile: 54px; width: 54px; }
  .toast { font-size: 16px; padding: 13px 22px; }
}
@media (min-width: 1000px) and (min-height: 600px) {
  #app { max-width: 1320px; padding: 24px 48px 18px; display: grid; grid-template-columns: minmax(0, 1fr) 380px; grid-template-rows: auto minmax(0, 1fr) auto; column-gap: 56px; row-gap: 12px; }
  .top { grid-column: 1 / -1; } .play { grid-column: 1; grid-row: 2; gap: 12px; }
  .foot { grid-column: 1 / -1; font-size: 12px; }
  .side { display: flex; flex-direction: column; gap: 16px; grid-column: 2; grid-row: 2; overflow-y: auto; padding: 4px 2px 8px; scrollbar-width: none; }
  .side::-webkit-scrollbar { display: none; }
  .brand p { display: block; }
  #b-lb, #b-user { display: none; }
  .logo { width: 58px; height: 58px; font-size: 32px; }
  .brand h1 { font-size: 30px; }
  #board { --tile: min(104px, calc((100dvh - 430px) / var(--rows, 5) - 10px)); gap: 12px; }
  .row { gap: 12px; }
  #kb { max-width: 780px; } #playbar { max-width: 780px; }
  .key { height: 66px; font-size: 24px; }
  .tile.cur { box-shadow: 0 0 0 5px rgba(127,127,127,.12), 0 0 28px -2px var(--glow); }
}

/* Толкование */
.def { margin: 0 0 14px; padding: 14px 16px; border-radius: 16px; background: var(--panel); border: 1px solid var(--panel-b); text-align: left; animation: rise .4s var(--ease); }
.def-h { font: 800 12px var(--font-ui); letter-spacing: .6px; text-transform: uppercase; color: var(--accent2); margin-bottom: 7px; }
.def p, .def li { margin: 0; font-size: 15px; line-height: 1.5; }
.def ol { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.def-src { margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.def-none { color: var(--muted); font-size: 14px !important; }
.shim { height: 12px; border-radius: 6px; margin: 6px 0; background: linear-gradient(90deg, var(--panel-b), var(--tile-b), var(--panel-b)); background-size: 200% 100%; animation: shim 1.2s linear infinite; }
.shim.s2 { width: 70%; }
@keyframes shim { to { background-position: -200% 0; } }
