:root {
    --bg-color: #0f0c29;
    --bg-gradient: linear-gradient(to bottom, #302b63, #24243e, #0f0c29);
    --text-color: #ffffff;
    --primary-color: #ff007f;
    --secondary-color: #00d2ff;
    --glass-bg: rgba(80, 76, 76, 0.4);
    --glass-border: rgba(255, 255, 255, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

html,
body {
    height: 100%;
}

body {
    background: var(--bg-gradient);
    color: var(--text-color);
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#app {
    width: 100%;
    max-width: 600px;
    height: 100vh;
    height: 100dvh;
    max-height: 900px;
    background: url('../img/bg_dark.png') no-repeat left center, var(--glass-bg);
    background-size: min(50%, 250px) auto, cover;
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.screen {
    display: none;
    flex-direction: column;
    height: 100%;
    width: 100%;
    padding: 20px;
    overflow-y: auto;
}

.screen.active {
    display: flex;
}

/* --- OVERLAY SCREENS (Hide Tabs) --- */
.overlay-screen {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-gradient);
    z-index: 100;
    padding: 20px;
    overflow-y: auto;
}

.overlay-screen.active {
    display: flex;
}

/* --- TAB NAVIGATION SYSTEM --- */
#tab-system {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

#tab-views {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
}

.tab-content {
    display: none;
    flex-direction: column;
}

.tab-content.active {
    display: flex;
}

#main-nav {
    display: flex;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    border-top: 1px solid var(--glass-border);
}

.nav-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-color);
    padding: 15px 5px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    opacity: 0.6;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.nav-btn.active {
    opacity: 1;
    color: var(--secondary-color);
    border-top: 3px solid var(--secondary-color);
}

/* --- GENERIC COMPONENTS --- */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

h1,
h2 {
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Settings Form */
.settings {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.settings label {
    font-weight: bold;
    color: var(--secondary-color);
}

select,
input[type="range"] {
    padding: 10px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    outline: none;
}

select option {
    background: #24243e;
}

.primary-btn {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 15px;
    border-radius: 10px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 20px;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 0, 127, 0.4);
}

#btn-open-vocab-manager {
    background: linear-gradient(45deg, #ff8c00, #ff007f);
    margin-top: 20px;
    margin-bottom: 25px;
    animation: attentionPulseBtn 2s infinite alternate;
}

@keyframes attentionPulseBtn {
    0% {
        box-shadow: 0 0 10px rgba(255, 140, 0, 0.3);
    }

    100% {
        box-shadow: 0 0 20px rgba(255, 0, 127, 0.7);
    }
}

/* Game Area */
#game-header {
    display: flex;
    justify-content: space-between;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--glass-border);
    font-size: 0.9rem;
    font-weight: bold;
}

#game-area {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    border-left: 2px solid var(--glass-border);
    border-right: 2px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
}

.falling-word {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background: var(--secondary-color);
    color: #000;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

.stacked-block {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 30px;
    background: rgba(255, 0, 0, 0.5);
    border-top: 2px solid red;
    transition: bottom 0.3s;
}

#game-footer {
    display: flex;
    justify-content: space-around;
    padding-top: 10px;
    border-top: 2px solid var(--glass-border);
    gap: 10px;
}

.option-btn {
    flex: 1;
    padding: 15px 5px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.option-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Results Table */
#results-table-container {
    max-height: 350px;
    overflow-y: auto;
    margin-top: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th,
td {
    padding: 10px;
    border-bottom: 1px solid var(--glass-border);
    text-align: left;
}

.error-row {
    color: #ff4d4d;
    background: rgba(255, 0, 0, 0.1);
}

/* Error List Specific Styles */
#errors-table-container {
    background: #ffffff;
    color: #000000;
    border-radius: 10px;
    padding: 10px;
    margin-top: 15px;
}

#errors-table-container th {
    color: #000000;
    border-bottom: 2px solid #aaaaaa;
}

#errors-table-container td {
    color: #000000;
    border-bottom: 1px solid #eeeeee;
}

#errors-table-container p {
    color: #000000;
}

/* Vokabel-Manager Styles */
textarea {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    outline: none;
    resize: vertical;
    font-size: 14px;
}

#manage-lists-container,
#play-lists-container {
    overflow-x: auto;
    width: 100%;
}

#manage-lists-container table {
    margin-top: 10px;
    min-width: 320px; /* Sicherstellen, dass die Tabelle auf ganz kleinen Displays nicht crasht, sondern scrollt */
}

#manage-lists-container th,
#manage-lists-container td {
    padding: 6px;
    font-size: 13px;
    white-space: nowrap; /* Tasten und Bezeichner nicht unglücklich umbrechen */
}

#edit-list-words-container table {
    margin-top: 0;
}

#edit-list-words-container th,
#edit-list-words-container td {
    padding: 8px;
}

#vocab-manager-detail input[type="text"] {
    padding: 10px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    outline: none;
    flex: 1;
    min-width: 0;
}

/* Gamification & Juice */

.particle {
    position: absolute;
    width: 6px;
    height: 6px;
    background-color: var(--primary-color);
    border-radius: 50%;
    pointer-events: none;
    transition: transform 0.6s ease-out, opacity 0.6s ease-out;
    z-index: 50;
}

.combo-text {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    font-size: 2.5rem;
    font-weight: 900;
    color: #ffd700;
    text-shadow: 0 0 10px #ff8c00, 0 0 20px #ff0000;
    pointer-events: none;
    opacity: 0;
    z-index: 100;
    animation: comboPop 1.5s forwards;
}

@keyframes comboPop {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }

    20% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }

    80% {
        transform: translate(-50%, -100%) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -150%) scale(1);
        opacity: 0;
    }
}

.shake {
    animation: shakeAnim 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shakeAnim {

    10%,
    90% {
        transform: translate3d(-2px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(4px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-8px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(8px, 0, 0);
    }
}

.boss-word {
    background: linear-gradient(45deg, #ff0000, #ff8c00);
    color: white;
    box-shadow: 0 0 15px #ff0000;
    animation: pulseBoss 0.5s infinite alternate;
}

@keyframes pulseBoss {
    0% {
        transform: translateX(-50%) scale(1);
    }

    100% {
        transform: translateX(-50%) scale(1.15);
        box-shadow: 0 0 25px #ff0000;
    }
}

/* Flashcard Training Camp */
.flashcard-container {
    background-color: transparent;
    width: 100%;
    height: 250px;
    perspective: 1000px;
    margin: 0 auto;
    cursor: pointer;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flashcard-container.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    background: linear-gradient(135deg, var(--secondary-color), #3a7bd5);
    color: white;
}

.flashcard-back {
    background: linear-gradient(135deg, var(--primary-color), #ff8c00);
    transform: rotateY(180deg);
}

.swipe-left {
    animation: swipeLeftAnim 0.5s forwards;
}

.swipe-right {
    animation: swipeRightAnim 0.5s forwards;
}

@keyframes swipeLeftAnim {
    to {
        transform: translateX(-150vw) rotate(-20deg);
        opacity: 0;
    }
}

@keyframes swipeRightAnim {
    to {
        transform: translateX(150vw) rotate(20deg);
        opacity: 0;
    }
}

.particle-train {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #00ff00;
    border-radius: 50%;
    pointer-events: none;
    transition: transform 0.8s cubic-bezier(.2, .8, .3, 1), opacity 0.8s ease-out;
    z-index: 200;
}

/* ── Schreib-Trainer ── */
#writing-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

#writing-word-display {
    width: 100%;
    text-align: center;
    font-size: 2.4rem;
    font-weight: 900;
    padding: 28px 20px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--secondary-color), #3a7bd5);
    color: #fff;
    letter-spacing: 1px;
    box-shadow: 0 6px 24px rgba(0, 210, 255, 0.35);
    transition: background 0.4s;
}

#writing-word-display.correct {
    background: linear-gradient(135deg, #00c853, #69f0ae);
    box-shadow: 0 6px 24px rgba(0, 200, 83, 0.5);
    animation: popCorrect 0.4s ease-out;
}

#writing-word-display.wrong {
    background: linear-gradient(135deg, #d50000, #ff6d00);
    box-shadow: 0 6px 24px rgba(213, 0, 0, 0.5);
    animation: shakeAnim 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes popCorrect {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.06); }
    100% { transform: scale(1); }
}

#writing-feedback {
    width: 100%;
    text-align: center;
    font-size: 1.1rem;
    font-weight: bold;
    padding: 12px;
    border-radius: 10px;
    transition: opacity 0.3s;
}

.writing-feedback-hidden {
    opacity: 0;
    pointer-events: none;
}

.writing-feedback-correct {
    opacity: 1;
    color: #69f0ae;
    background: rgba(0, 200, 83, 0.15);
    border: 1px solid rgba(0, 200, 83, 0.4);
}

.writing-feedback-wrong {
    opacity: 1;
    color: #ff6d6d;
    background: rgba(213, 0, 0, 0.15);
    border: 1px solid rgba(213, 0, 0, 0.4);
}

#writing-input-area {
    width: 100%;
    display: flex;
    flex-direction: column;
}

#writing-input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 10px;
    border: 2px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.12);
    color: white;
    font-size: 1.2rem;
    outline: none;
    transition: border-color 0.2s;
    text-align: center;
}

#writing-input:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(0, 210, 255, 0.2);
}