@font-face {
    font-family: c64;
    src: url("/font/C64.ttf");
}

* {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background: #1a1a2e;
    color: #eee;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
}

.game-container {
    max-width: 800px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    color: #fff;
    margin-bottom: 5px;
}

/* Status bar */
.status-bar {
    background: #16213e;
    border-radius: 8px;
    padding: 12px 20px;
    text-align: center;
    margin-bottom: 20px;
}

.status-bar.hidden {
    display: none;
}

.status-text {
    font-size: 16px;
    color: #ff9800;
}

/* Race track card */
.race-track-card {
    background: #16213e;
    border-radius: 12px;
    padding: 8px 15px;
    margin-bottom: 20px;
}

.race-lane {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
}

.race-lane:not(:last-child) {
    border-bottom: 1px solid #2d3a4a;
}

.race-track {
    display: flex;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

.race-group {
    display: flex;
    gap: 0.5px;
}

.race-square {
    width: 6px;
    height: 6px;
    flex-shrink: 0;
    border-radius: 50%;
}

.race-lane.RED .race-square.empty { background: rgba(239, 83, 80, 0.15); }
.race-lane.RED .race-square.filled { background: #ef5350; }

.race-lane.GREEN .race-square.empty { background: rgba(102, 187, 106, 0.15); }
.race-lane.GREEN .race-square.filled { background: #66bb6a; }

.race-lane.BLUE .race-square.empty { background: rgba(66, 165, 245, 0.15); }
.race-lane.BLUE .race-square.filled { background: #42a5f5; }

.score-value {
    font-size: 16px;
    font-family: c64, monospace;
    font-weight: bold;
    min-width: 24px;
    text-align: right;
    color: #eee;
}

.team-label {
    font-size: 11px;
    width: 90px;
    min-width: 90px;
    max-width: 90px;
    flex-shrink: 0;
    flex-grow: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #aaa;
}

.race-lane.RED .team-label { color: #ef5350; }
.race-lane.GREEN .team-label { color: #66bb6a; }
.race-lane.BLUE .team-label { color: #42a5f5; }

/* Game board card */
.game-card {
    background: #16213e;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    position: relative;
}

.player-badge {
    position: absolute;
    top: 12px;
    right: 15px;
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 13px;
}

.team-name-badge {
    color: #ccc;
    font-weight: bold;
}

.colour-badge {
    padding: 3px 10px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 12px;
    text-transform: uppercase;
}

.colour-badge.RED {
    background: #ef5350;
    color: white;
}

.colour-badge.GREEN {
    background: #66bb6a;
    color: white;
}

.colour-badge.BLUE {
    background: #42a5f5;
    color: white;
}

.board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.board-grid {
    position: relative;
    width: 100%;
    max-width: 440px;
    height: 400px;
    margin: 0 auto 20px;
}

.cell {
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #2d3a4a;
    border: 2px solid #4a5568;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 6px 0 0 10px;
    font-size: 9px;
    color: #666;
    cursor: default;
    transition: background 0.2s, border-color 0.2s;
    pointer-events: none; /* Allow clicks to pass through to pawns */
}

.cell.target {
    cursor: pointer;
    pointer-events: auto; /* Re-enable when cell is a valid move target */
}

.cell.target:hover {
    border-color: #fff;
}

.cell.out-cell {
    width: 28px;
    height: 28px;
    background: #1a1a2e;
    border: 1px dashed #4a5568;
    font-size: 9px;
    cursor: default;
    z-index: 1;
}

.cell.target-RED {
    background: #ffcdd2;
    border-color: #c62828;
}
.cell.target-RED:hover {
    background: #ef5350;
}

.cell.target-GREEN {
    background: #c8e6c9;
    border-color: #2e7d32;
}
.cell.target-GREEN:hover {
    background: #66bb6a;
}

.cell.target-BLUE {
    background: #bbdefb;
    border-color: #1565c0;
}
.cell.target-BLUE:hover {
    background: #42a5f5;
}

.cell.selected {
    border-color: #fff;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
}

/* Pawn start positions - below the board */
.pawn-start-area {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 15px;
    background: #0d1117;
    border-radius: 8px;
}

/* Add extra spacing between color groups */
.pawn-slot:nth-child(4) {
    margin-left: 16px;
}

.pawn-slot:nth-child(7) {
    margin-left: 16px;
}

.pawn-slot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.pawn-slot:empty {
    border: 2px dashed #4a5568;
}
.pawn-slot.RED:empty { border-color: #c62828; }
.pawn-slot.GREEN:empty { border-color: #2e7d32; }
.pawn-slot.BLUE:empty { border-color: #1565c0; }

/* Pulse-glow effect when a player makes a move */
@keyframes pulse-glow-RED {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 83, 80, 0.6);
    }
    50% {
        box-shadow: 0 0 12px 4px rgba(239, 83, 80, 0.8);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 83, 80, 0);
    }
}

@keyframes pulse-glow-GREEN {
    0% {
        box-shadow: 0 0 0 0 rgba(102, 187, 106, 0.6);
    }
    50% {
        box-shadow: 0 0 12px 4px rgba(102, 187, 106, 0.8);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(102, 187, 106, 0);
    }
}

@keyframes pulse-glow-BLUE {
    0% {
        box-shadow: 0 0 0 0 rgba(66, 165, 245, 0.6);
    }
    50% {
        box-shadow: 0 0 12px 4px rgba(66, 165, 245, 0.8);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(66, 165, 245, 0);
    }
}

.pawn-slot.pulse-glow-RED {
    animation: pulse-glow-RED 0.6s ease-out;
}

.pawn-slot.pulse-glow-GREEN {
    animation: pulse-glow-GREEN 0.6s ease-out;
}

.pawn-slot.pulse-glow-BLUE {
    animation: pulse-glow-BLUE 0.6s ease-out;
}

/* Pawns */
.pawn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    position: absolute;
    cursor: default;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: c64, monospace;
    font-weight: bold;
    font-size: 14px;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    z-index: 10;
}

.pawn.RED { background: radial-gradient(circle at 30% 30%, #ef5350, #b71c1c); }
.pawn.GREEN { background: radial-gradient(circle at 30% 30%, #66bb6a, #1b5e20); }
.pawn.BLUE { background: radial-gradient(circle at 30% 30%, #42a5f5, #0d47a1); }

.pawn.my-pawn:hover {
    transform: scale(1.1);
}

.pawn.selected {
    transform: scale(1.15);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
}

.pawn.my-pawn {
    cursor: pointer;
}

.pawn.opponent {
    cursor: default;
}

.pawn.in-slot {
    position: relative;
    transform: none;
}

.pawn.in-slot.my-pawn:hover {
    transform: scale(1.1);
}

.pawn.in-slot.selected {
    transform: scale(1.15);
}

/* Info cards container */
.info-cards-container {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* Player Info card */
.info-card {
    background: #16213e;
    border-radius: 8px;
    padding: 0;
    flex: 1;
    min-width: 200px;
}

.info-card[open] {
    flex-basis: 100%;
}

.info-card summary {
    padding: 10px 15px;
    cursor: pointer;
    list-style: none;
    font-size: 14px;
    color: #aaa;
    user-select: none;
}

.info-card summary::-webkit-details-marker {
    display: none;
}

.info-card summary::before {
    content: '▶ ';
    display: inline-block;
    transition: transform 0.2s;
}

.info-card[open] summary::before {
    transform: rotate(90deg);
}

.info-card summary:hover {
    color: #fff;
}

.info-content {
    padding: 0 15px 12px 15px;
}

.info-section-title {
    font-size: 12px;
    font-weight: bold;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 8px;
    margin-bottom: 4px;
}

.info-section-title:first-child {
    margin-top: 0;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 13px;
}

.info-label {
    color: #888;
}

.info-value {
    color: #ccc;
    font-weight: normal;
    word-break: break-all;
}

.stats-divider {
    border-top: 1px solid #2d3a4a;
    margin: 8px 0;
}

.colour-red { color: #ef5350; }
.colour-green { color: #66bb6a; }
.colour-blue { color: #42a5f5; }

/* Game log card */
.log-card {
    background: #16213e;
    border-radius: 8px;
    padding: 0;
    flex: 1;
    min-width: 200px;
}

.log-card[open] {
    flex-basis: 100%;
}

.log-card summary {
    padding: 10px 15px;
    cursor: pointer;
    list-style: none;
    font-size: 14px;
    color: #aaa;
    user-select: none;
}

.log-card summary::-webkit-details-marker {
    display: none;
}

.log-card summary::before {
    content: '▶ ';
    display: inline-block;
    transition: transform 0.2s;
}

.log-card[open] summary::before {
    transform: rotate(90deg);
}

.log-card summary:hover {
    color: #fff;
}

.log-entries {
    background: #0d1117;
    border-radius: 6px;
    padding: 8px;
    margin: 0 15px 12px 15px;
    height: 120px;
    overflow-y: auto;
    font-family: c64, monospace;
    font-size: 10px;
}

.log-entry {
    margin-bottom: 3px;
    color: #888;
}

.log-entry .timestamp {
    color: #555;
}

/* Move controls */
.controls-area {
    text-align: center;
    padding: 15px;
    background: #0d1117;
    border-radius: 8px;
    margin-top: 15px;
    transition: all 0.3s;
    border: 3px solid transparent;
    position: relative;
}

.controls-area.my-turn {
    border-color: #2e7d32;
    box-shadow: 0 0 20px rgba(46, 125, 50, 0.4);
}

.turn-indicator {
    font-size: 14px;
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
}

.turn-indicator.your-turn {
    background: #2e7d32;
    color: white;
}

.turn-indicator.waiting {
    background: #37474f;
    color: #aaa;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    margin: 5px;
    transition: all 0.2s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-pass { background: #f57c00; color: white; }
.btn-pass:hover:not(:disabled) { background: #ef6c00; }

.btn-score { background: #2e7d32; color: white; }
.btn-score:hover:not(:disabled) { background: #1b5e20; }

/* Footer */
.footer-links {
    text-align: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #333;
    font-size: 14px;
}

a {
    color: #2196f3;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a2e;
}

::-webkit-scrollbar-thumb {
    background: #4a5568;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive design for smaller screens */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .game-container {
        max-width: 100%;
    }

    .race-track-card {
        padding: 8px 10px;
    }

    .race-lane {
        gap: 6px;
        padding: 4px 0;
    }

    .race-square {
        width: 5px;
        height: 5px;
    }

    .score-value {
        font-size: 14px;
        min-width: 22px;
    }

    .team-label {
        width: 70px;
        min-width: 70px;
        max-width: 70px;
        font-size: 10px;
    }

    .game-descriptions {
        display: none;
    }

    .game-card {
        padding: 15px 10px;
    }

    .board-grid {
        max-width: 340px;
        height: 320px;
    }

    .cell {
        width: 38px;
        height: 38px;
        font-size: 8px;
        padding: 4px 0 0 6px;
    }

    .pawn {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .pawn-start-area {
        padding: 10px;
        gap: 6px;
    }

    .pawn-slot {
        width: 30px;
        height: 30px;
    }

    .pawn-slot:nth-child(4),
    .pawn-slot:nth-child(7) {
        margin-left: 10px;
    }

    .cell.out-cell {
        width: 22px;
        height: 22px;
    }

    .player-badge {
        position: static;
        justify-content: center;
        margin-bottom: 10px;
    }
}

@media (max-width: 400px) {
    h1 {
        font-size: 22px;
    }

    .race-track-card {
        padding: 6px 8px;
    }

    .race-lane {
        gap: 4px;
        padding: 3px 0;
    }

    .race-square {
        width: 4px;
        height: 4px;
    }

    .race-group {
        gap: 0.5px;
    }

    .race-track {
        gap: 1px;
    }

    .score-value {
        font-size: 12px;
        min-width: 18px;
    }

    .team-label {
        width: 50px;
        min-width: 50px;
        max-width: 50px;
        font-size: 9px;
    }

    .board-grid {
        max-width: 280px;
        height: 260px;
    }

    .cell {
        width: 32px;
        height: 32px;
        font-size: 7px;
        padding: 3px 0 0 5px;
    }

    .pawn {
        width: 26px;
        height: 26px;
        font-size: 10px;
    }

    .pawn-start-area {
        padding: 8px;
        gap: 4px;
    }

    .pawn-slot {
        width: 26px;
        height: 26px;
    }

    .pawn-slot:nth-child(4),
    .pawn-slot:nth-child(7) {
        margin-left: 8px;
    }

    .cell.out-cell {
        width: 18px;
        height: 18px;
    }

    .controls-area {
        padding: 10px;
    }

    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }
}

/* Save Failed Warning Banner */
.save-failed-warning {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #5c2d2d;
    border: 1px solid #ef5350;
    border-radius: 8px;
    margin-bottom: 16px;
    color: #ffcdd2;
}

.save-failed-warning .warning-icon {
    font-size: 20px;
    color: #ef5350;
}

.save-failed-warning .warning-text {
    flex: 1;
    font-size: 14px;
}

.save-failed-warning .warning-dismiss {
    background: none;
    border: none;
    color: #ef9a9a;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
}

.save-failed-warning .warning-dismiss:hover {
    color: #fff;
}

/* Inactivity Warning Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #16213e;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    max-width: 400px;
    border: 2px solid #f57c00;
    box-shadow: 0 0 30px rgba(245, 124, 0, 0.5);
}

.modal-content h2 {
    color: #f57c00;
    margin: 0 0 20px 0;
    font-size: 24px;
}

.modal-content p {
    color: #ccc;
    margin: 10px 0;
    font-size: 16px;
}

.countdown-timer {
    font-size: 48px;
    font-weight: bold;
    color: #ef5350;
    font-family: c64, monospace;
    margin: 20px 0;
    padding: 20px;
    background: #0d1117;
    border-radius: 8px;
}

.btn-confirm {
    background: #2e7d32;
    color: white;
    padding: 15px 40px;
    font-size: 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.2s;
}

.btn-confirm:hover {
    background: #1b5e20;
    transform: scale(1.05);
}

/* Game Over Modal */
.game-over-modal {
    border-color: #4ecdc4;
    box-shadow: 0 0 30px rgba(78, 205, 196, 0.5);
    position: relative;
}

.game-over-modal h2 {
    color: #4ecdc4;
    font-size: 32px;
}

.game-over-modal h2.winner {
    color: #66bb6a;
}

.game-over-modal h2.loser {
    color: #ef5350;
}

.game-over-modal p {
    font-size: 20px;
}

.game-over-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
}

/* Modal close button (X in top-right corner) */
.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    background: #2d3a4a;
    border: none;
    border-radius: 4px;
    color: #aaa;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close-btn:hover {
    background: #455a64;
    color: #fff;
}

/* Return to lobby button - floating after modal dismissed */
.return-to-lobby-floating {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #4ecdc4;
    color: #1a1a2e;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.4);
    z-index: 100;
    transition: all 0.2s;
}

.return-to-lobby-floating:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(78, 205, 196, 0.5);
}

/* Save warning in game over modal */
.save-warning {
    background: #5c2d2d;
    border: 1px solid #ef5350;
    border-radius: 6px;
    padding: 10px 14px;
    margin: 15px 0;
    color: #ffcdd2;
    font-size: 13px;
    text-align: left;
}
