:root {
    --bg-dark: #0a0a0f;
    --glass-bg: rgba(20, 20, 30, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #f0f0f5;
    --text-muted: #9ca3af;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --remove-color: #ef4444;
    --remove-bg: rgba(239, 68, 68, 0.1);
    --add-color: #10b981;
    --add-bg: rgba(16, 185, 129, 0.1);
    --error-bg: rgba(239, 68, 68, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 1rem;
    position: relative;
    overflow-x: hidden;
}

/* Background Orbs */
.background-orbs {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s ease-in-out infinite alternate;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: #6366f1;
    top: -100px;
    left: -100px;
}

.orb-2 {
    width: 300px;
    height: 300px;
    background: #8b5cf6;
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

.orb-3 {
    width: 200px;
    height: 200px;
    background: #ec4899;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.1); }
}

/* Glass Panel */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    max-width: 600px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}
.section-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.secondary-btn {
    width: 100%;
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.badge {
    background-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badges-container {
    display: flex;
    gap: 0.5rem;
}

.badge-add {
    background-color: rgba(46, 204, 113, 0.35);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, 0.6);
}

.badge-remove {
    background-color: rgba(231, 76, 60, 0.35);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.6);
}

.badge-success {
    background-color: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
}

.warning-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #eab308;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
}
.warning-box svg {
    opacity: 0.8;
}

.cheering-text {
    font-style: italic;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 2rem;
    margin-bottom: 0.5rem;
    font-size: 1.15rem;
    text-align: center;
    font-weight: 500;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.secondary-btn.copied {
    background: rgba(46, 204, 113, 0.1);
    border-color: rgba(46, 204, 113, 0.3);
    color: #2ecc71;
}

.remove-title {
    margin-bottom: 0.5rem;
    color: var(--remove-color);
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #a5b4fc, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Forms */
.motivation-text {
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.95rem;
    line-height: 1.6;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.motivation-text p {
    margin-bottom: 0.75rem;
}

.motivation-text p:last-child {
    margin-bottom: 0;
}

.motivation-text strong {
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
}

form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.half {
    flex: 1;
}

label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.875rem 1rem;
    color: white;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
    outline: none;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
    background: rgba(0, 0, 0, 0.3);
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
    opacity: 0.6;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

button {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 0.5rem;
}

button:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px var(--primary);
}

button:active {
    transform: translateY(0);
}

/* Loader */
.loader {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Results Area */
#error-message {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--error-bg);
    border: 1px solid var(--remove-color);
    border-radius: 12px;
    color: #fca5a5;
    font-size: 0.9rem;
    text-align: center;
}

#results-container {
    margin-top: 2rem;
    border-top: 1px solid var(--glass-border);
    padding-top: 2rem;
    animation: fadeIn 0.4s ease forwards;
}

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

.results-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    margin-bottom: 0;
    padding: 5.5rem 1.5rem 2rem 1.5rem;
    border-radius: 16px 16px 0 0;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: none;
    cursor: pointer;
    transition: filter 0.2s;
}

.results-header:hover {
    filter: brightness(1.1);
}

#commander-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: top center;
    opacity: 0;
    z-index: 0;
    transition: opacity 0.5s ease;
}

#commander-bg::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, rgba(20, 20, 30, 0.95) 0%, rgba(20, 20, 30, 0.4) 100%);
}

.results-header-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 0.75rem;
    width: 100%;
}

.results-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}

.item-quantity {
    font-weight: 700;
    margin-right: 0.5rem;
    color: rgba(255, 255, 255, 0.9);
}

/* FAQ Section */
.faq-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--glass-border);
}

.faq-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: rgba(255, 255, 255, 0.9);
}

.faq-item {
    margin-bottom: 1.25rem;
}

.faq-item h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.type-badge {
    font-size: 0.65rem;
    font-weight: 600;
    width: 20px;
    height: 20px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

.type-creature { background: rgba(46, 204, 113, 0.2); border-color: rgba(46, 204, 113, 0.4); color: #2ecc71; }
.type-artifact { background: rgba(189, 195, 199, 0.2); border-color: rgba(189, 195, 199, 0.4); color: #bdc3c7; }
.type-enchantment { background: rgba(155, 89, 182, 0.2); border-color: rgba(155, 89, 182, 0.4); color: #9b59b6; }
.type-instant { background: rgba(52, 152, 219, 0.2); border-color: rgba(52, 152, 219, 0.4); color: #3498db; }
.type-sorcery { background: rgba(231, 76, 60, 0.2); border-color: rgba(231, 76, 60, 0.4); color: #e74c3c; }
.type-planeswalker { background: rgba(241, 196, 15, 0.2); border-color: rgba(241, 196, 15, 0.4); color: #f1c40f; }
.type-land { background: rgba(211, 84, 0, 0.2); border-color: rgba(211, 84, 0, 0.4); color: #e67e22; }
.type-battle { background: rgba(26, 188, 156, 0.2); border-color: rgba(26, 188, 156, 0.4); color: #1abc9c; }

.stats-overview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0;
    margin-bottom: 1.5rem;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.05);
    padding: 1rem;
    border-radius: 0 0 16px 16px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-width: 42px;
    align-items: center;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    padding: 0.5rem;
    border-radius: 8px;
}

.stat-label {
    font-size: 0.55rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.stat-diff {
    font-size: 0.65rem;
    margin-top: 0.25rem;
    display: flex;
    gap: 0.25rem;
    min-height: 0.8rem;
}

.stat-diff-add { color: #2ecc71; }
.stat-diff-remove { color: #e74c3c; }

.faq-item p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.footer {
    text-align: center;
    margin-top: 3rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.4);
}

.footer a {
    color: rgba(255, 255, 255, 0.6);
    text-decoration: underline;
    transition: color 0.2s ease;
}

.footer a:hover {
    color: rgba(255, 255, 255, 0.9);
}

.legal-disclaimer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.3);
    line-height: 1.4;
}

.legal-disclaimer p {
    margin-bottom: 0.5rem;
}

.legal-disclaimer p:last-child {
    margin-bottom: 0;
}

.badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Card Hover Preview */
#card-preview-container {
    position: fixed;
    z-index: 9999;
    pointer-events: none; /* prevent the preview from capturing mouse events */
    width: 250px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
}

#card-preview-container:not(.hidden) {
    opacity: 1;
}

#card-preview-container.hidden {
    display: block; /* Override default hidden so opacity transition works, rely on opacity=0 and pointer-events=none */
    opacity: 0;
}

#card-preview-img {
    width: 100%;
    display: block;
    border-radius: 12px; /* standard MTG card corner */
}

.perfect-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
    background: var(--add-bg);
    border-radius: 16px;
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--add-color);
    text-align: center;
}

.diff-lists {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.section-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.remove-title { color: var(--remove-color); }
.add-title { color: var(--add-color); }

.checklist {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
}

.check-item:hover {
    background: rgba(0, 0, 0, 0.4);
}

.check-item.remove {
    border-left: 3px solid var(--remove-color);
}

.check-item.add {
    border-left: 3px solid var(--add-color);
}

@keyframes destroyCard {
    0% { transform: scale(1) rotate(0); filter: brightness(1); }
    30% { transform: scale(1.02) rotate(-1deg); filter: brightness(1.5) sepia(1) hue-rotate(-50deg) saturate(5); border-color: rgba(231, 76, 60, 0.8); }
    100% { transform: scale(0.98) rotate(1deg); opacity: 0.4; filter: grayscale(1) blur(1px); border-color: rgba(255, 255, 255, 0.05); }
}

@keyframes shineCard {
    0% { box-shadow: 0 0 0 rgba(46, 204, 113, 0); border-color: rgba(255, 255, 255, 0.05); }
    40% { box-shadow: 0 0 25px rgba(46, 204, 113, 0.8), inset 0 0 15px rgba(46, 204, 113, 0.5); border-color: rgba(46, 204, 113, 1); transform: scale(1.02); }
    100% { box-shadow: 0 0 10px rgba(46, 204, 113, 0.2); border-color: rgba(46, 204, 113, 0.4); transform: scale(1); opacity: 0.6; }
}

.check-item.remove.checked {
    animation: destroyCard 0.5s ease-out forwards;
    text-decoration: line-through;
}

.check-item.add.checked {
    animation: shineCard 0.8s ease-out forwards;
    text-decoration: line-through;
}

.checkbox {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.check-item.remove .checkbox.checked-box {
    background: var(--remove-color);
    border-color: var(--remove-color);
}

.check-item.add .checkbox.checked-box {
    background: var(--add-color);
    border-color: var(--add-color);
}

.checkbox svg {
    width: 12px;
    height: 12px;
    stroke: white;
    stroke-width: 3;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.checkbox.checked-box svg {
    opacity: 1;
}

.item-qty {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.check-item.remove .item-qty { color: var(--remove-color); }
.check-item.add .item-qty { color: var(--add-color); }

.item-name {
    flex: 1;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 480px) {
    .form-row {
        flex-direction: column;
    }
    .glass-panel {
        padding: 1.5rem;
    }
}


/* Hover preview animations for checked items */
/* Static checked states for preview */
.preview-remove-checked img {
    filter: grayscale(1) brightness(0.6);
    box-shadow: 0 0 30px rgba(231, 76, 60, 0.4);
    border: 2px solid rgba(231, 76, 60, 0.6);
}

.preview-add-checked img {
    box-shadow: 0 0 30px rgba(46, 204, 113, 0.4);
    border: 2px solid rgba(46, 204, 113, 0.6);
}

/* Animated states for when it is JUST checked */
.preview-add-animate img {
    box-shadow: 0 0 30px rgba(46, 204, 113, 1);
    border: 2px solid rgba(46, 204, 113, 1);
}

.preview-add-animate::after {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    border-radius: 12px;
    background: linear-gradient(125deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.4) 40%, rgba(255,255,255,0.8) 50%, rgba(255,255,255,0.4) 60%, rgba(255,255,255,0) 100%);
    background-size: 200% 200%;
    animation: foilShine 0.8s ease-in-out forwards;
    pointer-events: none;
    mix-blend-mode: overlay;
}

@keyframes foilShine {
    0% { background-position: -100% -100%; }
    100% { background-position: 200% 200%; }
}

.share-btn {
    width: auto;
    margin-top: 0;
    padding: 0.4rem 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    background: rgba(88, 101, 242, 0.15);
    border-color: rgba(88, 101, 242, 0.3);
    color: #e0e7ff;
    transition: all 0.2s ease;
}
.share-btn:hover {
    background: rgba(88, 101, 242, 0.3);
    border-color: rgba(88, 101, 242, 0.6);
}
.share-btn.copied {
    background: rgba(46, 204, 113, 0.15);
    border-color: rgba(46, 204, 113, 0.3);
    color: #2ecc71;
}

.share-buttons-container {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    padding: 0 1.5rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.share-btn.wa-share {
    background: rgba(37, 211, 102, 0.15);
    border-color: rgba(37, 211, 102, 0.3);
    color: #25D366;
    text-decoration: none;
}
.share-btn.wa-share:hover {
    background: rgba(37, 211, 102, 0.3);
    border-color: rgba(37, 211, 102, 0.6);
}

.share-btn.tw-share {
    background: rgba(29, 161, 242, 0.15);
    border-color: rgba(29, 161, 242, 0.3);
    color: #1DA1F2;
    text-decoration: none;
}
.share-btn.tw-share:hover {
    background: rgba(29, 161, 242, 0.3);
    border-color: rgba(29, 161, 242, 0.6);
}

.share-btn.native-share {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}
.share-btn.native-share:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Favorites Section */
.favorites-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.favorite-card {
    position: relative;
    border-radius: 12px;
    height: 70px;
    overflow: hidden;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    padding: 0 1rem;
}

.favorite-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.favorite-card-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center 25%;
    opacity: 0.6;
    z-index: 0;
    transition: opacity 0.2s ease;
}

.favorite-card:hover .favorite-card-bg {
    opacity: 0.8;
}

.favorite-card-bg::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, rgba(15, 15, 22, 0.95) 0%, rgba(15, 15, 22, 0.3) 100%);
}

.favorite-card-content {
    position: relative;
    z-index: 1;
    width: 100%;
}

.favorite-deck-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

@media (max-width: 480px) {
    .favorites-grid {
        grid-template-columns: 1fr;
    }
}

.favorite-card.pinned-card {
    border-color: #eab308;
    box-shadow: 0 0 10px rgba(234, 179, 8, 0.2);
}

.pin-container {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    padding: 0.5rem;
    color: rgba(255, 255, 255, 0.3);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.pin-container:hover {
    color: #eab308;
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-50%) scale(1.1);
}

.pin-star.pinned {
    color: #eab308;
    fill: #eab308;
}
