/**
 * Bayerisches Schafkopf - Komplettes Stylesheet
 * ALLE STYLES: Basis + Ass-Auswahl-Erweiterungen
 */

/* === RESET UND BASIS === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #2c5530, #1a3d1f);
    color: white;
    min-height: 100vh;
    overflow-x: hidden;
}

/* === HEADER === */
.header {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    text-align: center;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.game-info {
    display: flex;
    justify-content: center;
    gap: 30px;
    font-size: 1.1em;
    margin-top: 10px;
}

.game-info > div {
    padding: 5px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

/* === HAUPTSPIELBEREICH === */
.game-area {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    min-height: calc(100vh - 200px);
    gap: 30px;
}

.players {
    position: relative;
    width: 70vw;
    height: 70vh;
    max-width: 800px;
    max-height: 600px;
    display: grid;
    grid-template-areas: 
        "cpu1 cpu2 cpu3"
        "center center center"
        "human human human";
    grid-template-rows: 1fr 1fr 1fr;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    flex-shrink: 0;
}

/* === SPIELER-LAYOUTS === */
.player {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    backdrop-filter: blur(10px);
}

.player.active {
    border-color: #3b82f6;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
    animation: pulse 2s infinite;
}

.player h3 {
    font-size: 1.3em;
    margin-bottom: 10px;
    text-align: center;
}

.player-info {
    display: flex;
    gap: 15px;
    font-size: 0.9em;
    margin: 5px 0;
}

.player-info > div {
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

/* Spieler-Positionierung */
.cpu1 {
    grid-area: cpu1;
    justify-self: start;
}

.cpu2 {
    grid-area: cpu2;
    justify-self: center;
}

.cpu3 {
    grid-area: cpu3;
    justify-self: end;
}

.human {
    grid-area: human;
    justify-self: center;
}

.center-area {
    grid-area: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    padding: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

/* === KARTEN === */
.cards {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    margin-top: 10px;
    position: relative;
}

.card {
    width: 45px;
    height: 65px;
    background: linear-gradient(145deg, #f0f0f0, #d0d0d0);
    border: 2px solid #888;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8em;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Karten mit Bildern */
.card-image-container {
    background: transparent;
    padding: 0;
    overflow: hidden;
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

/* Fallback für kaputte Bilder */
.card-image-container.fallback {
    background: linear-gradient(145deg, #f0f0f0, #d0d0d0);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8em;
    color: #333;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.card-back {
    background: linear-gradient(145deg, #8b4513, #654321);
    color: #ffd700;
    font-size: 1.2em;
}

.suit-symbol {
    font-size: 1.1em;
    margin-bottom: 2px;
}

/* Kartenfarben */
.card.red {
    color: #dc2626;
}

.card.green {
    color: #16a34a;
}

/* Spielbare Karten */
.card.playable {
    cursor: pointer;
    transform: translateY(-5px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    border-color: #22c55e;
}

.card.playable:hover {
    transform: translateY(-8px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
    border-color: #16a34a;
}

/* Trump-Karten */
.card.trump {
    border: 2px solid #fbbf24;
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

/* === TRUMP-INFO === */
.trump-info {
    text-align: center;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.trump-info > div {
    margin: 5px 0;
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
}

#called-ace {
    font-weight: bold;
    font-size: 1.2em;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.2);
}

/* === SPIELSTATUS === */
.game-status {
    text-align: center;
    font-size: 1.2em;
    padding: 10px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    margin: 10px 0;
    transition: all 0.3s ease;
}

/* === STICH-ANZEIGE === */
.trick-card {
    position: relative;
    margin: 0 5px;
    transition: all 0.3s ease;
}

.trick-card.completed-trick {
    opacity: 0.8;
    filter: grayscale(20%);
}

.trick-card.completed-trick .card {
    border: 2px solid #fbbf24;
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

.trick-area {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 120px;
    margin: 20px auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.trick-card {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.trick-card .card {
    transform: scale(0.9);
    /* Animation entfernt - keine Dreh-Animation mehr */
}

/* Erste Karte leicht hervorheben */
.trick-card:first-child .card {
    border: 2px solid #fbbf24;
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.6);
}

/* Animation entfernt - keine Dreh-Animation mehr
@keyframes cardPlay {
    from {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
    to {
        transform: scale(0.9) rotate(0deg);
        opacity: 1;
    }
}
*/

/* === BEDIENELEMENTE === */
.controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 200px;
    align-self: flex-start;
    position: sticky;
    top: 20px;
}

.btn {
    padding: 12px 24px;
    background: linear-gradient(145deg, #4a7c59, #357a3a);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn:hover {
    background: linear-gradient(145deg, #5a8c69, #4a8a4a);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

/* Debug-Button aktiv */
.debug-active {
    background: #f59e0b !important;
    color: white !important;
}

/* Card-Images-Button aktiv */
.images-active {
    background: #10b981 !important;
    color: white !important;
}

/* === MODAL === */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(145deg, #2a4a2e, #1e3d22);
    margin: 5% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    border: 2px solid #4a7c59;
    color: white;
    text-align: center;
}

.modal-content h2 {
    color: #66bb6a;
    margin-bottom: 15px;
    font-size: 1.8em;
}

.modal-content p {
    line-height: 1.6;
    margin-bottom: 20px;
    white-space: pre-line;
}

/* === DEBUG-MODUS === */
.debug-mode .card-back {
    display: none;
}

.debug-mode .player.cpu .cards .card {
    opacity: 0.9;
}

/* === ASS-AUSWAHL INLINE (unter Spielerkarten) === */

.ace-selection-container {
    margin-top: 15px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    border: 2px solid #66bb6a;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ace-selection-prompt {
    text-align: center;
    margin-bottom: 15px;
}

.ace-selection-prompt strong {
    color: #66bb6a;
    font-size: 1.1em;
    display: block;
    margin-bottom: 5px;
}

.ace-selection-help {
    font-size: 0.9em;
    color: #a5d6a7;
    line-height: 1.3;
}

.ace-selection-buttons-inline {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ace-btn-inline {
    background: linear-gradient(145deg, #4a7c59, #357a3a) !important;
    border: 2px solid #66bb6a !important;
    padding: 10px 15px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 14px !important;
    min-width: 120px;
}

.ace-btn-inline:hover {
    background: linear-gradient(145deg, #5a8c69, #4a8a4a) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.ace-symbol {
    font-size: 16px;
}

.ace-name {
    font-weight: bold;
}

.cancel-btn-inline {
    background: linear-gradient(145deg, #666, #555) !important;
    border: 2px solid #777 !important;
    color: #ddd !important;
    padding: 10px 15px !important;
    font-size: 14px !important;
}

.cancel-btn-inline:hover {
    background: linear-gradient(145deg, #777, #666) !important;
    transform: translateY(-2px);
}

/* === ASS-AUSWAHL ERWEITERUNGEN (Modal - fallback) === */

/* Ass-Auswahl Buttons im Modal */
.ace-selection-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin: 20px 0;
}

.ace-btn {
    padding: 15px !important;
    font-size: 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    background: linear-gradient(145deg, #4a7c59, #357a3a) !important;
    border: 2px solid #66bb6a !important;
    transition: all 0.3s ease !important;
}

.ace-btn:hover {
    background: linear-gradient(145deg, #5a8c69, #4a8a4a) !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

/* === CONTINUE-BUTTON NACH STICH === */
.continue-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 20px;
    border-radius: 15px;
    border: 2px solid #3b82f6;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 100;
    min-width: 250px;
    animation: fadeInScale 0.3s ease-out;
}

.continue-status {
    margin-bottom: 15px;
    font-size: 1.2em;
    color: #fbbf24;
}

.btn-continue {
    background: linear-gradient(145deg, #3b82f6, #2563eb);
    border: none;
    color: white;
    padding: 12px 24px;
    font-size: 1.1em;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    min-width: 200px;
}

.btn-continue:hover {
    background: linear-gradient(145deg, #2563eb, #1d4ed8);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(59, 130, 246, 0.4);
}

.btn-continue:active {
    transform: translateY(0);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.4);
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* === TEAM-MARKIERUNGEN === */
.player.teammate {
    border: 2px solid #4ade80;
    background: rgba(74, 222, 128, 0.1);
}

.player.opponent {
    border: 2px solid #f87171;
    background: rgba(248, 113, 113, 0.1);
}

.player.teammate::before {
    content: "👥";
    position: absolute;
    top: -5px;
    right: -5px;
    background: #4ade80;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    z-index: 10;
}

.player.opponent::before {
    content: "🔥";
    position: absolute;
    top: -5px;
    right: -5px;
    background: #f87171;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    z-index: 10;
}

/* === TOAST-NACHRICHTEN === */
#toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
    max-width: 300px;
    word-wrap: break-word;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* === ANIMATIONEN === */

/* Spielerwechsel-Animation */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

/* CPU-Denk-Animation */
.player.cpu.active .cards::after {
    content: "🤔";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2em;
    animation: thinking 1s infinite;
}

@keyframes thinking {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Gewinnende Karte hervorheben - SPEZIFISCHER für nur Trick-Karten */
.trick-card.trick-winner .card {
    border: 3px solid #ffffff !important;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.8), 0 0 40px rgba(255, 255, 255, 0.6) !important;
    animation: trickWinnerGlow 2s ease-in-out infinite alternate;
}

/* Sicherstellen dass nur Karten in Trick-Area den Glow bekommen */
.trick-area .trick-card.trick-winner .card {
    border: 3px solid #ffffff !important;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.8), 0 0 40px rgba(255, 255, 255, 0.6) !important;
}

@keyframes trickWinnerGlow {
    from {
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.8), 0 0 40px rgba(255, 255, 255, 0.6);
    }
    to {
        box-shadow: 0 0 30px rgba(255, 255, 255, 1), 0 0 60px rgba(255, 255, 255, 0.8);
    }
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2em;
    }
    
    .game-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .game-area {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    
    .players {
        width: 95vw;
        height: 60vh;
        grid-template-areas: 
            "cpu2"
            "cpu1 cpu3"
            "center"
            "human";
        grid-template-rows: auto auto 1fr auto;
        grid-template-columns: 1fr 1fr;
    }
    
    .center-area {
        grid-column: 1 / -1;
    }
    
    .human {
        grid-column: 1 / -1;
    }
    
    .card {
        width: 35px;
        height: 50px;
        font-size: 0.7em;
    }
    
    .controls {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        min-width: auto;
        position: static;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 0.9em;
    }
    
    .ace-selection-buttons {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .ace-btn {
        padding: 12px !important;
        font-size: 14px !important;
    }
    
    .continue-container {
        min-width: 200px;
        padding: 15px;
    }
    
    .btn-continue {
        min-width: 160px;
        font-size: 1em;
        padding: 10px 16px;
    }
    
    .player.teammate::before,
    .player.opponent::before {
        width: 16px;
        height: 16px;
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .game-area {
        padding: 10px;
    }
    
    .player {
        padding: 10px;
    }
    
    .card {
        width: 30px;
        height: 42px;
        font-size: 0.6em;
    }
    
    .modal-content {
        margin: 10% auto;
        padding: 20px;
        width: 95%;
    }
}