/* Mobile-first responsive design */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    padding: 1rem;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    text-align: center;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.section {
    padding: 1.5rem;
}

.hidden {
    display: none !important;
}

/* Player Setup */
.player-count {
    margin-bottom: 1.5rem;
}

.player-count label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
}

.player-names {
    margin-bottom: 1.5rem;
}

.player-input {
    margin-bottom: 1rem;
}

.player-input label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-sweep {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-bottom: 0.5rem;
    touch-action: manipulation;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f8f9fa;
    color: #495057;
    border: 2px solid #e1e5e9;
}

.btn-secondary:hover {
    background: #e9ecef;
}

.btn-sweep {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
}

.btn-sweep:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

/* Game Section */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.game-header h2 {
    color: #495057;
    font-size: 1.5rem;
}

.game-header .btn-secondary {
    width: auto;
    margin-bottom: 0;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Score Board */
.score-board {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.player-score {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: white;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.player-name {
    font-weight: 500;
    color: #495057;
}

.score-details {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
}

.score-item {
    text-align: center;
}

.score-value {
    display: block;
    font-weight: 600;
    color: #667eea;
}

.score-label {
    display: block;
    color: #6c757d;
    font-size: 0.8rem;
}

/* Scoring Section */
.scoring-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.scoring-section h3 {
    margin-bottom: 1.5rem;
    color: #495057;
    text-align: center;
}

.scoring-category {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e1e5e9;
}

.scoring-category:last-of-type {
    border-bottom: none;
}

.scoring-category h4 {
    margin-bottom: 0.75rem;
    color: #495057;
    font-size: 1rem;
    font-weight: 500;
}

.winner-select {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.winner-option {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    background: white;
    border-radius: 6px;
    border: 2px solid #e1e5e9;
    cursor: pointer;
    transition: all 0.3s ease;
}

.winner-option:hover {
    border-color: #667eea;
}

.winner-option.selected {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.winner-option input[type="radio"] {
    margin-right: 0.75rem;
    transform: scale(1.2);
}

.sweeps-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sweep-input {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: white;
    border-radius: 6px;
    border: 2px solid #e1e5e9;
}

.sweep-input label {
    font-weight: 500;
    color: #495057;
}

.sweep-input input[type="number"] {
    width: 60px;
    padding: 0.5rem;
    border: 1px solid #e1e5e9;
    border-radius: 4px;
    text-align: center;
    font-size: 1rem;
}

/* Primiera Section */
.primiera-section {
    width: 100%;
}

.primiera-toggle {
    margin-bottom: 1rem;
}

.primiera-toggle button {
    width: 100%;
    margin-bottom: 0;
}

.primiera-explanation {
    background: #e3f2fd;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid #2196f3;
}

.primiera-explanation p {
    margin-bottom: 0.5rem;
    color: #1565c0;
    font-size: 0.9rem;
}

.primiera-explanation p:last-of-type {
    margin-bottom: 0.75rem;
}

.card-values {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.card-values span {
    background: #1976d2;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.primiera-players {
    margin-bottom: 1.5rem;
}

.primiera-player {
    background: white;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 2px solid #e1e5e9;
}

.primiera-player-name {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.75rem;
    text-align: center;
}

.primiera-suits {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.primiera-suit {
    background: #f8f9fa;
    border-radius: 4px;
    padding: 0.5rem;
}

.primiera-suit-name {
    font-weight: 500;
    margin-bottom: 0.4rem;
    text-align: center;
    font-size: 0.8rem;
}

.primiera-suit-name.hearts { color: #dc3545; }
.primiera-suit-name.diamonds { color: #dc3545; }
.primiera-suit-name.clubs { color: #343a40; }
.primiera-suit-name.spades { color: #343a40; }

.primiera-card-select {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.25rem;
    width: 100%;
}

.primiera-card {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    padding: 0.25rem;
    text-align: center;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    line-height: 1.1;
    overflow: hidden;
    word-break: break-all;
}

.primiera-card:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.primiera-card.selected {
    background: #667eea;
    color: white;
    border-color: #667eea;
    font-weight: 500;
}

.primiera-card.none {
    background: #e9ecef;
    color: #6c757d;
    font-style: italic;
}

.primiera-results {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 1rem;
}

.primiera-results h5 {
    margin-bottom: 0.75rem;
    color: #495057;
    text-align: center;
}

.primiera-totals {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.primiera-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: white;
    border-radius: 4px;
    border: 2px solid #e1e5e9;
}

.primiera-total.winner {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
    font-weight: 600;
}

.primiera-total.invalid {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

/* Final Results */
#winner-display {
    text-align: center;
    padding: 2rem;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    margin: -1.5rem -1.5rem 1.5rem -1.5rem;
    color: white;
}

#winner-display h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

#final-scores {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

/* Responsive Design */
@media (min-width: 768px) {
    .container {
        max-width: 600px;
    }
    
    .btn-primary,
    .btn-secondary,
    .btn-sweep {
        width: auto;
        flex: none;
    }
    
    .winner-select {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .sweeps-section {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .sweep-input {
        flex: 1;
        min-width: 200px;
    }
    
    .primiera-suits {
        grid-template-columns: 1fr 1fr 1fr 1fr;
    }
    
    .primiera-totals {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .primiera-total {
        flex: 1;
        min-width: 150px;
        margin: 0.25rem;
    }
}