:root {

    --bg: #edf3ef;

    --card: rgba(255,255,255,0.88);

    --text: #243b67;

    --muted: #718096;

    --primary: #5b7cfa;

    --success: #9be7b1;

    --danger: #ffb4b4;

    --border: #d7dee8;

    --shadow:
        0 12px 35px rgba(0,0,0,0.08);

    --radius: 30px;
}
* {
    box-sizing: border-box;
}

html {

    -webkit-text-size-adjust: 100%;
}

body {

    margin: 0;

    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    background:
        linear-gradient(
            180deg,
            #f3f7f2 0%,
            #edf3ef 100%
        );

    color: var(--text);
	
	padding-bottom: 120px;

    min-height: 100svh;

    overflow-x: hidden;
}

/* =====================================
APP
===================================== */

.app {

    width: 100%;

    max-width: 980px;

    margin: 0 auto;

    padding:
        calc(env(safe-area-inset-top) + 18px)
        16px
        calc(env(safe-area-inset-bottom) + 40px);

    display: flex;

    flex-direction: column;

    align-items: center;
}

/* =====================================
TOP PANEL
===================================== */

.top-panel {

    width: 100%;

    background: var(--card);

    backdrop-filter: blur(10px);

    border-radius: var(--radius);

    padding: 24px;

    box-shadow: var(--shadow);

    margin-bottom: 22px;
}

.title {

    margin: 0 0 22px;

    text-align: center;

    font-size:
        clamp(42px, 6vw, 72px);

    line-height: 1.1;

    font-weight: 900;

    color: var(--text);
}

/* =====================================
STATS
===================================== */

.stats {

    display: grid;

    grid-template-columns:
        repeat(3, 1fr);

    gap: 18px;
}

.stat-card {

    background:
        rgba(245,247,250,0.9);

    border-radius: 22px;

    padding: 20px;

    text-align: center;
}

.stat-label {

    display: block;

    color: var(--muted);

    margin-bottom: 10px;

    font-size: 18px;
}

.stat-value {

    font-size: 34px;

    font-weight: 900;

    color: var(--text);
}

/* =====================================
GAME AREA
===================================== */

.game-area {

    width: 100%;

    background: var(--card);

    border-radius: var(--radius);

    padding: 24px;

    box-shadow: var(--shadow);

    display: flex;

    flex-direction: column;

    align-items: center;
}

/* =====================================
MESSAGE
===================================== */

.message {

    width: 100%;

    text-align: center;

    padding: 24px;

    border-radius: 24px;

    font-size: clamp(22px, 3vw, 38px);

    font-weight: 800;

    margin-bottom: 18px;
}

.message.info {

    background: #dfe7f2;
}

.message.success {

    background: #b9efc8;
}

.message.error {

    background: #ffd2d2;
}

/* =====================================
BOARD
===================================== */

.board {

    width: min(92vw, 620px);

    height: min(92vw, 620px);

    display: grid;

    grid-template-columns: repeat(8, 1fr);

    border-radius: 24px;

    overflow: hidden;

    border: 6px solid #c8d2df;

    background: white;

    box-shadow:
        inset 0 2px 12px rgba(0,0,0,0.06);

    transition: transform 0.35s ease;
}
.board.flipped {
    transform: rotate(180deg);
}
.board.flipped .piece {
    transform: rotate(180deg);
}

/* =====================================
SQUARES
===================================== */

.square {

    position: relative;

    display: flex;

    align-items: center;

    justify-content: center;

    overflow: hidden;

    user-select: none;

    min-width: 0;

    min-height: 0;
}

.square.light {

    background: #ded8c4;
}

.square.dark {

    background: #a9be8a;
}

.square.selected {

    box-shadow:
        inset 0 0 0 6px rgba(91,124,250,0.45);
}

.square.correct {

    animation:
        correctPulse 0.5s ease;
}

.square.wrong {

    animation:
        wrongShake 0.35s ease;
}

/* =====================================
PIECES
===================================== */

.piece {

    position: absolute;

    inset: 0;

    display: flex;

    align-items: center;

    justify-content: center;

    font-size: clamp(34px, 6vw, 64px);

    line-height: 1;

    font-family:
        "Segoe UI Symbol",
        "Noto Sans Symbols",
        "Arial Unicode MS",
        sans-serif;

    cursor: pointer;

    user-select: none;

    transition:
        transform 0.12s ease;

    transform: translateY(-2%);
}

/* Белые фигуры */

.piece.w {

    color: #ffffff;

    text-shadow:
        0 2px 2px rgba(0,0,0,0.35),
        0 0 1px rgba(0,0,0,0.6);
}

/* Чёрные фигуры */

.piece.b {

    color: #1f2937;

    text-shadow:
        0 1px 1px rgba(255,255,255,0.15);
}

/* Hover */

.piece:hover {

    transform:
        translateY(-2%)
        scale(1.08);
}

/* =====================================
BUTTONS
===================================== */

.controls {

    width: 100%;

    display: flex;

    gap: 16px;

    justify-content: center;

    margin-top: 26px;

    flex-wrap: wrap;
}

.btn {

    border: none;

    border-radius: 22px;

    padding: 18px 28px;

    font-size: 22px;

    font-weight: 800;

    cursor: pointer;

    transition:
        transform 0.15s ease,
        opacity 0.15s ease;

    min-width: 240px;
}

.btn:hover {

    transform: translateY(-2px);
}

.btn:active {

    transform: scale(0.98);
}

.btn {

    background: #8dc0ff;

    color: #102a56;
}

.btn.secondary {

    background: #dfe4ec;
}

.hidden {

    display: none;
}

/* =====================================
FOOTER
===================================== */

footer {

    width: 100%;

    text-align: center;

    padding: 30px 20px;

    color: var(--muted);

    font-size: 14px;
}

footer a {

    color: inherit;
}

/* =====================================
ADS SAFE
===================================== */

.adsbygoogle {

    max-width: 100% !important;

    overflow: hidden !important;
}

ins.adsbygoogle[data-ad-status="unfilled"] {

    display: none !important;

    height: 0 !important;
}

/* =====================================
ANIMATIONS
===================================== */

@keyframes correctPulse {

    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.03);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes wrongShake {

    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-6px);
    }

    50% {
        transform: translateX(6px);
    }

    75% {
        transform: translateX(-4px);
    }

    100% {
        transform: translateX(0);
    }
}

/* =====================================
TABLETS
===================================== */

@media (max-width: 768px) {

    .top-panel {

        padding: 20px;
    }

    .stats {

        gap: 10px;
    }

    .stat-card {

        padding: 16px 10px;
    }

    .stat-label {

        font-size: 15px;
    }

    .stat-value {

        font-size: 28px;
    }

    .game-area {

        padding: 16px;
    }

    .btn {

        width: 100%;

        min-width: auto;

        font-size: 20px;
    }
}

/* =====================================
PHONES
===================================== */

@media (max-width: 520px) {

    .title {

        font-size: 48px;
    }

    .stats {

        grid-template-columns: 1fr;
    }

   .board {

    width: 96vw;

    height: 96vw;
}

    .message {

        font-size: 24px;

        padding: 18px;
    }

    .btn {

        padding: 16px;

        font-size: 18px;
    }
}