:root {
    --primary: #d4af37;
    /* 金色 */
    --primary-hover: #b8860b;
    /* 暗金 */
    --bg-dark: #1e140d;
    /* 深褐黑 */
    --card-bg: #2d1f14;
    /* 深木色 */
    --text-main: #f4e4bc;
    /* 羊皮紙色 */
    --text-dim: #a8947a;
    /* 昏暗木色 */
    --accent: #a8ffb5;
    /* 魔法螢光綠 */
    --glass: rgba(255, 255, 255, 0.05);
    --gold-glow: 0 0 10px rgba(212, 175, 55, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background-color: var(--bg-dark);
    background-image:
        linear-gradient(rgba(30, 20, 13, 0.85), rgba(30, 20, 13, 0.85)),
        url('/static/images/banner.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

.container {
    width: 100%;
    max-width: 450px;
    text-align: center;
}

header {
    margin-bottom: 30px;
    animation: fadeInDown 0.8s ease-out;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--primary);
    text-shadow:
        2px 2px 0px #000,
        -1px -1px 0px #000,
        1px -1px 0px #000,
        -1px 1px 0px #000,
        0px 0px 15px rgba(212, 175, 55, 0.6);
    text-align: center;
    text-transform: uppercase;
}

.subtitle {
    color: var(--text-dim);
    font-size: 1.1rem;
    margin-top: 10px;
    font-style: italic;
}

.card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 40px;
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.6),
        inset 0 0 20px rgba(0, 0, 0, 0.3);
    border: 2px solid #5d4037;
    backdrop-filter: blur(5px);
    animation: scaleIn 0.5s ease-out;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('https://www.transparenttextures.com/patterns/parchment.png');
    opacity: 0.05;
    pointer-events: none;
}

.login-card h2 {
    margin-bottom: 10px;
}

.login-card p {
    color: var(--text-dim);
    margin-bottom: 30px;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 32px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-primary {
    background-color: var(--primary);
    color: #1e140d;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(212, 175, 55, 0.5);
    color: #000;
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--glass);
    color: var(--text-dim);
    margin-top: 20px;
}

.btn-secondary:hover {
    color: var(--text-main);
    border-color: var(--text-dim);
}

/* Profile Card Styles */
.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    text-align: left;
    margin-bottom: 30px;
}

.avatar-placeholder,
.user-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--glass);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.avatar-placeholder {
    background: linear-gradient(45deg, var(--primary), var(--accent));
}

.user-info h2 {
    font-size: 1.5rem;
}

.badge {
    font-size: 0.8rem;
    background: var(--glass);
    padding: 4px 12px;
    border-radius: 20px;
    color: var(--accent);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.stat-item {
    background: var(--glass);
    padding: 15px;
    border-radius: 16px;
}

.stat-item .label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.stat-item .value {
    font-size: 1.4rem;
    font-weight: 600;
}

.progress-container {
    text-align: left;
    margin-bottom: 20px;
}

.progress-bar {
    height: 8px;
    background: var(--glass);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(to right, var(--primary), var(--accent));
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(168, 255, 181, 0.4);
}

.progress-text {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.user-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
    box-shadow: var(--gold-glow);
}

.lang-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    z-index: 100;
}

.lang-selector select {
    background: var(--card-bg);
    border: 1px solid var(--glass);
    color: var(--text-main);
    border-radius: 8px;
    padding: 4px 8px;
    outline: none;
    cursor: pointer;
    font-family: inherit;
}

.lang-selector select option {
    background: var(--card-bg);
    color: var(--text-main);
}

footer {
    margin-top: 40px;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.version-display {
    position: fixed;
    bottom: 15px;
    right: 15px;
    font-size: 0.75rem;
    color: var(--text-dim);
    z-index: 1000;
    pointer-events: none;
    opacity: 0.7;
}

footer a {
    color: var(--accent);
    text-decoration: none;
    transition: all 0.3s ease;
    border-bottom: 1px border transparent;
}

footer a:hover {
    color: var(--primary);
    text-decoration: underline;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Items Page Styles */
.items-page-container {
    max-width: 1000px;
    width: 95%;
}

/* Navigation Bar */
.top-nav-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 1.2rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

.nav-left,
.nav-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
    padding: 8px 12px;
    border-radius: 8px;
    background: transparent;
}

.back-btn:hover {
    color: var(--accent);
    background: var(--glass);
    transform: translateX(-4px);
}

.back-btn .icon {
    font-size: 1.2rem;
}


.items-layout {
    display: flex;
    gap: 20px;
    margin-top: 20px;
    align-items: flex-start;
    flex-direction: row;
    /* 強制併排 */
}

.grid-card {
    flex: 1;
    padding: 20px;
    min-width: 0;
    /* 防止內容撐開 */
}

.detail-card {
    width: 280px;
    flex-shrink: 0;
    padding: 24px;
    position: sticky;
    top: 20px;
    text-align: center;
}

.items-grid {
    display: grid;
    gap: 12px;
    justify-content: center;
    grid-template-columns: repeat(5, 1fr);
    /* 預設 5 欄 */
}

/* Responsive Grid Logic */
@media (max-width: 768px) {
    .items-layout {
        /* 依據需求：不論橫直版，及詳細資訊一律排版於右方 */
        flex-direction: row;
        gap: 10px;
    }

    .detail-card {
        width: 180px;
        /* 手機版寬度縮小 */
        padding: 15px;
        position: static;
    }

    .items-grid {
        grid-template-columns: repeat(2, 1fr);
        /* 手機版/直版 2 欄 */
    }
}

/* Landscape / Desktop: 5x4 or auto-fill */
@media (min-width: 769px) {
    .items-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

.item-box {
    background: var(--glass);
    border-radius: 16px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.item-box:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-5px);
}

.item-box.selected {
    border-color: var(--accent);
    background: rgba(255, 121, 198, 0.1);
    box-shadow: 0 0 15px rgba(255, 121, 198, 0.3);
}

.item-icon-wrapper {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.item-icon {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.item-name {
    font-size: 0.85rem;
    font-weight: 600;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-quantity {
    font-size: 0.7rem;
    background: var(--primary);
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 600;
    color: #1e140d;
}

/* Detail View Styles */
.empty-detail {
    color: var(--text-dim);
    padding: 40px 0;
}

.hint {
    font-size: 0.8rem;
    margin-top: 10px;
}

.detail-view {
    animation: fadeIn 0.4s ease-out;
}

.detail-icon {
    width: 128px;
    height: 128px;
    object-fit: contain;
    margin-bottom: 20px;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.3));
}

.detail-name {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: var(--accent);
}

.detail-desc {
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.6;
    margin-bottom: 25px;
    text-align: left;
    background: var(--glass);
    padding: 15px;
    border-radius: 12px;
}

.detail-qty {
    display: inline-block;
    background: var(--primary);
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e140d;
}

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid var(--glass);
}

.page-btn {
    background: var(--glass);
    border: 1px solid var(--glass);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.page-btn:hover:not(:disabled) {
    background: var(--primary);
    border-color: var(--primary);
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-info {
    font-size: 0.9rem;
    color: var(--text-dim);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* �����M�ݼ˦� */
.landing-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    z-index: 10;
}

.hero-section {
    text-align: center;
    padding: 2rem 0;
    animation: fadeIn 1s ease-out;
}

.product-title {
    font-size: clamp(2.2rem, 8vw, 3.8rem) !important;
    margin-bottom: 2rem;
    line-height: 1.2;
    white-space: nowrap !important;
    word-break: keep-all !important;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    color: var(--primary);
    text-shadow:
        2px 2px 0px #000,
        -1px -1px 0px #000,
        1px -1px 0px #000,
        -1px 1px 0px #000,
        0px 0px 15px rgba(212, 175, 55, 0.6);
}





.hero-section .card {
    max-width: 650px !important;
    width: 90% !important;
    margin: 0 auto;
}

.card-content-p {
    text-align: center;
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-main);
    word-break: keep-all !important;
    overflow-wrap: break-word !important;
}

/* Navigation Bar Adjustment */
.top-nav-bar .nav-right {
    justify-content: flex-end;
}

.lang-selector {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    white-space: nowrap !important;
}

.login-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}