/* style.css — Шахматная фея */
:root {
  --bg1: #fde7f3;
  --bg2: #e9e1ff;
  --bg3: #dff7f0;
  --card: rgba(255, 255, 255, 0.78);
  --ink: #4a3b5c;
  --ink-soft: #8a7a9c;
  --accent: #ff7bb0;
  --accent-dark: #e0559a;
  --lilac: #b79cf0;
  --mint: #8fdcc4;
  --sun: #ffd166;
  --sq-light: #fff6fb;
  --sq-dark: #cdbbee;
  --sq-select: #ffd0e6;
  --sq-last: #fff0b8;
  --sq-check: #ff8a8a;
  --shadow: 0 10px 30px rgba(120, 90, 160, 0.18);
  --radius: 22px;
  --font: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(135deg, var(--bg1) 0%, var(--bg2) 50%, var(--bg3) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.bg-blobs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg-blobs span {
  position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55;
  animation: float 14s ease-in-out infinite;
}
.bg-blobs span:nth-child(1) { width: 40vw; height: 40vw; background: #ffc2dd; top: -10vw; left: -10vw; }
.bg-blobs span:nth-child(2) { width: 35vw; height: 35vw; background: #c9b8ff; bottom: -10vw; right: -5vw; animation-delay: -5s; }
.bg-blobs span:nth-child(3) { width: 30vw; height: 30vw; background: #b8f0dc; top: 40vh; left: 55vw; animation-delay: -9s; }
@keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(3vw, -3vh) scale(1.08); } }

#app { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; gap: 10px;
}
.topbar-title { font-weight: 900; font-size: 1.25rem; letter-spacing: .3px; text-align: center; flex: 1; }
.icon-btn {
  width: 44px; height: 44px; border: none; border-radius: 14px; background: var(--card);
  box-shadow: var(--shadow); font-size: 1.3rem; cursor: pointer; transition: transform .15s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.muted { opacity: .5; }

#screen { flex: 1; padding: 8px 16px 32px; max-width: 1100px; width: 100%; margin: 0 auto; }

/* ---------- Кнопки ---------- */
.btn {
  font-family: var(--font); font-weight: 800; font-size: 1rem; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border: none; border-radius: 16px; padding: 12px 22px; cursor: pointer;
  box-shadow: 0 6px 18px rgba(224, 85, 154, .35); transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(224, 85, 154, .4); }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.secondary { background: linear-gradient(135deg, var(--lilac), #9b7fe0); box-shadow: 0 6px 18px rgba(155, 127, 224, .35); }
.btn.mint { background: linear-gradient(135deg, var(--mint), #5fc7a7); box-shadow: 0 6px 18px rgba(95, 199, 167, .35); }
.btn.ghost { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.btn.small { padding: 8px 14px; font-size: .9rem; border-radius: 12px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* ---------- Карточки ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; backdrop-filter: blur(8px);
}

/* ---------- Меню ---------- */
.menu { display: flex; flex-direction: column; align-items: center; gap: 22px; padding-top: 12px; }
.hero { text-align: center; }
.hero .mascot { font-size: 4.5rem; line-height: 1; animation: bob 3s ease-in-out infinite; display: inline-block; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-8px) rotate(3deg); } }
.hero h1 { margin: 8px 0 4px; font-size: 2.2rem; font-weight: 900;
  background: linear-gradient(90deg, #e0559a, #9b7fe0, #5fc7a7); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { margin: 0; color: var(--ink-soft); font-weight: 700; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; width: 100%; max-width: 1000px; }
.menu-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 18px;
  text-align: center; cursor: pointer; transition: transform .2s, box-shadow .2s; border: 3px solid transparent;
}
.menu-card:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 16px 36px rgba(120, 90, 160, .25); }
.menu-card .big { font-size: 3rem; line-height: 1; }
.menu-card h3 { margin: 10px 0 4px; font-size: 1.3rem; font-weight: 900; }
.menu-card p { margin: 0; color: var(--ink-soft); font-size: .92rem; font-weight: 600; }
.menu-card .progress { margin-top: 10px; font-size: .85rem; font-weight: 800; color: var(--accent-dark); }
.menu-card.pink { border-color: #ffc2dd; }
.menu-card.lilac { border-color: #d3c4ff; }
.menu-card.mint { border-color: #b8f0dc; }
.menu-card.sun { border-color: #ffe4a8; }

/* ---------- Список уроков / задачек ---------- */
.list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.list-card {
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 16px;
  cursor: pointer; transition: transform .15s; display: flex; flex-direction: column; gap: 6px; position: relative;
}
.list-card:hover { transform: translateY(-3px); }
.list-card .num { font-size: .75rem; font-weight: 800; color: var(--ink-soft); }
.list-card .emoji { font-size: 2.2rem; }
.list-card h4 { margin: 0; font-size: 1.05rem; font-weight: 900; }
.list-card .stars { color: var(--sun); font-size: 1rem; letter-spacing: 1px; }
.list-card .stars .off { color: #dcd3ea; }
.list-card.done::after { content: '✓'; position: absolute; top: 10px; right: 12px; background: var(--mint); color: #fff; font-weight: 900; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; }
.list-card .mini { width: 100%; aspect-ratio: 1; border-radius: 10px; overflow: hidden; display: grid; grid-template-columns: repeat(8, 1fr); }
.list-card .mini i { display: block; }
.list-card .mini i.l { background: var(--sq-light); }
.list-card .mini i.d { background: var(--sq-dark); }
.list-card .mini svg { width: 100%; height: 100%; }

.page-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 16px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 1.5rem; font-weight: 900; flex: 1; }

/* ---------- Раскладка урок/игра ---------- */
.play-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; grid-template-areas: "board top" "board bottom"; gap: 20px; align-items: start; }
.area-board { grid-area: board; min-width: 0; }
.area-top { grid-area: top; min-width: 0; }
.area-bottom { grid-area: bottom; min-width: 0; }
@media (max-width: 860px) { .play-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "board" "bottom"; gap: 14px; } }

.side { display: flex; flex-direction: column; gap: 14px; }
.side .card p { margin: 0 0 10px; line-height: 1.5; font-weight: 600; }
.side .card p:last-child { margin-bottom: 0; }
.lesson-title { display: flex; align-items: center; gap: 10px; font-size: 1.3rem; font-weight: 900; margin-bottom: 8px; }
.lesson-title .big { font-size: 2rem; }

/* Пузырь феи */
.fairy { display: flex; gap: 10px; align-items: flex-start; }
.fairy .face { font-size: 2.4rem; line-height: 1; flex-shrink: 0; transition: transform .2s; }
.fairy.happy .face { animation: jump .5s ease; }
@keyframes jump { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-10px) scale(1.1); } }
.bubble {
  background: #fff; border-radius: 16px; border-top-left-radius: 4px; padding: 10px 14px;
  font-weight: 700; line-height: 1.4; box-shadow: var(--shadow); flex: 1; min-height: 44px;
}
.task-steps { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.task-steps span { width: 12px; height: 12px; border-radius: 50%; background: #e4dbf5; }
.task-steps span.done { background: var(--sun); }
.task-steps span.cur { background: var(--accent); transform: scale(1.25); }

/* ---------- Доска ---------- */
.board-wrap { width: min(100%, 78vh); margin: 0 auto; }
.board-frame {
  position: relative; padding: 22px; border-radius: 20px;
  background: linear-gradient(160deg, #fff, #f2e9ff); box-shadow: var(--shadow);
}
.board {
  position: relative; width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden;
  box-shadow: inset 0 0 0 3px rgba(183, 156, 240, .5);
}
.board.shake { animation: shake .4s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
.squares { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.sq { position: relative; cursor: pointer; transition: background .15s; }
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq.selected { background: var(--sq-select) !important; box-shadow: inset 0 0 0 4px var(--accent); }
.sq.last { background: var(--sq-last) !important; }
.sq.check { background: var(--sq-check) !important; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: inset 0 0 0 0 rgba(255, 80, 80, .5); } 50% { box-shadow: inset 0 0 0 6px rgba(255, 80, 80, .5); } }
.sq.hint { box-shadow: inset 0 0 0 4px var(--mint); }
.sq.target::after {
  content: ''; position: absolute; inset: 0; margin: auto; width: 26%; height: 26%;
  border-radius: 50%; background: rgba(224, 85, 154, .45);
}
.sq.target.capture::after { width: 100%; height: 100%; background: none; border: 5px solid rgba(224, 85, 154, .55); border-radius: 50%; box-sizing: border-box; }
.sq .star { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(14px, 3.6vmin, 30px); pointer-events: none; animation: twinkle 1.6s ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { transform: scale(1) rotate(-6deg); } 50% { transform: scale(1.18) rotate(6deg); } }
.sq .coord { position: absolute; font-size: clamp(8px, 1.6vmin, 12px); font-weight: 900; color: rgba(74, 59, 92, .55); pointer-events: none; }
.sq .coord.file { right: 3px; bottom: 1px; }
.sq .coord.rank { left: 3px; top: 1px; }

.pieces { position: absolute; inset: 0; pointer-events: none; }
.piece {
  position: absolute; width: 12.5%; height: 12.5%; padding: 0.7%;
  transition: left .28s cubic-bezier(.4, 0, .2, 1), top .28s cubic-bezier(.4, 0, .2, 1), opacity .25s, transform .2s;
  filter: drop-shadow(0 3px 3px rgba(60, 30, 90, .25));
}
.piece.w { --fill: #fffaf3; --line: #b58cc7; --blush: #ffc2dd; }
.piece.b { --fill: #8e6fc4; --line: #4a3175; --blush: #f2a0c8; }
.piece.gone { opacity: 0; transform: scale(.3); }
.piece.lifted { transform: scale(1.12) translateY(-4%); z-index: 2; }
.piece.pop { animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(.4); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }

/* ---------- Игра ---------- */
.status-line { font-weight: 800; text-align: center; margin: 12px 0 0; min-height: 22px; }
.captured { display: flex; flex-wrap: wrap; gap: 2px; min-height: 28px; align-items: center; }
.captured svg { width: 24px; height: 24px; }
.captured .piece { position: static; width: 24px; height: 24px; padding: 0; filter: none; }
.captured .adv { font-size: .8rem; font-weight: 900; color: var(--ink-soft); margin-left: 4px; }
.opponent-row { display: flex; align-items: center; gap: 12px; }
.opponent-row .avatar { font-size: 2.4rem; }
.opponent-row .name { font-weight: 900; font-size: 1.1rem; }
.opponent-row .sub { font-size: .85rem; color: var(--ink-soft); font-weight: 700; }
.thinking { display: inline-block; animation: think 1s infinite; }
@keyframes think { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
.moves-list { max-height: 160px; overflow-y: auto; font-size: .9rem; font-weight: 700; display: grid; grid-template-columns: 34px 1fr 1fr; gap: 2px 8px; }
.moves-list .n { color: var(--ink-soft); }

.level-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.level-card { background: var(--card); border-radius: 18px; padding: 18px; text-align: center; cursor: pointer; border: 3px solid transparent; box-shadow: var(--shadow); transition: transform .15s; }
.level-card:hover { transform: translateY(-3px); }
.level-card.active { border-color: var(--accent); background: #fff; }
.level-card .big { font-size: 2.6rem; }
.level-card h4 { margin: 8px 0 4px; font-size: 1.1rem; font-weight: 900; }
.level-card p { margin: 0; font-size: .85rem; color: var(--ink-soft); font-weight: 600; }
.level-card .wins { margin-top: 8px; font-size: .8rem; font-weight: 800; color: var(--accent-dark); }
.color-pick { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 20px; }
.color-pick .chip { padding: 10px 18px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); font-weight: 800; cursor: pointer; border: 3px solid transparent; }
.color-pick .chip.active { border-color: var(--lilac); background: #fff; }
.center { text-align: center; }

/* ---------- Модалка / тост ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(74, 59, 92, .35); display: grid; place-items: center; padding: 20px; backdrop-filter: blur(4px); }
.modal-card { background: #fff; border-radius: 26px; padding: 28px; max-width: 420px; width: 100%; text-align: center; box-shadow: 0 20px 60px rgba(60, 30, 90, .35); animation: pop .35s ease; }
.modal-card .big { font-size: 4rem; line-height: 1; }
.modal-card h3 { margin: 10px 0 6px; font-size: 1.6rem; font-weight: 900; }
.modal-card p { margin: 0 0 14px; color: var(--ink-soft); font-weight: 700; }
.modal-card .btn-row { justify-content: center; }
.promo-pick { display: flex; gap: 10px; justify-content: center; margin: 10px 0; }
.promo-pick .opt { width: 72px; height: 72px; border-radius: 16px; background: var(--bg2); cursor: pointer; padding: 6px; border: 3px solid transparent; }
.promo-pick .opt:hover { border-color: var(--accent); }
.promo-pick .opt .piece { position: static; width: 100%; height: 100%; padding: 0; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 70; pointer-events: none; }

.tip { font-size: .85rem; color: var(--ink-soft); font-weight: 700; }

[hidden] { display: none !important; }

/* фигурки вне большой доски: миниатюры, съеденные, выбор при превращении */
.list-card .mini .piece { position: static; width: 100%; height: 100%; padding: 4%; filter: none; transition: none; }
.list-card .mini { grid-template-rows: repeat(8, 1fr); }
.list-card .mini i { min-height: 0; min-width: 0; overflow: hidden; }
.list-card .mini .piece { display: block; }

/* ---------- Практика ---------- */
.quiz-opts { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.quiz-opts:empty { display: none; }
.opt-btn { font-family: var(--font); font-weight: 800; font-size: .95rem; text-align: left; color: var(--ink); background: #fff; border: 3px solid #e9e1ff; border-radius: 14px; padding: 10px 14px; cursor: pointer; transition: transform .15s, border-color .15s; }
.opt-btn:hover { transform: translateY(-2px); border-color: var(--lilac); }
.opt-btn.wrong { border-color: #ff8a8a; background: #fff0f0; }
.opt-btn.right { border-color: var(--mint); background: #eefbf6; }
.opt-btn:disabled { cursor: default; transform: none; }
.list-card .kind { font-size: .72rem; font-weight: 800; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .5px; }
.list-card .count { font-size: .9rem; font-weight: 800; color: var(--accent-dark); }
.side .card p.tip { margin-bottom: 6px; }

/* ---------- Кабинет, друзья, онлайн ---------- */
.menu-card.sky { border-color: #bfe3ff; }
.form-card { max-width: 480px; }
.form-card label { display: block; font-weight: 800; margin: 10px 0 4px; }
.form-card input, .add-friend input { width: 100%; font-family: var(--font); font-size: 1rem; font-weight: 700; padding: 10px 14px; border: 3px solid #e9e1ff; border-radius: 14px; background: #fff; color: var(--ink); outline: none; }
.form-card input:focus, .add-friend input:focus { border-color: var(--lilac); }
.form-error { color: #e05555; font-weight: 800; min-height: 20px; margin-top: 6px; font-size: .9rem; }
.account-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.friend-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed #e9e1ff; flex-wrap: wrap; }
.friend-row:last-child { border-bottom: none; }
.friend-row .fname { font-weight: 900; flex: 1; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #d6cfe6; vertical-align: middle; }
.dot.online { background: #5fc7a7; box-shadow: 0 0 0 3px rgba(95, 199, 167, .25); }
.icon-mini { border: none; background: transparent; color: var(--ink-soft); font-weight: 900; cursor: pointer; font-size: 1rem; padding: 4px 6px; }
.add-friend { display: flex; gap: 8px; margin-top: 10px; }
.add-friend input { flex: 1; }
.chat-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip-btn { font-family: var(--font); font-weight: 800; font-size: .85rem; background: #fff; border: 2px solid #e9e1ff; border-radius: 999px; padding: 6px 10px; cursor: pointer; color: var(--ink); }
.chip-btn:hover { border-color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 16px; font-weight: 800; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: 90vw; text-align: center; }
.form-card.gate { width: 100%; max-width: 420px; }
.form-card.gate input { font-size: 1.1rem; }
