/* ───────────────────────────────────────────────────────────────
   backgammon.css : バックギャモン
   scope: .game-bg
   ─────────────────────────────────────────────────────────────── */

.game-bg {
    --bg-felt: #0f5132;
    --bg-felt-2: #134d2c;
    --bg-frame: #6b4226;
    --bg-spike-odd: #7f1d1d;
    --bg-spike-even: #b8860b;
    --bg-bar-bg: #3d1f0a;
    --bg-checker-size: clamp(18px, 4.4vmin, 28px);
}

.game-bg.bg-room {
    align-items: stretch;
    padding: 0;
    gap: 12px;
}

/* 自分マーカー（白/黒） */
.game-bg .bg-you-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.85);
}
.game-bg .bg-you-badge.white {
    color: #1e293b;
    background: #fafafa;
    border: 1px solid var(--border-strong);
}
.game-bg .bg-you-badge.black {
    color: #f8fafc;
    background: #1f2937;
}
.game-bg .bg-you-badge.none {
    color: var(--text-muted);
    background: var(--surface-soft);
}

/* 盤本体（フェルト） */
.game-bg .bg-board {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: linear-gradient(135deg, var(--bg-felt), var(--bg-felt-2));
    border: 4px solid var(--bg-frame);
    border-radius: var(--r-lg);
    padding: 8px;
    box-shadow:
        var(--sh-md),
        inset 0 2px 8px rgba(0, 0, 0, 0.45);
    width: 100%;
    max-width: 700px;
    align-self: center;
}

.game-bg .bg-summary {
    display: flex;
    justify-content: space-between;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8rem;
    color: #d1fae5;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 10px;
    border-radius: 6px;
}

.game-bg .bg-dice {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    flex-wrap: wrap;
}
.game-bg .bg-dice-label {
    font-weight: 700;
    color: #d1fae5;
    font-size: 13px;
}

.game-bg .bg-die {
    min-width: 2.4rem;
    height: 2.4rem;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: white;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text);
    cursor: default;
    box-shadow: var(--sh-sm);
}
.game-bg .bg-die.clickable {
    cursor: pointer;
}
.game-bg .bg-die.selected {
    background: #fde68a;
    border-color: #b45309;
    box-shadow: 0 0 0 3px #fbbf24;
}

.game-bg .bg-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr) auto repeat(6, 1fr);
    gap: 2px;
    align-items: stretch;
}

/* スパイク（三角ポイント） */
.game-bg .bg-spike {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: clamp(110px, 22vmin, 160px);
    padding: 4px 2px;
    gap: 2px;
    user-select: none;
    cursor: default;
}

.game-bg .bg-spike::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
}

.game-bg .bg-spike.top::before {
    clip-path: polygon(0 0, 100% 0, 50% 92%);
}
.game-bg .bg-spike.bottom::before {
    clip-path: polygon(50% 8%, 100% 100%, 0 100%);
}

.game-bg .bg-spike.odd::before {
    background: var(--bg-spike-odd);
}
.game-bg .bg-spike.even::before {
    background: var(--bg-spike-even);
}

.game-bg .bg-spike-num {
    position: relative;
    z-index: 1;
    font-size: 0.62rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.88);
    line-height: 1.2;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.game-bg .bg-spike.clickable {
    cursor: pointer;
}
.game-bg .bg-spike.clickable::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    background: rgba(249, 115, 22, 0.3);
    pointer-events: none;
}

/* 駒 */
.game-bg .bg-checker {
    position: relative;
    z-index: 2;
    width: var(--bg-checker-size);
    height: var(--bg-checker-size);
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.5),
        inset 0 1px 1px rgba(255, 255, 255, 0.18);
}

.game-bg .bg-checker.white {
    background: radial-gradient(circle at 38% 30%, #ffffff, #b8b8b8);
    border: 1.5px solid rgba(0, 0, 0, 0.4);
}

.game-bg .bg-checker.black {
    background: radial-gradient(circle at 38% 30%, #4a4a4a, #0f0f0f);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
}

.game-bg .bg-checker.bar {
    width: calc(var(--bg-checker-size) * 0.8);
    height: calc(var(--bg-checker-size) * 0.8);
}

.game-bg .bg-checker-overflow {
    position: relative;
    z-index: 2;
    font-size: 0.7rem;
    font-weight: 800;
    color: #fde68a;
    background: rgba(0, 0, 0, 0.62);
    border-radius: 999px;
    padding: 1px 6px;
    line-height: 1.4;
}

/* バー */
.game-bg .bg-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-bar-bg);
    width: 2.2rem;
    border-radius: 6px;
    gap: 3px;
    padding: 4px 0;
}
.game-bg .bg-bar.clickable {
    cursor: pointer;
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.7);
}

.game-bg .bg-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 0.25rem;
}

@media (max-width: 640px) {
    .game-bg .bg-board {
        padding: 6px;
        border-width: 3px;
    }
    .game-bg .bg-bar {
        width: 1.6rem;
    }
    .game-bg .bg-spike-num {
        font-size: 0.56rem;
    }
    .game-bg .bg-die {
        min-width: 2rem;
        height: 2rem;
        font-size: 1rem;
    }
}
