/* Allgemeine Resets und Grundstile */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(to right, #141e30, #243b55);
    color: #ecf0f1;
}

#game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Startmenü */
#startMenu {
    text-align: center;
    margin-top: 50px;
}

#startMenu h1 {
    color: #e74c3c;
    margin-bottom: 20px;
}

#startMenu p {
    font-size: 18px;
    margin-bottom: 30px;
}

.game-mode-selection {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.game-mode-selection button {
    padding: 15px 30px;
    font-size: 18px;
    background-color: #e74c3c;
    border: none;
    border-radius: 5px;
    color: #ecf0f1;
    cursor: pointer;
}

.game-mode-selection button:hover {
    background-color: #c0392b;
}

/* Setup & Spielbereich (Busfahrer/Zugfahrer) */
#setup, #gameArea {
    margin-top: 20px;
}

.setup-item {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

input[type="text"],
input[type="number"],
select,
input[type="range"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #34495e;
    border-radius: 5px;
    background-color: #34495e;
    color: #ecf0f1;
}

button {
    padding: 10px 20px;
    background-color: #e74c3c;
    border: none;
    border-radius: 5px;
    color: #ecf0f1;
    cursor: pointer;
    margin-top: 10px;
}

button:hover {
    background-color: #c0392b;
}

#gameHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#openSettings,
#openSettingsSetup {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #ecf0f1;
}

/* Kartenlayout (Busfahrer/Zugfahrer) */
#cardLayout {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    overflow-x: auto;
}

.row {
    display: flex;
    justify-content: center;
    flex-wrap: nowrap;
    margin-bottom: 10px;
}

.card {
    width: var(--card-width, 120px);
    height: calc(var(--card-width, 120px) * 1.5);
    border-radius: 10px;
    margin: 5px;
    position: relative;
    box-shadow: 0 5px 10px rgba(0,0,0,0.3);
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.6s;
}

.card .front,
.card .back {
    backface-visibility: hidden;
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 10px;
}

.card .front {
    background-color: #ecf0f1;
    color: #2c3e50;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--card-width, 120px) / 4);
    transform: rotateY(180deg);
}

.card .back {
    background-color: #e74c3c;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--card-width, 120px) / 3);
    color: #ecf0f1;
}

.card.flipped {
    transform: rotateY(180deg);
}

/* Spieleranzeige */
#players {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

.player {
    background-color: #34495e;
    padding: 10px;
    margin: 10px;
    border-radius: 10px;
    cursor: pointer;
    position: relative;
    min-width: 200px;
    text-align: center;
    transition: background-color 0.3s;
}

.player:hover {
    background-color: #3b5998;
}

.player .received-cards {
    margin-top: 5px;
    color: #ecf0f1;
}

/* Nachrichtenbereich */
#messageArea {
    margin-top: 20px;
    text-align: center;
    font-size: 18px;
}

/* Modale Fenster */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #34495e;
    margin: 10% auto;
    padding: 20px;
    border: 2px solid #888;
    width: 80%;
    color: #ecf0f1;
    border-radius: 10px;
    position: relative;
}

/* Schließen-Button für Widgets */
.close-btn {
    margin-top: 10px;
    padding: 8px 16px;
    background-color: #e74c3c;
    border: none;
    border-radius: 5px;
    color: #ecf0f1;
    cursor: pointer;
}

.close-btn:hover {
    background-color: #c0392b;
}

#distributionArea .distribution-item {
    margin-bottom: 20px;
}

#distributionArea label {
    display: block;
    margin-bottom: 5px;
}

#distributionArea .recipient-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.recipient-button {
    padding: 10px;
    background-color: #3b5998;
    color: #ecf0f1;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: border 0.3s;
}

.recipient-button.selected {
    border: 2px solid #e74c3c;
    box-shadow: 0 0 10px #e74c3c;
}

#generalMessageModal .modal-content {
    text-align: center;
}

/* Handkarten Modal */
#handCardsModal .modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#handCardsContainer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 20px;
}

.hand-card {
    width: var(--card-width, 100px);
    height: calc(var(--card-width, 100px) * 1.5);
    border-radius: 10px;
    margin: 5px;
    background-color: #ecf0f1;
    color: #2c3e50;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--card-width, 100px) / 4);
    box-shadow: 0 5px 10px rgba(0,0,0,0.3);
}

/* Würfel (Busfahrer/Zugfahrer) */
#dice {
    color: #333;
}

/* ============================= */
/* Board Game Mode (Brettspiel) */
/* ============================= */

/* Setup & Spielbereich */
#boardGameSetup,
#boardGameArea {
    margin-top: 20px;
    text-align: center;
}

#boardGameSetup {
    padding: 20px;
    background-color: #2c3e50;
    border-radius: 10px;
}

#boardGameSetup input[type="text"] {
    width: 80%;
    padding: 10px;
    border: 1px solid #34495e;
    border-radius: 5px;
    background-color: #34495e;
    color: #ecf0f1;
}

#boardGameArea {
    display: none;
}

/* Brettspiel-Brett */
#bgBoardContainer {
    position: relative;
    width: 400px;
    height: 320px;
    margin: 20px auto;
    border: 2px solid #333;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

#bgBoard {
    display: grid;
    grid-template-columns: repeat(5, 80px);
    grid-auto-rows: 80px;
}

.bgCell {
    border: 1px solid #ccc;
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
}

.bgCellNumber {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 10px;
    color: #2c3e50; /* dunkle Schrift für gute Lesbarkeit auf weißem Hintergrund */
}

.bgCellAction {
    position: absolute;
    bottom: 2px;
    left: 2px;
    right: 2px;
    font-size: 8px;
    color: #555;
    text-align: center;
    word-break: break-word;
}

#bgPiecesContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.bgPiece {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    position: absolute;
    transition: top 0.5s ease, left 0.5s ease;
    border: 2px solid #fff;
}

#bgDiceContainer {
    width: 50px;
    height: 50px;
    margin: 20px auto;
    perspective: 500px;
}

#bgDice {
    width: 50px;
    height: 50px;
    background: #eee;
    border: 2px solid #333;
    line-height: 50px;
    font-size: 24px;
    font-weight: bold;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.5s ease;
    border-radius: 5px;
}

@keyframes bgRoll {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.bgRolling {
    animation: bgRoll 0.5s linear;
}

#bgMessage {
    font-size: 18px;
    margin: 20px;
    min-height: 24px;
}

/* Widgets (Overlay für Aktionen, Minispiele, allgemeine Nachrichten) */
/* Wir überschreiben hier den Standard-Modale Stil für die Widgets, sodass sie einen weißen Hintergrund und dunklen Text haben */
#actionWidget,
#bgActionWidget,
#generalMessageModal .modal-content {
    background: #fff;
    color: #333;
    border: 2px solid #ccc;
    text-align: center;
    padding: 20px 30px;
}

/* Brettspiel-Kartensprite */
.bgCardSprite {
    width: 80px;
    height: 120px;
    background: white;
    border: 2px solid #333;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 36px;
    font-weight: bold;
    margin: 10px auto;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Responsives Design */
@media (max-width: 768px) {
    .card {
        --card-width: 100px;
    }
}

@media (max-width: 480px) {
    .card {
        --card-width: 80px;
    }
    .player {
        min-width: 100%;
    }
    #players {
        flex-direction: column;
    }
    #game-container {
        padding: 10px;
    }
}