/* File: public/css/style.css */

/* --- Global & Reset Styles --- */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: sans-serif; background-color: #0a6b2e; color: white; height: 100%; width: 100%; overflow: hidden; }

/* --- Menu & Screen Styles --- */
.screen { width: 100%; height: 100%; display: none; }
#game-container { position: relative; display: none; flex-direction: column; align-items: center; }
.lobby-container { max-width: 600px; margin: 40px auto; padding: 20px 40px; text-align: center; background-color: rgba(0,0,0,0.2); border: 2px solid #5c3c10; border-radius: 12px; }
.lobby-container h1 { font-size: 2.5em; color: #ffdd77; text-shadow: 1px 1px 2px rgba(0,0,0,0.5); margin-bottom: 20px; }
.lobby-container h2 { margin-bottom: 10px; } /* General h2 styling for lobby */
.lobby-container p { margin-bottom: 20px; }
button { font-size: 1.2em; padding: 10px 20px; border-radius: 8px; border: none; background-color: #ffdd77; color: #4a2e0a; font-weight: bold; cursor: pointer; transition: background-color 0.2s ease; }
button:hover:not(:disabled) { background-color: #fff0b3; }
button:disabled { background-color: #ccc; color: #666; cursor: not-allowed; }
.game-mode-options button, .lobby-form button { margin: 10px; }
.back-button { margin-top: 20px; background-color: #aaa; color: #333; }
.back-button:hover { background-color: #ccc; }
.error-message { color: #ff8a8a; margin-top: 15px; height: 1.2em; font-weight: bold; }

/* NEW: Spacing for the separated lobby sections */
.host-section, .join-section {
    padding: 10px 0;
}

#player-name-input, #join-modal-player-name {
    padding: 10px;
    font-size: 1em;
    border-radius: 5px;
    border: 1px solid #555;
    background-color: #f0f0f0;
    color: #333;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

#lobby-list-container { margin-top: 10px; min-height: 100px; background-color: rgba(0,0,0,0.1); border-radius: 5px; padding: 10px; }
.lobby-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.lobby-item:last-child { border-bottom: none; }
#lobby-waiting-screen ul { list-style-type: none; }
#lobby-waiting-screen li { padding: 8px; font-size: 1.2em; }

/* NEW: Position the leave lobby button */
#leave-lobby-btn {
    margin-top: 20px;
}

/* --- Game Board Styles --- */
h2, h3 { margin: 5px 0; text-shadow: 1px 1px 2px rgba(0,0,0,0.5); }
#score-board { display: flex; justify-content: space-around; padding: 10px; background-color: #4a2e0a; color: #f0f0f0; width: 90%; max-width: 600px; margin: 10px 0; border-radius: 8px; border: 2px solid #5c3c10; gap: 20px; }

.team-score {
    font-size: 1.2em;
    font-weight: bold;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 0 8px;
}

#player-team-name,
#opponent-team-name {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
    line-height: 1.2;
    gap: 0 0.4em;
}

.score-value {
    padding: 2px 8px;
    background-color: #333;
    border-radius: 4px;
    margin-left: 0;
}

.trick-count-display {
    font-size: 0.85em;
    font-weight: normal;
    opacity: 0.8;
    margin-left: 0;
}

#dealer-indicator { text-align: center; font-size: 1.1em; font-weight: bold; color: #ffdd77; text-shadow: 1px 1px 1px rgba(0,0,0,0.7); margin-bottom: 10px; }
#game-table { position: relative; width: 90vw; height: 75vh; max-width: 900px; max-height: 700px; border: 5px solid #5c3c10; border-radius: 50%; background-color: #0c8a3c; flex-shrink: 0; }
.player-area { position: absolute; text-align: center; z-index: 2; }
#player-area-south { bottom: 10px; left: 50%; transform: translateX(-50%); }
#player-area-west  { left: 10px; top: 50%; transform: translateY(-50%); }
#player-area-north { top: 10px; left: 50%; transform: translateX(-50%); }
#player-area-east  { right: 10px; top: 50%; transform: translateY(-50%); }
.player-area h2 { position: absolute; margin: 0; padding: 2px 8px; background: rgba(0,0,0,0.2); border-radius: 4px; font-size: 1em; }
/* MODIFIED: Moved the "You" player name up */
#player-area-south h2 { bottom: 120px; left: 50%; transform: translateX(-50%); }
#player-area-north h2 { top: 105px; left: 50%; transform: translateX(-50%); }
#player-area-west h2 { left: 95px; top: 50%; transform: translateY(-50%); } 
/* MODIFIED: Moved the "East" player name away from the hand */
#player-area-east h2 { right: 115px; top: 50%; transform: translateY(-50%); } 
.hand { display: flex; gap: 5px; justify-content: center; min-height: 100px; }
#player-hand-north, #player-hand-east, #player-hand-west { gap: 0; }
.card { width: 60px; height: 90px; padding: 5px; border: 1px solid black; border-radius: 5px; background-color: white; color: black; font-size: 1.5em; font-weight: bold; display: flex; justify-content: center; align-items: center; cursor: pointer; user-select: none; transition: transform 0.2s ease-out, box-shadow 0.2s ease-out; line-height: 1.1; flex-direction: column; }
#player-hand-south .card:hover { transform: translateY(-10px); box-shadow: 0 4px 8px rgba(0,0,0,0.3); }
.card.disabled { cursor: not-allowed; background-color: #ccc; color: #666; }
#player-hand-south .card.disabled:hover { transform: none; box-shadow: none; }
.card-back { background-color: #5577ff; background-image: repeating-radial-gradient( circle at 0 0, transparent 0, #5577ff 10px ), repeating-linear-gradient( #4466ee55, #4466ee ); color: transparent; cursor: default; }
.card-back:hover { transform: none; box-shadow: none; }
#player-hand-west, #player-hand-east { flex-direction: column; width: 90px; height: auto; }
#player-hand-west .card, #player-hand-east .card { transform: rotate(90deg); }
#player-hand-west .card:not(:first-child), #player-hand-east .card:not(:first-child) { margin-top: -60px; margin-left: 0; }
#player-hand-west .card:hover, #player-hand-east .card:hover { transform: rotate(90deg); box-shadow: none; }
/* MODIFIED: Moved the entire center column up slightly */
#center-column { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -55%); display: flex; flex-direction: column; align-items: center; gap: 10px; z-index: 1; }
#trump-area { margin-top: 15px; padding: 5px 10px; background-color: rgba(0, 0, 0, 0.2); border-radius: 8px; min-height: 40px; display: flex; justify-content: center; align-items: center; }
#trump-area p { margin: 0; font-size: 1.1em; font-weight: bold; }
.suit-symbol { font-size: 1.4em; margin-left: 8px; }
.card .suit-symbol { font-size: 1em; margin-left: 0; }
.suit-red { color: #ff5555; }
.suit-black { color: #333333; }
#current-trick-container { position: relative; width: 200px; height: 150px; margin-top: 10px; z-index: 2; }
.played-card { position: absolute; transition: transform 1s ease-in, opacity 0.8s ease-in; }
.played-card:hover { transform: none; box-shadow: none; }
.played-card-south { bottom: 0; left: 50%; transform: translateX(-50%); }
.played-card-west  { left: 0; top: 50%; transform: translateY(-50%) rotate(90deg); } 
.played-card-north { top: 0; left: 50%; transform: translateX(-50%); }
.played-card-east  { right: 0; top: 50%; transform: translateY(-50%) rotate(90deg); } 
.played-card.clearing-to-south { transform: translate(0, 220px) scale(0.3); opacity: 0; }
.played-card.clearing-to-north { transform: translate(0, -220px) scale(0.3); opacity: 0; }
.played-card.clearing-to-west { transform: translate(-250px, 0) scale(0.3); opacity: 0; }
.played-card.clearing-to-east { transform: translate(250px, 0) scale(0.3); opacity: 0; }
.player-action-indicator { position: absolute; background-color: #fff; color: #333; padding: 8px 15px; border-radius: 15px; font-size: 1.1em; font-weight: bold; z-index: 100; opacity: 0; transition: opacity 0.3s ease-in-out; width: fit-content; white-space: nowrap; }
#indicator-south { bottom: 135px; left: 50%; transform: translateX(-50%); }
#indicator-north { top: 135px; left: 50%; transform: translateX(-50%); }
#indicator-west { left: 125px; top: 50%; transform: translateY(-50%); }
#indicator-east { right: 125px; top: 50%; transform: translateY(-50%); }
.player-action-indicator.visible { opacity: 1; }
.up-card-turned-down::after { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.6); border-radius: 5px; z-index: 1; }
.host-options { display: flex; justify-content: center; align-items: center; gap: 10px; margin: 15px 0; }
.host-options label { font-weight: bold; }
.host-options select { padding: 8px; border-radius: 4px; border: 1px solid #ccc; font-size: 1em; }

/* --- KITTY SPOT REPOSITIONING --- */
.kitty-spot { position: absolute; display: none; flex-direction: column; align-items: center; gap: 5px; z-index: 3; }
#kitty-spot-south { bottom: 35%; left: 35%; transform: translateX(-50%); } 
#kitty-spot-west  { top: 35%; left: 25%; transform: translateY(-50%) rotate(90deg); } 
#kitty-spot-north { top: 25%; left: 65%; transform: translateX(-50%); } 
#kitty-spot-east  { top: 65%; right: 25%; transform: translateY(-50%) rotate(90deg); } 

#player-area-south { display: flex; flex-direction: column; align-items: center; }
#action-buttons { position: relative; margin-top: 15px; display: flex; gap: 10px; }

/* --- Trick Pile Styles --- */
.trick-pile { position: absolute; width: 5vw; max-width: 60px; height: 7vw; max-height: 84px; transform-style: preserve-3d; perspective: 1000px; z-index: 1; }
#trick-pile-north { top: 22%; left: 2%; }
#trick-pile-west { top: 5%; left: 22%; }
#trick-pile-south { bottom: 22%; right: 2%; }
#trick-pile-east { bottom: 5%; right: 22%; }
.trick-pile .card-stack { position: absolute; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.3s ease-out; }
.trick-pile .card-back { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; transform-origin: center; }

/* --- Modal Styles --- */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}
.modal-content {
    background-color: #fff;
    color: #333;
    padding: 20px 30px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    max-width: 400px;
    width: 90%;
    text-align: center;
}
.modal-content h2 {
    color: #4a2e0a;
    margin-bottom: 15px;
}
.modal-content p {
    color: #555;
    margin-bottom: 20px;
}
.modal-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}
.modal-actions .back-button {
    margin-top: 0; /* Override default margin */
}

/* NEW: Specific styles for the End of Game modal */
#end-of-game-modal .modal-actions {
    justify-content: center; /* Center the 'Play Again' and 'Return' buttons */
}

#return-to-menu-btn {
    background-color: #aaa;
    color: #333;
}

#return-to-menu-btn:hover {
    background-color: #ccc;
}

/* --- ADDED: Waiting Room Team & Player Slot Styles --- */
#team-layout-container {
    margin: 20px 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.1);
    text-align: left; /* Align team headers to the left */
}
.team-box-container { margin-bottom: 15px; }
.team-box-container:last-child { margin-bottom: 0; }
.team-box-container h3 {
    color: #ffdd77;
    margin-bottom: 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 5px;
}
.team-box {
    min-height: 80px; /* Give it a minimum height for dropping */
    padding: 5px;
    border-radius: 5px;
    background-color: rgba(0,0,0,0.15);
}
.player-slot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 5px;
    font-size: 1.2em;
}
.player-slot.empty-slot {
    justify-content: center;
    opacity: 0.6;
    text-align: center;
}
.kick-player-btn {
    font-size: 0.8em;
    padding: 4px 10px;
    margin-left: 15px;
    background-color: #b94e4e;
    color: white;
}
.kick-player-btn:hover:not(:disabled) {
    background-color: #d15b5b;
}
/* SortableJS helper classes */
.sortable-ghost { opacity: 0.4; background: #4a2e0a; }
.sortable-drag { opacity: 1 !important; }