:root {
    --bg: #faf8ef;
    --panel: #fff;
    --board: #e9e5dc;
    --dark: #3e3a37;
    --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;
    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: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    text-align: center;
    min-width: 90px;
}

.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;
    flex-wrap: wrap;
    margin: 14px 0 10px;
}

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

.file input {
    display: inline-block;
    padding: 6px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #ddd;
}

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

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

.board {
    background: var(--panel);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .08);
}

.grid {
    width: 100%;
    aspect-ratio: 1/1;
    display: grid;
    gap: 6px;
    touch-action: none;
    /* جلوگیری از ژست‌های مرورگر داخل بازی */
}

.tile {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    background: #f2f2f2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 18px;
    color: #fff;
    cursor: pointer;
    transition: transform .07s ease, box-shadow .1s ease;
}

.tile:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, .08);
}

.tile.empty {
    background: #ddd;
    cursor: default;
    box-shadow: none;
}

.tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* اورلی پایان */
.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
}