/* Bismarck Game Styles */

/* Body and Container */
body {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
}

.back-to-games {
    position: absolute;
    left: 0;
    top: 10px;
    padding: 10px 16px;
    background: rgba(255,255,255,0.95);
    color: #1e3c72;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 14px;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.back-to-games:hover {
    background: white;
    transform: translateY(-2px);
}

/* Hide back-to-games in game screen (use menu instead) */
.game-screen .back-to-games {
    display: none;
}

h1 {
    color: white;
    font-size: 48px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

/* Hide all screens by default */
.welcome-screen,
.lobby-screen,
.game-screen {
    display: none;
}

.welcome-screen.active,
.lobby-screen.active,
.game-screen.active {
    display: block;
}

/* Welcome Screen */
.welcome-screen {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    max-width: 500px;
    margin: 0 auto;
}

.welcome-screen h2 {
    color: #1e3c72;
    margin-bottom: 30px;
    text-align: center;
}

.game-info {
    margin-top: 40px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 10px;
    color: #333;
}

.game-info h3 {
    margin-bottom: 15px;
    color: #1e3c72;
}

.game-info ul {
    list-style: none;
    padding: 0;
}

.game-info ul li {
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
}

.game-info ul li:last-child {
    border-bottom: none;
}

/* Lobby Screen */
.lobby-screen {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    max-width: 600px;
    margin: 0 auto;
}

.lobby-screen h2 {
    color: #1e3c72;
    text-align: center;
    margin-bottom: 20px;
}

.room-code-display {
    font-size: 20px;
    text-align: center;
    margin: 20px 0;
    color: #333;
}

.room-code-display strong {
    font-size: 32px;
    color: #1e3c72;
    letter-spacing: 5px;
    background: #f0f8ff;
    padding: 10px 20px;
    border-radius: 8px;
    display: inline-block;
}

.players-waiting {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
}

.players-waiting h3 {
    margin-bottom: 15px;
}

#lobbyPlayers {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lobby-player {
    padding: 15px;
    background: #f0f0f0;
    border-radius: 5px;
    font-size: 18px;
    font-weight: bold;
}

.waiting-message {
    text-align: center;
    margin: 30px 0;
    color: white;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* Game Screen */
.game-screen {
    background: white;
    padding: 20px;
    border-radius: 10px;
}

/* Turn Indicator */
.turn-indicator {
    background: rgba(255,255,255,0.95);
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    font-weight: bold;
    font-size: 16px;
    margin: 15px 0;
    text-align: center;
    color: #666;
}

.turn-indicator.your-turn {
    background: #4CAF50;
    color: white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(76, 175, 80, 0.7);
    }
}

.game-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    border-radius: 8px;
    margin-bottom: 20px;
}

.round-info,
.dealer-info {
    font-size: 18px;
    font-weight: bold;
}

.round-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.room-code-inline {
    font-size: 14px;
    opacity: 0.9;
}

.room-code-inline strong {
    font-size: 16px;
    letter-spacing: 2px;
}

.saved-game-name-inline {
    font-size: 14px;
    opacity: 0.9;
    color: #4CAF50;
}

.saved-game-name-inline strong {
    font-size: 15px;
}

.btn-save-small {
    padding: 6px 12px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    transition: all 0.3s;
    margin-left: 10px;
}

.btn-save-small:hover {
    background: #45a049;
    transform: translateY(-2px);
}

/* Contract Tracking */
.contract-tracking {
    margin: 10px 0;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 8px;
}

.contract-tracking h3 {
    margin-bottom: 8px;
    color: #2a5298;
    font-size: 14px;
}

.contract-grid {
    display: grid;
    grid-template-columns: auto repeat(4, 1fr);
    gap: 4px;
    align-items: center;
}

.contract-header {
    font-weight: bold;
    text-align: center;
    padding: 4px;
    background: #2a5298;
    color: white;
    border-radius: 3px;
    font-size: 11px;
}

.player-row-label {
    font-weight: bold;
    padding: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    font-size: 11px;
}

.contract-cell {
    padding: 6px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: white;
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.contract-cell.chosen {
    background: #e8f5e9;
    color: #4CAF50;
    border-color: #4CAF50;
    font-weight: bold;
}

.contract-cell.current {
    background: #4CAF50;
    color: white;
    border-color: #2e7d32;
    font-weight: bold;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

.contract-cell.current-playing {
    background: #4CAF50;
    color: white;
    border-color: #2e7d32;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
    }
    50% {
        box-shadow: 0 0 16px rgba(76, 175, 80, 0.9);
    }
}

/* Score Display */
.score-display {
    margin: 10px 0;
    padding: 10px;
    background: #f0f8ff;
    border-radius: 8px;
}

.score-display h3 {
    margin-bottom: 8px;
    color: #2a5298;
    font-size: 14px;
}

.score-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
}

.player-score {
    padding: 10px;
    background: white;
    border-radius: 5px;
    border: 2px solid #ddd;
    text-align: center;
}

.player-score.current-player {
    border-color: #2a5298;
    background: #e6f3ff;
}

.player-score-name {
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 5px;
}

.player-score-value {
    font-size: 24px;
    font-weight: bold;
    color: #2a5298;
}

.player-score-value.winning {
    color: #4CAF50;
}

/* Phase Container */
.phase-container {
    margin: 20px 0;
}

.phase-content {
    display: none;
}

.phase-content.active {
    display: block;
}

.phase-instruction {
    padding: 15px;
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    color: #856404;
}

.phase-instruction.you {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.phase-instruction.waiting {
    background: #e2e3e5;
    border-color: #6c757d;
    color: #383d41;
}

/* Contract Selection Phase */
#contractSelectionPhase h2 {
    text-align: center;
    color: #2a5298;
    margin-bottom: 20px;
}

.face-up-cards {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 30px 0;
    padding: 20px;
    background: #f0f0f0;
    border-radius: 10px;
}

.contract-choices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.contract-btn {
    padding: 20px;
    background: white;
    border: 3px solid #2a5298;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.contract-btn:hover {
    background: #2a5298;
    color: white;
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.contract-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #e0e0e0;
    border-color: #ccc;
}

.contract-btn:disabled:hover {
    transform: none;
}

.contract-name {
    font-size: 20px;
    font-weight: bold;
}

.contract-desc {
    font-size: 14px;
    opacity: 0.8;
}

/* Trump Selection Phase */
#trumpSelectionPhase h2 {
    text-align: center;
    color: #2a5298;
    margin-bottom: 30px;
}

.trump-choices {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    max-width: 800px;
    margin: 0 auto;
}

.trump-btn {
    padding: 40px 20px;
    font-size: 48px;
    background: white;
    border: 3px solid #2a5298;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.trump-btn:hover {
    background: #2a5298;
    color: white;
    transform: scale(1.1);
}

/* Discard Phase */
#discardPhase {
    text-align: center;
}

.discard-instruction {
    font-size: 16px;
    color: #666;
    margin: 20px 0;
}

.discard-area {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    min-height: 140px;
    padding: 20px;
    background: #ffe6e6;
    border: 2px dashed #ff6b6b;
    border-radius: 10px;
    margin: 20px 0;
}

#confirmDiscardBtn {
    margin: 20px auto;
    display: block;
}

/* Trick-Taking Phase */
.current-contract-display {
    padding: 15px;
    background: #2a5298;
    color: white;
    border-radius: 8px;
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 20px;
}

.trick-area {
    margin: 30px 0;
    padding: 30px;
    background: #f9f9f9;
    border-radius: 10px;
    min-height: 200px;
}

.trick-cards {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.trick-card-wrapper {
    text-align: center;
}

.trick-card-player {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 5px;
}

.trick-info {
    text-align: center;
    font-size: 18px;
    color: #666;
}

.player-hand {
    margin: 30px 0;
}

.hand-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.player-hand h3 {
    margin: 0;
    color: #2a5298;
}

.sort-buttons {
    display: flex;
    gap: 8px;
}

.btn-sort {
    padding: 6px 12px;
    background: #f0f0f0;
    color: #333;
    border: 2px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.3s;
}

.btn-sort:hover {
    background: #e0e0e0;
}

.btn-sort.active {
    background: #2a5298;
    color: white;
    border-color: #2a5298;
}

.hand-cards {
    display: flex;
    justify-content: center;
    gap: 5px;
    flex-wrap: wrap;
}

.hand-cards .card {
    cursor: pointer;
    transition: all 0.3s;
}

.hand-cards .card:hover {
    transform: translateY(-20px);
}

.hand-cards .card.playable {
    cursor: pointer;
}

.hand-cards .card.unplayable {
    opacity: 0.5;
    cursor: not-allowed;
}

.hand-cards .card.selected {
    transform: translateY(-30px);
    box-shadow: 0 0 20px rgba(42, 82, 152, 0.8);
}

.tricks-won-display {
    margin: 20px 0;
    padding: 15px;
    background: #f0f8ff;
    border-radius: 8px;
}

.tricks-won-display h4 {
    margin-bottom: 10px;
    color: #2a5298;
}

#tricksWonDisplay {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 15px;
}

.tricks-won-item {
    padding: 10px 20px;
    background: white;
    border-radius: 5px;
    border: 2px solid #ddd;
}

.tricks-won-item strong {
    color: #2a5298;
}

/* Round End Phase */
#roundEndPhase {
    text-align: center;
}

.round-results {
    margin: 30px 0;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 10px;
}

.result-item {
    padding: 15px;
    margin: 10px 0;
    background: white;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-player {
    font-size: 18px;
    font-weight: bold;
}

.result-tricks {
    font-size: 16px;
    color: #666;
}

.result-score {
    font-size: 24px;
    font-weight: bold;
}

.result-score.positive {
    color: #f44336;
}

.result-score.negative {
    color: #4CAF50;
}

.result-score.zero {
    color: #666;
}

/* Game End Phase */
#gameEndPhase {
    text-align: center;
}

.final-results {
    margin: 30px 0;
}

.final-result-item {
    padding: 20px;
    margin: 15px 0;
    background: white;
    border-radius: 10px;
    border: 3px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.final-result-item.winner {
    background: #ffd700;
    border-color: #ffa500;
}

.final-result-place {
    font-size: 24px;
    font-weight: bold;
    color: #666;
}

.final-result-player {
    font-size: 22px;
    font-weight: bold;
}

.final-result-score {
    font-size: 32px;
    font-weight: bold;
    color: #2a5298;
}

/* Menu System */
.desktop-header {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 10px;
}

.desktop-header .menu-btn {
    position: static;
}

.menu-btn {
    width: 50px;
    height: 50px;
    background: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: all 0.3s;
}

.menu-btn.mobile-only {
    position: fixed;
    top: 20px;
    right: 20px;
    display: none;
}

.menu-btn.desktop-only {
    position: static;
    display: flex;
}

.menu-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.menu-btn span {
    width: 25px;
    height: 3px;
    background: #1e3c72;
    border-radius: 2px;
    transition: all 0.3s;
}

.side-menu {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 12px rgba(0,0,0,0.2);
    z-index: 99;
    transition: right 0.3s;
    overflow-y: auto;
    padding: 80px 30px 30px 30px;
}

.side-menu.active {
    right: 0;
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 98;
    display: none;
}

.menu-overlay.active {
    display: block;
}

.menu-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e8e8e8;
}

.menu-section:last-child {
    border-bottom: none;
}

.menu-section h3 {
    color: #1e3c72;
    margin-bottom: 15px;
    font-size: 18px;
}

.menu-info-item {
    margin-bottom: 15px;
}

.menu-info-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.menu-info-value {
    font-size: 16px;
    font-weight: bold;
    color: #1e3c72;
}

.menu-players {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.menu-player-item {
    padding: 10px;
    background: #f5f5f5;
    border-radius: 5px;
    font-size: 14px;
}

.menu-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-save,
.btn-rules,
.btn-back-games,
.btn-leave {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-save {
    background: #28a745;
    color: white;
}

.btn-save:hover {
    background: #218838;
}

.btn-rules {
    background: #2a5298;
    color: white;
}

.btn-rules:hover {
    background: #1e3c72;
}

.btn-back-games {
    background: #6c757d;
    color: white;
}

.btn-back-games:hover {
    background: #5a6268;
}

.btn-leave {
    background: #dc3545;
    color: white;
}

.btn-leave:hover {
    background: #c82333;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    max-height: 80vh;
    width: 90%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px;
    background: #1e3c72;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    opacity: 0.8;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-body h3 {
    color: #1e3c72;
    margin-top: 20px;
    margin-bottom: 10px;
}

.modal-body h3:first-child {
    margin-top: 0;
}

.modal-body ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.modal-body li {
    margin-bottom: 8px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .desktop-header {
        display: none;
    }

    .menu-btn.desktop-only {
        display: none;
    }

    .menu-btn.mobile-only {
        display: flex;
    }

    .contract-grid {
        /* Keep grid layout on mobile */
        grid-template-columns: auto repeat(4, 1fr);
        gap: 3px;
        font-size: 10px;
    }

    .contract-header {
        padding: 3px;
        font-size: 10px;
    }

    .player-row-label {
        padding: 4px;
        font-size: 10px;
    }

    .contract-cell {
        padding: 4px;
        min-height: 25px;
        font-size: 14px;
    }

    .trump-choices {
        grid-template-columns: repeat(2, 1fr);
    }

    .trump-btn {
        padding: 30px 15px;
        font-size: 36px;
    }

    .hand-cards {
        gap: 2px;
    }

    .face-up-cards {
        gap: 5px;
        padding: 10px;
    }

    .side-menu {
        width: 100%;
        right: -100%;
    }
}
