:root {
    --bg-transparent: rgba(255, 255, 255, 0.9);
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-dark: 0 4px 15px rgba(0, 0, 0, 0.2);
    --border-light: rgba(0, 0, 0, 0.1);
    --transition: 0.3s ease;
    --logo-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    --silver-border: #c0c0c0; /* Farbe für Silver-Karten */
    --toggle-active-bg: rgba(255, 98, 0, 0.3); /* MapleStory-Orange für aktiven Zustand - schwächer */
    --toggle-silver-bg: #c0c0c0; /* Silber für Kippschalter im Silver-Modus */
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    background: #000000;
}

body {
    font: 16px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    color: #e4e4e7;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
    position: relative;
}

/* iPhone Hintergrund mit Logo */
@media (max-width: 430px) {
    body {
        background: #000000 url('./logo.jpeg') no-repeat center center;
        background-size: cover;
        background-attachment: fixed;
    }
    
    .stars-container {
        display: none;
    }
}

/* Container für blinkende Sterne */
.stars-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.star {
    position: absolute;
    width: 1px;
    height: 1px;
    background: white;
    border-radius: 50%;
    animation: twinkle 3s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% {
        opacity: 0.2;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

.container {
    max-width: 1200px;
    width: 100%;
    margin: 50px auto;
    padding: 20px;
    border-radius: 15px;
    box-shadow: none;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    position: relative;
    z-index: 1;
    transition: opacity 0.3s ease;
    overflow-x: hidden;
    box-sizing: border-box;
}

.container:has(.item-image-wrapper.centered) {
    z-index: 1;
}

.container.fade-out {
    opacity: 0;
}

.container.fade-in {
    opacity: 1;
    animation: fadeIn 0.5s ease;
}

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

.logo {
    width: 300px;
    height: 150px;
    margin: 0 auto 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    box-shadow: var(--logo-shadow);
    transition: transform var(--transition), box-shadow var(--transition);
}

.logo img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    transition: transform var(--transition);
    pointer-events: none;
}

.logo:hover {
    transform: scale(1.1);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
}

.search-bar {
    text-align: center;
    margin-bottom: 15px;
}

.search-bar input {
    width: 80%;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #e4e4e7;
    box-shadow: var(--shadow-light);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-bar input::placeholder {
    color: rgba(228, 228, 231, 0.6);
}

.search-bar input:focus {
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
    outline: none;
}

.button-group {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.filter-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #e4e4e7;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    cursor: pointer;
    font-size: 13px;
    transition: background var(--transition), transform 0.2s ease, box-shadow var(--transition);
    box-shadow: var(--shadow-light);
    width: 120px;
    height: 40px;
    text-align: center;
}

.filter-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: var(--shadow-dark);
}

.filter-button.active {
    background: var(--toggle-active-bg);
    color: #fff;
    border: 1px solid rgba(255, 98, 0, 0.3);
    box-shadow: 0 0 0 2px rgba(255, 98, 0, 0.2);
}

.toggle-button.silver-active {
    background: var(--toggle-silver-bg);
    color: #333;
    border: 1px solid rgba(192, 192, 192, 0.5);
    box-shadow: 0 0 0 2px rgba(192, 192, 192, 0.3);
}

.toggle-button {
    position: relative;
    font-weight: bold;
}

.filter-button.set6-hidden {
    display: none !important;
}

.set6-count {
    display: none;
    align-items: center;
    justify-content: center;
    width: 120px;
    min-width: 120px;
    padding: 0;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e4e4e7;
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.set6-count.active {
    display: flex;
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    justify-content: center;
    position: relative;
    z-index: 1;
    transform: translateZ(0);
    will-change: auto;
}

.item {
    text-align: center;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    min-height: 220px;
    transition: opacity 0.8s ease;
    cursor: pointer;
    position: relative;
    z-index: 1;
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.item:has(.item-image-wrapper.centered) .card-name-box {
    opacity: 0.3 !important;
    pointer-events: none;
}

.item.quantity-zero {
    background: rgba(248, 215, 218, 0.05);
    border: 1px solid rgba(248, 215, 218, 0.2);
}

.item.quantity-nonzero {
    background: rgba(255, 255, 255, 0.02);
}

.item.silver-card {
    border: 2px solid rgba(192, 192, 192, 0.2);
    background: rgba(240, 240, 240, 0.02);
}

.item.quantity-zero.silver-card {
    background: rgba(248, 215, 218, 0.05);
}

.item.filter-hidden, .item.search-hidden, .item.quantity-hidden, .item.rarity-hidden {
    display: none;
}

.item {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.item-image-wrapper {
    perspective: 1000px;
    width: 150px;
    height: 210px;
    margin-bottom: 8px;
    cursor: pointer;
    position: relative;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), top 0.8s cubic-bezier(0.4, 0, 0.2, 1), left 0.8s cubic-bezier(0.4, 0, 0.2, 1), position 0s 0.8s, z-index 0s;
    z-index: 1;
}

.item-image-wrapper.flipped {
    z-index: 1000;
}

.item-image-wrapper.centered {
    transform: translate(-50%, -50%) translate(var(--offset-x, 0), var(--offset-y, 0)) scale(var(--scale, 1)) !important;
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    z-index: 999999 !important;
    will-change: transform;
    transform-origin: center center;
    margin: 0 !important;
    padding: 0 !important;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.item.card-open-backdrop {
    opacity: 0.3;
    pointer-events: none;
    z-index: 0 !important;
    transition: opacity 0.8s ease;
    will-change: opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}


.item-card {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px;
}

.item-card.flipped {
    transform: rotateY(360deg);
}

.item-image-wrapper.centered .item-card {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.card-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.02);
    z-index: 99998;
    cursor: pointer;
    animation: fadeIn 0.3s ease;
}

.item-card-front,
.item-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.item-card-front img,
.item-card-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    transition: transform 0.3s ease;
}

.item-image-wrapper.flipped .item-card-front img,
.item-image-wrapper.flipped .item-card-back img {
    transform: none;
}


.item-card-back {
    transform: rotateY(180deg);
}

.item img {
    width: 150px;
    margin-bottom: 8px;
    transition: transform var(--transition);
    cursor: pointer;
    border-radius: 8px;
}


.item-info {
    width: 100%;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 8px;
    margin-top: 8px;
}

.card-name-box {
    width: 100%;
    padding: 6px 8px;
    border-radius: 6px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    position: relative;
    z-index: 1;
    transition: none !important;
    opacity: 1 !important;
}

.card-name-box h3 {
    font-weight: normal;
    font-size: 0.85rem;
    margin: 0;
    color: #e4e4e7;
}


.quantity-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 5px;
    width: 100%;
    position: relative;
    z-index: 1;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    overflow: hidden;
}

.quantity-display {
    flex: 1;
    text-align: center;
    font-size: 0.9rem;
    color: #e4e4e7;
    padding: 8px 4px;
    background: transparent;
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    transition: color var(--transition);
}

.quantity-display.quantity-zero {
    color: rgba(255, 98, 0, 0.8);
}

.quantity-button {
    width: 36px;
    height: 36px;
    background: transparent;
    color: #e4e4e7;
    border: none;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: background var(--transition), color var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.quantity-button:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.quantity-button:active {
    background: rgba(255, 255, 255, 0.25);
}

.quantity-green {
    animation: flashGreen 0.3s ease;
}

.quantity-red {
    animation: flashRed 0.3s ease;
}

@keyframes flashGreen {
    0% { background-color: rgba(255, 255, 255, 0.1); }
    50% { background-color: rgba(144, 238, 144, 0.4); }
    100% { background-color: rgba(255, 255, 255, 0.1); }
}

@keyframes flashRed {
    0% { background-color: rgba(255, 255, 255, 0.1); }
    50% { background-color: rgba(255, 99, 71, 0.4); }
    100% { background-color: rgba(255, 255, 255, 0.1); }
}

.set-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s, opacity 0.3s ease;
    z-index: 1000;
    overflow-x: hidden;
}

.set-modal.open {
    visibility: visible;
    opacity: 1;
}


.set-modal-content {
    max-width: min(420px, calc(100vw - 24px));
    width: calc(100% - 24px);
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 16px;
    border-radius: 12px;
    text-align: center;
    color: #e4e4e7;
    overflow-x: hidden;
    box-sizing: border-box;
}

.set-modal-content h1 {
    margin-bottom: 12px;
    font-size: 16px;
    font-weight: 600;
    color: #e4e4e7;
}

.set-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 60vh;
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
}

.set-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-width: 0;
    min-height: 48px;
    cursor: pointer;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    transition: transform var(--transition), opacity var(--transition);
    box-sizing: border-box;
}

.set-item:hover {
    transform: translateY(-1px);
    opacity: 0.95;
}

/* Set-Farben – dezente Akzente passend zum Thema */
.set-item-set1 { border-left: 3px solid #3b82f6; background: rgba(59, 130, 246, 0.06); }
.set-item-set2 { border-left: 3px solid #ef4444; background: rgba(239, 68, 68, 0.06); }
.set-item-set3 { border-left: 3px solid #a855f7; background: rgba(168, 85, 247, 0.06); }
.set-item-set4 { border-left: 3px solid #eab308; background: rgba(251, 191, 36, 0.06); }
.set-item-set5 { border-left: 3px solid #f97316; background: rgba(249, 115, 22, 0.06); }
.set-item-set6 { border-left: 3px solid #22c55e; background: rgba(34, 197, 94, 0.06); }

.set-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
    min-width: 0;
}

.set-num {
    font-size: 0.8rem;
    font-weight: 500;
    color: rgba(228, 228, 231, 0.8);
}

.set-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #e4e4e7;
    text-align: center;
}

.set-subtitle {
    font-size: 0.75rem;
    color: rgba(228, 228, 231, 0.7);
    margin-top: 2px;
    text-align: center;
}

.set-modal .close {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 1.8rem;
    color: white;
    background: none;
    border: none;
    cursor: pointer;
}

.set-modal .close:hover {
    transform: scale(1.2);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s, opacity 0.3s ease;
    z-index: 1000;
}

.modal.open {
    visibility: visible;
    opacity: 1;
}


.modal-content {
    background: none;
    padding: 0;
    text-align: center;
}

.modal img {
    max-width: 80%;
    max-height: 80%;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.modal .close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 2rem;
    color: white;
    background: none;
    border: none;
    cursor: pointer;
}

.modal .close:hover {
    transform: scale(1.2);
}

/* Beim Laden: Hintergrund und Inhalt ausblenden */
body.app-loading .stars-container,
body.app-loading .container {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

body.app-loading .set-modal {
    visibility: hidden;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s, opacity 0.3s ease;
    z-index: 1200;
}

.loading-overlay.active {
    visibility: visible;
    opacity: 1;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}

.loading-gif {
    max-width: min(160px, 90vw);
    max-height: min(160px, 30vh);
    width: auto;
    height: auto;
    object-fit: contain;
}

.loading-overlay .loading-text {
    font-size: 18px;
    color: #e4e4e7;
}

@media (max-width: 768px) {
    .container { 
        margin: 15px auto;
        max-width: calc(100% - 30px); 
        padding: 10px;
        padding-top: 10px;
    }
    .logo { 
        width: 200px; 
        height: 100px; 
    }
    .search-bar input { 
        width: 90%; 
        padding: 10px; 
    }
    .button-group { 
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        gap: 4px; 
    }
    .filter-button { 
        width: auto;
        flex: 1;
        padding: 0; 
        font-size: 10px;
        height: 32px;
        min-width: 0;
        position: relative;
    }
    .set6-count {
        flex: 1;
        width: auto;
        min-width: 0;
        height: 32px;
        font-size: 10px;
    }
    #filter-all {
        font-size: 0;
    }
    #filter-all::before {
        content: "Alle";
        font-size: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
    }
    #filter-zero {
        font-size: 0;
    }
    #filter-zero::before {
        content: "Fehlend";
        font-size: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
    }
    #filter-nonzero {
        font-size: 0;
    }
    #filter-nonzero::before {
        content: "Vorhanden";
        font-size: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
    }
    #filter-rarity {
        font-size: 0;
    }
    #filter-rarity::before {
        content: "Normal";
        font-size: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
    }
    #filter-rarity.silver-active::before {
        content: "Silver";
    }
    .item-grid { 
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 10px;
    }
    .item-image-wrapper {
        width: 120px;
        height: 168px;
    }
    .item img { 
        width: 120px; 
    }
    .quantity-controls {
        height: 32px;
    }
    .quantity-button {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    .quantity-display {
        font-size: 0.8rem;
        padding: 6px 4px;
    }
    .set-modal-content { 
        max-width: min(400px, calc(100vw - 24px));
        padding: 10px; 
    }
    .set-grid { 
        gap: 6px; 
        max-height: 50vh; 
    }
    .set-item { 
        min-height: 44px;
        padding: 8px 12px;
    }
    .set-name { font-size: 0.9rem; }
    .set-subtitle { font-size: 0.7rem; }
}

/* Optimierungen für sehr kleine Bildschirme (iPhone Pro, etc.) */
@media (max-width: 430px) {
    .container { 
        margin: 10px auto;
        padding: 8px; 
    }
    .logo { 
        width: 180px; 
        height: 90px; 
        margin-bottom: 15px;
    }
    .search-bar input { 
        width: 95%; 
        padding: 8px; 
        font-size: 14px;
    }
    .button-group { 
        gap: 3px; 
    }
    .filter-button { 
        font-size: 9px;
        height: 30px;
    }
    .set6-count {
        font-size: 9px;
        height: 30px;
    }
    #filter-all::before,
    #filter-zero::before,
    #filter-nonzero::before,
    #filter-rarity::before {
        font-size: 9px;
    }
    .item-grid { 
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 8px;
    }
    .item-image-wrapper {
        width: 100px;
        height: 140px;
    }
    .item img { 
        width: 100px; 
    }
    .item {
        min-height: 200px;
        padding: 8px;
    }
    .item-info {
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding-top: 6px;
        margin-top: 6px;
    }
    .item-info h3 {
        font-size: 0.85rem;
    }
    .quantity-controls {
        height: 28px;
        margin-top: 4px;
    }
    .quantity-button {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    .quantity-display {
        font-size: 0.75rem;
        padding: 5px 3px;
    }
    .set-modal-content { 
        max-width: min(95%, calc(100vw - 24px));
        width: calc(100% - 24px);
        padding: 8px; 
        background: rgba(0, 0, 0, 0.1);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.05);
        color: #e4e4e7;
    }
    .set-grid { gap: 6px; }
    .set-item { 
        min-height: 42px;
        padding: 8px 10px;
    }
    .set-name { font-size: 0.85rem; }
    .set-subtitle { font-size: 0.65rem; }
    .modal img {
        max-width: 95%;
        max-height: 85%;
    }
}