/* ==================== RESET & BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a2e;
    color: #eee;
    min-height: 100vh;
    overflow-x: hidden;
}

.screen {
    display: none;
    min-height: 100vh;
}
.screen.active {
    display: flex;
}

.red { color: #e74c3c; }
.hidden { display: none !important; }

/* ==================== SETTINGS SCREEN ==================== */
#settings-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    padding: 20px;
}

.settings-container {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 40px;
    max-width: 700px;
    width: 100%;
    backdrop-filter: blur(10px);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.settings-header > div { flex: 1; }

.logout-btn {
    background: none;
    border: 1px solid rgba(231,76,60,0.4);
    color: #e74c3c;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85em;
    white-space: nowrap;
    transition: all 0.2s;
}
.logout-btn:hover {
    background: rgba(231,76,60,0.15);
    border-color: #e74c3c;
}

.title {
    text-align: center;
    font-size: 2.5em;
    color: #e94560;
    margin-bottom: 5px;
    text-shadow: 0 0 20px rgba(233,69,96,0.3);
}

.subtitle {
    text-align: center;
    color: #888;
    margin-bottom: 30px;
    font-size: 1.1em;
}

.settings-section {
    margin-bottom: 25px;
}

.settings-section h2 {
    font-size: 1.1em;
    color: #e94560;
    margin-bottom: 12px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(233,69,96,0.3);
}

.admin-section {
    margin-top: 30px;
    padding-top: 15px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.admin-section h2 { color: #e8a020; font-size: 1em; }
.admin-subsection { margin-top: 18px; }
.admin-subtitle { color: #aaa; font-size: 0.9em; margin-bottom: 8px; }
.admin-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.admin-info {
    font-size: 0.9em;
    color: #aaa;
}
.admin-info .hint-text {
    display: block;
    margin-top: 2px;
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85em;
    color: #ccc;
}
.admin-table th {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    color: #888;
    font-weight: 600;
}
.admin-table td {
    padding: 6px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    vertical-align: middle;
}
.admin-table tr:hover td { background: rgba(255,255,255,0.03); }
.admin-role-admin { color: #e8a020; font-weight: 600; }
.admin-actions { white-space: nowrap; }
.admin-btn-sm {
    padding: 3px 8px;
    font-size: 0.8em;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.05);
    color: #ccc;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 4px;
    transition: all 0.2s;
}
.admin-btn-sm:hover { border-color: #e94560; color: #fff; }
.admin-btn-promote { color: #e8a020; border-color: rgba(232,160,32,0.3); }
.admin-btn-promote:hover { background: rgba(232,160,32,0.15); border-color: #e8a020; }
.admin-btn-delete { color: #e74c3c; border-color: rgba(231,76,60,0.3); }
.admin-btn-delete:hover { background: rgba(231,76,60,0.15); border-color: #e74c3c; }

/* Seat Picker */
.seat-picker {
    display: flex;
    justify-content: center;
}

.seat-table {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    gap: 8px;
    width: 280px;
    height: 280px;
}

.seat-pos {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 12px;
    background: rgba(255,255,255,0.05);
    border: 2px solid rgba(255,255,255,0.1);
    transition: all 0.3s;
}

.seat-pos:hover {
    border-color: #e94560;
    background: rgba(233,69,96,0.1);
}

.seat-pos.selected {
    border-color: #e94560;
    background: rgba(233,69,96,0.2);
    box-shadow: 0 0 15px rgba(233,69,96,0.3);
}

.seat-north { grid-column: 2; grid-row: 1; }
.seat-west  { grid-column: 1; grid-row: 2; }
.seat-east  { grid-column: 3; grid-row: 2; }
.seat-south { grid-column: 2; grid-row: 3; }

.seat-center-table {
    grid-column: 2;
    grid-row: 2;
    background: #2d5a27;
    border-radius: 10px;
    border: 2px solid #3a7a32;
}

.seat-icon {
    font-size: 1.5em;
    font-weight: bold;
    color: #e94560;
}

.seat-label {
    font-size: 0.8em;
    color: #aaa;
    margin-bottom: 4px;
}

/* Option Buttons */
.option-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.option-btn {
    padding: 10px 18px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.15);
    color: #ccc;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s;
}

.option-btn:hover {
    border-color: #e94560;
    color: #fff;
}

.option-btn.selected {
    background: rgba(233,69,96,0.2);
    border-color: #e94560;
    color: #fff;
}

.hint-text {
    font-size: 0.8em;
    color: #666;
    margin-bottom: 8px;
    font-style: italic;
}

/* Slider */
.slider-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e94560;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(233,69,96,0.4);
    transition: box-shadow 0.2s;
}

.slider::-webkit-slider-thumb:hover {
    box-shadow: 0 0 15px rgba(233,69,96,0.6);
}

.slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e94560;
    cursor: pointer;
    border: none;
}

.slider-value {
    min-width: 40px;
    text-align: center;
    color: #e94560;
    font-weight: bold;
    font-size: 1.1em;
    font-family: monospace;
}

/* Convention Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.modal-overlay.hidden {
    display: none;
}

.modal-box {
    background: #1e2a3a;
    border: 1px solid rgba(233,69,96,0.3);
    border-radius: 16px;
    padding: 30px;
    max-width: 550px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-box h3 {
    color: #e94560;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.modal-box p {
    color: #ccc;
    line-height: 1.6;
    margin-bottom: 10px;
    font-size: 0.95em;
}

.modal-box ul {
    color: #bbb;
    padding-left: 20px;
    margin-bottom: 12px;
}

.modal-box ul li {
    margin-bottom: 5px;
    line-height: 1.5;
    font-size: 0.9em;
}

.modal-wide {
    max-width: 700px;
}

.modal-box .primary-btn {
    margin-top: 15px;
}

.analysis-section {
    margin-bottom: 18px;
}

.analysis-section h4 {
    color: #e94560;
    margin-bottom: 8px;
    font-size: 1em;
}

.analysis-hand {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.analysis-suit {
    font-size: 0.95em;
}

.analysis-suit .suit-symbol {
    font-weight: bold;
    margin-right: 2px;
}

.analysis-bid-sequence {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.analysis-bid {
    background: rgba(255,255,255,0.08);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.9em;
}

.analysis-comment {
    color: #aaa;
    font-size: 0.9em;
    line-height: 1.5;
    margin-bottom: 6px;
}

.primary-btn {
    display: block;
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #e94560, #c23152);
    border: none;
    color: #fff;
    font-size: 1.1em;
    font-weight: bold;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(233,69,96,0.4);
}

.primary-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.secondary-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: #aaa;
    font-size: 1em;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.3s;
}

.secondary-btn:hover {
    border-color: #e94560;
    color: #fff;
}

/* ==================== MAIN TABS ==================== */
.main-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 25px;
    border-bottom: 2px solid rgba(255,255,255,0.1);
}

.main-tab {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: #888;
    font-size: 1.05em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.main-tab:hover { color: #ccc; }

.main-tab.active {
    color: #e94560;
    border-bottom-color: #e94560;
}

.main-tab-panel.hidden { display: none; }

/* ==================== COMMUNITY TABS ====================*/
.community-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.community-tab {
    flex: 1;
    padding: 8px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #aaa;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.2s;
}

.community-tab:hover { color: #fff; border-color: #e94560; }
.community-tab.active { background: rgba(233,69,96,0.15); border-color: #e94560; color: #fff; }

.community-panel {
    background: rgba(0,0,0,0.2);
    border-radius: 0 0 10px 10px;
    padding: 12px;
    max-height: 350px;
    overflow-y: auto;
}

/* Player List */
.player-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.player-list-item:hover { background: rgba(255,255,255,0.05); }

.player-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.player-status-dot.online { background: #2ecc71; box-shadow: 0 0 6px rgba(46,204,113,0.5); }
.player-status-dot.in-game { background: #f39c12; box-shadow: 0 0 6px rgba(243,156,18,0.5); }
.player-status-dot.offline { background: #555; }

.player-info { flex: 1; min-width: 0; }
.player-info .player-name { font-weight: 600; color: #eee; font-size: 0.9em; }
.player-info .player-detail { font-size: 0.75em; color: #888; }

.player-rating-badge {
    background: rgba(233,69,96,0.2);
    color: #e94560;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8em;
    font-weight: bold;
    flex-shrink: 0;
}

.player-unread-badge {
    background: #e94560;
    color: #fff;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7em;
    font-weight: bold;
    flex-shrink: 0;
}

.player-you-badge {
    background: rgba(46,204,113,0.2);
    color: #2ecc71;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75em;
    flex-shrink: 0;
}

/* Rankings */
.my-rating-box {
    background: linear-gradient(135deg, rgba(233,69,96,0.15), rgba(233,69,96,0.05));
    border: 1px solid rgba(233,69,96,0.3);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 12px;
    text-align: center;
}

.my-rating-box .rating-value { font-size: 2em; font-weight: bold; color: #e94560; }
.my-rating-box .rating-title { color: #ccc; font-size: 0.9em; margin-top: 2px; }
.my-rating-box .rating-stats { color: #888; font-size: 0.8em; margin-top: 4px; }

.ranking-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 6px;
}

.ranking-row:nth-child(odd) { background: rgba(255,255,255,0.02); }

.ranking-pos {
    width: 28px;
    text-align: center;
    font-weight: bold;
    color: #888;
    font-size: 0.9em;
}

.ranking-pos.gold { color: #f1c40f; }
.ranking-pos.silver { color: #bdc3c7; }
.ranking-pos.bronze { color: #cd7f32; }

.ranking-name { flex: 1; color: #eee; font-size: 0.9em; }
.ranking-rating { font-weight: bold; color: #e94560; font-size: 0.9em; }
.ranking-title-badge { font-size: 0.7em; color: #888; padding-left: 4px; }

/* Chat Modal */
.chat-modal-box {
    display: flex;
    flex-direction: column;
    height: 70vh;
    max-height: 500px;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.chat-header h3 { flex: 1; margin: 0; }

.chat-status {
    font-size: 0.8em;
    padding: 2px 8px;
    border-radius: 10px;
}

.chat-status.online { background: rgba(46,204,113,0.2); color: #2ecc71; }
.chat-status.offline { background: rgba(85,85,85,0.3); color: #888; }
.chat-status.in-game { background: rgba(243,156,18,0.2); color: #f39c12; }

.chat-close-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 1.5em;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.chat-close-btn:hover { color: #e94560; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-msg {
    max-width: 80%;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.9em;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-msg.sent {
    align-self: flex-end;
    background: rgba(233,69,96,0.3);
    color: #eee;
    border-bottom-right-radius: 4px;
}

.chat-msg.received {
    align-self: flex-start;
    background: rgba(255,255,255,0.1);
    color: #ddd;
    border-bottom-left-radius: 4px;
}

.chat-msg .chat-time {
    font-size: 0.7em;
    color: #777;
    margin-top: 2px;
}

.chat-input-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.15);
    color: #eee;
    border-radius: 8px;
    font-size: 0.9em;
    outline: none;
}

.chat-input:focus { border-color: #e94560; }

.chat-send-btn {
    padding: 10px 18px;
    background: linear-gradient(135deg, #e94560, #c23152);
    border: none;
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9em;
    transition: all 0.2s;
}

.chat-send-btn:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(233,69,96,0.4); }

/* ==================== PROFILE ====================*/
.my-rating-row {
    display: flex;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 12px;
}

.my-rating-row .my-rating-box {
    flex: 1;
    margin-bottom: 0;
}

.profile-gear-btn {
    width: 48px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #888;
    font-size: 1.5em;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-gear-btn:hover {
    color: #e94560;
    border-color: #e94560;
    background: rgba(233,69,96,0.1);
}

.profile-modal-box {
    max-height: 85vh;
    overflow-y: auto;
}

.profile-section {
    margin-bottom: 18px;
}

.profile-section h4 {
    color: #e94560;
    font-size: 0.95em;
    margin-bottom: 10px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(233,69,96,0.2);
}

.profile-field {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.profile-field label {
    width: 130px;
    flex-shrink: 0;
    color: #aaa;
    font-size: 0.85em;
}

.profile-value {
    color: #eee;
    font-weight: 600;
    font-size: 0.9em;
}

.profile-input {
    flex: 1;
    padding: 8px 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.15);
    color: #eee;
    border-radius: 6px;
    font-size: 0.9em;
    outline: none;
}

.profile-input:focus { border-color: #e94560; }

.profile-ranking {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.profile-rank-card {
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    padding: 10px 16px;
    text-align: center;
    flex: 1;
    min-width: 100px;
}

.profile-rank-card .rank-label { font-size: 0.75em; color: #888; }
.profile-rank-card .rank-value { font-size: 1.3em; font-weight: bold; color: #e94560; margin-top: 2px; }
.profile-rank-card .rank-sub { font-size: 0.7em; color: #666; margin-top: 2px; }

.profile-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.summary-card {
    background: rgba(255,255,255,0.03);
    border-radius: 6px;
    padding: 8px 14px;
    text-align: center;
    flex: 1;
    min-width: 80px;
}

.summary-card .summary-val { font-size: 1.2em; font-weight: bold; color: #eee; }
.summary-card .summary-lbl { font-size: 0.7em; color: #888; margin-top: 2px; }

.profile-history {
    max-height: 300px;
    overflow-y: auto;
}

.profile-history table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8em;
    color: #bbb;
}

.profile-history th {
    text-align: left;
    padding: 5px 6px;
    color: #888;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-weight: 600;
    font-size: 0.85em;
}

.profile-history td {
    padding: 4px 6px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.profile-history tr:hover { background: rgba(255,255,255,0.02); }

/* ==================== GAME SCREEN ==================== */
#game-screen {
    flex-direction: column;
    background: #1a1a2e;
}

.game-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Info Bar */
.info-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 14px;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-wrap: wrap;
}

/* Game action buttons in info bar */
.game-action-btns {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-left: 4px;
}

.game-action-btn {
    padding: 4px 10px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    color: #ccc;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.78em;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}

.game-action-btn:hover {
    border-color: #e94560;
    color: #fff;
    background: rgba(233,69,96,0.15);
}

.game-action-undo {
    border-color: rgba(241,196,15,0.4);
    color: #f1c40f;
}

.game-action-undo:hover {
    background: rgba(241,196,15,0.15);
    border-color: #f1c40f;
}

.game-action-claim {
    border-color: rgba(46,204,113,0.4);
    color: #2ecc71;
}

.game-action-claim:hover {
    background: rgba(46,204,113,0.15);
    border-color: #2ecc71;
}

/* Dummy hand display: grouped by suit */
.dummy-hand {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 3px !important;
    min-height: auto !important;
    flex-wrap: nowrap !important;
    justify-content: center !important;
}

.dummy-suit-row {
    display: flex;
    align-items: center;
    gap: 0;
    min-height: 38px;
}

.dummy-suit-label {
    width: 22px;
    font-size: 1.1em;
    font-weight: bold;
    text-align: center;
    flex-shrink: 0;
    color: #333;
}

.dummy-suit-label.red {
    color: #e74c3c;
}

.dummy-void {
    color: #888;
    font-size: 0.85em;
    padding-left: 6px;
}

/* Cards inside dummy rows */
.dummy-suit-row .card {
    width: 34px !important;
    min-width: 34px !important;
    height: 52px !important;
    font-size: 0.75em !important;
    margin-left: -12px !important;
    border-radius: 5px !important;
    flex-shrink: 0;
}

.dummy-suit-row .card:first-of-type {
    margin-left: 2px !important;
}

.dummy-suit-row .card .card-tl {
    font-size: 0.7em;
    top: 2px;
    left: 3px;
}

.dummy-suit-row .card .card-br {
    font-size: 0.7em;
    bottom: 2px;
    right: 3px;
}

.dummy-suit-row .card .card-center {
    font-size: 1.3em;
}

.dummy-suit-row .card.playable {
    border: 2px solid #f1c40f;
    cursor: pointer;
}

.dummy-suit-row .card.playable:hover {
    transform: translateY(-6px);
    z-index: 10;
    box-shadow: 0 6px 14px rgba(241,196,15,0.5);
}

/* Previous tricks modal table */
.tricks-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88em;
    color: #bbb;
    margin-top: 8px;
}

.tricks-table th {
    text-align: center;
    padding: 6px 8px;
    color: #888;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-weight: 600;
    font-size: 0.85em;
}

.tricks-table td {
    text-align: center;
    padding: 5px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.tricks-table tr:hover { background: rgba(255,255,255,0.02); }

.tricks-table .winner-ns { color: #2ecc71; font-weight: bold; }
.tricks-table .winner-ew { color: #e74c3c; font-weight: bold; }
.tricks-table .card-red { color: #e74c3c; }
.tricks-table .card-black { color: #eee; }
.tricks-table .won-by-winner { text-decoration: underline; font-weight: bold; }

/* Bidding history modal during play */
#bidding-history-modal-body .bid-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    text-align: center;
    font-size: 0.95em;
    padding: 3px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

#bidding-history-modal-body .bid-header {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    text-align: center;
    font-size: 0.85em;
    color: #888;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    padding-bottom: 6px;
    margin-bottom: 4px;
}

#bidding-history-modal-body .bid-cell {
    padding: 3px;
}

.final-contract-line {
    margin-top: 12px;
    padding: 8px 12px;
    background: rgba(233,69,96,0.1);
    border: 1px solid rgba(233,69,96,0.3);
    border-radius: 6px;
    font-size: 0.9em;
    color: #ddd;
}

.info-item {
    font-size: 0.9em;
}

.info-label {
    color: #888;
}

.icon-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 1.3em;
    cursor: pointer;
    margin-left: auto;
    transition: color 0.3s;
}

.icon-btn:hover {
    color: #e94560;
}

/* Table Area */
.table-area {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(100px, 1fr) 3fr minmax(100px, 1fr);
    grid-template-rows: 1fr 2fr 1fr;
    gap: 5px;
    padding: 10px;
    background: radial-gradient(ellipse at center, #1f7a1f 0%, #186018 40%, #0e4a0e 70%, #0a350a 100%);
    border: none;
    box-shadow: inset 0 0 80px rgba(0,0,0,0.4);
    min-height: 0;
    overflow: clip;
}

/* Hand Areas - grid positions set by JS via .seat-* classes */
.hand-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 0;
    overflow: visible;
}

/* Screen positions (assigned dynamically) */
.seat-top    { grid-column: 2; grid-row: 1; align-self: end; }
.seat-left   { grid-column: 1; grid-row: 2; align-self: center; }
.seat-right  { grid-column: 3; grid-row: 2; align-self: center; }
.seat-bottom { grid-column: 2; grid-row: 3; align-self: start; }

/* Left/Right hands use vertical card layout */
.seat-left .cards-container,
.seat-right .cards-container {
    flex-direction: column;
    align-items: center;
    min-height: auto;
}

.seat-left .cards-container .card,
.seat-right .cards-container .card {
    margin-left: 0;
    margin-top: -80px;
}

.seat-left .cards-container .card:first-child,
.seat-right .cards-container .card:first-child {
    margin-top: 0;
}

.player-label {
    display: none;
}

.player-label.active-player {
    display: none;
}

.player-label.dummy-label {
    display: none;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 5px rgba(233,69,96,0.3); }
    50% { box-shadow: 0 0 15px rgba(233,69,96,0.6); }
}

@keyframes badge-pulse {
    0%, 100% { box-shadow: 0 0 6px rgba(232, 160, 32, 0.4); }
    50% { box-shadow: 0 0 16px rgba(232, 160, 32, 0.8); }
}

.pos-badge.active-badge .badge-name {
    background: rgba(232, 160, 32, 0.85);
    color: #000;
    animation: badge-pulse 1.5s infinite;
}

.pos-badge.dummy-badge .badge-name {
    color: #f1c40f;
}

/* Cards */
.cards-container {
    display: flex;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 0;
    min-height: 120px;
}

.cards-container .card {
    width: 82px;
    min-width: 30px;
    height: 120px;
    background: #fff;
    border-radius: 8px;
    display: block;
    font-size: 1.3em;
    color: #333;
    cursor: default;
    transition: all 0.2s;
    margin-left: -25px;
    box-shadow: 1px 2px 6px rgba(0,0,0,0.4);
    position: relative;
    user-select: none;
    border: 1px solid #ccc;
    overflow: hidden;
    flex-shrink: 1;
}

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

/* Card corners */
.card .card-tl, .card .card-br {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.1;
    font-size: 0.65em;
    font-weight: bold;
}

.card .card-tl {
    top: 4px;
    left: 5px;
}

.card .card-br {
    bottom: 4px;
    right: 5px;
    transform: rotate(180deg);
}

/* Card center symbol */
.card .card-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2em;
    line-height: 1;
}

.cards-container .card.red-card {
    color: #e74c3c;
}

.cards-container .card.not-my-turn,
.dummy-suit-row .card.not-my-turn {
    cursor: not-allowed;
    opacity: 0.5;
}

.cards-container .card.playable {
    cursor: pointer;
    border: 2px solid #f1c40f;
}

.cards-container .card.playable:hover {
    transform: translateY(-12px);
    box-shadow: 0 8px 20px rgba(241,196,15,0.4);
    z-index: 10;
}

.cards-container .card.face-down {
    background: linear-gradient(135deg, #1a237e 0%, #283593 50%, #1a237e 100%);
    background-image:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 4px,
            rgba(255,255,255,0.04) 4px,
            rgba(255,255,255,0.04) 8px
        ),
        repeating-linear-gradient(
            -45deg,
            transparent,
            transparent 4px,
            rgba(255,255,255,0.04) 4px,
            rgba(255,255,255,0.04) 8px
        );
    background-color: #1a237e;
    color: transparent;
    border-color: #0d1757;
    box-shadow: 1px 2px 8px rgba(0,0,0,0.5);
}

/* Horizontal cards overlap */
.seat-top .cards-container .card,
.seat-bottom .cards-container .card {
    margin-top: 0;
}

/* Center Area */
.center-area {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 0;
    border: 3px solid #e8a020;
    border-radius: 6px;
    box-shadow: 0 0 15px rgba(232, 160, 32, 0.15);
}

/* Position badges on center rectangle edges */
.pos-badge {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 20;
    font-size: 0.78em;
    font-weight: bold;
    white-space: nowrap;
}

.pos-badge .badge-letter {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.85em;
    color: #fff;
}

.pos-badge .badge-letter.human {
    background: #e8a020;
}

.pos-badge .badge-letter.ai {
    background: #2eaa2e;
}

.pos-badge .badge-name {
    background: rgba(20, 20, 40, 0.85);
    color: #ddd;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.9em;
    font-weight: 600;
}

.pos-badge.badge-top {
    top: -13px;
    left: 50%;
    transform: translateX(-50%);
}

.pos-badge.badge-bottom {
    bottom: -13px;
    left: 50%;
    transform: translateX(-50%);
}

.pos-badge.badge-left {
    left: 0;
    top: 50%;
    transform: translate(-50%, -50%) rotate(-90deg);
}

.pos-badge.badge-right {
    right: 0;
    top: 50%;
    transform: translate(50%, -50%) rotate(90deg);
}

/* Trick counters on the table */
.table-trick-counters {
    position: absolute;
    bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 20;
    pointer-events: none;
    background: rgba(0,0,0,0.45);
    padding: 3px 10px;
    border-radius: 8px;
}

.table-trick-counters.counters-left {
    left: 10px;
}

.table-trick-counters.counters-right {
    right: 10px;
}

.trick-counter {
    display: flex;
    align-items: baseline;
    gap: 5px;
    font-weight: bold;
}

.trick-counter .counter-label {
    font-size: 0.7em;
    color: #aaa;
}

.trick-counter .counter-value {
    font-size: 1.1em;
    color: #fff;
}

/* Bidding Panel */
#bidding-panel {
    background: rgba(0,0,0,0.6);
    border-radius: 12px;
    padding: 15px;
    width: 100%;
    max-width: 420px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,0.1);
}

#bidding-panel h3 {
    text-align: center;
    margin-bottom: 10px;
    color: #e94560;
}

.bidding-history {
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 10px;
    max-height: 150px;
    overflow-y: auto;
}

.bid-header {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    text-align: center;
    font-size: 0.8em;
    color: #888;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 4px;
    margin-bottom: 4px;
}

.bid-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    text-align: center;
    font-size: 0.9em;
    padding: 2px 0;
}

.bid-cell {
    padding: 2px;
}

.bid-cell.pass { color: #888; }
.bid-cell.double { color: #e74c3c; }
.bid-cell.redouble { color: #3498db; }

.bid-alert-badge {
    display: inline-block;
    background: #e8a020;
    color: #000;
    border-radius: 3px;
    padding: 0 3px;
    font-size: 0.7em;
    font-weight: bold;
    margin-left: 2px;
    vertical-align: super;
    cursor: help;
}

.bidding-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bid-level-row, .bid-suit-row, .bid-action-row {
    display: flex;
    gap: 4px;
    justify-content: center;
    flex-wrap: wrap;
}

.bid-level-btn, .bid-suit-btn {
    width: 42px;
    height: 36px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.05);
    color: #ccc;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.2s;
}

.bid-level-btn:hover, .bid-suit-btn:hover {
    border-color: #e94560;
    background: rgba(233,69,96,0.1);
}

.bid-level-btn.selected {
    background: rgba(233,69,96,0.3);
    border-color: #e94560;
    color: #fff;
}

.bid-suit-btn.selected {
    background: rgba(233,69,96,0.3);
    border-color: #e94560;
}

.bid-level-btn:disabled, .bid-suit-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.bid-action-btn {
    padding: 8px 14px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.05);
    color: #ccc;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
}

.bid-action-btn:hover {
    border-color: #e94560;
}

.bid-action-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#bid-confirm {
    padding: 8px 20px;
}

/* Trick Area - center of the table */
.trick-area {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.trick-card {
    position: absolute;
    width: 82px;
    height: 120px;
    display: block;
    background: #fff;
    border-radius: 8px;
    font-size: 1.3em;
    color: #333;
    box-shadow: 2px 3px 10px rgba(0,0,0,0.5);
    border: 2px solid #ddd;
    z-index: 10;
    overflow: hidden;
}

/* Trick card corners (same as hand cards) */
.trick-card .card-tl, .trick-card .card-br {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.1;
    font-size: 0.65em;
    font-weight: bold;
}

.trick-card .card-tl {
    top: 4px;
    left: 5px;
}

.trick-card .card-br {
    bottom: 4px;
    right: 5px;
    transform: rotate(180deg);
}

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

.trick-card.red-card {
    color: #e74c3c;
}

.trick-card.empty {
    background: transparent;
    border: none;
    box-shadow: none;
    color: transparent;
}

/* Trick card screen positions (assigned by JS) */
.trick-pos-top    { top: 8%;    left: 50%;  transform: translateX(-50%); }
.trick-pos-bottom { bottom: 8%; left: 50%;  transform: translateX(-50%); }
.trick-pos-left   { left: 18%;  top: 50%;   transform: translateY(-50%); }
.trick-pos-right  { right: 18%; top: 50%;   transform: translateY(-50%); }

/* Message Area */
.message-area {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: #f1c40f;
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 0.9em;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.message-area.visible {
    opacity: 1;
}

/* ==================== SCORE SCREEN ==================== */
#score-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    padding: 20px;
}

.score-container {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 40px;
    max-width: 500px;
    width: 100%;
    text-align: center;
    backdrop-filter: blur(10px);
}

.score-container h2 {
    color: #e94560;
    margin-bottom: 20px;
}

#score-details {
    text-align: left;
    margin-bottom: 20px;
}

.score-line {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.score-line.total {
    border-top: 2px solid #e94560;
    border-bottom: none;
    font-weight: bold;
    font-size: 1.2em;
    color: #e94560;
    margin-top: 10px;
    padding-top: 12px;
}

.score-line .score-positive { color: #2ecc71; }
.score-line .score-negative { color: #e74c3c; }

/* ==================== VERSION BADGE ==================== */
.version-badge {
    position: fixed;
    bottom: 8px;
    right: 12px;
    font-size: 0.7em;
    color: rgba(255,255,255,0.25);
    z-index: 9999;
    pointer-events: none;
    font-family: monospace;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .table-area {
        grid-template-columns: 80px 1fr 80px;
    }

    .cards-container .card {
        width: 55px;
        height: 80px;
        font-size: 1em;
        margin-left: -18px;
    }

    .seat-left .cards-container .card,
    .seat-right .cards-container .card {
        margin-top: -55px;
        margin-left: 0;
        width: 55px;
        height: 80px;
    }

    .trick-card {
        width: 55px;
        height: 80px;
        font-size: 1em;
    }

    .settings-container { padding: 20px; }
    .title { font-size: 1.8em; }
    .seat-table { width: 220px; height: 220px; }
    #bidding-panel { padding: 10px; }
    .bid-level-btn, .bid-suit-btn { width: 36px; height: 32px; font-size: 0.9em; }

    .pos-badge .badge-name { font-size: 0.75em; padding: 1px 5px; }
    .pos-badge .badge-letter { width: 18px; height: 18px; font-size: 0.75em; }
}

/* ==================== MULTIPLAYER TABLES UI ==================== */

.mp-section-title {
    font-size: 1em;
    color: #e94560;
    margin-bottom: 10px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(233,69,96,0.2);
    display: flex;
    align-items: center;
    gap: 8px;
}

.mp-create-section,
.mp-join-section,
.mp-tables-section {
    margin-bottom: 22px;
}

.mp-create-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mp-select {
    flex: 1;
    min-width: 120px;
    padding: 8px 10px;
    background: #1e1e3a;
    border: 1px solid rgba(255,255,255,0.15);
    color: #eee;
    border-radius: 8px;
    font-size: 0.9em;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23888' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

.mp-select:focus { border-color: #e94560; }

.mp-select option {
    background: #1e1e3a;
    color: #eee;
}

.mp-join-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.mp-code-input {
    width: 80px;
    padding: 8px 10px;
    background: #1e1e3a;
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: bold;
    letter-spacing: 3px;
    text-transform: uppercase;
    text-align: center;
    outline: none;
}

.mp-code-input:focus { border-color: #e94560; }

.mp-pos-select {
    width: 90px;
    min-width: 90px;
    flex: none;
}

.mp-refresh-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 1.1em;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.2s;
}

.mp-refresh-btn:hover { color: #e94560; }

/* Active table rows */
.mp-table-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 4px;
}

.mp-table-row:hover { background: rgba(255,255,255,0.05); border-color: rgba(233,69,96,0.3); }

.mp-tl-code {
    font-weight: bold;
    color: #e94560;
    letter-spacing: 2px;
    font-size: 1em;
    width: 50px;
    flex-shrink: 0;
}

.mp-tl-seats {
    display: flex;
    gap: 3px;
}

.mp-tl-seat {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75em;
    font-weight: bold;
}

.mp-tl-seat.taken { background: rgba(46,204,113,0.3); color: #2ecc71; }
.mp-tl-seat.free { background: rgba(255,255,255,0.08); color: #666; }

.mp-tl-status {
    font-size: 0.75em;
    padding: 2px 7px;
    border-radius: 10px;
}

.status-waiting { background: rgba(241,196,15,0.2); color: #f1c40f; }
.status-playing { background: rgba(46,204,113,0.2); color: #2ecc71; }

.mp-tl-deal {
    font-size: 0.75em;
    color: #888;
    margin-left: auto;
}

/* Lobby box */
.mp-lobby-box {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(233,69,96,0.2);
    border-radius: 12px;
    padding: 18px;
}

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

.mp-lobby-code {
    font-size: 1.3em;
    color: #e94560;
    letter-spacing: 3px;
}

.mp-seat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 14px 0;
}

.mp-seat {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 64px;
    justify-content: center;
}

.mp-seat.mp-seat-me {
    border-color: #e8a020;
    background: rgba(232,160,32,0.1);
}

.mp-seat.mp-seat-taken {
    border-color: rgba(46,204,113,0.3);
}

.mp-seat-pos {
    font-size: 0.75em;
    color: #888;
    font-weight: 600;
}

.mp-seat-name {
    font-size: 0.9em;
    color: #eee;
    font-weight: 600;
}

/* Invitation toast */
.mp-invitation-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #1e2a3a;
    border: 1px solid rgba(233,69,96,0.4);
    border-radius: 12px;
    padding: 14px 18px;
    max-width: 320px;
    z-index: 99999;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    font-size: 0.9em;
    color: #ddd;
    animation: slideInRight 0.3s ease;
}

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

.mp-invitation-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* Multiplayer player labels in game (no "IA" needed) */
.mp-player-human { color: #e8a020; }
.mp-player-ai { color: #888; }
