@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Cinzel:wght@600;800&display=swap');

:root {
    /* Base Theme - Will be overridden by JS */
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-primary: #27272a;
    --text-secondary: #52525b;
    --hud-bg: #18181b;
    --hud-text: #ffffff;
    --hud-border: #3f3f46;

    --card-width: 260px;
    --card-height: 440px;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 40px 20px 200px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

/* --- Header --- */
header {
    text-align: center;
    margin-bottom: 40px;
    max-width: 600px;
}

h1 {
    font-family: 'Cinzel', serif;
    font-size: 2.5rem;
    margin: 0 0 10px 0;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

p.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin: 0;
    line-height: 1.5;
}

/* --- Grid --- */
.card-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    max-width: 1200px;
    perspective: 1000px;
}

/* --- Card Styles --- */
.card {
    width: var(--card-width);
    height: var(--card-height);
    background: var(--card-bg);
    border-radius: 16px;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05), 
                0 8px 10px -6px rgba(0,0,0,0.01),
                0 0 0 1px rgba(0,0,0,0.04);
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    border-top: 6px solid transparent;
    cursor: pointer;
    user-select: none;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px -12px rgba(0,0,0,0.1);
}

.card.active {
    transform: translateY(-8px);
    box-shadow: 0 0 0 2px var(--text-primary), 0 20px 40px -12px rgba(0,0,0,0.2);
}

.card.disabled {
    filter: grayscale(1) opacity(0.5);
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Card Internals */
.card-header {
    padding: 20px 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.points-badge {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Cinzel', serif;
    font-weight: 800;
    font-size: 1.1rem;
    border: 2px solid currentColor;
    background: white;
    z-index: 2;
}

.duration-tag {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 12px;
    border-radius: 6px;
    background-color: #f4f4f5;
    color: var(--text-secondary);
}

.emblem-container {
    height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 15px;
    position: relative;
}

.emblem-icon {
    font-size: 72px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.05));
    transition: transform 0.3s ease;
}

.card:hover .emblem-icon {
    transform: scale(1.1) rotate(5deg);
}

.card-content {
    padding: 10px 24px 24px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    text-align: center;
}

.quest-name {
    font-family: 'Cinzel', serif;
    font-size: 1.25rem;
    font-weight: 800;
    margin: 0 0 6px 0;
    color: var(--text-primary);
}

.role-name {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
    display: block;
}

.description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
    flex-grow: 1;
}

.divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0,0,0,0.1), transparent);
    width: 100%;
    margin: 0 auto 16px auto;
}

.quote {
    font-family: 'Inter', sans-serif;
    font-style: italic;
    font-size: 0.8rem;
    color: var(--text-primary);
    opacity: 0.7;
}

/* Controls */
.card-controls {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease;
    pointer-events: none;
    z-index: 10;
}

.card.active .card-controls {
    opacity: 1;
    transform: scale(1);
    pointer-events: all;
}

.card-badge {
    background: #ef4444;
    color: white;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.card-remove {
    background: #ffffff;
    color: #ef4444;
    border: 2px solid #ef4444;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: background 0.2s, color 0.2s;
}

.card-remove:hover {
    background: #ef4444;
    color: white;
}

/* --- HUD --- */
.sprint-hud {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--hud-bg);
    color: var(--hud-text);
    padding: 16px 20px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 100;
    width: 90vw;
    max-width: 450px;
    min-width: 0;
    border: 2px solid var(--hud-border);
}

.sprint-hud.shake {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

.hud-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.duration-toggles {
    display: flex;
    background: #27272a;
    padding: 3px;
    border-radius: 8px;
    border: 1px solid var(--hud-border);
    flex-shrink: 0;
}

.dur-btn {
    background: transparent;
    border: none;
    color: #71717a;
    padding: 5px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.dur-btn.active {
    background: var(--hud-border);
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.dur-btn:hover:not(.active) {
    color: #d4d4d8;
}

.hud-stats-container {
    flex-grow: 1;
    text-align: center;
    white-space: nowrap;
}

.hud-stats {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
}

.hud-stats-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #a1a1aa;
    margin-left: 4px;
}

.reset-btn {
    background: var(--hud-border);
    color: #a1a1aa;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.reset-btn:hover {
    background: #ef4444;
    color: white;
    transform: rotate(90deg);
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background: #27272a;
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #a855f7);
    width: 0%;
    transition: width 0.3s ease;
}

.hud-legend {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    border-top: 1px solid #27272a;
    padding-top: 10px;
    min-height: 28px;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #27272a;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 0.8rem;
    border: 1px solid var(--hud-border);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.legend-item i {
    font-size: 1rem;
}

.legend-count {
    color: #a1a1aa;
    font-weight: 600;
}

/* --- Animations & Utilities --- */
@keyframes shake {
    0%, 100% { transform: translateX(-50%); }
    10%, 90% { transform: translateX(calc(-50% - 2px)); }
    20%, 80% { transform: translateX(calc(-50% + 4px)); }
    30%, 50%, 70% { transform: translateX(calc(-50% - 8px)); }
    40%, 60% { transform: translateX(calc(-50% + 8px)); }
}

@keyframes popIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Mobile specific adjustments */
@media (max-width: 480px) {
    .sprint-hud {
        padding: 12px 14px;
    }
    .dur-btn {
        padding: 6px 8px;
    }
    .hud-header {
        gap: 8px;
    }
    .hud-stats {
        font-size: 0.9rem;
    }
    .hud-stats-label {
        display: none;
    }
}

/* --- Toast --- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: #27272a;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    border-left: 4px solid #3b82f6;
    animation: slideIn 0.3s ease forwards;
    pointer-events: all;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 300px;
}

.toast.warning {
    border-left-color: #ef4444;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Print Optimization */
@media print {
    .sprint-hud, #toast-container, .card-controls { display: none !important; }
    .card.active { box-shadow: none !important; transform: none !important; border: 2px solid #000; }
    .card.active::after {
        content: 'x' attr(data-print-count);
        position: absolute; top: 10px; right: 10px;
        font-size: 24px; font-weight: bold; background: white;
        border: 2px solid black; border-radius: 50%; width: 40px; height: 40px;
        display: flex; align-items: center; justify-content: center; z-index: 20;
    }
    .card.disabled { filter: none; opacity: 1; }
    body { padding-bottom: 0; }
}
