/* --- START OF FILE style.css (COMPLETE AND CORRECTED) --- */

:root {
    --bg-color: #1a1a2e;
    --primary-color: #16213e;
    --secondary-color: #0f3460;
    --accent-color: #e94560;
    --text-color: #e0e0e0;
    --card-bg: #2c3e50;
    --card-border: #34495e;
    --card-back-bg: linear-gradient(135deg, #e94560, #a93247);
    --font-family: 'Roboto', sans-serif;
    --border-radius: 8px;
    --card-aspect-ratio: 2 / 3;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    background-image: radial-gradient(circle, #1e2a47, var(--bg-color) 70%);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 1200px;
    padding: 1rem;
    min-height: 100vh;
}

.screen.active {
    display: flex;
}

/* --- Language Selector --- */
#language-selector {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 10;
}

.lang-btn {
    padding: 0.5rem 0.8rem;
    border: 1px solid var(--secondary-color);
    background-color: rgba(26, 33, 62, 0.8);
    color: var(--text-color);
    width: auto;
    font-size: 0.9rem;
    opacity: 0.7;
    transition: all 0.3s;
}

.lang-btn:hover {
    opacity: 1;
    transform: translateY(-2px);
    background-color: var(--secondary-color);
}

.lang-btn.active {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    opacity: 1;
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.5);
}

/* --- Home & Lobby Screen --- */
.form-container, #lobby-screen, #post-round-screen {
    background: linear-gradient(145deg, #1a2a45, #131f35);
    padding: 2rem;
    border-radius: 16px;
    width: 90%;
    max-width: 450px;
    text-align: center;
    border: 1px solid var(--secondary-color);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3), inset 0 1px 1px rgba(255,255,255,0.05);
}

#lobby-screen p {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1.1rem;
}

#lobby-game-id {
    background: var(--bg-color);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 1.4rem;
    font-weight: bold;
    letter-spacing: 2px;
    border: 1px dashed var(--secondary-color);
}

#join-game-id {
    text-transform: uppercase;
}

#copy-game-id-button {
    background: var(--secondary-color);
    border: none;
    color: var(--text-color);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    width: auto;
    transition: background-color 0.2s, transform 0.2s;
}

#copy-game-id-button:hover {
    background: var(--accent-color);
    transform: scale(1.1);
}

h1, h2 {
    color: var(--accent-color);
    margin-bottom: 1rem;
}

.input-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
}

input[type="text"] {
    width: 100%;
    padding: 0.8rem 1rem;
    /* margin-bottom: 1rem; - removed, now on wrapper */
    border-radius: var(--border-radius);
    border: 1px solid var(--secondary-color);
    background-color: #1a1a2e;
    color: var(--text-color);
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
    padding-right: 3.5rem; /* Space for counter */
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.5);
}

.char-count {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    color: #888;
    pointer-events: none;
    transition: color 0.3s;
}

input[type="text"]:focus + .char-count {
    color: var(--accent-color);
}

input::placeholder {
    color: #888;
}

button {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    background-color: var(--accent-color);
    color: white;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s, box-shadow 0.3s;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

button:disabled {
    background-color: #555;
    cursor: not-allowed;
}

button:hover:not(:disabled) {
    background-color: #ff5777;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

hr {
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--secondary-color), transparent);
    margin: 2rem 0;
}

#player-list {
    list-style: none;
    margin: 1.5rem 0;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

#player-list li {
    background: var(--secondary-color);
    padding: 1rem 0.5rem;
    border-radius: 8px;
    font-weight: 500;
    border: 1px solid #0f3460;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: transform 0.2s, box-shadow 0.2s;
}

#player-list li:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

#npc-controls {
    margin-top: 1.5rem;
}

.npc-counter {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    background: var(--bg-color);
    padding: 0.5rem;
    border-radius: 8px;
    width: fit-content;
    margin: 0.5rem auto 0;
}

.npc-counter button {
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

#npc-count {
    font-size: 1.5rem;
    font-weight: bold;
    min-width: 30px;
}

.lobby-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
    width: 100%;
}

/* --- Game Screen --- */
#game-screen {
    display: none;
    gap: 1rem;
    width: 100vw;
    min-height: 100vh;
    overflow-y: auto;
    padding: 0.5rem;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
        "opponents"
        "main"
        "player";
    position: relative;
}

#game-screen.active {
    display: grid;
}

#leave-game-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: auto;
    padding: 0.4rem 0.8rem;
    background-color: var(--secondary-color);
    font-size: 0.9rem;
    border: 1px solid var(--accent-color);
    z-index: 50;
}
#leave-game-button:hover {
    background-color: var(--accent-color);
}


#opponents-area {
    grid-area: opponents;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    align-items: center;
}

.opponent {
    text-align: center;
    border-radius: var(--border-radius);
    padding: 0.5rem;
    transition: box-shadow 0.3s, opacity 0.3s, filter 0.3s;
}
.opponent-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}
.opponent .card {
    width: 30px;
    font-size: 0.6rem;
}

.opponent.is-disconnected {
    opacity: 0.4;
    filter: grayscale(80%);
}

#main-game-area {
    grid-area: main;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    padding: 1.5rem 0;
}

.pile-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.card-pile {
    position: relative;
    width: 90px;
    height: 135px;
    border-radius: 6px;
}

.card-pile .card-stack-item {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 6px;
    background: var(--card-back-bg);
    border: 1px solid rgba(0,0,0,0.7);
    box-shadow: 0 2px 5px rgba(0,0,0,0.4), inset 0 0 1px 1px rgba(255,255,255,0.1);
    transition: transform 0.3s ease-out;
    left: 0;
    top: 0;
}

#draw-pile, #discard-pile {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
#draw-pile:hover, #discard-pile:hover,
#draw-pile:focus-visible, #discard-pile:focus-visible {
    transform: scale(1.05);
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-color);
    outline: 2px solid var(--accent-color);
}

#draw-pile.pile-inactive:hover,
#discard-pile.pile-inactive:hover {
    transform: none;
    cursor: default;
    box-shadow: none;
}


#draw-pile .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
}
#draw-pile-count {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.8rem;
}

#player-area-wrapper {
    grid-area: player;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    transition: box-shadow 0.3s;
}

#player-area {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 300px;
    width: 100%;
    padding: 1rem;
    background-color: var(--secondary-color);
    border-radius: var(--border-radius);
}

.is-current-player {
    box-shadow: 0 0 15px 5px cyan;
}

/* --- Player Status Effects --- */
.is-round-ender {
    animation: pulse-gold 2s infinite;
}

@keyframes pulse-gold {
    0% { box-shadow: 0 0 12px 4px gold; }
    50% { box-shadow: 0 0 20px 10px gold; }
    100% { box-shadow: 0 0 12px 4px gold; }
}

.score-is-doubled {
    animation: pulse-red 1s infinite;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 12px 4px var(--accent-color); }
    50% { box-shadow: 0 0 25px 12px var(--accent-color); }
    100% { box-shadow: 0 0 12px 4px var(--accent-color); }
}

.score-is-safe {
    animation: pulse-green 1.5s infinite;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 12px 4px #2ecc71; }
    50% { box-shadow: 0 0 20px 10px #2ecc71; }
    100% { box-shadow: 0 0 12px 4px #2ecc71; }
}


.action-source {
    box-shadow: 0 0 12px 4px gold;
}

/* --- Card Styling --- */
.card {
    aspect-ratio: var(--card-aspect-ratio);
    border-radius: 6px;
    perspective: 1000px;
    background-color: transparent;
    border: none;
    position: relative;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
.card.clickable:hover,
.card.clickable:focus-visible {
    transform: scale(1.05) translateY(-5px);
    cursor: pointer;
    outline: 2px solid var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color);
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}
.card.face-up .card-inner {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 1.5rem;
}
.card-back {
    background: var(--card-back-bg);
}
.card-front {
    background-color: var(--card-bg);
    border: 2px solid var(--card-border);
    transform: rotateY(180deg);
}

/* Card Colors */
[data-color="HELLGRUEN"] { background-color: #a7e9af; color: #1a1a2e; }
[data-color="DUNKELGRUEN"] { background-color: #4b8f51; color: #e0e0e0; }
[data-color="GELB"] { background-color: #f7e01b; color: #1a1a2e; }
[data-color="ROT"] { background-color: #c70039; color: #e0e0e0; }
[data-color="MAGENTA"] { background-color: #c300c3; color: #e0e0e0; }
[data-color="ORANGE"] { background-color: #ff7b00; color: #e0e0e0; }
[data-color="DUNKELBLAU"] { background-color: #1a237e; color: #e0e0e0; }
[data-color="CYAN"] { background-color: #00bcd4; color: #1a1a2e; }

.card.hilo-option {
    box-shadow: 0 0 15px 5px #ffd700;
    cursor: pointer;
}

.card.hilo-highlight {
    box-shadow: 0 0 20px 8px #00e5ff;
    transform: scale(1.1);
}

/* --- Action Prompt & Notifications --- */
#action-prompt {
    grid-area: main;
    justify-self: center;
    align-self: center;
    z-index: 100;

    width: 90%;
    max-width: 500px;
    background: var(--primary-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 2px solid var(--accent-color);
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}
#action-prompt .card { width: 60px; }
#action-prompt button { 
    width: auto; 
    padding: 0.5rem 1rem; 
}

#action-prompt button.selected {
    background-color: #0f3460;
    border: 2px solid #00e5ff;
}

#notification-area {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.notification {
    background-color: rgba(15, 52, 96, 0.95);
    color: var(--text-color);
    padding: 12px 24px;
    border-radius: 24px;
    border: 1px solid var(--secondary-color);
    animation: fade-in-out 4s ease-in-out forwards;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.notification.success {
    border-color: #2ecc71;
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.2);
}
.notification.success::before {
    content: '\2714';
    color: #2ecc71;
    font-size: 1.2em;
}

.notification.error {
    border-color: var(--accent-color);
    box-shadow: 0 0 15px rgba(233, 69, 96, 0.2);
}
.notification.error::before {
    content: '\26A0';
    color: var(--accent-color);
    font-size: 1.2em;
}

.notification.info {
    border-color: #3498db;
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.2);
}
.notification.info::before {
    content: '\2139';
    color: #3498db;
    font-size: 1.2em;
}

@keyframes fade-in-out {
    0% { opacity: 0; transform: translateY(-20px); }
    15% { opacity: 1; transform: translateY(0); }
    85% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-20px); }
}


/* --- Post-Round Screen --- */
#post-round-screen {
    max-width: 600px;
    /* The rest of the styling is inherited from the .form-container group */
}
#score-table {
    width: 100%;
    margin-top: 1.5rem;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden; /* Ensures the border-radius is applied to the corners */
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

#score-table th, #score-table td {
    padding: 0.8rem 1rem;
    text-align: left;
    border-bottom: 1px solid #1e2a47;
}

#score-table th {
    background-color: var(--secondary-color);
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: bold;
}

#score-table tr:nth-child(even) {
    background-color: rgba(0,0,0,0.1);
}

#score-table tr:last-child td {
    border-bottom: none;
}

#score-table tr:hover {
    background-color: rgba(233, 69, 96, 0.1);
    cursor: default;
}
#winner-announcement:not(:empty) {
    margin-top: 2rem;
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--accent-color);
    padding: 1rem;
    background-color: rgba(0,0,0,0.2);
    border-radius: 8px;
    text-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
#next-round-button {
    margin-top: 2rem;
}

.score-doubled-indicator {
    color: var(--accent-color);
    font-size: 0.9em;
    font-weight: bold;
    margin-left: 0.5rem;
}


.hidden {
    display: none !important;
}

/* --- Countdown Overlay --- */
#countdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 1rem;
    pointer-events: none;
}

#countdown-overlay.hidden {
    display: none !important;
}

#countdown-timer {
    font-size: 4rem;
    color: var(--accent-color);
    font-weight: bold;
    text-shadow: 0 0 10px var(--bg-color), 0 0 5px var(--bg-color);
}

/* --- Desktop Layout --- */
@media (min-width: 768px) {
    #game-screen {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        grid-template-areas:
            "opponents"
            "main"
            "player";
        padding: 1rem;
        gap: 1rem; /* Add a gap between the rows */
    }

    #opponents-area {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }
    .opponent .card {
        width: 50px;
        font-size: 1rem;
    }

    #player-area {
        max-width: 300px;
    }

    .card-face {
        font-size: 2.5rem;
    }
    
    .card-pile {
        width: 120px;
        height: 180px;
    }
}

/* --- FUNDAMENTALES LAYOUT für alle schmalen Bildschirme (Handy-Hochformat) --- */
@media (max-width: 600px) {

    /* 1. Das Haupt-Grid wird von 3x1 auf 2x2 umgestellt */
    #game-screen {
        align-content: center; /* Zentriert die Grid-Zeilen vertikal */
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        grid-template-areas:
            "opponents opponents"
            "main      player";
        gap: 0;
        padding: 0.5rem;
    }
    
    /* 2. Gegner-Bereich anpassen */
    #opponents-area {
        margin-bottom: 1rem;
    }

    /* 3. Stapel-Bereich (links unten) anpassen */
    #main-game-area {
        padding: 0;
        flex-direction: column;
        justify-content: center;
        gap: 1.5rem;
    }

    .card-pile {
        width: 85px;
        height: 127.5px;
    }
    
    /* 4. Spieler-Grid (rechts unten) anpassen */
    #player-area-wrapper {
        justify-content: center;
        padding: 0;
    }

    #player-area {
        max-width: 200px;
        padding: 0.5rem;
        gap: 5px;
    }

    /* Kleinere Karten im Spieler-Grid, damit die Zahlen lesbar bleiben */
    #player-area .card-face {
        font-size: 1.2rem;
    }
}

.input-label {
    display: block;
    text-align: left;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-weight: bold;
}

/* --- Palette UX Improvements --- */

/* Success state for copy button */
#copy-game-id-button.success {
    background-color: #2ecc71; /* Green */
    transform: scale(1.1);
    box-shadow: 0 0 10px #2ecc71;
}

/* Ensure focus outline is visible when we programmatically focus headings */
h1[tabindex="-1"]:focus,
h2[tabindex="-1"]:focus,
h3[tabindex="-1"]:focus,
.screen[tabindex="-1"]:focus {
    outline: none; /* Remove default outline to avoid visual noise */
}

/* ...but maybe keep it for keyboard users? */
/* Actually, for headings, usually we don't want a visual ring if it's just for context shift. */
/* But let's make sure it's not totally invisible if it lands on something interactive */
