/* ===== Board Container ===== */
.board-container {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 2px;
    width: min(65vh, 100%);
    aspect-ratio: 8 / 6;
    position: relative;
}

/* ===== Board Center ===== */
.board-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    z-index: 1;
}

.center-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--color-primary);
    letter-spacing: 2px;
}

.center-subtitle {
    font-size: 0.85rem;
    color: var(--color-text-light);
}

/* ===== Board Cell ===== */
.board-cell {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2px;
    position: relative;
    cursor: default;
    transition: all var(--transition);
    font-size: 0.65rem;
    overflow: hidden;
    min-width: 0;
}

.board-cell:hover {
    z-index: 5;
    box-shadow: 0 0 8px rgba(0,0,0,0.2);
    transform: scale(1.05);
}

.board-cell .cell-icon {
    font-size: 1rem;
    line-height: 1;
}

.board-cell .cell-label {
    font-size: 0.55rem;
    text-align: center;
    line-height: 1.1;
    margin-top: 1px;
    color: var(--color-text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* Cell types */
.cell-payday {
    background: #dcfce7;
    border-color: #86efac;
}

.cell-opportunity {
    background: #dbeafe;
    border-color: #93c5fd;
}

.cell-market {
    background: #fef3c7;
    border-color: #fcd34d;
}

.cell-doodad {
    background: #fee2e2;
    border-color: #fca5a5;
}

.cell-baby {
    background: #fce7f3;
    border-color: #f9a8d4;
}

.cell-downsized {
    background: #fde68a;
    border-color: #f59e0b;
}

.cell-charity {
    background: #e0e7ff;
    border-color: #a5b4fc;
}

/* Current cell highlight */
.board-cell.current-cell {
    box-shadow: 0 0 0 2px var(--color-primary), 0 0 10px rgba(37, 99, 235, 0.3);
    z-index: 4;
}

/* ===== Player Token ===== */
.player-token {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    z-index: 6;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.player-token.moving {
    animation: tokenBounce 0.4s ease;
}

@keyframes tokenBounce {
    0% { transform: scale(1); }
    40% { transform: scale(1.3) translateY(-4px); }
    100% { transform: scale(1); }
}

/* ===== Fast Track Board ===== */
.fast-track-container {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    justify-content: center;
    width: min(65vh, 100%);
    aspect-ratio: 1;
    position: relative;
    padding: 8px;
}

.fast-track-cell {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px;
    position: relative;
    font-size: 0.65rem;
    width: calc(100% / 6 - 6px);
    aspect-ratio: 1.2;
    transition: all var(--transition);
}

.fast-track-cell:hover {
    box-shadow: 0 0 8px rgba(0,0,0,0.2);
    transform: scale(1.05);
    z-index: 5;
}

.ft-cashflow-day {
    background: #dcfce7;
    border-color: #86efac;
}

.ft-investment {
    background: #dbeafe;
    border-color: #93c5fd;
}

.ft-charity {
    background: #e0e7ff;
    border-color: #a5b4fc;
}

.ft-tax-audit {
    background: #fef3c7;
    border-color: #fcd34d;
}

.ft-lawsuit {
    background: #fee2e2;
    border-color: #fca5a5;
}

.ft-divorce {
    background: #fde68a;
    border-color: #f59e0b;
}

.ft-business {
    background: #f3e8ff;
    border-color: #c4b5fd;
}

.fast-track-cell.current-cell {
    box-shadow: 0 0 0 2px var(--color-warning), 0 0 10px rgba(245, 158, 11, 0.3);
    z-index: 4;
}

/* ===== Board layout: 24 cells on 8x6 rectangular ring ===== */
/* Top: 8 cells, Right: 4, Bottom: 8, Left: 4 = 24 */

/* Top row: cells 1-8 → row 1, cols 1-8 */
.board-cell:nth-child(1)  { grid-column: 1; grid-row: 1; }
.board-cell:nth-child(2)  { grid-column: 2; grid-row: 1; }
.board-cell:nth-child(3)  { grid-column: 3; grid-row: 1; }
.board-cell:nth-child(4)  { grid-column: 4; grid-row: 1; }
.board-cell:nth-child(5)  { grid-column: 5; grid-row: 1; }
.board-cell:nth-child(6)  { grid-column: 6; grid-row: 1; }
.board-cell:nth-child(7)  { grid-column: 7; grid-row: 1; }
.board-cell:nth-child(8)  { grid-column: 8; grid-row: 1; }

/* Right column: cells 9-12 → col 8, rows 2-5 */
.board-cell:nth-child(9)  { grid-column: 8; grid-row: 2; }
.board-cell:nth-child(10) { grid-column: 8; grid-row: 3; }
.board-cell:nth-child(11) { grid-column: 8; grid-row: 4; }
.board-cell:nth-child(12) { grid-column: 8; grid-row: 5; }

/* Bottom row: cells 13-20 → row 6, cols 8 down to 1 */
.board-cell:nth-child(13) { grid-column: 8; grid-row: 6; }
.board-cell:nth-child(14) { grid-column: 7; grid-row: 6; }
.board-cell:nth-child(15) { grid-column: 6; grid-row: 6; }
.board-cell:nth-child(16) { grid-column: 5; grid-row: 6; }
.board-cell:nth-child(17) { grid-column: 4; grid-row: 6; }
.board-cell:nth-child(18) { grid-column: 3; grid-row: 6; }
.board-cell:nth-child(19) { grid-column: 2; grid-row: 6; }
.board-cell:nth-child(20) { grid-column: 1; grid-row: 6; }

/* Left column: cells 21-24 → col 1, rows 5 down to 2 */
.board-cell:nth-child(21) { grid-column: 1; grid-row: 5; }
.board-cell:nth-child(22) { grid-column: 1; grid-row: 4; }
.board-cell:nth-child(23) { grid-column: 1; grid-row: 3; }
.board-cell:nth-child(24) { grid-column: 1; grid-row: 2; }

/* ===== Board Animations ===== */
@keyframes coinFly {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    50% { opacity: 1; transform: translate(0, -40px) scale(1.3); }
    100% { opacity: 0; transform: translate(0, -80px) scale(0.5); }
}

.coin-fly {
    position: absolute;
    font-size: 1.5rem;
    z-index: 50;
    pointer-events: none;
    animation: coinFly 0.8s ease-out forwards;
}

@keyframes tokenBounceEnhanced {
    0% { transform: scale(1) translateY(0); }
    30% { transform: scale(1.4) translateY(-8px); }
    50% { transform: scale(1.1) translateY(-2px); }
    70% { transform: scale(1.2) translateY(-4px); }
    100% { transform: scale(1) translateY(0); }
}

.player-token.bounce {
    animation: tokenBounceEnhanced 0.5s ease;
}

/* ===== Board Zoom/Pan ===== */
.board-wrapper {
    overflow: hidden;
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.board-zoomable {
    transform-origin: center center;
    transition: transform 0.1s ease;
}

/* ===== Dark Theme Board ===== */
[data-theme="dark"] .cell-payday { background: #14532d; border-color: #22c55e; }
[data-theme="dark"] .cell-opportunity { background: #1e3a5f; border-color: #3b82f6; }
[data-theme="dark"] .cell-market { background: #422006; border-color: #f59e0b; }
[data-theme="dark"] .cell-doodad { background: #450a0a; border-color: #ef4444; }
[data-theme="dark"] .cell-baby { background: #4a0e2b; border-color: #ec4899; }
[data-theme="dark"] .cell-downsized { background: #78350f; border-color: #f59e0b; }
[data-theme="dark"] .cell-charity { background: #312e81; border-color: #818cf8; }
[data-theme="dark"] .ft-cashflow-day { background: #14532d; border-color: #22c55e; }
[data-theme="dark"] .ft-investment { background: #1e3a5f; border-color: #3b82f6; }
[data-theme="dark"] .ft-charity { background: #312e81; border-color: #818cf8; }
[data-theme="dark"] .ft-tax-audit { background: #422006; border-color: #f59e0b; }
[data-theme="dark"] .ft-lawsuit { background: #450a0a; border-color: #ef4444; }
[data-theme="dark"] .ft-divorce { background: #78350f; border-color: #f59e0b; }
[data-theme="dark"] .ft-business { background: #3b0764; border-color: #a855f7; }

[data-theme="dark"] .board-cell .cell-label {
    color: var(--color-text-light);
}

/* Responsive board sizing */
@media (max-width: 768px) {
    .board-container {
        width: min(90vw, 65vh);
    }

    .board-cell .cell-icon {
        font-size: 0.85rem;
    }

    .board-cell .cell-label {
        font-size: 0.45rem;
    }

    .center-title {
        font-size: 1.2rem;
    }

    .center-subtitle {
        font-size: 0.7rem;
    }

    .player-token {
        width: 14px;
        height: 14px;
    }
}

@media (max-width: 480px) {
    .board-container {
        width: 95vw;
        gap: 1px;
    }

    .board-cell {
        padding: 1px;
        border-radius: 2px;
    }

    .board-cell .cell-icon {
        font-size: 0.75rem;
    }

    .board-cell .cell-label {
        display: none;
    }

    .player-token {
        width: 12px;
        height: 12px;
    }
}
