/* 1. Global Reset & Layout Foundation                               */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    color: #222222;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Global Navigation Top Bar (Present on V1-V6) */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #e8e8e8;
    padding: 12px 24px;
    border-bottom: 1px solid #cccccc;
    height: 60px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    width: 36px;
    height: 36px;
    background-color: #dddddd;
    border: 1px solid #cccccc;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #555555;
}

.brand-title {
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 1px;
}

.round-indicator {
    font-size: 18px;
    font-weight: bold;
    color: #222222;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.view {
    display: none;
    flex: 1;
    padding: 24px;
}

.view.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.error-banner {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 10px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 14px;
    text-align: center;
    max-width: 420px;
    width: 100%;
}

.hidden {
    display: none !important;
}

/* 2. Shared Interactive Button & State Rules (GUI-2 Compliance)     */
.btn {
    display: inline-block;
    padding: 10px 16px;
    font-size: 15px;
    font-weight: bold;
    text-align: center;
    background-color: #f8f9fa;
    color: #333333;
    border: 1px solid #cccccc;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.btn:hover:not(:disabled) {
    background-color: #e2e6ea;
    border-color: #adbbc4;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #e9ecef;
}

.top-bar .btn {
    width: auto;
    height: 46px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    margin-bottom: 0;
}

#rulesButton {
    width: 46px;
    height: 46px;
    padding: 0;
    font-size: 12px;
}

/* 3. Homepage Styles (V1 - HomepageView)                            */

.homepage-card {
    background-color: #ffffff;
    padding: 32px;
    border-radius: 8px;
    border: 1px solid #dddddd;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.homepage-card h1 {
    font-size: 24px;
    margin-bottom: 24px;
    color: #111111;
}

.homepage-card label {
    display: block;
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 8px;
    color: #444444;
}

.homepage-card input[type="text"],
.homepage-card select {
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;
    border: 1px solid #cccccc;
    border-radius: 4px;
    margin-bottom: 20px;
}

.homepage-card .btn {
    width: 100%;
    margin-bottom: 12px;
}

.join-row {
    display: flex;
    gap: 10px;
}

.join-row input[type="text"] {
    margin-bottom: 12px;
}

.homepage-card .join-row .btn {
    width: auto;
    white-space: nowrap;
}

/* 4. Game Lobby Styles (V2 - GameLobbyView)                         */

#gameLobbyView {
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
}

.lobby-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 20px;
    background: #ffffff;
    padding: 16px 20px;
    border-radius: 6px;
    border: 1px solid #dddddd;
}

.lobby-code-box span {
    font-size: 14px;
    color: #666666;
    margin-right: 8px;
}

.lobby-code-box strong {
    font-size: 18px;
    letter-spacing: 2px;
    background: #f1f1f1;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #cccccc;
}

.game-mode-box {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: bold;
    color: #444444;
}

.game-mode-box select,
.host-controls select {
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 4px;
    border: 1px solid #cccccc;
    background-color: #ffffff;
}

.lobby-card {
    background-color: #ffffff;
    border: 1px solid #dddddd;
    border-radius: 6px;
    width: 100%;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.player-count-header {
    font-weight: bold;
    font-size: 15px;
    margin-bottom: 16px;
    color: #333333;
}

.player-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.player-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background-color: #fafafa;
    border: 1px solid #e2e2e2;
    border-radius: 4px;
}

.player-name {
    font-weight: 600;
}

.player-status.ready {
    color: #2e7d32;
    font-weight: bold;
    font-size: 14px;
}

.player-status.not-ready {
    color: #c62828;
    font-size: 14px;
}

.lobby-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 15px;
}

.host-controls,
.player-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}



/* 5. Game Screen Styles (V3/V4 - GameScreenView)                    */

#gameScreenView {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    justify-content: space-between;
}

.trick-center-wrapper {
    grid-area: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.trump-badge-inline {
    background-color: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    white-space: nowrap;
}

.trump-color.red {
    color: #d32f2f;
}

.trump-color.blue {
    color: #1976d2;
}

.trump-color.green {
    color: #388e3c;
}

.trump-color.yellow {
    color: #fbc02d;
}

.table-container {
    display: grid;
    grid-template-areas:
        ". top ."
        "left center right"
        "bottom bottom bottom";
    grid-template-columns: 200px 1fr 200px;
    grid-template-rows: auto 1fr auto;
    width: 100%;
    flex: 1;
    align-items: center;
    justify-items: center;
    gap: 16px;
    padding: 10px 0;
}

.slot-top {
    grid-area: top;
}

.slot-left {
    grid-area: left;
}

.slot-right {
    grid-area: right;
}


.local-player-container {
    grid-area: bottom;
    width: 100%;
}


.player-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.player-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #ffffff;
    border: 1px solid #dddddd;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 14px;
}

.trick-center {
    position: relative;
    width: 280px;
    height: 240px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 4px 0;
}

/* All played cards stack centered on top of each other */
.trick-center .card-played {
    position: absolute;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.16);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.trick-center .card-played:first-child {
    margin-left: 0;
}

/* Optional: Slight directional nudges toward the seat that played the card */
.card-played.from-left {
    transform: translate(-65px, 0px);
}

.card-played.from-top-left {
    transform: translate(-55px, -70px);
}

.card-played.from-top {
    transform: translate(0px, -85px);
}

.card-played.from-top-right {
    transform: translate(55px, -70px);
}

.card-played.from-right {
    transform: translate(65px, 0px);
}

.card-played.from-bottom {
    transform: translate(0px, 80px);
}

/* Winning card highlight before the trick clears */
.trick-center .card-played.winning-card {
    box-shadow: 0 0 0 3px #fbc02d, 0 8px 16px rgba(0, 0, 0, 0.25);
    background-color: #fffde7;
    z-index: 10;
}

.trick-bid-count {
    font-size: 13px;
    color: #555555;
    font-weight: bold;
}

.hand-opponent {
    display: flex;
    justify-content: center;
}

.hand-opponent .card-back {
    width: 44px;
    height: 66px;
    background-color: #b0b0b0;
    border: 2px solid #777777;
    border-radius: 5px;
    margin-left: -22px;
    /* Overlaps opponent cards just like Figure 5/6 */
}

.hand-opponent .card-back:first-child {
    margin-left: 0;
}

.local-player-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.local-meta-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.turn-timer {
    background-color: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 14px;
    font-weight: bold;
}

.turn-timer.warning {
    background-color: #ffebee;
    color: #d32f2f;
    border-color: #d32f2f;
}

.dealer-badge {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background-color: #222222;
    color: #ffffff;
    font-size: 13px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.local-player-name {
    font-size: 16px;
    font-weight: bold;
}

.bid-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    background-color: #ffffff;
    padding: 12px 20px;
    border-radius: 8px;
    border: 1px solid #dddddd;
}

.prompt-text {
    font-size: 15px;
    font-weight: bold;
}

.bid-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-bid {
    width: 42px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hand-local {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px;
}

.card {
    width: 76px;
    height: 112px;
    background-color: #ffffff;
    border: 2px solid #444444;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    user-select: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.hand-local .card-face-up:hover:not(.disabled) {
    transform: translateY(-8px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
}

.card.red {
    border-color: #d32f2f;
    color: #d32f2f;
}

.card.blue {
    border-color: #1976d2;
    color: #1976d2;
}

.card.green {
    border-color: #388e3c;
    color: #388e3c;
}

.card.yellow {
    border-color: #fbc02d;
    color: #b28900;
}

.card.wizard {
    border-color: #6a1b9a;
    color: #6a1b9a;
    background-color: #f3e5f5;
}

.card.jester {
    border-color: #00838f;
    color: #00838f;
    background-color: #e0f7fa;
}

.card.disabled {
    background-color: #e0e0e0;
    border-color: #aaaaaa;
    color: #888888;
    opacity: 0.6;
    cursor: not-allowed;
}

.modal {
    position: fixed;
    top: 0px;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-card {
    background-color: #ffffff;
    padding: 24px 32px;
    border-radius: 8px;
    border: 1px solid #cccccc;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.modal-card h3 {
    margin-bottom: 16px;
}

.color-options {
    display: flex;
    gap: 10px;
}

/* 6. Scoreboard Styles (V5 EndOfRoundScoreboardView & FREQ-21)      */
.scoreboard-modal-card {
    background-color: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 10px;
    padding: 28px 32px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    text-align: center;
}

.scoreboard-modal-card h2 {
    font-size: 24px;
    margin-bottom: 20px;
    color: #111111;
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.scoreboard-row {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background-color: #fafafa;
    border: 1px solid #cccccc;
    border-radius: 6px;
    font-size: 16px;
}

.scoreboard-row.local-player-row {
    font-weight: bold;
    background-color: #f0f4f8;
}

.rank-col {
    width: 32px;
    text-align: left;
    color: #444444;
}

.name-col {
    flex: 1;
    text-align: left;
}

.score-col {
    width: 60px;
    text-align: right;
    font-weight: bold;
}

.delta-col {
    width: 55px;
    text-align: right;
    font-weight: bold;
    font-size: 15px;
}

.delta-positive {
    color: #2e7d32;
}

.delta-negative {
    color: #c62828;
}

.ready-col {
    width: 36px;
    text-align: right;
    font-size: 15px;
}

.ready-col.ready {
    color: #2e7d32;
}

.ready-col.not-ready {
    color: #999999;
}

.auto-start-timer {
    font-size: 13px;
    color: #666666;
    margin-bottom: 14px;
}

.next-round-btn {
    min-width: 180px;
}

.scoreboard-popover {
    position: absolute;
    top: 16px;
    right: 24px;
    width: 320px;
    background-color: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    z-index: 90;
}

.scoreboard-popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.scoreboard-popover-header h3 {
    font-size: 16px;
}

.btn-close {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #555555;
    padding: 2px 6px;
}

.btn-close:hover {
    color: #000000;
}

/* 7. Rules Overlay Styles (SDS 2.3.9 - RulesOverlay / FREQ-23)      */
.rules-modal-card {
    background-color: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 10px;
    width: 100%;
    max-width: 640px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
    overflow: hidden;
}

.rules-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #fafafa;
}

.rules-header h2 {
    font-size: 20px;
    color: #111111;
}

/* Matches rulesContent: ScrollablePanel (SDS 2.3.9) */
.rules-scrollable-panel {
    padding: 20px 24px;
    overflow-y: auto;
    text-align: left;
    line-height: 1.55;
    font-size: 14px;
    color: #333333;
}

.rules-scrollable-panel h3 {
    font-size: 16px;
    color: #111111;
    margin-top: 16px;
    margin-bottom: 6px;
}

.rules-scrollable-panel h3:first-child {
    margin-top: 0;
}

.rules-scrollable-panel p {
    margin-bottom: 10px;
}

.rules-scrollable-panel ul,
.rules-scrollable-panel ol {
    margin-left: 20px;
    margin-bottom: 12px;
}

.rules-scrollable-panel li {
    margin-bottom: 4px;
}

/* 8. Last Trick Overlay Styles (SDS 2.3.8 - LastTrickOverlay)       */
.last-trick-popover {
    position: absolute;
    top: 16px;
    right: 140px;
    /* Positioned below the "Last Trick" top-bar button */
    background-color: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    z-index: 90;
}

.last-trick-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.last-trick-header h3 {
    font-size: 16px;
    color: #111111;
}

.last-trick-cards-row {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 12px;
    padding-top: 8px;
    /* Leaves room for the winning card to lift upward */
}

.last-trick-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.last-trick-player {
    font-size: 12px;
    color: #555555;
    white-space: nowrap;
}

/* Highlights the winning card and player (FREQ-17 AC4 / winningCardHighlight) */
.winning-slot .card.winning-card {
    transform: translateY(-6px);
    box-shadow: 0 0 0 3px #fbc02d, 0 6px 14px rgba(0, 0, 0, 0.2);
    background-color: #fffde7;
}

.winning-slot .last-trick-player {
    font-weight: bold;
    color: #111111;
}


/* 9. End of Game Styles (V6 - EndOfGameView / FREQ-20)              */
.gameover-container {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.gameover-title {
    font-size: 36px;
    font-weight: bold;
    color: #111111;
    margin-bottom: 28px;
    letter-spacing: 0.5px;
}

.final-standings-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 32px;
}

.standing-row {
    display: flex;
    align-items: center;
    width: 90%;
    padding: 12px 20px;
    background-color: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 6px;
    font-size: 16px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.standing-row.winner-row {
    width: 100%;
    padding: 18px 24px;
    background-color: #e8e8e8;
    border: 2px solid #555555;
    border-radius: 8px;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.standing-rank {
    width: 36px;
    text-align: left;
}

.winner-crown {
    margin-right: 10px;
    font-size: 22px;
}

.standing-name {
    flex: 1;
    text-align: left;
}

.standing-score {
    text-align: right;
    font-weight: bold;
}

/* Bottom Action Buttons */
.gameover-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    width: 90%;
}

.gameover-btn {
    flex: 1;
    padding: 14px 20px;
    font-size: 16px;
    background-color: #e4e4e4;
    border: 1px solid #888888;
}

.player-info.active-turn,
.local-player-name.active-turn {
    border-color: #fbc02d;
    box-shadow: 0 0 0 3px rgba(251, 192, 45, 0.35);
    background-color: #fffde7;
}