/**
 * Cribbage Game Styles
 */

.cribbage-game {
    --cribbage-bg: #ffffff;
    --cribbage-text: #1d2327;
    --cribbage-muted: #646970;
    --cribbage-surface: #f8f9fa;
    --cribbage-border: #e0e0e0;
    --cribbage-accent: #2271b1;
    --cribbage-warning-bg: #fff3cd;
    --cribbage-warning-text: #856404;
    --cribbage-board-wood-start: #a0522d;
    --cribbage-board-wood-end: #8b4513;
    --cribbage-board-header: #2c1810;
    --cribbage-board-highlight: #ffd700;
    --cribbage-divider: rgba(255, 215, 0, 0.35);
    --cribbage-seat-0: #4caf50;
    --cribbage-seat-1: #2196f3;

    color: var(--cribbage-text);
}

/* Main game container with pegboard on left */
.cribbage-game .cribbage-game-container {
    display: flex;
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.cribbage-game .cribbage-pegboard-container {
    flex: 0 0 195px;
    position: sticky;
    top: 20px;
    align-self: flex-start;
}

.cribbage-game .cribbage-game-area {
    flex: 1;
    min-width: 0;
}

.cribbage-game .cribbage-discard {
    padding: 20px;
    text-align: center;
}

.cribbage-game .cribbage-discard h3 {
    margin-bottom: 8px;
}

.cribbage-game .cribbage-discard p {
    color: var(--cribbage-muted);
    margin-bottom: 20px;
}

.cribbage-game .cribbage-discard .waiting {
    color: var(--cribbage-warning-text);
    background: var(--cribbage-warning-bg);
    padding: 12px;
    border-radius: 6px;
    font-weight: 600;
}

.cribbage-game .cribbage-discard button {
    margin-top: 24px;
}

/* Pegging Phase */
.cribbage-game .cribbage-pegging {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.cribbage-game .starter-area {
    text-align: center;
    margin-bottom: 24px;
}

.cribbage-game .starter-area p {
    margin: 0 0 8px 0;
    font-weight: 600;
    color: var(--cribbage-text);
}

.cribbage-game .peg-count {
    text-align: center;
    font-size: 24px;
    padding: 16px;
    background: #f0f6fc;
    border-radius: 8px;
    margin-bottom: 20px;
}

.cribbage-game .peg-count strong {
    color: var(--cribbage-accent);
    font-size: 32px;
}

.cribbage-game .peg-pile {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    min-height: 120px;
    padding: 20px;
    background: var(--cribbage-surface);
    border-radius: 8px;
    margin-bottom: 24px;
}

.cribbage-game .peg-pile .empty-pile {
    color: var(--cribbage-muted);
    font-style: italic;
}

.cribbage-game .opponent-area {
    margin-bottom: 24px;
    text-align: center;
}

.cribbage-game .my-hand-section {
    margin-top: 24px;
    text-align: center;
}

.cribbage-game .my-hand-section .waiting {
    color: var(--cribbage-muted);
    margin-top: 12px;
}

.cribbage-game .my-hand-section button {
    margin-top: 16px;
}

.cribbage-game .sacga-hand {
    gap: 6px;
    padding: 8px;
}

.cribbage-game .sacga-hand .sacga-card {
    width: 60px;
    height: 84px;
}

/* Scoreboard */
.cribbage-game .cribbage-scoreboard {
    padding: 12px;
    background: var(--cribbage-bg);
    border-radius: 8px;
    border: 1px solid var(--cribbage-border);
}

.cribbage-game .player-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 8px;
    margin-bottom: 8px;
    background: var(--cribbage-surface);
    border-radius: 6px;
    border-left: 4px solid var(--cribbage-border);
    gap: 4px;
}

.cribbage-game .player-score.seat-0 {
    border-left-color: var(--cribbage-seat-0);
}

.cribbage-game .player-score.seat-1 {
    border-left-color: var(--cribbage-seat-1);
}

.cribbage-game .player-score.my-score {
    background: #e3f2fd;
}

.cribbage-game .player-score .name {
    font-weight: 600;
    font-size: 14px;
}

.cribbage-game .player-score .score {
    font-size: 16px;
    font-weight: 700;
    color: var(--cribbage-text);
}

/* Percentage-based Pegboard */
.cribbage-game .cribbage-board {
    position: relative;
    width: 100%;
    padding-top: 300%; /* 1:3 aspect ratio for vertical board */
    background: linear-gradient(135deg, var(--cribbage-board-wood-start) 0%, var(--cribbage-board-wood-end) 100%);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    margin: 12px 0;
    overflow: visible;
}

.cribbage-game .cribbage-board::before {
    content: '';
    position: absolute;
    inset: 3% 6%;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    pointer-events: none;
}

.cribbage-game .board-header {
    position: absolute;
    top: 0.5%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--cribbage-board-header);
    color: var(--cribbage-board-highlight);
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: bold;
    z-index: 10;
    white-space: nowrap;
}

.cribbage-game .board-divider {
    position: absolute;
    left: 50%;
    top: 3%;
    bottom: 3%;
    width: 2px;
    background: var(--cribbage-divider, rgba(255, 215, 0, 0.35));
    transform: translateX(-50%);
    z-index: 5;
}

.cribbage-game .player-lane-label {
    position: absolute;
    top: 50%;
    font-size: 7px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: translateY(-50%);
    z-index: 5;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cribbage-game .player-lane-label.lane-left {
    left: 2%;
}

.cribbage-game .player-lane-label.lane-right {
    right: 2%;
}

.cribbage-game .board-hole {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #654321;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.7;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
}

.cribbage-game .board-hole .hole-marker {
    position: absolute;
    width: 12px;
    height: 12px;
    border: 2px solid var(--cribbage-board-highlight);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.85;
}

.cribbage-game .board-hole .hole-label {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    font-weight: bold;
    color: var(--cribbage-board-highlight);
    white-space: nowrap;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.cribbage-game .board-peg {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    z-index: 100;
    transition: left 0.8s ease-in-out, top 0.8s ease-in-out;
    cursor: pointer;
}

.cribbage-game .board-peg.peg-0 {
    background: var(--cribbage-seat-0);
}

.cribbage-game .board-peg.peg-1 {
    background: var(--cribbage-seat-1);
}

.cribbage-game .board-peg.peg-back {
    opacity: 0.5;
    width: 12px;
    height: 12px;
    border-width: 1.5px;
    z-index: 99;
}

.cribbage-game .board-peg.peg-front {
    z-index: 101;
}

.cribbage-game .board-peg .peg-score {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: bold;
    white-space: nowrap;
    pointer-events: none;
}

/* Round End */
.cribbage-game .cribbage-round-end {
    text-align: center;
    padding: 32px 20px;
    max-width: 600px;
    margin: 0 auto;
}

.cribbage-game .cribbage-round-end h2 {
    margin-bottom: 24px;
}

.cribbage-game .cribbage-round-end button {
    margin-top: 24px;
}

/* Responsive */
@media (max-width: 1024px) {
    .cribbage-game .cribbage-game-container {
        flex-direction: column;
    }

    .cribbage-game .cribbage-pegboard-container {
        position: static;
        flex: none;
        max-width: 225px;
        margin: 0 auto 20px;
    }

    .cribbage-game .cribbage-board {
        max-width: 190px;
        margin: 12px auto;
    }
}

@media (max-width: 768px) {
    .cribbage-game .peg-count {
        font-size: 18px;
    }

    .cribbage-game .peg-count strong {
        font-size: 24px;
    }

    .cribbage-game .peg-pile {
        min-height: 80px;
        padding: 12px;
    }

    .cribbage-game .cribbage-board {
        max-width: 150px;
    }

    .cribbage-game .board-peg {
        width: 12px;
        height: 12px;
    }

    .cribbage-game .board-peg.peg-back {
        width: 10px;
        height: 10px;
    }

    .cribbage-game .board-hole {
        width: 6px;
        height: 6px;
    }

    .cribbage-game .player-lane-label {
        font-size: 6px;
    }
}

@media (max-width: 480px) {
    .cribbage-game .cribbage-discard,
    .cribbage-game .cribbage-pegging,
    .cribbage-game .cribbage-round-end {
        padding: 12px;
    }

    .cribbage-game .peg-count {
        font-size: 16px;
        padding: 12px;
    }

    .cribbage-game .peg-count strong {
        font-size: 20px;
    }

    .cribbage-game .cribbage-scoreboard {
        padding: 8px;
    }

    .cribbage-game .cribbage-board {
        max-width: 135px;
    }

    .cribbage-game .board-peg {
        width: 10px;
        height: 10px;
        border-width: 1px;
    }

    .cribbage-game .board-peg.peg-back {
        width: 8px;
        height: 8px;
    }

    .cribbage-game .board-hole {
        width: 5px;
        height: 5px;
    }

    .cribbage-game .board-header {
        font-size: 7px;
        padding: 2px 6px;
    }

    .cribbage-game .player-lane-label {
        font-size: 5px;
        letter-spacing: 0.5px;
    }

    .cribbage-game .board-divider {
        width: 1px;
    }
}
