/* Backgammon board and controls */

.game-area {
    background: var(--card-background, #ffffff);
    border-radius: var(--border-radius, 8px);
    box-shadow: var(--shadow, 0 4px 6px rgba(0,0,0,0.1));
    padding: 24px;
}

.online-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    color: var(--secondary-color, #2c3e50);
    font-weight: 600;
}

.status {
    margin: 12px auto 18px;
    padding: 14px 18px;
    max-width: 900px;
    border-radius: var(--border-radius, 8px);
    background: #16213e;
    color: #ffffff;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    box-shadow: var(--shadow, 0 4px 6px rgba(0,0,0,0.1));
}

.mode-selection .mode-btn {
    background: #f8fafc;
    color: #1f2937;
}

.mode-selection .mode-btn .label {
    color: #1f2937;
}

.mode-selection .mode-btn .desc {
    color: #4b5563;
}

.mode-selection .mode-btn:hover,
.mode-selection .mode-btn:hover .label {
    color: #ffffff;
}

.mode-selection .mode-btn:hover .desc {
    color: rgba(255,255,255,0.86);
}

.room-lobby .lobby-btn,
.room-lobby .btn-secondary,
.waiting-room .copy-btn,
.waiting-room .btn-secondary {
    color: #ffffff;
}

.backgammon-dashboard {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(240px, 1.4fr) minmax(180px, 1fr);
    gap: 16px;
    align-items: stretch;
    margin-bottom: 18px;
}

.player-card,
.dice-panel,
.game-side-panel,
.board-panel {
    border: 2px solid #d7dde8;
    border-radius: 14px;
    background: #f8fafc;
    color: #1f2937;
    box-shadow: var(--shadow, 0 4px 6px rgba(0,0,0,0.1));
}

.player-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 16px;
    text-align: center;
}

.player-card.active {
    border-color: #27ae60;
    background: #eafaf1;
}

.player-card.winner {
    border-color: #f39c12;
    background: #fff5d7;
}

.player-token {
    font-size: 2rem;
    line-height: 1;
}

.player-name {
    color: #102033;
    font-weight: 800;
}

.player-route {
    color: #4b5563;
    font-size: 0.88rem;
    font-weight: 600;
}

.dice-panel {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 16px;
    align-items: center;
    padding: 16px;
}

#roll-btn {
    grid-row: span 2;
    min-width: 140px;
    background: #0f766e;
    color: #ffffff;
}

#roll-btn:hover:not(:disabled) {
    background: #115e59;
}

.dice-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    min-height: 52px;
}

.die {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: 2px solid #111827;
    border-radius: 12px;
    background: #ffffff;
    color: #111827;
    font-size: 2rem;
    font-weight: 800;
    box-shadow: inset 0 -3px 0 rgba(0,0,0,0.12);
}

.die.empty {
    color: #6b7280;
    border-color: #cbd5e1;
    background: #f1f5f9;
}

.die.rolling {
    animation: dice-wiggle 0.28s ease-in-out infinite alternate;
}

@keyframes dice-wiggle {
    from { transform: rotate(-7deg) translateY(0); }
    to { transform: rotate(7deg) translateY(-3px); }
}

.moves-left {
    color: #1f2937;
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
}

.backgammon-shell {
    display: grid;
    grid-template-columns: minmax(150px, 190px) minmax(320px, 1fr) minmax(150px, 190px);
    gap: 18px;
    align-items: stretch;
}

.game-side-panel {
    padding: 16px;
}

.game-side-panel h2 {
    margin: 0 0 12px;
    color: #1f2937;
    font-size: 1.15rem;
    text-align: center;
}

.off-tray,
.bar-count-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin: 10px 0;
    padding: 12px;
    border-radius: 12px;
    border: 2px solid #cbd5e1;
    background: #ffffff;
    color: #111827;
    font-weight: 800;
    box-shadow: none;
}

.off-tray:hover {
    background: #e0f2fe;
    color: #0f172a;
    transform: none;
}

.off-tray.legal-target,
.bg-point.legal-target,
.bar-stack.selectable {
    outline: 4px solid #22c55e;
    outline-offset: -4px;
    cursor: pointer;
}

.off-tray strong,
.bar-count-row strong {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1f2937;
    color: #ffffff;
}

.white-off strong,
.white-count strong {
    background: #f8fafc;
    color: #111827;
    border: 2px solid #111827;
}

.black-off strong,
.black-count strong {
    background: #111827;
    color: #ffffff;
    border: 2px solid #111827;
}

.rule-note {
    margin-top: 14px;
    color: #4b5563;
    font-size: 0.88rem;
    line-height: 1.4;
    text-align: center;
}

.board-panel {
    padding: 14px;
    background: #172554;
    border-color: #0f172a;
}

.board-instructions {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #eff6ff;
    color: #1e3a8a;
    text-align: center;
    font-weight: 800;
}

.backgammon-board {
    display: grid;
    grid-template-columns: repeat(6, minmax(36px, 1fr)) minmax(54px, 70px) repeat(6, minmax(36px, 1fr));
    grid-template-rows: minmax(210px, 1fr) minmax(210px, 1fr);
    gap: 0;
    position: relative;
    overflow: hidden;
    min-height: 460px;
    border: 10px solid #6b3f20;
    border-radius: 16px;
    background: #c98d52;
    box-shadow: inset 0 0 0 4px #432818, 0 10px 24px rgba(15,23,42,0.22);
}

.bg-point {
    position: relative;
    display: flex;
    align-items: center;
    padding: 24px 4px;
    min-width: 0;
    border-left: 1px solid rgba(67,40,24,0.28);
    border-right: 1px solid rgba(67,40,24,0.28);
    cursor: pointer;
    background: transparent;
}

.bg-point::before {
    content: '';
    position: absolute;
    left: 6%;
    right: 6%;
    z-index: 0;
    height: 190px;
    background: #f2d39b;
    filter: drop-shadow(0 2px 1px rgba(0,0,0,0.2));
}

.bg-point.top {
    grid-row: 1;
    flex-direction: column;
    justify-content: flex-start;
}

.bg-point.top::before {
    top: 0;
    clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.bg-point.bottom {
    grid-row: 2;
    flex-direction: column-reverse;
    justify-content: flex-start;
}

.bg-point.bottom::before {
    bottom: 0;
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.bg-point.dark::before {
    background: #8f2f1f;
}

.bg-point.selected {
    background: rgba(250, 204, 21, 0.25);
}

.bg-point.blocked {
    cursor: not-allowed;
}

.point-number {
    position: absolute;
    z-index: 3;
    left: 50%;
    transform: translateX(-50%);
    min-width: 26px;
    padding: 2px 5px;
    border-radius: 999px;
    background: rgba(15,23,42,0.82);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 800;
    text-align: center;
}

.bg-point.top .point-number {
    top: 4px;
}

.bg-point.bottom .point-number {
    bottom: 4px;
}

.checker-stack {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    width: 100%;
}

.bg-point.bottom .checker-stack {
    flex-direction: column-reverse;
}

.checker {
    width: clamp(25px, 4.4vw, 42px);
    height: clamp(25px, 4.4vw, 42px);
    border-radius: 50%;
    border: 3px solid rgba(17,24,39,0.8);
    box-shadow: inset 0 3px 4px rgba(255,255,255,0.55), inset 0 -4px 5px rgba(0,0,0,0.25), 0 2px 4px rgba(0,0,0,0.28);
}

.checker.white {
    background: linear-gradient(145deg, #ffffff, #dbe4ef);
}

.checker.black {
    background: linear-gradient(145deg, #374151, #030712);
    border-color: #0f172a;
}

.stack-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: #facc15;
    color: #111827;
    font-weight: 900;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.bg-bar {
    grid-column: 7;
    grid-row: 1 / span 2;
    display: grid;
    grid-template-rows: 1fr 1fr;
    gap: 10px;
    padding: 10px 6px;
    background: linear-gradient(90deg, #4b2e1a, #7c4a24, #4b2e1a);
    border-left: 5px solid #2b170c;
    border-right: 5px solid #2b170c;
}

.bar-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    min-width: 0;
    padding: 8px 4px;
    border: 2px solid rgba(255,255,255,0.42);
    border-radius: 12px;
    background: rgba(15,23,42,0.38);
    color: #ffffff;
    box-shadow: none;
}

.bar-stack:hover {
    background: rgba(15,23,42,0.58);
    transform: none;
}

.bar-label {
    font-size: 0.75rem;
    font-weight: 900;
    text-transform: uppercase;
}

.bar-stack .checker {
    width: 30px;
    height: 30px;
}

.game-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.game-buttons button {
    color: #ffffff;
}

@media (max-width: 1100px) {
    .backgammon-shell {
        grid-template-columns: 1fr;
    }

    .game-side-panel {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        align-items: center;
    }

    .game-side-panel h2,
    .game-side-panel .rule-note {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .game-area {
        padding: 14px;
    }

    .backgammon-dashboard {
        grid-template-columns: 1fr;
    }

    .dice-panel {
        grid-template-columns: 1fr;
    }

    #roll-btn {
        grid-row: auto;
        width: 100%;
    }

    .backgammon-board {
        grid-template-columns: repeat(6, minmax(24px, 1fr)) minmax(38px, 48px) repeat(6, minmax(24px, 1fr));
        grid-template-rows: minmax(160px, 1fr) minmax(160px, 1fr);
        min-height: 350px;
        border-width: 6px;
        border-radius: 12px;
    }

    .bg-point {
        padding: 20px 2px;
    }

    .bg-point::before {
        height: 145px;
    }

    .point-number {
        min-width: 22px;
        font-size: 0.65rem;
    }

    .checker {
        width: 23px;
        height: 23px;
        border-width: 2px;
    }

    .bar-stack .checker {
        width: 22px;
        height: 22px;
    }

    .game-side-panel {
        grid-template-columns: 1fr;
    }

    .game-buttons button {
        width: 100%;
    }
}

@media (max-width: 440px) {
    .backgammon-board {
        grid-template-columns: repeat(6, minmax(19px, 1fr)) minmax(30px, 36px) repeat(6, minmax(19px, 1fr));
        min-height: 310px;
    }

    .checker {
        width: 19px;
        height: 19px;
    }

    .die {
        width: 42px;
        height: 42px;
        font-size: 1.7rem;
    }
}
