/* --------------------------------------------------
   플레이어 좌석 (손에 쥔 카드 부채꼴)
   모바일: 가로로 넘기는 한 줄 / 넓은 화면: 격자
   -------------------------------------------------- */

.seat-grid {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    margin: 0 -12px;            /* 화면 끝까지 스크롤되게 */
    padding: 16px 12px 6px;     /* 위쪽: 감정 말풍선이 잘리지 않게 */
}

.seat-grid::-webkit-scrollbar {
    display: none;
}

.seat {
    position: relative;
    flex: 1 0 104px;            /* 인원이 적으면 화면을 채우고, 많으면 가로로 넘김 */
    max-width: 180px;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 8px 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: border-color 0.2s ease, transform 0.2s ease;
    min-width: 0;
}

.seat-me {
    background: linear-gradient(180deg, rgba(139, 108, 255, 0.14), var(--surface) 70%);
}

.seat-turn {
    border-color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold);
}

.seat-head {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    min-width: 0;
}

.seat-order {
    display: none;              /* 모바일: 이름 공간 확보 (넓은 화면에서만 표시) */
    flex-shrink: 0;
    font-size: 11px;
    color: var(--muted);
    font-weight: 700;
}

.seat-avatar {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 11px;
    color: #fff;
    background: #3a4563;
}

.seat-me .seat-avatar { background: var(--accent); }
.seat-bot .seat-avatar { background: #2f3a57; font-size: 12px; }

.seat-name {
    flex: 1;
    min-width: 0;
    font-weight: 700;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.seat-tag {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 800;
    padding: 0 5px;
    border-radius: 6px;
    line-height: 16px;
}

.tag-me { background: rgba(139, 108, 255, 0.25); color: #cfc2ff; }
.tag-bot { background: rgba(255, 255, 255, 0.08); color: var(--muted); }

.btn-remove-bot {
    flex-shrink: 0;
    margin-left: auto;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--muted);
    font-size: 14px;
    line-height: 1;
}

.btn-remove-bot:hover {
    color: var(--down);
}

/* 카드 뒷면 부채꼴: 카드는 아래 중심을 축으로 회전 */
.seat-fan {
    position: relative;
    width: 100%;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-back {
    position: absolute;
    left: calc(50% - 11px);
    bottom: 2px;
    width: 22px;
    height: 32px;
    border-radius: 3px;
    border: 1.5px solid var(--surface);
    background:
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.16) 0 3px, transparent 3px 7px),
        linear-gradient(160deg, #6f55e0 0%, #3a2896 100%);
    transform-origin: 50% 100%;
    transform: translate(calc(var(--x) * 0.75), var(--y)) rotate(var(--r));
}

.seat-me .card-back {
    background:
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.18) 0 3px, transparent 3px 7px),
        linear-gradient(160deg, #a58cff 0%, #6a4fe6 100%);
}

.seat-bot .card-back {
    background:
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.12) 0 3px, transparent 3px 7px),
        linear-gradient(160deg, #4b5a80 0%, #2c3654 100%);
}

.seat-empty {
    font-size: 12px;
    color: var(--muted);
}

.fan-played { animation: fan-played 0.35s ease; }
.fan-drew { animation: fan-drew 0.35s ease; }

@keyframes fan-played {
    from { transform: translateY(-5px); }
    to { transform: translateY(0); }
}

@keyframes fan-drew {
    from { transform: scale(1.06); }
    to { transform: scale(1); }
}

.seat-foot {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
    min-height: 18px;
}

.seat-count {
    font-weight: 700;
    font-size: 12px;
}

.seat-status {
    font-size: 11px;
    font-weight: 700;
    color: #2a2000;
    background: var(--gold);
    padding: 0 6px;
    border-radius: 6px;
}

/* 방금 낸 카드 (예: ▼1 ← 89): 위쪽은 감정 말풍선 자리라 아래 모서리에 */
.seat-last {
    position: absolute;
    bottom: -9px;
    right: -4px;
    z-index: 2;
    font-size: 11px;
    font-weight: 800;
    padding: 1px 7px;
    border-radius: 999px;
    color: #0f1420;
}

.last-up { background: var(--up); }
.last-down { background: var(--down); }

/* 10 되돌리기 성공: 금색 + 살짝 커짐 (그냥 낸 카드와 한눈에 구분) */
.seat-last.last-backtrack {
    background: linear-gradient(160deg, #ffe07a, var(--gold));
    color: #3a2a00;
    box-shadow: 0 0 0 2px rgba(255, 201, 61, 0.35), 0 4px 12px rgba(255, 201, 61, 0.35);
    animation: backtrack-chip 0.5s cubic-bezier(.2, .9, .3, 1.4);
}

.seat-last.last-backtrack b {
    font-weight: 900;
}

@keyframes backtrack-chip {
    from { transform: scale(0.5); opacity: 0; }
}

/* 이번 판 되돌리기 성공 횟수 */
.tag-backtrack {
    background: rgba(255, 201, 61, 0.18);
    color: var(--gold);
}

@media (min-width: 900px) {
    .seat-order {
        display: inline;
    }

    /* 최대 5명이라 PC 에서는 항상 한 줄 (인원 수만큼 균등 분할) */
    .seat-grid {
        display: flex;
        overflow: visible;
        margin: 0;
        padding: 14px 0 0;      /* 말풍선 공간 */
    }

    .seat {
        flex: 1 1 0;
        max-width: 240px;
    }

    .seat-fan {
        height: 56px;
    }

    .card-back {
        width: 26px;
        height: 38px;
        left: calc(50% - 13px);
        transform: translate(var(--x), var(--y)) rotate(var(--r));
    }
}

/* 대기실: 준비한 사람 */
.seat-is-ready {
    border-color: rgba(47, 212, 134, 0.55);
}

.seat-ready-badge {
    font-size: 12px;
    font-weight: 800;
    color: var(--up);
    background: rgba(47, 212, 134, 0.14);
    padding: 2px 8px;
    border-radius: 999px;
}

/* 게임 종료: 남은 손패 공개 (작은 앞면 카드, 하나씩 뒤집힘) */
.seat-reveal {
    height: auto;
    min-height: 46px;
    flex-wrap: wrap;
    align-content: center;
    gap: 3px;
    padding: 2px 0;
}

.mini-card {
    width: 22px;
    height: 30px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: -0.03em;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    animation: card-flip 0.4s ease-out both;
    animation-delay: calc(var(--i, 0) * 70ms);
}

@keyframes card-flip {
    from { transform: rotateY(90deg); opacity: 0.3; }
    to { transform: rotateY(0deg); opacity: 1; }
}

@media (min-width: 900px) {
    .mini-card {
        width: 26px;
        height: 36px;
        font-size: 13px;
    }
}

/* 연결이 끊겨 재접속을 기다리는 사람 */
.seat-away {
    opacity: 0.75;
    border-style: dashed;
}

.seat-away-badge {
    font-size: 11px;
    font-weight: 800;
    color: #2a2000;
    background: var(--gold);
    padding: 1px 7px;
    border-radius: 6px;
}
