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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a5c1a;
    color: #fff;
    min-height: 100vh;
}

.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
}

.app > h1 {
    text-align: center;
    margin-bottom: 10px;
    font-size: 1.5rem;
    color: #ffd700;
}

/* Lobby */
.lobby {
    max-width: 450px;
    margin: 40px auto;
    background: rgba(0,0,0,0.3);
    padding: 20px;
    border-radius: 8px;
}

.lobby h2 {
    margin-bottom: 15px;
}

.form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
}

.form-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid #555;
    border-radius: 4px;
    background: #2a2a2a;
    color: #fff;
    font-size: 14px;
}

button {
    padding: 8px 16px;
    background: #2196F3;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin: 4px 2px;
}

button:hover:not(:disabled) {
    background: #1976D2;
}

button:disabled {
    background: #555;
    cursor: not-allowed;
    opacity: 0.6;
}

.player-list ul {
    list-style: none;
    margin: 10px 0;
}

.player-list li {
    padding: 4px 0;
}

.waiting {
    color: #aaa;
    font-style: italic;
    margin-top: 10px;
}

.error {
    background: #c62828;
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    margin-top: 10px;
}

/* Game Board */
.board-layout {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.player-area {
    background: rgba(0,0,0,0.2);
    padding: 8px 12px;
    border-radius: 6px;
}

.player-name {
    font-size: 0.9rem;
}

.center-area {
    display: flex;
    justify-content: center;
    gap: 40px;
    padding: 10px;
}

.stock, .discard-pile {
    text-align: center;
}

.stock h4, .discard-pile h4 {
    margin-bottom: 4px;
    font-size: 0.85rem;
    color: #ccc;
}

.stock-count, .pile-count {
    display: block;
    font-size: 0.8rem;
    color: #aaa;
    margin-top: 2px;
}

.empty-pile {
    width: 70px;
    height: 100px;
    border: 2px dashed #555;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 0.8rem;
}

/* Cards */
.card {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 55px;
    height: 80px;
    background: #fff;
    border: 2px solid #999;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: transform 0.1s, box-shadow 0.1s;
    position: relative;
}

.card.black {
    color: #000;
}

.card.red {
    color: #c62828;
}

.card.joker {
    color: #6a0dad;
}

.card.face-down {
    background: #1565C0;
    color: #fff;
    font-size: 24px;
    cursor: default;
}

.card.selected {
    transform: translateY(-10px);
    box-shadow: 0 4px 12px rgba(255,215,0,0.6);
    border-color: #ffd700;
}

.card:hover:not(.face-down) {
    transform: translateY(-3px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.card.selected:hover {
    transform: translateY(-10px);
}

.card-points {
    position: absolute;
    bottom: 2px;
    right: 3px;
    font-size: 9px;
    font-weight: normal;
    color: #2196F3;
}

/* Sort Buttons */
.sort-buttons {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.sort-buttons button {
    background: #37474F;
    font-size: 0.8rem;
    padding: 4px 12px;
}

.sort-buttons button:hover {
    background: #546E7A;
}

/* Selection Total */
.selection-total {
    text-align: center;
    padding: 4px 12px;
    background: rgba(33,150,243,0.15);
    border-radius: 4px;
    font-size: 0.85rem;
    color: #2196F3;
}

.selection-total.hidden {
    display: none;
}

/* Players List */
.players-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.player-area.active-turn {
    background: rgba(33,150,243,0.3);
    border: 1px solid #2196F3;
    font-weight: bold;
}

.player-area.me {
    border-left: 3px solid #ffd700;
}

/* Hand */
.my-hand {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 10px;
    justify-content: center;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    min-height: 100px;
}

.hand-card {
    transition: transform 0.1s;
}

/* Melds */
.melds-area {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.team-melds {
    background: rgba(0,0,0,0.2);
    padding: 8px;
    border-radius: 6px;
    min-width: 200px;
}

.team-melds h4 {
    margin-bottom: 6px;
    color: #ccc;
    font-size: 0.85rem;
}

.meld {
    margin-bottom: 6px;
    padding: 4px;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.1s, box-shadow 0.1s;
}

.meld.selected-meld {
    border-color: #ffd700;
    box-shadow: 0 0 8px rgba(255,215,0,0.5);
}

.meld-kind {
    font-size: 0.75rem;
    color: #aaa;
    display: block;
    margin-bottom: 2px;
}

.meld-points {
    font-size: 0.75rem;
    color: #2196F3;
    display: block;
    margin-bottom: 2px;
}

.meld-cards {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
}

.meld-cards .card {
    width: 40px;
    height: 58px;
    font-size: 11px;
}

.meld.completed {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 4px;
}

.meld.completed .meld-cards {
    flex-shrink: 0;
}

.meld.completed .meld-kind,
.meld.completed .meld-points {
    display: inline;
    margin-bottom: 0;
}

/* Action Bar */
.action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    padding: 8px;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
}

/* Turn Indicator */
.turn-indicator {
    text-align: center;
    padding: 6px;
    background: rgba(0,0,0,0.3);
    border-radius: 6px;
    font-size: 0.9rem;
}

.turn-indicator.my-turn {
    background: rgba(33,150,243,0.3);
    border: 1px solid #2196F3;
    font-weight: bold;
}

/* Scoreboard */
.scoreboard {
    background: rgba(0,0,0,0.3);
    padding: 8px;
    border-radius: 6px;
}

.scoreboard h3 {
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: #ffd700;
    cursor: pointer;
    user-select: none;
}

.scoreboard table.hidden {
    display: none;
}

.scoreboard table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.scoreboard th, .scoreboard td {
    padding: 4px 8px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.scoreboard th {
    color: #ccc;
}

/* Hand Scores */
.hand-scores {
    text-align: center;
    background: rgba(0,0,0,0.4);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #ffd700;
}

.hand-scores h3 {
    color: #ffd700;
    margin-bottom: 6px;
}

/* Go Out Prompt */
.go-out-prompt {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,215,0,0.2);
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #ffd700;
}

/* Game Over */
.game-over {
    text-align: center;
    font-size: 2rem;
    color: #ffd700;
    padding: 40px;
}
