/* ==================== 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);
}

.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);
}

/* 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;
}

/* 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-box .primary-btn {
    margin-top: 15px;
}

.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;
}

/* ==================== 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: 20px;
    padding: 8px 20px;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-wrap: wrap;
}

.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: auto 1fr auto;
    gap: 5px;
    padding: 10px;
    background: radial-gradient(ellipse at center, #2d5a27 0%, #1e3d1a 60%, #152e12 100%);
    border: 8px solid #3a2a1a;
    box-shadow: inset 0 0 50px rgba(0,0,0,0.3);
    min-height: 0;
}

/* 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;
}

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

/* 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 {
    font-size: 0.85em;
    color: #aaa;
    margin-bottom: 5px;
    padding: 2px 12px;
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    white-space: nowrap;
}

.player-label.active-player {
    color: #fff;
    background: rgba(233,69,96,0.5);
    animation: pulse 1.5s infinite;
}

.player-label.dummy-label {
    color: #f1c40f;
}

@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); }
}

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

.cards-container .card {
    width: 82px;
    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;
}

.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.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, #1a3a8a 0%, #2a4a9a 50%, #1a3a8a 100%);
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 5px,
        rgba(255,255,255,0.05) 5px,
        rgba(255,255,255,0.05) 10px
    );
    background-color: #1a3a8a;
    color: transparent;
    border-color: #0f2870;
}

/* 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: 300px;
}

/* 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; }

.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; }
}
