* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: #fff;
}

#game-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 15px;
}

#turn-indicator {
    font-size: 1rem;
    padding: 6px 18px;
    background: #27ae60;
    border-radius: 20px;
    font-weight: bold;
}

#turn-indicator.ai-turn {
    background: #3498db;
}

#game-area {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Player Areas */
.player-area {
    background: rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 8px 12px;
}

.green-area {
    border: 2px solid #27ae60;
}

.blue-area {
    border: 2px solid #3498db;
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.player-label {
    font-size: 1.1rem;
    font-weight: bold;
}

.player-position {
    font-size: 0.9rem;
    background: rgba(0,0,0,0.3);
    padding: 4px 10px;
    border-radius: 10px;
}

.card-collection {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
    min-height: 40px;
}

.collection-label {
    font-size: 0.85rem;
    color: #aaa;
}

.recruited-cards {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.card-stack {
    position: relative;
    width: 50px;
}

.hand {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Cards */
.card {
    width: 90px;
    height: 126px;
    border-radius: 8px;
    background: linear-gradient(145deg, #2c3e50, #34495e);
    border: 2px solid #555;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 6px;
    font-size: 0.7rem;
}

.card:hover:not(.disabled) {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
}

.card.selected {
    border-color: #f1c40f;
    box-shadow: 0 0 12px rgba(241, 196, 15, 0.6);
    transform: translateY(-4px);
}

.card.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.card.clickable {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(241, 196, 15, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(241, 196, 15, 0); }
}

.card-back {
    background: linear-gradient(145deg, #1a1a2e, #16213e);
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 8px,
        rgba(255,255,255,0.03) 8px,
        rgba(255,255,255,0.03) 16px
    );
    cursor: default;
}

.card-back::after {
    content: '🕵️';
    font-size: 1.8rem;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.card-name {
    font-weight: bold;
    font-size: 0.7rem;
    text-align: center;
    color: #f1c40f;
    line-height: 1.2;
}

.card-icon {
    font-size: 1.6rem;
    text-align: center;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-movement {
    display: flex;
    justify-content: space-around;
    font-size: 0.65rem;
    font-weight: bold;
}

.card-movement span {
    background: rgba(0,0,0,0.4);
    padding: 2px 5px;
    border-radius: 3px;
    min-width: 20px;
    text-align: center;
}

.card-movement span.active {
    background: #27ae60;
}

.card-movement span.win {
    background: #f1c40f;
    color: #000;
}

.card-movement span.lose {
    background: #e74c3c;
}

/* Mini cards for recruited area */
.mini-card {
    width: 50px;
    height: 70px;
    font-size: 0.55rem;
    padding: 3px;
}

.mini-card .card-name {
    font-size: 0.5rem;
}

.mini-card .card-icon {
    font-size: 1rem;
}

.mini-card .card-movement {
    font-size: 0.45rem;
}

.mini-card .card-movement span {
    padding: 1px 2px;
    min-width: 12px;
}

/* Card type colors */
.card.double-agent { border-color: #9b59b6; }
.card.enforcer { border-color: #3498db; }
.card.codebreaker { border-color: #f1c40f; }
.card.saboteur { border-color: #e67e22; }
.card.daredevil { border-color: #e74c3c; }
.card.sentinel { border-color: #1abc9c; }
.card.sidekick { border-color: #2ecc71; }
.card.mole { border-color: #95a5a6; }

/* Board */
#board-container {
    display: flex;
    justify-content: center;
    padding: 15px 0;
}

#board {
    position: relative;
    width: 860px;
    height: 350px;
}

.board-space {
    width: 160px;
    height: 80px;
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: bold;
    border: 2px solid rgba(255,255,255,0.2);
    transition: all 0.3s;
}

.board-space.home-green {
    background: rgba(39, 174, 96, 0.4);
    border-color: #27ae60;
}

.board-space.home-blue {
    background: rgba(52, 152, 219, 0.4);
    border-color: #3498db;
}

.board-space.has-green {
    box-shadow: 0 0 12px #27ae60;
}

.board-space.has-blue {
    box-shadow: 0 0 12px #3498db;
}

.meeple {
    width: 55px;
    height: 55px;
    position: absolute;
    font-size: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.5s ease;
    z-index: 10;
    transform: translate(-50%, -50%);
}

.meeple.green::after {
    content: '🦖';
}

.meeple.blue::after {
    content: '🦁';
}

/* Play Area */
#play-area {
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
}

#play-instruction {
    margin-bottom: 12px;
    color: #f1c40f;
}

#play-zone {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 12px;
}

.play-slot {
    text-align: center;
}

.play-slot > span {
    display: block;
    margin-bottom: 6px;
    font-weight: bold;
    font-size: 0.9rem;
}

.slot-content {
    width: 94px;
    height: 130px;
    border: 2px dashed rgba(255,255,255,0.3);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slot-content .card {
    margin: 0;
}

#play-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

button {
    padding: 10px 20px;
    font-size: 0.95rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#confirm-play-btn {
    background: #27ae60;
    color: white;
}

#confirm-play-btn:hover:not(:disabled) {
    background: #2ecc71;
}

#clear-play-btn {
    background: #7f8c8d;
    color: white;
}

#clear-play-btn:hover:not(:disabled) {
    background: #95a5a6;
}

/* Status Bar (Header) */
#status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: rgba(0,0,0,0.4);
    border-radius: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 15px;
}

#game-message {
    flex: 1;
    text-align: center;
    color: #f1c40f;
    font-style: italic;
}

#deck-info, #discard-info {
    font-size: 0.95rem;
    white-space: nowrap;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(145deg, #2c3e50, #1a252f);
    padding: 25px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    border: 2px solid #4a69bd;
}

#choice-cards {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

#choice-cards .card {
    cursor: pointer;
}

#choice-cards .card:hover {
    transform: scale(1.05);
    border-color: #f1c40f;
}

.gameover-content h2 {
    font-size: 1.8rem;
    margin-bottom: 15px;
}

#gameover-message {
    font-size: 1.1rem;
    margin-bottom: 20px;
}

#restart-btn {
    background: #4a69bd;
    color: white;
    padding: 12px 30px;
    font-size: 1.1rem;
}

#restart-btn:hover {
    background: #5a7bcf;
}

/* Rules */
#rules-btn {
    position: fixed;
    bottom: 15px;
    right: 15px;
    background: #4a69bd;
    color: white;
    border-radius: 25px;
    padding: 10px 18px;
    z-index: 50;
}

#rules-btn:hover {
    background: #5a7bcf;
}

#rules-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100%;
    background: linear-gradient(145deg, #2c3e50, #1a252f);
    padding: 20px;
    overflow-y: auto;
    z-index: 90;
    border-left: 2px solid #4a69bd;
}

#rules-panel.hidden {
    display: none;
}

.rules-content {
    font-size: 0.9rem;
}

.rules-content h2 {
    margin-bottom: 15px;
    color: #f1c40f;
}

.rules-content h3 {
    color: #3498db;
    margin: 15px 0 8px;
}

.rules-content p, .rules-content li {
    margin-bottom: 6px;
    line-height: 1.4;
}

.rules-content ol, .rules-content ul {
    padding-left: 20px;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 1.5rem;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 5px 10px;
}

/* Coin Flip Animation */
.coin-content {
    padding: 40px;
}

.coin {
    width: 100px;
    height: 100px;
    margin: 30px auto;
    position: relative;
    transform-style: preserve-3d;
    animation: none;
}

.coin.flipping {
    animation: coinFlip 2s ease-out forwards;
}

.coin-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    backface-visibility: hidden;
    background: linear-gradient(145deg, #3a3a3a, #2a2a2a);
    border: 4px solid #666;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

.coin-green {
    transform: rotateY(180deg);
}

@keyframes coinFlip {
    0% { transform: rotateY(0); }
    100% { transform: rotateY(1800deg); }
}

.coin.result-blue {
    animation: coinFlipBlue 2s ease-out forwards;
}

.coin.result-green {
    animation: coinFlipGreen 2s ease-out forwards;
}

@keyframes coinFlipBlue {
    0% { transform: rotateY(0); }
    100% { transform: rotateY(1800deg); }
}

@keyframes coinFlipGreen {
    0% { transform: rotateY(0); }
    100% { transform: rotateY(1980deg); }
}

#coin-result {
    font-size: 1.3rem;
    margin-top: 20px;
    min-height: 30px;
    color: #f1c40f;
    font-weight: bold;
}

/* Drag and Drop */
.card.dragging {
    opacity: 0.3;
    transform: scale(0.95);
}

.card[draggable="true"] {
    cursor: grab;
    transition: transform 0.2s, opacity 0.2s;
}

.card[draggable="true"]:active {
    cursor: grabbing;
}

/* Drag ghost/clone */
.drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.9;
    transform: rotate(5deg) scale(1.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    transition: none;
}

/* Landing animation */
@keyframes cardLand {
    0% { transform: scale(1.1) rotate(5deg); }
    50% { transform: scale(1.05) rotate(-2deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.card.just-landed {
    animation: cardLand 0.3s ease-out;
}

/* Card confirm/fly animation */
@keyframes cardConfirm {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15) rotate(-3deg); opacity: 1; }
    100% { transform: scale(0.8) translateY(-30px); opacity: 0; }
}

.card.confirming {
    animation: cardConfirm 0.5s ease-in forwards;
}

/* Play area glow when ready */
#play-area.ready-to-confirm {
    box-shadow: 0 0 20px rgba(39, 174, 96, 0.4);
    border: 2px solid #27ae60;
}

/* Slot filled indicator */
.play-slot.filled .slot-content {
    border-color: #27ae60;
    background: rgba(39, 174, 96, 0.1);
}

/* Confirm button pulse when ready */
#confirm-play-btn:not(:disabled) {
    animation: btnPulse 1.5s infinite;
}

@keyframes btnPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.5); }
    50% { box-shadow: 0 0 15px 5px rgba(39, 174, 96, 0.3); }
}

.drop-zone {
    transition: all 0.2s;
}

.drop-zone.drag-over {
    background: rgba(241, 196, 15, 0.2);
    border-color: #f1c40f !important;
    transform: scale(1.02);
}

.drop-zone .slot-content {
    pointer-events: none;
}

.drop-zone .slot-content .card {
    pointer-events: auto;
    cursor: grab;
}

/* Play Again Button */
#play-again-btn {
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: #27ae60;
    color: white;
    padding: 15px 30px;
    font-size: 1.2rem;
    border-radius: 30px;
    z-index: 50;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

#play-again-btn:hover {
    background: #2ecc71;
    transform: translateX(-50%) scale(1.05);
}

#play-again-btn.hidden {
    display: none;
}

#close-gameover-btn {
    background: #4a69bd;
    color: white;
    padding: 12px 25px;
}

#close-gameover-btn:hover {
    background: #5a7bcf;
}

/* Responsive */

/* Touch: make slots obviously tappable on mobile */
@media (hover: none) and (pointer: coarse) {
    .drop-zone {
        cursor: pointer;
    }

    .drop-zone > span::after {
        content: ' (tap)';
        font-size: 0.75rem;
        opacity: 0.6;
        font-weight: normal;
    }

    .card[draggable="true"] {
        cursor: pointer;
    }

    .slot-content {
        min-height: 110px;
    }
}

/* 860–900px: slight scale-down */
@media (max-width: 900px) {
    #board {
        transform: scale(0.72);
        transform-origin: top center;
        margin-bottom: -98px;
    }
}

/* 700px: medium screens / small tablets */
@media (max-width: 700px) {
    #board {
        transform: scale(0.56);
        transform-origin: top center;
        margin-bottom: -154px;
    }
}

/* 600px: large phones (landscape) */
@media (max-width: 600px) {
    .card {
        width: 75px;
        height: 105px;
    }

    #board {
        transform: scale(0.46);
        transform-origin: top center;
        margin-bottom: -189px;
    }

    #status-bar {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    #rules-panel {
        width: 100%;
    }

    #play-zone {
        gap: 16px;
    }
}

/* 480px: standard phones (portrait) */
@media (max-width: 480px) {
    .card {
        width: 65px;
        height: 91px;
        font-size: 0.6rem;
        padding: 4px;
    }

    .card-name {
        font-size: 0.58rem;
    }

    .card-icon {
        font-size: 1.3rem;
    }

    .card-movement {
        font-size: 0.55rem;
    }

    #board {
        transform: scale(0.38);
        transform-origin: top center;
        margin-bottom: -217px;
    }

    #game-container {
        padding: 8px;
    }

    #play-zone {
        gap: 12px;
    }

    .slot-content {
        width: 70px;
        height: 100px;
    }

    button {
        padding: 10px 14px;
        font-size: 0.85rem;
    }
}

/* 380px: small phones */
@media (max-width: 380px) {
    .card {
        width: 58px;
        height: 81px;
        padding: 3px;
    }

    .card-icon {
        font-size: 1.1rem;
    }

    #board {
        transform: scale(0.33);
        transform-origin: top center;
        margin-bottom: -234px;
    }

    .hand {
        gap: 5px;
    }

    #play-zone {
        gap: 8px;
    }
}
