/******************************************************
 * 1. Grund-Variablen & Themes
 ******************************************************/
:root {
    --primary-gradient: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    --secondary-gradient: linear-gradient(135deg, #3a3a3a 0%, #505050 100%);
    --accent-gradient: linear-gradient(135deg, #4a4a4a 0%, #5a5a5a 100%);
    --gold-gradient: linear-gradient(135deg, #9ca3af 0%, #d4af37 50%, #c0c0c0 100%);
    --christmas-gradient: linear-gradient(135deg, #ff6b6b 0%, #ffd93d 50%, #6bcf7f 100%);
    --shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    --shadow-hover: 0 12px 35px rgba(0, 0, 0, 0.7);
    --shadow-large: 0 15px 45px rgba(0, 0, 0, 0.8);
    --border-radius: 12px;
    --border-radius-large: 20px;
    --transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

:root.light {
    --primary-gradient: linear-gradient(135deg, #eaf2fb 0%, #dbe2ec 100%);
    --secondary-gradient: linear-gradient(135deg, #ffffff 0%, #e3f1f7 100%);
    --accent-gradient: linear-gradient(135deg, #eaf6fc 0%, #bde4fa 100%);
    --gold-gradient: linear-gradient(135deg, #fbecc0 0%, #ffe082 50%, #fffbe7 100%);
    --christmas-gradient: linear-gradient(135deg, #fffbe7 0%, #ffd93d 50%, #fbecc0 100%);
    --shadow: 0 8px 25px rgba(90, 130, 170, 0.18);
    --shadow-hover: 0 12px 35px rgba(90, 130, 170, 0.28);
    --shadow-large: 0 15px 45px rgba(90, 130, 170, 0.28);
    --border-radius: 12px;
    --border-radius-large: 20px;
    --transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/******************************************************
 * 2. Basis-Layout & Hintergrund
 ******************************************************/
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Futura', 'Tahoma', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

html {
    height: 100%;
    background-attachment: fixed;
}

body {
    background-attachment: fixed;
    background-color: #1a1a1a; /* Fallback Farbe für Dark Mode */
    min-height: 100%;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height für mobile Browser */
    padding: 20px;
    margin: 0;
    overflow-x: hidden;
    width: 100%;
    overscroll-behavior-y: none;
}

:root.light html {
    background-color: #eaf2fb !important; /* Fallback Farbe für Light Mode */
    background: var(--primary-gradient) !important;
    background-attachment: fixed !important;
}
:root.light body {
    background-color: #eaf2fb !important; /* Fallback Farbe für Light Mode */
    background-attachment: fixed !important;
}

.background-decoration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}
.bg-circle {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    animation: float 8s ease-in-out infinite;
}
.bg-circle:nth-child(1) {
    width: 250px;
    height: 250px;
    top: 5%;
    left: 5%;
    animation-delay: 0s;
}
.bg-circle:nth-child(2) {
    width: 180px;
    height: 180px;
    top: 70%;
    right: 5%;
    animation-delay: 3s;
}
.bg-circle:nth-child(3) {
    width: 120px;
    height: 120px;
    top: 25%;
    right: 25%;
    animation-delay: 6s;
}
@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-25px) rotate(180deg); }
}

/******************************************************
 * 3. Header & Steuerung
 ******************************************************/
.container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    animation: slideUp 0.8s ease-out;
}

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

.header {
    text-align: center;
    margin-bottom: 40px;
}

.header-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.lang-btn, .theme-btn, .back-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 8px;
    padding: 6px 16px;
    font-size: 1.13rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.17s, color 0.15s;
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    box-shadow: none;
    min-height: 38px;
    line-height: 1.1;
    text-decoration: none;
    outline: none;
}

.lang-btn:hover, .theme-btn:hover, .back-btn:hover {
    background: rgba(255,255,255,0.28);
    color: #fff;
}

.lang-btn.active {
    background: #ffe082 !important;
    color: #222 !important;
}

/* Titel (mit Farbverlauf im Dark Mode, einfarbig im Light Mode) */
.title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 700;
    background: linear-gradient(135deg, #ffffff, #f0f8ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    text-shadow: 0 4px 8px rgba(0,0,0,0.3);
}
.subtitle {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 300;
    margin-bottom: 20px;
}

/******************************************************
 * 4. Kalender, Türen, Zahlen, Emojis
 ******************************************************/
.calendar-container {
    max-width: 1000px;
    margin: 0 auto;
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 24px;
    padding: 8px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    width: 100%;
}
.door {
    position: relative;
    perspective: 1000px;
    cursor: pointer;
    transition: var(--transition);
    border-radius: var(--border-radius);
    overflow: hidden;
    aspect-ratio: 1;
}
.door.regular { grid-column: span 1; grid-row: span 1; }
.door.special { grid-column: span 2; grid-row: span 2; z-index: 10; }

.door-inner {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}
.door-front, .door-back {
    position: absolute;
    width: 100%; height: 100%;
    backface-visibility: hidden;
    border-radius: var(--border-radius);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    box-shadow: var(--shadow);
}
.door.special .door-front,
.door.special .door-back {
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-large);
}
.door-front {
    background: linear-gradient(135deg, #4a4a4a 0%, #e0e0e0 100%);
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    font-size: 2.2rem;
}
.door.special .door-front {
    background: linear-gradient(135deg, #3a3a3a 0%, #f0f0f0 100%);
    font-size: 4.5rem;
    border: 3px solid rgba(255, 255, 255, 0.3);
}
.door.has-thumbnail .door-front {
    background: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 0;
    display: flex; align-items: center; justify-content: center;
    position: relative;
}
.door.special.has-thumbnail .door-front { padding: 0; }
.thumbnail-preview {
    width: 100%; height: 100%; object-fit: cover;
    border-radius: var(--border-radius);
}
.door.special .thumbnail-preview {
    border-radius: var(--border-radius-large);
}
.day-number-with-thumb {
    position: absolute; bottom: 8px; right: 8px;
    background: rgba(0, 0, 0, 0.4);
    padding: 4px 8px; border-radius: 6px;
    backdrop-filter: blur(4px);
}
.day-number-text {
    font-size: 1.2rem;
    color: #ffffff;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}
.door.special .day-number-with-thumb {
    bottom: 12px; right: 12px; padding: 8px 16px; border-radius: 10px;
}
.door.special .day-number-text { font-size: 2.5rem; }
.door-front::before {
    content: '';
    position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transition: left 0.5s;
}
body.highlight-enabled .door:hover .door-front::before { left: 100%; }
.door-emoji {
    position: absolute; font-size: 5em; opacity: 0.15;
    filter: grayscale(1) brightness(1.5);
    z-index: 1; pointer-events: none;
}
.door.special .door-emoji { font-size: 8em; }
.door-front .day-number {
    position: relative; z-index: 2;
    text-shadow: 0 3px 6px rgba(0,0,0,0.3);
}
.door.special .day-number {
    text-shadow: 0 5px 10px rgba(0,0,0,0.4);
    font-weight: 800;
}

/* Türen-Rückseite */
.door-back {
    background: #ffffff;
    transform: rotateY(180deg);
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.1);
}
.door.special .door-back { border: 3px solid rgba(255, 255, 255, 0.2); }
.door-back img {
    width: 100%; height: 100%; object-fit: cover;
    border-radius: calc(var(--border-radius) - 2px);
    transition: transform 0.3s ease;
}
.door.special .door-back img { border-radius: calc(var(--border-radius-large) - 3px); }

/* Türen-Zustände */
.door.opened { cursor: pointer; }
.door.opened:hover .door-back img { transform: scale(1.05); }
.door.opened:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}
.door.locked { cursor: not-allowed; }
.door.locked .door-front {
    background: linear-gradient(135deg, #4a4a4a 0%, #e0e0e0 100%);
    color: #ffffff;
}

/* Türen-Hover (nur bei Highlight) */
body.highlight-enabled .door:not(.locked):not(.opened):hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}
body.highlight-enabled .door.special:not(.locked):not(.opened):hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: var(--shadow-large);
}
body.highlight-enabled .door:not(.locked):not(.opened):hover .door-front {
    background: linear-gradient(135deg, #5a5a5a 0%, #f5f5f5 100%);
}
body.highlight-enabled .door.special:not(.locked):not(.opened):hover .door-front {
    background: linear-gradient(135deg, #4a4a4a 0%, #ffffff 100%);
}

/******************************************************
 * 5. Statusbar & Progressbar
 ******************************************************/
.status-bar {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius-large);
    padding: 20px;
    margin: 30px auto 0;
    max-width: 600px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.status-message {
    color: #ffffff;
    font-weight: 500;
    font-size: 1.1rem;
    margin-bottom: 10px;
}
.progress-bar {
    background: rgba(255,255,255,0.32);
    height: 14px;
    border-radius: 7px;
    overflow: hidden;
    margin-top: 18px;
    box-shadow: 0 2px 10px 0 rgba(120,160,200,0.07);
}
.progress-fill {
    height: 100%;
    border-radius: 7px;
    transition: width 0.6s cubic-bezier(.47,1.64,.41,.8);
    position: relative;
    box-shadow: 0 0 10px 2px #d4af3780, 0 0 1px 0 #fff;
    background: linear-gradient(90deg, #8a8a8a 0%, #d4af37 100%);
}

/******************************************************
 * 6. Modal, Notification, Snow
 ******************************************************/
.snow {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1000;
    transform-origin: center center;
    transition: transform 0.3s ease-out;
}
.snowflake {
    position: absolute;
    color: rgba(255, 255, 255, 0.7);
    user-select: none;
    pointer-events: none;
    animation: fall linear infinite;
    font-size: 1.1rem;
}
@keyframes fall {
    from { transform: translateY(-100vh) rotate(0deg); }
    to   { transform: translateY(100vh) rotate(360deg); }
}

.notification {
    position: fixed;
    top: 20px; right: 20px;
    background: var(--secondary-gradient);
    color: white;
    padding: 15px 25px;
    border-radius: var(--border-radius);
    font-weight: 500;
    box-shadow: var(--shadow);
    transform: translateX(400px);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2000;
}
.notification.show { transform: translateX(0); }
.notification.special {
    background: var(--christmas-gradient);
    font-size: 1.2rem;
    padding: 20px 30px;
}

.image-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center; justify-content: center;
    z-index: 5000;
    padding: 20px;
    cursor: pointer;
}
.image-modal.show { display: flex; }
.modal-content {
    max-width: 90%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--border-radius-large);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
    animation: modalZoom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes modalZoom {
    from { transform: scale(0.3); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}
.modal-close {
    position: absolute;
    top: 30px; right: 30px;
    width: 54px; height: 54px;
    display: flex; align-items: center; justify-content: center;
    font-size: 2.7rem;
    font-family: 'Arial Black', Arial, 'Segoe UI', sans-serif;
    font-weight: 900; line-height: 1;
    letter-spacing: 0;
    cursor: pointer;
    z-index: 5001;
    background: rgba(255,255,255,0.07);
    border-radius: 50%;
    border: none;
    box-shadow: 0 2px 16px rgba(0,0,0,0.10);
    transition: background 0.3s, transform 0.4s cubic-bezier(.47,1.64,.41,.8), color 0.2s;
    color: #fff;
    user-select: none;
    outline: none;
    text-align: center;
    padding: 0;
}
.modal-close:hover {
    background: rgba(255,255,255,0.16);
    transform: rotate(90deg) scale(1.08);
}

/******************************************************
 * 7. Light Theme – Spezielle Anpassungen
 ******************************************************/
:root.light,
:root.light body { color-scheme: light; }

/* HEADER */
:root.light .title {
    background: none !important;
    -webkit-background-clip: initial !important;
    -webkit-text-fill-color: initial !important;
    background-clip: initial !important;
    color: #234966 !important;
    text-shadow: 0 2px 4px rgba(200,210,255,0.12);
    filter: grayscale(1) brightness(0.4) sepia(1) hue-rotate(185deg) saturate(5) !important;
}
:root.light .subtitle {
    color: #395375 !important;
    text-shadow: none;
}

/* Türen & Zahlen */
:root.light .door-front {
    background: linear-gradient(135deg, #f8fafc 0%, #dbe5ef 100%) !important;
    color: #22304a !important;
    border: 2px solid #e3e9ef !important;
    box-shadow: var(--shadow);
}
:root.light .door.special .door-front {
    background: linear-gradient(135deg, #dbe5ef 0%, #fff 100%) !important;
    color: #22304a !important;
    border: 3px solid #e3e9ef !important;
}
:root.light .door.has-thumbnail .door-front,
:root.light .door.special.has-thumbnail .door-front {
    background: #f9f9fa !important;
    border: 2px solid #e3e9ef !important;
}
:root.light .door-back { background: #f4f9fd !important; border: 2px solid #e3e9ef !important; }
:root.light .door.special .door-back { border: 3px solid #e3e9ef !important; }
:root.light .day-number-with-thumb { background: rgba(220, 220, 255, 0.80); }
:root.light .day-number-text { color: #283560; text-shadow: 0 1px 1px #fff; }
:root.light .door-emoji { opacity: 0.10; filter: grayscale(0.2) brightness(1.2); }
:root.light .door.locked .door-front {
    background: linear-gradient(135deg, #dde5ed 0%, #f1f1f1 100%) !important;
    color: #b0b9c7 !important;
}
/* Zahlen auf allen nicht geöffneten Türen: subtil & einheitlich */
:root.light .door:not(.opened) .door-front .day-number {
    color: #234966 !important;
    opacity: 0.64 !important;
    text-shadow: 0 1px 8px #fff, 0 2px 10px #d5e6fa44;
    font-weight: 700;
    transition: color 0.3s, opacity 0.3s;
}
:root.light body.highlight-enabled .door:not(.opened):hover .door-front .day-number {
    color: #234966 !important;
    opacity: 1 !important;
    text-shadow: 0 2px 10px #bedcff;
    transition: color 0.2s, opacity 0.2s;
}

/* STATUSBAR & PROGRESSBAR */
:root.light .status-bar {
    background: rgba(240, 244, 248, 0.96) !important;
    color: #21324c;
    border: 1px solid #d2e1f2 !important;
}
:root.light .status-message { color: #21324c !important; }
:root.light .progress-bar {
    background: #e2f0fb;
    box-shadow: 0 2px 12px 0 #b9d6f640;
}
:root.light .progress-fill {
    background: linear-gradient(90deg, #d4af37 0%, #234966 100%) !important;
    box-shadow: 0 0 14px 2px #23496630, 0 0 1px 0 #fff;
    filter: brightness(0.96) contrast(1.17);
}

/* MODAL & CLOSE-X */
:root.light .image-modal { background: rgba(255,255,255,0.95) !important; }
:root.light .modal-content { box-shadow: 0 12px 45px rgba(80,120,200,0.13) !important; }
:root.light .modal-close {
    color: #234966 !important;
    background: rgba(225,235,255,0.93) !important;
    box-shadow: 0 2px 8px #b2c8e555;
    border: 1.5px solid #b3cde4;
}
:root.light .modal-close:hover {
    background: #dbe9fa !important;
    color: #0d2942 !important;
    border-color: #234966;
}

/* NOTIFICATION & BUTTONS */
:root.light .notification {
    background: var(--secondary-gradient) !important;
    color: #23355a !important;
}
:root.light .notification.special {
    background: var(--christmas-gradient) !important;
    color: #b57a0f !important;
}
:root.light .lang-btn,
:root.light .theme-btn,
:root.light .back-btn {
    background: rgba(100,130,200,0.07) !important;
    color: #234 !important;
    border: none;
}

:root.light .lang-btn.active {
    background: #ffe082 !important;
    color: #222 !important;
}

:root.light .lang-btn:hover,
:root.light .theme-btn:hover,
:root.light .back-btn:hover {
    background: rgba(60,140,230,0.16) !important;
    color: #1a2945 !important;
}

/* Hintergrund-Deko & Schnee */
:root.light .bg-circle {
    background: rgba(120, 170, 220, 0.11);
}
:root.light .snowflake {
    color: #6ca5d8 !important;
    opacity: 0.66 !important;
    text-shadow: 0 0 8px #fff, 0 0 2px #8ecff9;
    mix-blend-mode: screen;
}

/******************************************************
 * 8. Media Queries – Responsiveness
 ******************************************************/
@media (max-width: 768px) {
    .calendar-grid { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
    .door-front { font-size: 1.8rem; }
    .door.special .door-front { font-size: 3.2rem; }
    .status-bar { margin: 20px 10px 0; padding: 15px; }
    .title { font-size: 2.5rem; }
}
@media (max-width: 480px) {
    body { padding: 10px; }
    .calendar-grid { grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); }
    .door-front { font-size: 1.2rem; }
    .door.special .door-front { font-size: 2.2rem; }
    .title { font-size: 2rem; }
    .subtitle { font-size: 0.9rem; }
}

.back-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 8px;
    padding: 6px 16px;
    font-size: 1.13rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.17s, color 0.15s;
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    box-shadow: none;
    min-height: 38px;
    line-height: 1.1;
    text-decoration: none;
    outline: none;
}

.back-btn:hover {
    background: rgba(255,255,255,0.28);
    color: #fff;
}

:root.light .back-btn {
    background: rgba(100,130,200,0.07) !important;
    color: #234 !important;
    border: none;
}
:root.light .back-btn:hover {
    background: rgba(60,140,230,0.16) !important;
    color: #1a2945 !important;
}
.back-icon {
    font-size: 1.3em;
    font-weight: bold;
}