/* 숫자 슬라이딩 퍼즐. 클래식한 빨강·흰색 타일과 금색 숫자를 그대로 옮겼다.
   프레임은 테마와 무관하게 검정을 유지한다 — 그게 이 퍼즐의 생김새다. */

.puzzle-frame {
    background: linear-gradient(160deg, #2b2b2b, #111);
    border-radius: 14px;
    padding: 12px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12),
                0 10px 24px rgba(0, 0, 0, 0.28);
    max-width: 420px;
    margin: 0 auto;
}

.puzzle-board {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #0a0a0a;
    border-radius: 6px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.9);
    touch-action: manipulation;
}

/* 타일은 그리드가 아니라 절대 위치다. 그래야 자리를 옮길 때 미끄러지듯 움직인다. */
.puzzle-tile {
    position: absolute;
    top: 0;
    left: 0;
    width: calc(100% / var(--puzzle-size));
    height: calc(100% / var(--puzzle-size));
    padding: 3px;
    border: 0;
    background: none;
    transform: translate(calc(var(--tile-col) * 100%), calc(var(--tile-row) * 100%));
    transition: transform 0.16s ease-out;
}

.puzzle-face {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 5px;
    font-family: var(--quiz-font-display);
    font-weight: 800;
    /* 판 크기가 커져도 숫자가 넘치지 않게 칸 폭에 비례시킨다. */
    font-size: calc(min(420px, 78vw) / var(--puzzle-size) * 0.44);
    line-height: 1;
    color: #e8bf5a;
    text-shadow: 0 1px 0 #8a6410, 0 2px 2px rgba(0, 0, 0, 0.45);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35),
                inset 0 -2px 3px rgba(0, 0, 0, 0.2),
                0 1px 2px rgba(0, 0, 0, 0.5);
    user-select: none;
}

.puzzle-tile--red .puzzle-face {
    background: linear-gradient(165deg, #e0323b, #b3151d);
}

.puzzle-tile--white .puzzle-face {
    background: linear-gradient(165deg, #fbfaf6, #e2ded2);
}

/* 움직일 수 있는 타일만 눌리는 느낌을 준다. */
.puzzle-tile--movable {
    cursor: pointer;
}

.puzzle-tile--movable:hover .puzzle-face {
    filter: brightness(1.07);
}

.puzzle-tile:active .puzzle-face {
    transform: scale(0.97);
}

.puzzle-tile:focus-visible {
    outline: none;
}

.puzzle-tile:focus-visible .puzzle-face {
    outline: 3px solid #6ea8fe;
    outline-offset: -3px;
}

.puzzle-board--solved .puzzle-face {
    animation: puzzle-pop 0.5s ease-out;
}

@keyframes puzzle-pop {
    50% { box-shadow: 0 0 14px 2px rgba(232, 191, 90, 0.7); }
}

.puzzle-stat {
    background: var(--bs-tertiary-bg);
    border-radius: 10px;
    padding: 0.5rem 0.25rem;
}

.puzzle-stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
}

.puzzle-stat-value {
    display: block;
    font-family: var(--quiz-font-display);
    font-weight: 700;
    font-size: 1.15rem;
    font-variant-numeric: tabular-nums;
}

.puzzle-status {
    min-height: 1.5rem;
    font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
    .puzzle-tile { transition: none; }
    .puzzle-board--solved .puzzle-face { animation: none; }
}
