body {
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    color: #ffffff;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
    line-height: 1.6;
}

h1 {
    margin: 0;
    padding: 0;
}

h3 {
    margin: 0;
    margin-bottom: 8px;
    padding: 0;
}

.container {
    max-width: 1000px;
    margin: 0px auto;
    padding-top: 20px;
}

.binder-navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.nav-button {
    padding: 8px 16px;
    background: #666;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: Arial, sans-serif;
}

.nav-button:disabled {
    background: #444;
    cursor: not-allowed;
}

#page-display {
    font-family: Arial, sans-serif;
    color: white;
}

.binder-view {
    aspect-ratio: 2/1.5;
    width: 100%;
    background: #444;
    padding: 20px;
    box-sizing: border-box;
    border-radius: 8px;
    perspective: 2000px;
    overflow: visible; 
    position: relative;
}

.binder-underneath {
    display: flex;
    height: calc(100% - 0px);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: -1;
    padding: 20px;
    box-sizing: border-box;
    border-radius: 8px;
    background: rgba(0,0,0,0.10);
    pointer-events: none;
}

.binder-spread {
    display: flex;
    height: 100%;
    position: relative;
    width: 100%;
    top: 0;
    left: 0;
    z-index: 1;
}

.binder-page {
    flex: 1;
    background: #555;
    padding: 10px;
    border-radius: 4px;
    transition: transform 0.7s ease-in-out;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    position: relative;
    z-index: 1;
    min-width: 0;
    min-height: 0;
    box-sizing: border-box;
}

.binder-page.left-page-underneath,
.binder-page.right-page-underneath {
    flex: 1;
    background: #555;
    padding: 10px;
    border-radius: 4px;
    min-width: 0;
    min-height: 0;
    box-sizing: border-box;
}

.binder-page.left-page {
    transform-origin: calc(100% + 5px) 50%; 
}

.binder-page.right-page {
    transform-origin: -5px 50%;
}

.binder-page.flipping {
    z-index: 10;
}

.right-page.flipping-forward {
    animation: flipRightForward 0.7s ease-in-out forwards;
}

.left-page.flipping-backward {
    animation: flipLeftBackward 0.7s ease-in-out forwards;
}

@keyframes flipRightForward {
    0% {
        transform: rotateY(0deg);
    }
    100% {
        transform: rotateY(-180deg);
    }
}

@keyframes flipLeftBackward {
    0% {
        transform: rotateY(0deg);
    }
    100% {
        transform: rotateY(180deg);
    }
}

.page-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #555;
    border-radius: 4px;
    backface-visibility: hidden;
    transform: rotateY(180deg);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    box-sizing: border-box;
}

.left-back {
    transform: rotateY(180deg) scaleX(-1);
}

.right-back {
    transform: rotateY(180deg) scaleX(-1); 
}

.left-back .page-grid, .right-back .page-grid {
    transform: scaleX(-1); 
}

.page-grid {
    display: grid;
    height: 100%;
    gap: 6px;
}

.page-back .page-grid {
    transform: rotateY(180deg);
}

.binder-slot {
    background: #666;
    border-radius: 4px;
    aspect-ratio: 59/86;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
}

.binder-slot:hover{
    transform: translateY(-2px) scale(1.05);
}

.binder-slot img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.cover {
    background: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    color: #666;
    font-family: Arial, sans-serif;
}

.binder-page::before {
    content: '';
    position: absolute;
    top: 0;
    width: 30%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 5;
}

.right-page.flipping-forward::before,
.left-page.flipping-backward::before {
    opacity: 1;
}

.binder-spine {
    width: 10px;
    height: 100%;
    background: black;
    z-index: 5;
    position: relative;
}

.page-grid[data-rows="2"] {
    grid-template-rows: repeat(2, 1fr);
}

.page-grid[data-rows="3"] {
    grid-template-rows: repeat(3, 1fr);
}

.page-grid[data-rows="4"] {
    grid-template-rows: repeat(4, 1fr);
}

.page-grid[data-rows="5"]{
    grid-template-rows: repeat(5, 1fr);
}

.page-grid[data-cols="2"] {
    grid-template-columns: repeat(2, 1fr);
}

.page-grid[data-cols="3"] {
    grid-template-columns: repeat(3, 1fr);
}

.page-grid[data-cols="4"] {
    grid-template-columns: repeat(4, 1fr);
}

.page-grid[data-cols="5"] {
    grid-template-columns: repeat(5, 1fr);
}

.slot-popup,
.card-search-popup,
.edit-inventory-popup {
    background: linear-gradient(135deg, #1e1e3f 0%, #2a2a4a 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(20px);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    border-radius: 8px;
    z-index: 1000;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.card-search-popup {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    height: 550px;
    min-height: 550px;
    max-height: 550px;
    overflow: hidden;
    position: relative;
}

#search-results.card-search-grid {
    flex: 1 1 auto;
    overflow-y: auto;
    margin-bottom: 0;
}

#search-pagination.pagination {
    flex-shrink: 0;
    margin-top: auto;
    margin-bottom: 0;
    position: relative;
    bottom: 0;
    left: 0;
    right: 0;
    background: none;
}

.card-search-popup {
    height: 550px;
    min-height: 550px;
    max-height: 550px;
    overflow-y: auto;
}

.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 999;
}

.close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

.search-result img {
    width: 40px;
    height: 56px;
    object-fit: contain;
    margin-right: 10px;
}

#card-search-input {
    width: 60%;
    min-width: 180px;
    max-width: 260px;
    margin: 0 auto 8px auto;
    display: block;
    padding: 6px 10px;
    font-size: 1em;
}

.card-search-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-top: 12px;
    margin-bottom: 8px;
    min-height: 120px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 0 0 auto;
}

.search-result-card {
    background: #444;
    border-radius: 6px;
    padding: 8px 4px 4px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: box-shadow 0.15s, transform 0.15s, background-color 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 2px solid transparent;
    height: auto;
    min-height: 0;
    max-height: 200px;
    box-sizing: border-box;
}


.search-result-card:hover {
    background: #0080cc;
}

.search-result-card img {
    width: 100%;
    height: 120px;
    max-height: 120px;
    object-fit: contain;
    border-radius: 4px;
    margin-bottom: 6px;
    display: block;
}


.dropdown-container {
    display: flex;
    width: 100%;
    gap: 12px;
}

.language-dropdown, .rarity-dropdown {
    background: linear-gradient(135deg, #495057 0%, #343a40 100%);
    color:white;
    height:41px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 50%;
    min-width: 0;
    box-sizing: border-box;
}
.language-dropdown option, .rarity-dropdown option {
    background: #2a2a3e;
    color: white;
}

.language-dropdown:focus, .language-dropdown:active, 
.rarity-dropdown:focus, .rarity-dropdown:active {
    background: #2a2a3e;
    border-color: #4a90e2;
    box-shadow: 0 0 10px rgba(74, 144, 226, 0.2);
}

.language-dropdown::-ms-expand, .rarity-dropdown::-ms-expand {
    display: none;
}

@font-face {
    font-family: 'CardNameFont';
    src: url('/static/font/cardname.ttf') format('truetype');
    font-display: swap;
}
@font-face {
    font-family: 'CardTextFont';
    src: url('/static/font/cardtext.ttf') format('truetype');
    font-display: swap;
}
@font-face {
    font-family: 'TypelineFont';
    src: url('/static/font/typeline.ttf') format('truetype');
    font-display: swap;
}

.card-name {
    font-family: 'CardNameFont', Arial, sans-serif;
    font-size: 16px;
    color: #eee;
    text-align: center;
    word-break: break-word;
    line-height: 1.1;
    margin-top: 2px;
    letter-spacing: 0.5px;
}

.printing-list,
.printings-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    margin: 15px 0;
}

.printing-entry {
    background: #33333366;
    padding: 10px;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.printing-entry img {
    width: 100%;
    height: auto;
    object-fit: contain;
    margin-bottom: 10px;
    border-radius: 4px;
}

.printing-info {
    text-align: center;
}

.printing-info p {
    margin: 5px 0;
    font-size: 12px;
}

.quantity-input {
    width: 60px;
    padding: 4px;
    background: #333;
    border: 1px solid #666;
    border-radius: 4px;
    color: white;
    text-align: center;
}

.popup-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

.cancel-button {
    padding: 12px 24px;
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.2);
    margin-top: 10px;
}

.cancel-button:hover {
    background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 117, 125, 0.3);
}

.cancel-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(108, 117, 125, 0.2);
}

.edit-button,
.save-button {
    padding: 12px 24px;
    background: linear-gradient(135deg, #28a745 0%, #20923a 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.2);
    margin-top: 10px;
}

.edit-button:hover,
.save-button:hover {
    background: linear-gradient(135deg, #20923a 0%, #1e7e34 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.3);
}

.delete-button {
    padding: 12px 24px;
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.2);
    margin-top: 10px;
}

.delete-button:hover {
    background: linear-gradient(135deg, #c82333 0%, #bd2130 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(220, 53, 69, 0.3);
}

.edit-binder-button {
    background:#333;
    border-radius:50%;
    padding:8px;
    transition: all 0.3s ease;
    box-shadow:0 2px 8px rgba(33,150,243,0.10);
}

.edit-binder-button:hover {
    background: #444;
    box-shadow: 0 4px 16px rgba(33,150,243,0.25);
    transform: translateY(-2px)
}

.binder-view-title, .container > h1 {
    text-align: center;
    font-size: 1.6em;
    font-weight: 700;
    margin: 0 0 24px 0;
    color: #fff;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.12);
    font-family: 'Arial', sans-serif;
}

.page-transition-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20;
    display: none;
}

.page-transition-layer.active {
    display: block;
}

#search-pagination.pagination {
    width: 100%;
    justify-content: space-between;
    align-items: center;
    gap: 0;
    margin: 10px 0 0 0;
    box-sizing: border-box;
}
#search-pagination > * {
    flex: 1 1 0;
    text-align: center;
}
#search-pagination .pagination-info {
    justify-content: center;
    display: flex;
    align-items: center;
    height: 40px;
    font-size: 14px;
    color: white;
}
#search-pagination .pagination-button {
    margin: 0 2px;
}
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
}
.pagination-button {
    width: 50px;
    height: 40px;
    padding: 0;
    background-color: #666;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    text-align: center;
    font-size: 14px;
    line-height: 40px;
    transition: background-color 0.3s ease, font-size 0.3s ease;
    border: none;
}
.pagination-button:hover:not(.disabled) {
    background-color: #0080cc;
    font-size: 18px;
}
.pagination-button.disabled {
    background-color: #444;
    cursor: not-allowed;
}
.pagination-info {
    font-size: 14px;
    color: white;
    display: flex;
    align-items: center;
    height: 40px;
}

.card-info-popup {
    position: fixed;
    z-index: 3000;
    min-width: 320px;
    max-width: 380px;
    background: #232323;
    color: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px 0 rgba(0,0,0,0.45);
    padding: 18px 18px 12px 18px;
    font-family: 'Arial', sans-serif;
    pointer-events: none;
    font-size: 15px;
    border: 1.5px solid #444;
    transition: opacity 0.1s;
    opacity: 0.98;
}
.card-info-popup .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}
.card-info-popup .card-name {
    font-family: 'CardNameFont', Arial, sans-serif;
    font-size: 1.2em;
    font-weight: bold;
    margin: 0;
    color: #fff;
}
.card-info-popup .attribute-icons {
    display: flex;
    gap: 6px;
}
.card-info-popup .card-art-container {
    margin-top:16px;
    margin-bottom:12px;
    margin-left:auto;
    margin-right:auto;
    position: relative;
    width: 220px;
    height: 220px;
    overflow: visible !important;
}
.card-info-popup .card-art {
    width: 220px;
    height: 220px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}
.card-info-popup .typeline {
    font-family: 'TypelineFont', Arial, sans-serif;
    font-size: 1em;
    color: white;
    margin: 4px 0 2px 0;
}
.card-info-popup .icon-container {
    display: flex;
    align-items: center;
    gap: 1px;
    margin-bottom: 5px;
    overflow: visible !important;
}
.card-info-popup .icon-container.right {
    justify-content: flex-end;
}
.card-info-popup .icon-container img {
    width: 18px;
    max-height: 18px;
    display: inline-block;
}
.card-info-popup .icon-container.pend {
    gap: 8px;
}
.card-info-popup .card-type {
    font-size: 1em;
    color: white;
    font-family: 'CardNameFont', Arial, sans-serif;
    margin-right: 6px;
}
.card-info-popup .card-type-icon {
    width: 22px;
    height: 22px;
    margin-left: 2px;
    vertical-align: middle;
}
.card-info-popup .card-attribute {
    width: 25px;
    height: 25px;
}
.card-info-popup .card-text-section {
    font-weight: bold;
    margin: 6px 0 2px 0;
}
.card-info-popup .card-text {
    font-family: 'CardTextFont', Arial, sans-serif;
    font-size: 1em;
    color: #fff;
    margin: 0 0 6px 0;
    line-height: 1.3;
}
.link-marker {
    position: absolute;
    z-index: 3;
    text-decoration: none;
    border: none;
    outline: none;
}
.link-marker.top-left {
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    transform: translate(-35%, -35%);
    background-image: url('/static/icon/lm/top-left-off.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}
.link-marker.top-left.activated {
    background-image: url('/static/icon/lm/top-left-on.png');
}
.link-marker.top-center {
    top: 0;
    left: 50%;
    width: 50px;
    height: 20px;
    transform: translate(-50%, -80%);
    background-image: url('/static/icon/lm/top-center-off.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}
.link-marker.top-center.activated {
    background-image: url('/static/icon/lm/top-center-on.png');
}
.link-marker.top-right {
    top: 0;
    right: 0;
    width: 40px;
    height: 40px;
    transform: translate(35%, -35%);
    background-image: url('/static/icon/lm/top-right-off.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}
.link-marker.top-right.activated {
    background-image: url('/static/icon/lm/top-right-on.png');
}
.link-marker.center-left {
    top: 50%;
    left: 0;
    width: 20px;
    height: 50px;
    transform: translate(-80%, -50%);
    background-image: url('/static/icon/lm/center-left-off.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}
.link-marker.center-left.activated {
    background-image: url('/static/icon/lm/center-left-on.png');
}
.link-marker.center-right {
    top: 50%;
    right: 0;
    width: 20px;
    height: 50px;
    transform: translate(80%, -50%);
    background-image: url('/static/icon/lm/center-right-off.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}
.link-marker.center-right.activated {
    background-image: url('/static/icon/lm/center-right-on.png');
}
.link-marker.bottom-left {
    bottom: 0;
    left: 0;
    width: 40px;
    height: 40px;
    transform: translate(-35%, 35%);
    background-image: url('/static/icon/lm/bottom-left-off.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}
.link-marker.bottom-left.activated {
    background-image: url('/static/icon/lm/bottom-left-on.png');
}
.link-marker.bottom-center {
    bottom: 0;
    left: 50%;
    width: 50px;
    height: 20px;
    transform: translate(-50%, 80%);
    background-image: url('/static/icon/lm/bottom-center-off.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}
.link-marker.bottom-center.activated {
    background-image: url('/static/icon/lm/bottom-center-on.png');
}
.link-marker.bottom-right {
    bottom: 0;
    right: 0;
    width: 40px;
    height: 40px;
    transform: translate(35%, 35%);
    background-image: url('/static/icon/lm/bottom-right-off.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}
.link-marker.bottom-right.activated {
    background-image: url('/static/icon/lm/bottom-right-on.png');
}
@media (max-width: 600px) {
    .card-info-popup {
        min-width: 220px;
        max-width: 98vw;
        padding: 8px 4px 8px 4px;
    }
    .card-info-popup .card-art-container {
        width: 120px;
        height: 120px;
    }
}