:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent: #e94560;
    --accent-hover: #c73e54;
    --success: #4caf50;
    --error: #f44336;
    --warning: #ff9800;
    --border-radius: 12px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* Header */
.header {
    background: var(--bg-secondary);
    padding: 1rem 2rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--transition);
}

.logo:hover {
    color: var(--accent);
}

.nav {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.nav-diamonds {
    color: #ffd740;
    font-weight: bold;
    padding: 0.5rem 1rem;
    background: rgba(255, 215, 64, 0.1);
    border-radius: 8px;
}

/* Main content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.card-item {
    background: var(--bg-card);
    border: 2px solid;
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
}

.card-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
}

.card-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.card-image-placeholder {
    width: 100%;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    background: rgba(0, 0, 0, 0.3);
}

.card-name {
    padding: 0.5rem;
    text-align: center;
    font-weight: bold;
    font-size: 0.9rem;
}

.card-rarity {
    text-align: center;
    padding-bottom: 0.5rem;
    font-size: 0.8rem;
    font-weight: bold;
}

.card-count {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
}

.not-owned {
    opacity: 0.5;
    filter: grayscale(80%);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: var(--transition);
    text-decoration: none;
    text-align: center;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

.btn-checkin {
    background: var(--success);
    color: white;
    margin-top: 1rem;
}

.btn-draw {
    padding: 1.5rem 2rem;
    font-size: 1.2rem;
    min-width: 150px;
}

.btn-single {
    background: #2196f3;
    color: white;
}

.btn-ten {
    background: #ff9800;
    color: white;
}

.btn-filter {
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--text-secondary);
    padding: 0.5rem 1rem;
}

.btn-filter.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-fusion {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: bold;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--bg-card);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* Tables */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.admin-table th,
.admin-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-table th {
    background: var(--bg-card);
    color: var(--text-secondary);
    font-weight: bold;
}

.admin-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Toast */
#toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease;
    max-width: 350px;
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--error);
}

.toast-warning {
    background: var(--warning);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.draw-modal-content {
    text-align: center;
}

.draw-result-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin: 1.5rem 0;
}

.draw-result-card {
    width: 120px;
    border: 3px solid;
    border-radius: 8px;
    overflow: hidden;
    animation: cardReveal 0.5s ease;
}

.draw-result-card img {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.draw-result-card .result-name {
    padding: 0.5rem;
    font-size: 0.8rem;
    font-weight: bold;
    text-align: center;
}

@keyframes cardReveal {
    from {
        transform: scale(0) rotateY(180deg);
        opacity: 0;
    }
    to {
        transform: scale(1) rotateY(0deg);
        opacity: 1;
    }
}

/* Rarity glow effects */
.rarity-N {
    box-shadow: 0 0 10px rgba(158, 158, 158, 0.3);
}

.rarity-R {
    box-shadow: 0 0 15px rgba(66, 165, 245, 0.5);
}

.rarity-SR {
    box-shadow: 0 0 20px rgba(171, 71, 188, 0.6);
}

.rarity-SSR {
    box-shadow: 0 0 25px rgba(255, 215, 64, 0.7);
    animation: glowGold 2s infinite;
}

.rarity-UR {
    box-shadow: 0 0 30px rgba(255, 109, 0, 0.8);
    animation: glowOrange 1.5s infinite;
}

@keyframes glowGold {
    0%, 100% { box-shadow: 0 0 25px rgba(255, 215, 64, 0.7); }
    50% { box-shadow: 0 0 40px rgba(255, 215, 64, 1); }
}

@keyframes glowOrange {
    0%, 100% { box-shadow: 0 0 30px rgba(255, 109, 0, 0.8); }
    50% { box-shadow: 0 0 50px rgba(255, 109, 0, 1); }
}

/* Login page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 70vh;
}

.login-card {
    background: var(--bg-secondary);
    padding: 2.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
}

.login-card h2 {
    text-align: center;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.login-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.btn-tab {
    flex: 1;
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--text-secondary);
}

.btn-tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.admin-hint {
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(255, 152, 0, 0.1);
    border-radius: 8px;
    text-align: center;
    font-size: 0.85rem;
}

.hint-warning {
    color: var(--warning);
}

/* Index page */
.index-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.user-info-card {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.user-stats {
    display: flex;
    gap: 2rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--accent);
}

.draw-section {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.draw-buttons {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.probability-info {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    font-size: 0.85rem;
}

.prob-n { color: #9e9e9e; }
.prob-r { color: #42a5f5; }
.prob-sr { color: #ab47bc; }
.prob-ssr { color: #ffd740; }
.prob-ur { color: #ff6d00; }

.card-pool-section {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.rarity-summary {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.rarity-badge {
    border: 2px solid;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.85rem;
}

/* Collection page */
.collection-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.collection-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.progress-bar {
    flex: 1;
    height: 20px;
    background: var(--bg-secondary);
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #42a5f5, #ab47bc, #ffd740);
    transition: width 0.5s ease;
}

.progress-text {
    font-weight: bold;
    color: var(--text-secondary);
}

.filter-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Fusion page */
.fusion-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.fusion-desc {
    color: var(--text-secondary);
}

.fusion-options {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.fusion-option {
    background: var(--bg-secondary);
    border: 2px solid;
    border-radius: var(--border-radius);
    padding: 1.5rem;
}

.fusion-cards {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.fusion-card-img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Admin page */
.admin-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.admin-section {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.admin-card-form {
    margin-bottom: 2rem;
}

.admin-card-list {
    margin-top: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .nav {
        width: 100%;
        justify-content: flex-start;
    }

    .main-content {
        padding: 1rem;
    }

    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1rem;
    }

    .card-image {
        height: 140px;
    }

    .draw-buttons {
        flex-direction: column;
        align-items: center;
    }

    .btn-draw {
        width: 100%;
        max-width: 300px;
    }

    .user-stats {
        gap: 1rem;
    }

    .admin-table {
        font-size: 0.85rem;
    }

    .admin-table th,
    .admin-table td {
        padding: 0.5rem;
    }
}