/* Grundlegende Stile und Variablen */
:root {
    --primary-color: #108B72;
    --primary-hover-color: #0d6e5a;
    --secondary-color: #10b981;
    --text-color: #e5e7eb;
    --light-text-color: #9ca3af;
    --surface-color: rgba(31, 41, 55, 0.5); /* Semi-transparent dark surface */
    --border-color: rgba(255, 255, 255, 0.1);
    --success-color: #10b981;
    --error-color: #ef4444;
    --font-family: 'Poppins', sans-serif;
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --border-radius: 16px;
}

@keyframes gradient-animation {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

body {
    font-family: var(--font-family);
    background-color: #111827; /* Fallback */
    background-image: radial-gradient(circle at top left, #374151, #111827 50%);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
}

#app-container {
    width: 100%;
    max-width: 800px;
    background: var(--surface-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    padding: 40px;
    box-sizing: border-box;
}

header {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin-bottom: 40px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
    position: relative;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(90deg, #fdfbfb, #ebedee);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.back-button {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    padding: 8px 12px;
    line-height: 1;
}

.button {
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.button:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.back-button:hover {
    transform: translateY(-50%) scale(1.1);
}

.button.primary-button {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}
.button.primary-button:hover {
    background-color: var(--primary-hover-color);
    border-color: var(--primary-hover-color);
}

.button.filter-button.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.sub-nav {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 30px;
    width: 100%;
}

.home-title {
    text-align: center;
    margin-bottom: 40px;
    font-size: 2.2rem;
    font-weight: 600;
    color: var(--text-color);
}

.mode-selection-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
}

.mode-select-button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 20px;
    animation: button-fade-in 0.5s ease-out backwards;
}

.mode-select-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

.button-icon {
    width: 40px;
    height: 40px;
    color: var(--primary-color);
}
.button-icon svg {
    width: 100%;
    height: 100%;
}
.button-text {
    display: flex;
    flex-direction: column;
}

.button-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 4px;
}

.button-description {
    font-size: 0.9rem;
    color: var(--light-text-color);
}

.dictionary-controls, #anagram-trainer-view, #definition-trainer-view, #dictionary-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 20px;
}

#word-search {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    background: rgba(0,0,0,0.2);
    color: var(--text-color);
}
#word-search::placeholder {
    color: var(--light-text-color);
}

#word-list {
    list-style-type: none;
    padding: 0;
    width: 100%;
    text-align: left;
    background: rgba(0,0,0,0.1);
    border-radius: var(--border-radius);
    overflow: hidden;
}

#word-list li {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

#word-list li:last-child {
    border-bottom: none;
}

#word-list strong {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
}

.word-definition {
    font-size: 0.95rem;
    color: var(--light-text-color);
    margin-top: 5px;
    display: inline-block;
}

.letter-tiles-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.letter-tile {
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(145deg, #374151, #1f2937);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.letter-tile:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 15px rgba(0,0,0,0.4);
}

.letter-tile.used {
    background: #1f2937;
    color: #6b7280;
    cursor: not-allowed;
    opacity: 0.6;
}

.progress-container {
    width: 100%;
    height: 8px;
    background-color: rgba(0,0,0,0.3);
    border-radius: 4px;
    overflow: hidden;
}

#progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary-color), #34d399);
    transition: width 0.5s ease-in-out;
    border-radius: 4px;
}

#progress-text {
    text-align: center;
    font-size: 0.9rem;
    color: var(--light-text-color);
    margin-bottom: 20px;
}

.input-container {
    position: relative;
    width: 100%;
    max-width: 400px;
}

#word-input {
    width: 100%;
    padding: 12px 40px 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 1.1rem;
    box-sizing: border-box;
    background: rgba(0,0,0,0.2);
    color: var(--text-color);
}

.clear-button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--secondary-color);
    cursor: pointer;
}

.game-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

#timer {
    font-size: 1rem;
    color: var(--secondary-color);
    font-weight: 600;
}

.filter-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

#found-words-container {
    width: 100%;
    margin-top: 20px;
}

#found-words-container h3 {
    text-align: center;
    margin-bottom: 10px;
}

#found-words-list, #wc-found-words-list {
    list-style-type: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.found-word-item {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 1rem;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s;
}

.found-word-item:hover {
    background-color: #dee2e6;
}

.definition-box, .definition-answer-box {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: var(--border-radius);
    text-align: center;
    font-size: 1.2rem;
    color: var(--text-color);
    width: 100%;
    min-height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.definition-answer-box {
    border-style: dashed;
    min-height: 60px;
    color: var(--secondary-color);
    gap: 10px; /* Add gap for tiles */
}

.score-counter {
    display: flex;
    justify-content: center;
    gap: 20px;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 15px;
}

.score-correct {
    color: var(--success-color);
}

.score-incorrect {
    color: var(--error-color);
}

#virtual-keyboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 600px;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.keyboard-key {
    flex-grow: 1;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px 5px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.keyboard-key:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.keyboard-key.special {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

#feedback-message {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px); /* Start outside */
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 15px 30px;
    border-radius: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 1001;
    font-size: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s;
}

#feedback-message.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

#feedback-message.success {
    background: linear-gradient(90deg, var(--success-color), #34d399);
}

#feedback-message.error {
    background: linear-gradient(90deg, var(--error-color), #f87171);
}

#feedback-message.info {
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
}


.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal.hidden {
    display: none;
}

.modal-box {
    background: var(--surface-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: slide-in 0.3s ease-out;
}

@keyframes slide-in {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-out-up {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.view-active {
    animation: fade-in-up 0.4s ease-out forwards;
}

.view-hiding {
    animation: fade-out-up 0.3s ease-in forwards;
}

.hidden {
    display: none !important;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.modal-close:hover,
.modal-close:focus {
    color: var(--text-color);
    text-decoration: none;
}

#back-to-home {
    opacity: 1;
    transition: opacity 0.3s ease;
}

#back-to-home.hiding {
    opacity: 0;
}

.modal {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0.3s;
}

.modal.hiding {
    opacity: 0;
    visibility: hidden;
}

@keyframes button-fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mode-select-button {
    /* ... existing styles ... */
    animation: button-fade-in 0.5s ease-out backwards;
}

.mode-select-button:nth-child(1) { animation-delay: 0.1s; }
.mode-select-button:nth-child(2) { animation-delay: 0.2s; }
.mode-select-button:nth-child(3) { animation-delay: 0.3s; }


/* Ensure definition text inside a toast is readable */
#feedback-message .word-definition {
    color: rgba(255, 255, 255, 0.9);
    font-style: italic;
    font-size: 0.9em;
    display: block;
    margin-top: 5px;
}


.input-display-box {
    border: 2px dashed var(--border-color);
    min-height: 74px; /* Ensures consistent height (tile 50px + padding 2*10px) */
    padding: 10px;
    border-radius: var(--border-radius);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    width: 100%;
    max-width: 400px;
    box-sizing: border-box;
}

.placeholder-text {
    color: var(--light-text-color);
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%; /* Ensure it doesn't overflow its container */
}


.letter-controls-container {
    display: flex;
    align-items: center;
    gap: 20px;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

.input-controls-container {
    display: flex;
    align-items: stretch; /* Align items to have the same height */
    gap: 10px;
    width: 100%;
    justify-content: center;
}

.letter-tiles-container {
    flex-grow: 1;
}

.letter-actions, .input-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.icon-button {
    padding: 10px;
    width: 48px;
    height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.icon-button svg {
    width: 24px;
    height: 24px;
}

.input-display-box {
    flex-grow: 1;
    max-width: none; /* Override previous max-width */
}

.input-actions {
    flex-direction: row; /* Override for horizontal buttons */
    align-items: stretch;
}
/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    #app-container {
        padding: 20px;
    }

    header h1 {
        font-size: 2rem;
    }

    .button-title {
        font-size: 1.2rem;
    }

    .letter-tile {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
        border-radius: 8px;
    }

    .keyboard-key {
        padding: 12px 4px;
        font-size: 1rem;
    }
    
    .input-controls-container {
        width: 100%;
    }
    #anagram-trainer-view .input-display-box {
        height: 64px; /* 40px tile + 2*10px padding + 2*2px border */
    }
    #word-chain-trainer-view .input-display-box {
        height: 64px; /* 40px tile + 2*10px padding + 2*2px border */
    }
    .letter-actions {
        order: 3; /* Move actions below tiles */
        width: 100%;
        justify-content: center;
        flex-direction: row;
    }
    .sub-nav {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.8rem;
    }

    .mode-selection-container {
        grid-template-columns: 1fr;
    }

    .letter-tile {
        width: 35px;
        height: 35px;
        font-size: 1.3rem;
    }

    #anagram-trainer-view .input-display-box {
        height: 59px; /* 35px tile + 2*10px padding + 2*2px border */
    }
    #word-chain-trainer-view .input-display-box {
        height: 59px; /* 35px tile + 2*10px padding + 2*2px border */
    }

    .keyboard-key {
        padding: 10px 3px;
        font-size: 0.9rem;
    }
}

