:root {
    --bg-color: #0f1115;
    --card-bg: #1a1d24;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent-color: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.4);

    /* Status Colors */
    --soulmate-color: #d946ef;
    --soulmate-bg: rgba(217, 70, 239, 0.1);
    --friendly-color: #10b981;
    --friendly-bg: rgba(16, 185, 129, 0.1);
    --frenemy-color: #f97316;
    --frenemy-bg: rgba(249, 115, 22, 0.1);
    --neutral-color: #94a3b8;
    --neutral-bg: rgba(148, 163, 184, 0.1);
    --enemy-color: #ef4444;
    --enemy-bg: rgba(239, 68, 68, 0.1);

    --master-color: #a855f7;
    --master-bg: rgba(168, 85, 247, 0.15);

    --font-family: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 1rem;
    overflow-x: hidden;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(217, 70, 239, 0.1) 0%, transparent 40%);
}

.app-container {
    width: 100%;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin: 0 auto;
}

/* Tabs */
.app-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem;
    border-radius: 16px;
    gap: 0.5rem;
    align-self: center;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.tab-content {
    display: none;
    width: 100%;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

main {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 17, 21, 0.95);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(15px);
}

.login-box {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    width: 90%;
    max-width: 400px;
}

.login-box input {
    width: 100%;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    outline: none;
}

.login-box button {
    width: 100%;
    padding: 1rem;
    background: var(--accent-color);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 700;
    cursor: pointer;
}

header {
    text-align: center;
    margin-bottom: 1rem;
}

header h1 {
    font-size: 2rem;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-secondary);
}

/* Relations View */
.selector-section {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.number-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 0.75rem;
    justify-items: center;
}

.num-btn {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--card-bg);
    color: white;
    font-weight: 600;
    cursor: pointer;
}

.num-btn.active {
    background: var(--accent-color);
    box-shadow: 0 0 15px var(--accent-glow);
}

.relations-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.relation-card {
    background: rgba(30, 33, 40, 0.6);
    border-radius: 16px;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    min-height: 180px;
}

.card-header h3 {
    font-size: 0.9rem;
}

.card-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.card-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    font-size: 0.8rem;
}

.number-tag {
    padding: 0.5rem;
    border-radius: 8px;
    font-weight: 700;
    text-align: center;
}

/* Calendar View */
.calendar-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 1.5rem;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.currentMonthYear {
    cursor: pointer;
}

.calendar-header h2 {
    font-size: 1.25rem;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
}

.calendar-grid-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
    position: relative;
}

.calendar-day:hover {
    background: rgba(255, 255, 255, 0.08);
}

.calendar-day.other-month {
    opacity: 0.2;
    pointer-events: none;
}

.calendar-day.today {
    border: 2px solid var(--friendly-color);
}

.calendar-day.selected {
    background: var(--accent-color);
    color: white;
}

.calendar-day.master {
    background: var(--master-bg);
}

.day-num {
    font-weight: 600;
}

.master-mark {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.6rem;
    color: var(--master-color);
}

.moon-mark {
    position: absolute;
    top: 4px;
    left: 4px;
    font-size: 0.7rem;
    line-height: 1;
}

.calendar-legend {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot.today {
    background: var(--friendly-color);
}

.dot.selected {
    background: var(--accent-color);
}

.dot.master {
    background: var(--master-color);
}

/* Details Section */
.day-details {
    background: rgba(30, 33, 40, 0.4);
    border-radius: 20px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.small-btn {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.detail-box {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
}

.detail-box h4 {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 0.75rem;
}

.energy-circle {
    width: 60px;
    height: 60px;
    background: var(--accent-bg);
    border: 2px solid var(--accent-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 auto;
    color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-glow);
}

.energy-circle.secondary {
    border-color: var(--soulmate-color);
    color: var(--soulmate-color);
    box-shadow: 0 0 10px rgba(217, 70, 239, 0.3);
}

#breakdownText {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.highlight {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    margin-top: 0.5rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--card-bg);
    margin: 20% auto;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    width: 90%;
    max-width: 350px;
    position: relative;
}

.close-modal {
    position: absolute;
    right: 1.5rem;
    top: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
}

.select-group {
    margin-bottom: 1rem;
}

.select-group label {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.select-group select {
    width: 100%;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: white;
    font-family: inherit;
}

.select-group select option {
    background-color: #1a1d24;
    /* Dark background for dropdown options */
    color: white;
}

.primary-btn {
    width: 100%;
    padding: 1rem;
    background: var(--accent-color);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 700;
    cursor: pointer;
}

/* Color Overrides for tags */
.tag-soulmate {
    background: var(--soulmate-bg);
    color: var(--soulmate-color);
    border: 1px solid rgba(217, 70, 239, 0.3);
}

.tag-friendly {
    background: var(--friendly-bg);
    color: var(--friendly-color);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.tag-frenemy {
    background: var(--frenemy-bg);
    color: var(--frenemy-color);
    border: 1px solid rgba(249, 115, 22, 0.3);
}

.tag-neutral {
    background: var(--neutral-bg);
    color: var(--neutral-color);
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.tag-enemy {
    background: var(--enemy-bg);
    color: var(--enemy-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Responsive */
@media (max-width: 768px) {
    .relations-container {
        grid-template-columns: repeat(2, 1fr);
    }

    .details-grid {
        grid-template-columns: 1fr;
    }

    .app-container {
        padding: 0.5rem;
    }
}

/* Name Calculator */
.section-header-row {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.input-wrapper label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

#nameInput {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 12px;
    font-size: 1.1rem;
    color: white;
    outline: none;
    transition: all 0.3s;
}

#nameInput:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-glow);
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.toggle-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent-color);
}

input:checked+.slider:before {
    transform: translateX(24px);
}

/* Result Box */
.name-result-box {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    animation: fadeIn 0.3s ease;
}

.name-result-box.hidden {
    display: none;
}

.result-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.95rem;
}

.result-row:last-child {
    border-bottom: none;
}

.result-row .label {
    color: var(--text-secondary);
}

.result-row .value {
    font-weight: 600;
    text-align: right;
    word-break: break-all;
    max-width: 70%;
}

.highlight-row .value {
    color: var(--accent-color);
    font-size: 1.1rem;
}

.final-result {
    margin-top: 1.5rem;
    text-align: center;
    background: rgba(168, 85, 247, 0.1);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--master-color);
}

.final-result h4 {
    color: var(--master-color);
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.mode-annotation {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Forecast View */
.forecast-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(30, 33, 40, 0.4);
    border-radius: 12px;
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.forecast-controls h3 {
    font-size: 1.1rem;
    margin: 0;
}

.forecast-container {
    overflow-x: auto;
    padding-bottom: 20px;
}

/* Scroller: Fixed headers for animals */
.forecast-scroller {
    display: table;
    min-width: 1000px;
    border-collapse: separate;
    border-spacing: 0.5rem;
}

.f-head-row {
    display: table-row;
}

.f-head-cell {
    display: table-cell;
    background: #1a1d24;
    color: var(--text-secondary);
    text-align: center;
    padding: 0.75rem;
    border-radius: 8px;
    font-weight: 600;
    min-width: 100px;
}

.f-row {
    display: table-row;
}

.f-cell {
    display: table-cell;
    background: #1e2128;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0.75rem;
    text-align: center;
    vertical-align: top;
    position: relative;
    transition: all 0.2s;
}

.f-cell.current-year {
    border: 2px solid var(--accent-color);
    box-shadow: 0 0 15px var(--accent-glow);
    z-index: 10;
}

.f-year {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: white;
}

.f-univ {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.f-cny {
    display: block;
    font-size: 0.8rem;
    color: #a5b4fc;
    margin-bottom: 0.25rem;
}

.f-elem-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
}

.elem-Metal {
    background: #94a3b8;
    color: #0f172a;
}

.elem-Water {
    background: #3b82f6;
}

.elem-Wood {
    background: #10b981;
}

.elem-Fire {
    background: #ef4444;
}

/* Compatibility View */
.comp-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.comp-person-input {
    display: flex;
    flex-direction: column;
}

.comp-person-input label,
.comp-mode-select label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.date-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.8rem;
    border-radius: 12px;
    color: white;
    font-family: inherit;
    width: 100%;
}

.comp-mode-select {
    margin-bottom: 2rem;
}

.select-wrapper select {
    width: 100%;
    padding: 1rem;
    background: #1a1d24;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
}

.comp-result-container {
    margin-top: 2rem;
    animation: fadeIn 0.5s ease;
}

.score-card {
    text-align: center;
    margin-bottom: 2rem;
}

.score-circle-outer {
    margin: 0 auto 1rem;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: conic-gradient(var(--accent-color) 0%, rgba(255, 255, 255, 0.1) 0%);
    padding: 4px;
    position: relative;
    /* We will update this gradient via JS */
}

.score-circle-inner {
    width: 100%;
    height: 100%;
    background: #151921;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#finalScoreVal {
    font-size: 2rem;
    font-weight: 700;
}

.comp-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.person-col h4 {
    margin-bottom: 1rem;
    color: var(--accent-color);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.stat-val {
    font-weight: 600;
    color: white;
}

.matchmaking-guide {
    margin-top: 1.5rem;
    background: rgba(16, 185, 129, 0.1);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.match-row {
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.match-list.avoid {
    color: #ef4444;
}

@media (max-width: 600px) {
    .comp-details-grid {
        grid-template-columns: 1fr;
    }
}

/* Directory View */
.search-controls {
    margin-bottom: 1.5rem;
}

#dirSearch {
    width: 100%;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    outline: none;
    margin-bottom: 1rem;
}

#dirSearch:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-glow);
}

.filter-chips {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.chip.active,
.chip:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.directory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.brand-card {
    background: rgba(30, 33, 40, 0.6);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.2s;
}

.brand-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-color);
}

.brand-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.75rem;
}

.brand-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
}

.brand-cat {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 8px;
    color: var(--text-secondary);
}

.brand-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.5rem;
}

.brand-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.b-stat {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
    border-radius: 8px;
    text-align: center;
}

.b-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.7rem;
    margin-bottom: 2px;
}

.b-val {
    font-weight: 700;
    color: white;
}

.b-val.highlight {
    color: var(--accent-color);
}

.b-val.master {
    color: var(--master-color);
    text-shadow: 0 0 5px var(--master-color);
}

/* Modal Custom Inputs */
.select-group {
    margin-bottom: 1rem;
    text-align: left;
}

.select-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

#addEntryModal input,
#addEntryModal select {
    width: 100%;
}

#addEntryModal .modal-content {
    background: #1e2128;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Directory Personalize */
.personalize-box {
    background: #1a1d24;
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    margin-top: 1rem;
}

.p-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-color);
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.p-icon {
    font-size: 1.2rem;
}

.p-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.p-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.brand-card.dir-match {
    border: 2px solid var(--accent-color);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.1);
    position: relative;
}

.match-badge {
    position: absolute;
    top: -10px;
    right: 10px;
    background: var(--accent-color);
    color: #0f172a;
    font-size: 0.75rem;
    padding: 2px 10px;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
    font-weight: 700;
    z-index: 5;
    animation: bounceIn 0.5s;
}

@keyframes bounceIn {
    0% {
        transform: scale(0);
    }

    80% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* Tracker Styles */
#trackerDetailMode .brand-card {
    text-align: center;
}

.profile-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.profile-card:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.profile-content {
    text-align: left;
}

.profile-name {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.profile-dob {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

#backToProfiles {
    background: transparent;
    border: none;
    color: var(--accent-color);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    font-weight: 600;
}

/* --- MOBILE OPTIMIZATION --- */
@media (max-width: 768px) {

    /* Layout */
    .app-container {
        padding: 0.5rem;
        gap: 1rem;
    }

    /* Reduce card padding on mobile */
    .calendar-card,
    .brand-card,
    .day-details {
        padding: 0.75rem;
    }

    .calendar-grid {
        gap: 2px;
        /* Tighter grid */
    }

    /* Headers */
    header h1 {
        font-size: 1.5rem;
        /* Smaller title */
    }

    /* Tabs: Scrollable instead of wrapping messy */
    .app-tabs {
        width: 100%;
        max-width: 100vw;
        overflow-x: auto;
        white-space: nowrap;
        justify-content: flex-start;
        padding: 0.5rem;
        background: rgba(255, 255, 255, 0.03);
        border-radius: 12px;
        -webkit-overflow-scrolling: touch;
    }

    /* Show scrollbar for UX clarity (thin) */
    .app-tabs::-webkit-scrollbar {
        height: 4px;
        display: block;
    }

    .app-tabs::-webkit-scrollbar-thumb {
        background: var(--accent-color);
        border-radius: 4px;
    }

    .tab-btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
        flex-shrink: 0;
        border-bottom: 2px solid transparent;
    }

    /* Calendar Grid */
    .calendar-day {
        font-size: 0.85rem;
        border-radius: 6px;
        min-height: 40px;
        /* Ensure logical height */
    }

    .master-mark {
        font-size: 0.5rem;
        top: 2px;
        right: 2px;
    }

    .moon-mark {
        font-size: 0.6rem;
        top: 2px;
        left: 2px;
    }

    /* Details Grid: Stack */
    .details-grid {
        grid-template-columns: 1fr;
    }

    /* Tracker Stats: Keep as grid on small screens but compact */
    .tracker-stats-grid {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 0.25rem;
        font-size: 0.75rem;
    }

    .tracker-stats-grid .b-stat {
        padding: 0.25rem;
    }

    .tracker-stats-grid .b-label {
        font-size: 0.65rem;
    }

    .tracker-stats-grid .b-val {
        font-size: 0.9rem !important;
        /* Force smaller size */
    }

    /* Directory: Full width cards */
    .directory-grid {
        grid-template-columns: 1fr;
    }

    .search-controls {
        flex-direction: column;
    }

    .search-controls button {
        width: 100%;
        margin-top: 0.5rem;
    }

    /* Forecast Scroller */
    .forecast-scroller {
        /* Ensure it scrolls well */
        min-width: 800px;
    }

    /* Modals */
    .modal-content {
        width: 95%;
        margin: 5% auto;
        /* Higher up */
        padding: 1rem;
    }
}