:root {
    --bg: #faf8ef;
    --board: #bbada0;
    --cell: #cdc1b4;
    --dark: #3e3a37;
    --white: #fff;
    --accent: #4CAF50;
    --accent-2: #8f7a66;
}

* {
    box-sizing: border-box
}

html,
body {
    height: 100%
}

body {
    margin: 0;
    background: var(--bg);
    font-family: "Vazirmatn", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    color: var(--dark);
    overscroll-behavior: none;
    /* جلوگیری از pull-to-refresh */
    touch-action: none;
    /* محدود کردن ژست‌های مرورگر داخل بازی */
    user-select: none;
}

.wrap {
    max-width: min(92vw, 680px);
    margin: 24px auto 40px;
    padding: 0 12px;
}

.header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

h1 {
    margin: 0;
    line-height: 1.15;
    font-size: clamp(20px, 5vw, 32px);
    font-weight: 800
}

.scores {
    display: flex;
    gap: 10px;
    flex-wrap: wrap
}

.score-box {
    background: var(--accent-2);
    color: var(--white);
    padding: 8px 12px;
    border-radius: 8px;
    text-align: center;
    min-width: 84px;
}

.score-box .lbl {
    display: block;
    font-size: 12px;
    opacity: .9
}

.score-box span:last-child {
    display: block;
    font-weight: 700;
    font-size: 18px
}

.controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 14px 0 10px;
    flex-wrap: wrap;
}

.select select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
}

.btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 700;
}

.btn:hover {
    filter: brightness(.95)
}

.grid {
    background: var(--board);
    border-radius: 12px;
    padding: 10px;
    display: grid;
    gap: 10px;
    width: 100%;
}

/* کارت‌ها */
.card {
    position: relative;
    perspective: 800px;
    border-radius: 10px;
    aspect-ratio: 1/1;
}

.inner {
    position: absolute;
    inset: 0;
    transition: transform .35s ease;
    transform-style: preserve-3d;
    border-radius: 10px;
}

.card.flipped .inner,
.card.matched .inner {
    transform: rotateY(180deg);
}

.face {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    backface-visibility: hidden;
    font-size: clamp(18px, 6vw, 32px);
    font-weight: 800;
}

.front {
    background: #eee;
    color: #888;
    border: 2px solid #e2e2e2;
}

.back {
    background: #f9f6f2;
    color: #333;
    border: 2px solid #f0e9d9;
    transform: rotateY(180deg);
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.hidden {
    display: none
}

.modal {
    background: #fff;
    color: #333;
    padding: 22px 18px;
    border-radius: 12px;
    width: min(92vw, 420px);
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .2)
}

.modal h2 {
    margin: 8px 0 6px
}

.modal p {
    margin: 0 0 12px
}