/* Mobile-first, responsive design for Queen of Hearts */

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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #0f4c3a, #1a5f4a);
    color: white;
    min-height: 100vh;
    overflow-x: hidden;
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 5px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.game-header {
    margin-bottom: 10px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.header-top {
    display: flex;
    align-items: center;
    width: 100%;
    height: 32px;
}

.title-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.title-area h1 {
    font-size: 1.3rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin: 0;
    white-space: nowrap;
}

.header-buttons {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    align-items: center;
}

.header-button {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: background-color 0.2s ease;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
}

.header-button:hover {
    background: rgba(255,255,255,0.2);
}

.header-button.new-game {
    background: #2196f3;
}

.header-button.help {
    background: #ff9800;
    font-weight: bold;
    font-size: 0.85rem;
}

.game-info {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    flex-wrap: wrap;
    gap: 10px;
}

.scores {
    background: rgba(0,0,0,0.3);
    padding: 8px;
    border-radius: 8px;
    min-width: 200px;
}

.scores h3 {
    font-size: 0.9rem;
    margin-bottom: 6px;
}

#score-display {
    font-size: 0.85rem;
    line-height: 1.3;
}

.player-score {
    display: inline;
}

.player-score.current-player {
    background-color: rgba(144, 238, 144, 0.3);
    padding: 2px 4px;
    border-radius: 3px;
    color: lightgreen;
    font-weight: bold;
}

.game-status {
    background: rgba(0,0,0,0.3);
    padding: 8px;
    border-radius: 8px;
    font-size: 0.85rem;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    align-items: center;
}

.status-pill {
    background: rgba(255,255,255,0.1);
    padding: 4px 8px;
    border-radius: 12px;
    white-space: nowrap;
}

/* Game Board */
.game-board {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-height: 0;
}

/* Opponents */
.opponents {
    display: flex;
    justify-content: space-around;
    flex-wrap: nowrap;
    gap: 5px;
    flex-shrink: 0;
}

.opponent {
    background: rgba(0,0,0,0.2);
    padding: 6px 8px 4px 8px;
    border-radius: 6px;
    text-align: center;
    min-width: 80px;
    flex: 1;
    max-width: 120px;
    transition: background-color 0.3s ease;
}

.opponent.current-player {
    background: rgba(144, 238, 144, 0.3);
    border: 1px solid rgba(144, 238, 144, 0.5);
}

.player-name {
    font-weight: bold;
    margin-bottom: 3px;
    font-size: 0.8rem;
}

.player-score {
    font-size: 0.75rem;
    margin-bottom: 3px;
    color: #cc0000;
    font-weight: bold;
}

.card-count {
    display: none;
}

.player-cards {
    position: relative;
    overflow: hidden;
}

/* Trick Area */
.trick-area {
    background: rgba(0,0,0,0.4);
    border-radius: 6px;
    padding: 5px;
    text-align: center;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.trick-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 5px;
    width: 100%;
    justify-content: center;
    align-items: center;
}

.played-card {
    width: 50px;
    height: 70px;
    background: rgba(255,255,255,0.1);
    border: 2px dashed rgba(255,255,255,0.3);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    position: relative;
    transition: all 0.3s ease;
    box-shadow: none;
    color: rgba(255,255,255,0.3);
}

.played-card.lead-card {
    border: 3px solid #4caf50;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
    background: #f8fff8;
    color: #333;
}

.played-card.empty {
    background: rgba(255,255,255,0.1);
    border: 2px dashed rgba(255,255,255,0.3);
    color: rgba(255,255,255,0.3);
    box-shadow: none;
}

.played-card:not(.empty) {
    background: white;
    border: 2px solid #333;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    color: #333;
}

.played-card.empty::after {
    content: "Empty";
    font-size: 0.6rem;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.played-card.red {
    color: #d32f2f;
}

.played-card.black {
    color: #333;
}

.trick-info {
    font-size: 0.8rem;
    line-height: 1.2;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

#lead-suit {
    font-size: 1.2rem;
    font-weight: bold;
}

/* Player Hand */
.player-hand {
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    padding: 15px;
    margin-top: 10px;
    transition: background-color 0.3s ease;
}

.player-hand.current-player {
    background: rgba(144, 238, 144, 0.2);
    border: 1px solid rgba(144, 238, 144, 0.5);
}

.hand-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.hand-header h3 {
    font-size: 1.2rem;
}

.passing-info {
    font-size: 0.9rem;
    text-align: right;
}

.selected-cards {
    margin-top: 5px;
    font-size: 0.8rem;
    opacity: 0.8;
}

/* Cards */
.cards {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    margin-bottom: 15px;
    padding: 0 10px;
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
}

.card {
    width: 55px;
    height: 77px;
    background: white;
    border: 1px solid #333;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    color: #333;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    margin-left: -37px; /* Overlap cards - show only 1/3 */
    flex-shrink: 0;
}

.card:first-child {
    margin-left: 0;
}

.card.red {
    color: #d32f2f;
}

.card.black {
    color: #333;
}

.card:hover {
    transform: translateY(-10px) scale(1.05);
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

.card.selected {
    border-color: #4caf50;
    background: #e8f5e8;
    transform: translateY(15px) scale(1.05);
    box-shadow: 0 8px 20px rgba(76, 175, 80, 0.4);
}

.card.unplayable {
    opacity: 0.5;
    cursor: not-allowed;
}

.card.unplayable:hover {
    transform: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.card-rank-top {
    position: absolute;
    top: 3px;
    left: 3px;
    font-size: 0.75rem;
    line-height: 1;
    font-weight: bold;
}

.card-suit-top {
    position: absolute;
    top: 15px;
    left: 3px;
    font-size: 0.85rem;
    line-height: 1;
}

.card-suit-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.8rem;
    line-height: 1;
}

.card-rank-bottom {
    position: absolute;
    bottom: 3px;
    right: 3px;
    font-size: 0.75rem;
    line-height: 1;
    font-weight: bold;
    transform: rotate(180deg);
}

.card-suit-bottom {
    position: absolute;
    bottom: 15px;
    right: 3px;
    font-size: 0.85rem;
    line-height: 1;
    transform: rotate(180deg);
}

/* Playing card layout for trick cards */
.played-card .card-rank-top {
    position: absolute;
    top: 3px;
    left: 3px;
    font-size: 0.7rem;
    line-height: 1;
    font-weight: bold;
}

.played-card .card-suit-top {
    position: absolute;
    top: 12px;
    left: 3px;
    font-size: 0.8rem;
    line-height: 1;
}

.played-card .card-suit-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.4rem;
    line-height: 1;
}

.played-card .card-rank-bottom {
    position: absolute;
    bottom: 3px;
    right: 3px;
    font-size: 0.7rem;
    line-height: 1;
    font-weight: bold;
    transform: rotate(180deg);
}

.played-card .card-suit-bottom {
    position: absolute;
    bottom: 12px;
    right: 3px;
    font-size: 0.8rem;
    line-height: 1;
    transform: rotate(180deg);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

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

#pass-cards {
    background: #4caf50;
    color: white;
}

#pass-cards:enabled:hover {
    background: #45a049;
}

#pass-cards:disabled {
    background: #666;
    cursor: not-allowed;
}

/* Messages */
.message-area {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.message {
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 0.9rem;
    max-width: 300px;
    animation: slideIn 0.3s ease;
}

.message.error {
    background: rgba(211, 47, 47, 0.9);
}

.message.success {
    background: rgba(76, 175, 80, 0.9);
}

.message.info {
    background: rgba(33, 150, 243, 0.9);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Help Modal */
.help-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
}

.help-content {
    background: #2a2a2a;
    border-radius: 8px;
    max-width: 600px;
    margin: 0 auto;
    max-height: 90vh;
    overflow-y: auto;
    color: white;
}

.help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.help-header h2 {
    margin: 0;
    font-size: 1.3rem;
}

.close-help {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-help:hover {
    color: #f44336;
}

.help-body {
    padding: 20px;
    line-height: 1.5;
}

.help-body h3 {
    color: #4caf50;
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.help-body h3:first-child {
    margin-top: 0;
}

.help-body ul {
    margin: 10px 0;
    padding-left: 20px;
}

.help-body li {
    margin-bottom: 5px;
}

.help-body p {
    margin: 10px 0;
}

/* Desktop Responsive */
@media (min-width: 768px) {
    .game-header h1 {
        font-size: 2.5rem;
    }
    
    .header-button {
        padding: 6px 12px;
        font-size: 0.9rem;
        height: 36px;
        min-width: 40px;
    }
    
    .header-button.help {
        font-size: 1.1rem;
    }
    
    .game-info {
        justify-content: center;
        gap: 40px;
        
    }
    
    .trick-cards {
        gap: 15px;
    }
    
    .played-card {
        width: 80px;
        height: 112px;
    }
    
    .card {
        width: 60px;
        height: 84px;
        margin-left: -40px;
    }
    
    .card:first-child {
        margin-left: 0;
    }
    
    .card-rank-top, .card-rank-bottom {
        font-size: 0.8rem;
        top: 4px;
        left: 4px;
    }
    
    .card-rank-bottom {
        top: auto;
        bottom: 4px;
        right: 4px;
        left: auto;
    }
    
    .card-suit-top, .card-suit-bottom {
        font-size: 0.9rem;
        top: 16px;
        left: 4px;
    }
    
    .card-suit-bottom {
        top: auto;
        bottom: 16px;
        right: 4px;
        left: auto;
    }
    
    .card-suit-center {
        font-size: 2.0rem;
    }
    
    .played-card .card-rank-top, .played-card .card-rank-bottom {
        font-size: 1rem;
    }
    
    .played-card .card-suit-top, .played-card .card-suit-bottom {
        font-size: 1.2rem;
    }
    
    .played-card .card-suit-center {
        font-size: 1.6rem;
    }
    
    .opponents {
        flex-wrap: nowrap;
    }
    
    .opponent {
        max-width: none;
    }
}

@media (min-Width: 1024px) {
    .card {
        width: 70px;
        height: 98px;
        margin-left: -45px;
    }
    
    .card:first-child {
        margin-left: 0;
    }
    
    .card-rank-top, .card-rank-bottom {
        font-size: 0.9rem;
        top: 5px;
        left: 5px;
    }
    
    .card-rank-bottom {
        top: auto;
        bottom: 5px;
        right: 5px;  
        left: auto;
    }
    
    .card-suit-top, .card-suit-bottom {
        font-size: 1rem;
        top: 18px;
        left: 5px;
    }
    
    .card-suit-bottom {
        top: auto;
        bottom: 18px;
        right: 5px;
        left: auto;
    }
    
    .card-suit-center {
        font-size: 2.2rem;
    }
    
    .played-card {
        width: 90px;
        height: 126px;
    }
    
    .played-card .card-rank-top, .played-card .card-rank-bottom {
        font-size: 1.1rem;
    }
    
    .played-card .card-suit-top, .played-card .card-suit-bottom {
        font-size: 1.3rem;
    }
    
    .played-card .card-suit-center {
        font-size: 1.8rem;
    }
}

/* Portrait mode specific adjustments */
@media (orientation: portrait) and (max-width: 480px) {
    .cards {
        padding: 0 5px;
    }
    
    .card {
        width: 48px;
        height: 67px;
        margin-left: -32px;
    }
    
    .card:first-child {
        margin-left: 0;
    }
    
    .card-rank-top, .card-rank-bottom {
        font-size: 0.65rem;
        top: 2px;
        left: 2px;
    }
    
    .card-rank-bottom {
        top: auto;
        bottom: 2px;
        right: 2px;
        left: auto;
    }
    
    .card-suit-top, .card-suit-bottom {
        font-size: 0.75rem;
        top: 13px;
        left: 2px;
    }
    
    .card-suit-bottom {
        top: auto;
        bottom: 13px;
        right: 2px;
        left: auto;
    }
    
    .card-suit-center {
        font-size: 1.5rem;
    }
    
    .trick-cards {
        gap: 6px;
    }
    
    .played-card {
        width: 50px;
        height: 70px;
    }
    
    .played-card .card-rank-top, .played-card .card-rank-bottom {
        font-size: 0.7rem;
    }
    
    .played-card .card-suit-top, .played-card .card-suit-bottom {
        font-size: 0.9rem;
    }
    
    .played-card .card-suit-center {
        font-size: 1.2rem;
    }
    
    .opponent {
        padding: 6px;
        min-width: 70px;
        max-width: 100px;
    }
    
    .player-name {
        font-size: 0.75rem;
    }
    
    .card-count {
        font-size: 0.65rem;
    }
}
.cards {
    overflow-y: hidden;
}