html {
    margin: 0;
    padding: 0;
    height: 100%;
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #333;
    /* Hintergrundfarbe wird per JS gesetzt */
    background-color: #fff; /* Fallback */
    transition: background-color 0.5s cubic-bezier(0.4,0.2,0.2,1);
}
body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    height: 100%;
    width: 100vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    box-sizing: border-box;
}
.setup {
    display: flex;
    flex-direction: column;
    align-items: center;
}
h1 {
    margin-bottom: 1rem;
}
textarea {
    width: 300px;
    height: 120px;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 0.5rem;
    font-size: 16px;
    margin-bottom: 1rem;
    resize: none;
}
button {
    padding: 0.5rem 1rem;
    font-size: 16px;
    border: none;
    border-radius: 0.5rem;
    background-color: #4f46e5;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
}
button:hover {
    background-color: #4338ca;
}
.controls {
    margin-top: 1rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
}
.controls input[type="radio"] {
    display: none;
}
.controls label {
    background-color: #e5e7eb;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    font-weight: bold;
}
.controls input[type="radio"]:checked + label {
    background-color: #4f46e5;
    color: white;
    transform: scale(1.05);
}
#mainGameContainer {
    flex: 1 1 auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100vw;
    min-height: 0;
    padding: 0 2vw;
    box-sizing: border-box;
}
.hide{
    display: none !important;
}
#wordDisplay {
    background: none;
    border: none;
    padding: 0;
    display: flex;
    align-items: center; /* Vertikal zentrieren */
    justify-content: center;
    min-height: 12vh;
    height: auto;
    margin-bottom: 24px;
    width: 100%;
    max-width: 100vw;
}
#currentWord {
    color: #4f46e5;
    letter-spacing: 0.2em;
    font-size: 5rem;
    font-weight: bold;
    text-align: center;
    line-height: 1.1;
    max-width: 100vw;
    overflow-x: auto;
}
#currentWord.shake {
    animation: shake-horizontal 0.35s cubic-bezier(.36,.07,.19,.97) both;
}
@keyframes shake-horizontal {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-8px); }
    40%, 60% { transform: translateX(8px); }
    100% { transform: translateX(0); }
}
@media (max-width: 600px) {
  #currentWord {
    font-size: 2.2rem;
    letter-spacing: 0.12em;
  }
}
#grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 18px;
    width: 100%;
    max-width: 650px;
    height: auto;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    box-sizing: border-box;
}
.tile {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 4vmin;
    font-weight: bold;
    color: white;
    border-radius: 0.5rem;
    background-color: grey;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.2s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    aspect-ratio: 1 / 1;
    user-select: none;
    /* Die Box-Shadow-Farbe wird per JS gesetzt */
    will-change: transform;
    perspective: 400px;
}
.tile.flipping {
    animation: tile-flip 0.4s cubic-bezier(0.4,0.2,0.2,1);
}


@keyframes tile-flip {
    0% {
        transform: rotateY(0deg);
    }
    40% {
        transform: rotateY(90deg);
    }
    60% {
        transform: rotateY(90deg);
    }
    100% {
        transform: rotateY(0deg);
    }
}
#wordStatsContainer {
    font-size: 2.2rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
}
#wordStatsContainer span {
    padding: 6px 22px;
    border-radius: 12px;
    font-size: 2.2rem;
    min-width: 48px;
    box-sizing: border-box;
    display: inline-block;
    font-weight: bold;
}
#wordStatsContainer .orange-score {
    background: #ffb347;
    color: #fff;
    box-shadow: 0 2px 8px rgba(255,152,0,0.15);
}
#wordStatsContainer .blue-score {
    background: #00cfff;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,164,217,0.15);
}

/* Game Over Screen Styles */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#gameOverContainer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6); /* Transparenter Hintergrund */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 2rem;
    box-sizing: border-box;
    animation: fadeIn 0.5s ease-in-out;
}

#gameOverContainer h1 {
    color: white;
    margin-bottom: 2rem;
    font-size: 3.5rem;
    text-align: center;
}

#gameOverScoreBox {
    background-color: rgb(60, 34, 34); /* Vollständig schwarzer Hintergrund */
    border-radius: 1rem;
    padding: 2rem 3rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    width: 80%;
    max-width: 500px;
    scale: 1.1;
    color: white;
}

#gameOverResults {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    font-size: 3rem;
}

.gameOverOrangeScore, .gameOverBlueScore {
    padding: 0.5rem 1.5rem;
    color: white;
    border-radius: 0.5rem;
    font-weight: bold;
    min-width: 3rem;
    text-align: center;
}

.gameOverOrangeScore {
    background-color: #ff8800;
}

.gameOverBlueScore {
    background-color: #00a4d9;
}

#gameOverWinner {
    color: white;
    font-size: 1.8rem;
    text-align: center;
    padding: 1rem;
}

#gameOverWinner.orange-win {
    color: #ffb347;
}

#gameOverWinner.blue-win {
    color: #4fc3f7;
}

#gameOverWinner.tie {
    color: #f5f5f5;
}

#restartGameButton {
    background-color: #4bb37d;
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 0.7rem;
    font-size: 1.5rem;
    margin-top: 2rem;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transition: transform 0.2s, background-color 0.2s;
}

#restartGameButton:hover {
    background-color: #42a06f;
    transform: scale(1.05);
}

