/* =====================================================================
   Самоцветы — стили игры
   Использует дизайн-токены из base.css (:root).
   Всё ограничено классом .jwl-root.
   ===================================================================== */

.jwl-root {
    --jwl-size: clamp(44px, 10vw, 64px);
    --jwl-gap: clamp(4px, 1.5vw, 8px);
    max-width: 600px;
    margin-inline: auto;
}

/* ---------- Панель управления ---------- */
.jwl-ui {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.jwl-pill {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: .45rem 1rem;
    font-size: .92rem;
    font-weight: 600;
    color: var(--ink);
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}

.jwl-pill strong {
    color: var(--terracotta-d);
}

.jwl-restart {
    all: unset;
    cursor: pointer;
    font: inherit;
    background: var(--terracotta);
    color: #fff;
    font-weight: 700;
    border-radius: 999px;
    padding: .45rem 1.1rem;
    font-size: .92rem;
    transition: background .15s;
    box-shadow: var(--shadow-sm);
}

.jwl-restart:hover {
    background: var(--terracotta-d);
}

.jwl-restart:active {
    transform: translateY(1px);
}

/* ---------- Доска ---------- */
.jwl-board-wrap {
    display: inline-block;
    padding: clamp(10px, 2vw, 18px);
    border-radius: var(--radius-lg);
    background: var(--bg-alt);
    box-shadow: var(--shadow-lg);
    margin: 0 auto;
}

.jwl-board {
    display: grid;
    grid-template-columns: repeat(var(--jwl-cols, 8), var(--jwl-size));
    gap: var(--jwl-gap);
}

/* ---------- Ячейка ---------- */
.jwl-cell {
    width: var(--jwl-size);
    height: var(--jwl-size);
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    position: relative;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* ---------- Самоцвет ---------- */
.jwl-candy {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-sm);
    box-shadow:
        inset 0 6px 14px rgba(255, 255, 255, .3),
        0 6px 18px rgba(58, 46, 42, .15);
    position: relative;
    will-change: transform;
}

.jwl-candy.is-selected {
    outline: 3px solid var(--ink);
    filter: brightness(1.1);
}

/* ---------- Цвета самоцветов ---------- */
.jwl-candy--0 { background: #C75B2C; }  /* терракота */
.jwl-candy--1 { background: #E8B042; }  /* золотой */
.jwl-candy--2 { background: #7B9E6B; }  /* шалфей */
.jwl-candy--3 { background: #5D8CA8; }  /* небесный */
.jwl-candy--4 { background: #A07CBC; }  /* лавандовый */

/* ---------- Бомба ---------- */
.jwl-candy--bomb::after {
    content: "";
    position: absolute;
    inset: 20%;
    border-radius: 50%;
    border: 4px solid rgba(58, 46, 42, .8);
    box-shadow: 0 0 10px rgba(58, 46, 42, .25) inset;
}

/* ---------- Радуга ---------- */
.jwl-candy--rainbow {
    background: conic-gradient(#C75B2C, #E8B042, #7B9E6B, #5D8CA8, #A07CBC, #C75B2C);
}

.jwl-candy--rainbow::after {
    content: "";
    position: absolute;
    inset: 12%;
    border-radius: var(--radius-sm);
    box-shadow: inset 0 0 16px rgba(58, 46, 42, .3);
}

/* ---------- Конец игры ---------- */
.jwl-end {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 100;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    background: rgba(58, 46, 42, .86);
    color: #fff;
    border-radius: var(--radius-lg);
    text-align: center;
    padding: 1.5rem;
}

.jwl-end.is-active {
    display: flex;
}

.jwl-end__title {
    font-size: 1.6rem;
    font-weight: 800;
}

.jwl-end__score {
    font-size: 1.1rem;
    color: var(--terracotta-l);
}

.jwl-end__restart {
    cursor: pointer;
    font: inherit;
    background: var(--terracotta);
    color: #fff;
    font-weight: 700;
    border: none;
    border-radius: 999px;
    padding: .55rem 1.4rem;
    font-size: .95rem;
    transition: background .15s;
    margin-top: .4rem;
}

.jwl-end__restart:hover {
    background: var(--terracotta-d);
}

/* ---------- Инструкция ---------- */
.jwl-help {
    text-align: center;
    font-size: .88rem;
    color: var(--ink-muted);
    margin-bottom: 1rem;
    line-height: 1.5;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .jwl-candy,
    .jwl-cell {
        transition: none !important;
        animation: none !important;
    }
}
