:root {
    --primary-color: #2563eb;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-color: #1f2937;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: background-color 0.3s, color 0.3s;
}

/* --- RESET FÜR FORMULAR-ELEMENTE --- */
button, input, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* --- DARK MODE --- */
body.dark-mode {
    --bg-color: #111827;
    --card-bg: #1f2937;
    --text-color: #f9fafb;
}
body.dark-mode .mod-info, body.dark-mode .config-card, body.dark-mode .help-card { background-color: #374151; color: #f9fafb; }
body.dark-mode .refresh-btn { background-color: #374151; border-color: #4b5563; color: #60a5fa; }
body.dark-mode .refresh-btn:disabled { background-color: #1f2937; border-color: #374151; color: #4b5563; }
body.dark-mode .help-btn { background-color: #374151; color: #d1d5db; }
body.dark-mode .help-btn:active { background-color: #4b5563; }
body.dark-mode .level-badge.lvl-1 { background: #374151; color: #d1d5db; }
body.dark-mode .task-header, body.dark-mode .config-header { border-color: #374151; }
body.dark-mode .label { color: #9ca3af; }
body.dark-mode .config-text-input { background: #374151; color: white; border-color: #4b5563; }
body.dark-mode .add-config-btn { background: #374151; color: #d1d5db; border-color: #4b5563; }
body.dark-mode .add-config-btn:hover { background-color: #4b5563; }
body.dark-mode .config-section h3, body.dark-mode .help-card h3 { color: #60a5fa; border-bottom-color: #374151; }
body.dark-mode .add-zusatz-btn { background-color: #064e3b; border-color: #065f46; color: #a7f3d0; }
body.dark-mode .add-zusatz-btn:disabled { background-color: #1f2937; border-color: #374151; color: #4b5563; }
body.dark-mode .cost-hint { color: #6b7280; }

body.dark-mode .finale-ruin-box { background: rgba(0,0,0,0.4); border-color: #e11d48; }
body.dark-mode .finale-ruin-box.safe { background: rgba(6,78,59,0.4); border-color: #059669; }
body.dark-mode .finale-check-info { background: rgba(0,0,0,0.5); color: #fda4af; }
body.dark-mode .sexy-ruin-text { color: #f43f5e; }
body.dark-mode .finale-title { color: #f43f5e; text-shadow: 2px 2px 4px rgba(0,0,0,0.8); }

/* MODAL STYLES FÜR IMPORT/EXPORT & AUFNAHME */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    padding: 20px;
}
.modal-box {
    background-color: var(--card-bg);
    padding: 24px;
    border-radius: 12px;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    color: var(--text-color);
}
.modal-textarea {
    width: 100%;
    height: 180px;
    margin: 15px 0;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.85rem;
    box-sizing: border-box;
    background-color: var(--bg-color);
    color: var(--text-color);
    resize: vertical;
}
body.dark-mode .modal-box { background-color: #1f2937; border: 1px solid #374151; }
body.dark-mode .modal-textarea { background-color: #111827; border-color: #4b5563; }
.modal-input-number { width: 100%; padding: 10px; margin: 15px 0; border-radius: 8px; border: 1px solid #d1d5db; font-size: 1rem; box-sizing: border-box; }
body.dark-mode .modal-input-number { background-color: #111827; border-color: #4b5563; color: white; }

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

/* --- ANIMATION --- */
@keyframes popIn {
    0% { opacity: 0; transform: translateY(10px) scale(0.98); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
.animate-pop {
    animation: popIn 0.35s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

.main-btn {
    width: 100%;
    padding: 18px;
    font-size: 1.1rem;
    font-weight: bold;
    color: white;
    background-color: var(--primary-color);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    transition: transform 0.1s, background-color 0.2s;
}

.main-btn:active {
    background-color: #1d4ed8;
    transform: translateY(2px);
}
.btn-record-action { background-color: #dc2626; }
.btn-record-action:active { background-color: #b91c1c; }

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.top-icons {
    display: flex;
    gap: 15px;
}

.top-actions {
    display: flex;
    gap: 10px;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    margin: 0;
    transition: transform 0.2s;
}

.icon-btn:active { transform: scale(0.9); }

.help-btn {
    background-color: #e5e7eb;
    color: #4b5563;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: background-color 0.2s;
}

.help-btn:active { background-color: #d1d5db; }
.btn-record-trigger { color: #dc2626; border: 1px solid #fecaca; background-color: #fef2f2; }
body.dark-mode .btn-record-trigger { background-color: #450a0a; border-color: #7f1d1d; color: #fca5a5; }

.finale-btn {
    background-color: #7c3aed;
    margin-top: 20px;
    margin-bottom: 40px;
}

.nav-buttons {
    display: flex;
    gap: 12px;
    margin-top: 30px;
}

.btn-back { background-color: #4b5563; }
.btn-end { background-color: #dc2626; }
.btn-save { background-color: #059669; }

/* --- AUFNAHME-BANNER --- */
.record-banner {
    background-color: #fee2e2;
    color: #b91c1c;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    margin-bottom: 20px;
    border: 1px solid #f87171;
    animation: pulse 2s infinite;
}
body.dark-mode .record-banner {
    background-color: #7f1d1d;
    color: #fecaca;
    border-color: #991b1b;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.8; }
    100% { opacity: 1; }
}

/* --- NORMALE UI STYLES --- */
.task-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    line-height: 1.6;
}

.joker-container {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.joker-btn {
    flex: 1;
    padding: 14px 10px;
    font-size: 1rem;
    font-weight: bold;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-action { background-color: #f59e0b; }
.btn-extreme { background-color: #dc2626; }
.joker-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(100%);
    font-size: 14px;
}

.level-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 12px;
}
.lvl-1 { background: #e5e7eb; color: #374151; }
.lvl-2 { background: #fef3c7; color: #b45309; border: 1px solid #fcd34d; }
.lvl-3 { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

.task-header {
    font-size: 1.1rem;
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.mod-info {
    background-color: #f3f4f6;
    padding: 8px;
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 16px;
}

.task-row {
    margin-bottom: 12px;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    min-height: 38px;
}

.label {
    font-weight: 600;
    color: #4b5563;
    margin-right: 6px;
}

.refresh-btn {
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
    color: var(--primary-color);
    border-radius: 8px;
    width: 38px;
    height: 38px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    margin-right: 12px;
    flex-shrink: 0;
    transition: transform 0.2s ease-out;
}

.refresh-btn:active:not(:disabled) { transform: rotate(180deg); }

.refresh-btn:disabled {
    background-color: #f3f4f6;
    border-color: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
    transform: none !important;
}

.zusatz-content { flex: 1; display: flex; flex-direction: column; }
.add-zusatz-wrapper { display: flex; align-items: center; margin-top: 6px; }
.add-zusatz-btn {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s;
}
.add-zusatz-btn:active:not(:disabled) { transform: scale(0.95); }
.add-zusatz-btn:disabled {
    background-color: #f9fafb;
    border-color: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
}

.cost-hint { font-size: 0.75rem; color: #6b7280; margin-left: 6px; font-weight: normal; }
.refresh-btn svg { width: 20px; height: 20px; }
.no-btn-spacer { width: 50px; flex-shrink: 0; }

/* --- FINALE UI STYLES --- */
.finale-title {
    text-align: center;
    font-size: 3rem;
    font-family: 'Georgia', serif;
    font-style: italic;
    color: #881337;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(254, 205, 211, 0.8);
    letter-spacing: 1px;
}

.finale-ruin-box {
    background: rgba(255, 255, 255, 0.6);
    border: 2px dashed #fda4af;
    padding: 16px;
    border-radius: 16px;
    margin: 20px 0;
    text-align: center;
}

.finale-ruin-box.safe { border-color: #a7f3d0; background: rgba(240, 253, 244, 0.7); }

.finale-check-info {
    font-size: 0.9rem;
    color: #881337;
    margin-bottom: 15px;
    text-align: left;
    background: rgba(255,255,255,0.8);
    padding: 12px;
    border-radius: 12px;
    line-height: 1.5;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.sexy-ruin-text {
    font-size: 1.2rem;
    font-family: 'Georgia', serif;
    font-style: italic;
    color: #be123c;
    display: block;
    margin: 15px 0;
    font-weight: bold;
}

.strikethrough {
    text-decoration: line-through;
    color: #9ca3af !important;
    font-size: 1.1rem;
    display: block;
    margin: 15px 0;
    font-weight: bold;
}

.sexy-gnade-btn {
    background-color: #fda4af;
    color: #881337;
    border: none;
    border-radius: 20px;
    padding: 10px;
    font-weight: bold;
    width: 100%;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(159, 18, 57, 0.1);
}
.sexy-gnade-btn:active { background-color: #fb7185; }

.gnade-granted {
    display: block;
    color: #f43f5e;
    font-weight: bold;
    font-style: italic;
    margin-top: 5px;
    font-size: 1.1rem;
}

/* --- KONFIG & HILFE STYLES --- */
.help-card, .config-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    line-height: 1.6;
    color: var(--text-color);
}

.help-card h2, .config-card h2 { color: var(--primary-color); margin-top: 0; }
.help-card h3 { color: #4b5563; border-bottom: 1px solid #e5e7eb; padding-bottom: 5px; margin-top: 20px;}
.help-card ul { padding-left: 20px; }
.help-card li { margin-bottom: 8px; }

.config-actions-top {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px dashed #d1d5db;
}

.config-section { margin-bottom: 25px; }

.config-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 10px;
    padding-bottom: 4px;
}
.config-header h3 {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
    color: var(--primary-color);
}
.active-count {
    font-size: 0.85rem;
    color: #6b7280;
    font-weight: normal;
}

.config-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 5px;
}

.config-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.delete-config-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: #ef4444;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    transition: color 0.2s;
    margin-top: 3px;
}
.delete-config-btn:hover {
    color: #dc2626;
}

.config-text-input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    overflow: hidden;
    height: 38px;
    box-sizing: border-box;
    transition: height 0.25s ease, background-color 0.2s, border-color 0.2s;
    line-height: 1.4;
    appearance: none;
    -webkit-appearance: none;

    /* Input-Look im inaktiven Zustand */
    white-space: nowrap;
    text-overflow: ellipsis;
}

.config-text-input:focus {
    height: 110px;
    overflow-y: auto;
    resize: vertical;
    outline: 2px solid var(--primary-color);
    outline-offset: -1px;

    /* Textarea-Look beim Editieren */
    white-space: pre-wrap;
}

.add-config-btn {
    background-color: #f3f4f6;
    border: 1px dashed #9ca3af;
    color: #4b5563;
    width: 100%;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
    font-family: inherit;
    font-size: 0.95rem;
}
.add-config-btn:hover { background-color: #e5e7eb; }

.name-input {
    width: 100% !important;
    box-sizing: border-box !important;
    height: 40px !important;
    white-space: normal !important;
}

.name-input:focus {
    width: 100% !important;
    height: 40px !important;
    white-space: normal !important;
    resize: none !important;
}
/* --- TEILEN BUTTON --- */
.share-task-btn {
    position: absolute;
    top: -2px;
    right: 0;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.1s;
}

.share-task-btn:hover {
    opacity: 1;
}

.share-task-btn:active {
    transform: scale(0.9);
}

/* --- TOAST MELDUNG --- */
#toast-msg {
    visibility: hidden;
    min-width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 12px 20px;
    position: fixed;
    z-index: 1000;
    left: 50%;
    transform: translateX(-50%);
    bottom: 30px;
    font-size: 0.95rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out, bottom 0.3s ease-in-out;
}

#toast-msg.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px; /* Leichter Slide-Up-Effekt */
}

/* Anpassung für Dark Mode */
body.dark-mode #toast-msg {
    background-color: var(--primary-color);
}

/* --- MEILENSTEIN MELDUNG --- */
#milestone-msg {
    visibility: hidden;
    min-width: 280px;
    max-width: 90%;
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    color: #ffffff;
    text-align: center;
    border-radius: 12px;
    padding: 15px 20px;
    position: fixed;
    z-index: 2500;

    /* Zentrierung */
    left: 50%;
    top: 50%;

    /* Leichter Offset nach unten für den Einfade-Effekt */
    transform: translate(-50%, -40%);

    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out, transform 0.5s ease-in-out;
}

#milestone-msg.show {
    visibility: visible;
    opacity: 1;
    /* Exakt zentriert im sichtbaren Zustand */
    transform: translate(-50%, -50%);
}

/* Optional: Goldenes Leuchten im Dark Mode */
body.dark-mode #milestone-msg {
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.4);
}

/* --- STATISTIKEN & KARTEN --- */
.stat-card {
    background-color: var(--card-bg);
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
body.dark-mode .stat-card {
    border-color: #374151;
}
.stat-header {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 5px;
    font-weight: bold;
}
body.dark-mode .stat-header {
    border-color: #4b5563;
    color: #9ca3af;
}
.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
    margin-bottom: 6px;
}
.stat-row:last-child { margin-bottom: 0; }
.stat-val { font-weight: bold; }

/* --- BEWERTUNGS-MODAL --- */
.rating-group {
    margin-bottom: 20px;
}
.rating-label {
    display: block;
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 0.95rem;
}
.radio-row {
    display: flex;
    justify-content: space-between;
}
.radio-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.85rem;
    cursor: pointer;
}
.radio-item input { margin-bottom: 4px; cursor: pointer; }
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    font-size: 0.95rem;
    margin-bottom: 25px;
    cursor: pointer;
}
.checkbox-row input {
    width: 20px;
    height: 20px;
    cursor: pointer;
}
.link-stats {
    text-align: center;
    margin-top: 10px;
    margin-bottom: 30px;
}
.link-stats a {
    color: var(--primary-color);
    font-size: 0.95rem;
    text-decoration: underline;
    cursor: pointer;
}
body.dark-mode .link-stats a {
    color: #60a5fa;
}
/* --- EINZELNEN STATISTIK-EINTRAG LÖSCHEN --- */
.stat-card {
    position: relative; /* Wichtig, damit das x absolut in der Karte platziert werden kann */
}

.delete-stat-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: #ef4444; /* Dezentes Rot */
    font-size: 1.4rem;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: transform 0.2s, color 0.2s;
}

.delete-stat-btn:active {
    transform: scale(0.9);
}

body.dark-mode .delete-stat-btn {
    color: #f87171; /* Etwas helleres Rot für den Dark Mode */
}

#milestone-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.7); /* Dunkelt den Hintergrund ab */
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
#milestone-overlay.show {
    opacity: 1;
    pointer-events: all;
}
.milestone-box {
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    color: white;
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    max-width: 90%;
    transform: scale(0.8);
    transition: transform 0.3s ease;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    margin: 0 10px;
    box-sizing: border-box;
}
#milestone-overlay.show .milestone-box {
    transform: scale(1);
}

/* --- AKTIVER JOKER HERVORHEBUNG --- */
.joker-btn.active-joker {
    opacity: 1 !important; /* Hebt die Transparenz des 'disabled'-Status auf */
    box-shadow: 0 0 12px currentColor; /* Leuchteffekt in der Farbe des Buttons */
    transform: scale(1.02); /* Lässt den Button minimal größer wirken */
    border: 2px solid #fff;
    cursor: default !important; /* Zeigt, dass er aktuell nicht mehr klickbar ist */
}

/* Optional: Anpassung des Rahmens für den Dark-Mode */
body.dark-mode .joker-btn.active-joker {
    border-color: #f9fafb;
}

/* --- CHAOS-GÖTTIN MODUS --- */
body.chaos-active {
    --primary-color: #9333ea; /* Lila/Violett Theme */
}

body.chaos-active .top-bar,
body.chaos-active .task-header {
    border-color: #d8b4fe;
}

body.chaos-active .refresh-btn {
    background-color: #faf5ff;
    border-color: #e9d5ff;
}

body.dark-mode.chaos-active .refresh-btn {
    background-color: #3b0764;
    border-color: #581c87;
    color: #c084fc;
}

.chaos-banner {
    background: linear-gradient(90deg, #9333ea, #c084fc);
    color: white;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(147, 51, 234, 0.3);
    animation: pulseChaos 2s infinite;
}

@keyframes pulseChaos {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); box-shadow: 0 4px 12px rgba(147, 51, 234, 0.5); }
    100% { transform: scale(1); }
}
