/* Шашки VK Mini App. Светлая по умолчанию, тёмная — [data-scheme="dark"]. */
:root {
    --brand: #0f9b8a;
    --brand-2: #16b8a3;
    --accent: #5b6ef5;
    --bg: #eef1f4;
    --surface: #ffffff;
    --text: #0b1720;
    --text-dim: #5c6b78;
    --border: #e4e8ec;
    --radius: 16px;
    --font: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --shadow: 0 6px 24px rgba(16,32,48,.12);

    --sq-light: #e9dcc3;
    --sq-dark: #7d5a3c;
    --piece-w: #f5f2ec;
    --piece-w-edge: #c9c2b4;
    --piece-b: #2a2f38;
    --piece-b-edge: #11151b;
    --sel: rgba(91,110,245,.55);
    --hint: rgba(15,155,138,.55);
    --cap: rgba(224,72,61,.5);
}
[data-scheme="dark"] {
    --bg: #0e151d; --surface: #182029; --text: #eaf0f3; --text-dim: #90a0ac; --border: #2a333d;
    --sq-light: #b9a687; --sq-dark: #5e442d;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px; line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}
.hidden { display: none !important; }
#app { min-height: 100%; display: flex; flex-direction: column; }
.screen {
    flex: 1; display: flex; flex-direction: column;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

/* --- Меню --- */
#screen-menu { align-items: center; justify-content: center; gap: 8px; }
.menu-logo { font-size: 56px; letter-spacing: -6px; }
.menu-logo-img { width: 88px; height: 88px; border-radius: 22px; box-shadow: var(--shadow); }
.menu-title { font-size: 34px; font-weight: 800; margin: 6px 0 24px; }
.menu-actions { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.rules-link { margin-top: 22px; background: none; border: none; color: var(--text-dim); font-family: var(--font); font-size: 14px; font-weight: 600; text-decoration: underline; cursor: pointer; }

.btn {
    font-family: var(--font); font-size: 16px; font-weight: 700;
    border: none; border-radius: var(--radius); padding: 15px 18px;
    cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: transform .06s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1.5px solid var(--border); }
.btn-ghost { background: transparent; color: var(--text-dim); }
.badge { font-size: 11px; font-weight: 700; background: var(--border); color: var(--text-dim); padding: 2px 8px; border-radius: 999px; }

.difficulty { margin-top: 28px; text-align: center; }
.difficulty-label { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.seg { display: inline-flex; background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px; padding: 4px; gap: 4px; }
.seg-btn { border: none; background: transparent; color: var(--text-dim); font-family: var(--font); font-weight: 700; font-size: 14px; padding: 8px 16px; border-radius: 9px; cursor: pointer; }
.seg-btn.active { background: var(--brand); color: #fff; }

/* --- Игра --- */
.game-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font-size: 22px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.status { font-weight: 700; font-size: 15px; text-align: center; flex: 1; }

.board-wrap { display: flex; justify-content: center; }
.board {
    width: min(92vw, 460px); aspect-ratio: 1;
    display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
    border-radius: 12px; overflow: hidden; box-shadow: 0 6px 24px rgba(16,32,48,.14);
    touch-action: manipulation;
}
.sq { position: relative; display: flex; align-items: center; justify-content: center; }
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq.playable { cursor: pointer; }

.piece {
    width: 76%; height: 76%; border-radius: 50%;
    box-shadow: inset 0 -3px 6px rgba(0,0,0,.25), 0 2px 4px rgba(0,0,0,.3);
    display: flex; align-items: center; justify-content: center;
    transition: transform .12s ease;
}
.piece.w { background: radial-gradient(circle at 35% 30%, #ffffff, var(--piece-w) 55%, var(--piece-w-edge)); }
.piece.b { background: radial-gradient(circle at 35% 30%, #40474f, var(--piece-b) 55%, var(--piece-b-edge)); }
.piece.king::after { content: '♛'; font-size: 60%; color: var(--brand); opacity: .9; }
.piece.b.king::after { color: #ffd35b; }

.sq.sel::before { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 0 4px var(--sel); }
.sq.hint::after { content: ''; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: var(--hint); }
.sq.hint.hint-cap::after { width: 84%; height: 84%; background: transparent; box-shadow: inset 0 0 0 4px var(--cap); }
/* Подсказка: этой фигурой обязателен бой */
.sq.must::before { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 0 3px var(--cap); border-radius: 2px; animation: mustPulse 1.1s ease-in-out infinite; }
@keyframes mustPulse { 0%,100% { opacity: .35; } 50% { opacity: .9; } }

.game-footer { margin-top: 14px; text-align: center; color: var(--text-dim); font-size: 13px; min-height: 20px; }

/* --- Комната PvP --- */
.room-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
.room-code-label { color: var(--text-dim); font-size: 14px; }
.room-code { font-size: 40px; font-weight: 800; letter-spacing: 8px; }
.room-status { color: var(--text-dim); font-size: 14px; }

/* Кнопки шеринга на финальном оверлее */
.share-row { display: flex; gap: 10px; }
.share-row .btn { flex: 1; padding: 12px 10px; font-size: 15px; }

/* --- Оверлей --- */
.overlay { position: fixed; inset: 0; background: rgba(6,12,18,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.overlay-card { background: var(--surface); border-radius: 22px; padding: 28px 24px; width: 100%; max-width: 320px; text-align: center; display: flex; flex-direction: column; gap: 12px; }
.overlay-emoji { font-size: 56px; }
.overlay-title { font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.rules-card { text-align: left; max-width: 360px; }
.rules-card .overlay-title { text-align: center; }
.rules-list { margin: 4px 0 4px; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; color: var(--text-dim); font-size: 14px; line-height: 1.4; }
.rules-list li { padding-left: 2px; }

/* --- Toast --- */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; z-index: 60; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
