* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, rgba(102,126,234,0.6) 0%, rgba(118,75,162,0.6) 100%), url('background.jpg') center/cover fixed no-repeat;
    min-height: 100vh;
    color: #333;
}

/* Body lock for mobile/tablet when modals are open */
body.modal-open-mobile {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Lock scroll to specific element on mobile/tablet */
body.modal-open-mobile .scroll-lock-target {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    color: white;
    position: relative;
    padding: 20px 20px;
}

header > * {
    position: relative;
    z-index: 1;
}

.logo-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
    pointer-events: none;
}

.app-logo {
    width: 10rem;
    height: 10rem;
    opacity: 0.15;
    filter: blur(0.5px);
    transition: all 0.4s ease;
}

header:hover .app-logo {
    opacity: 0.3;
    filter: blur(0px);
    animation: logoHop 0.6s ease-in-out infinite;
}

@keyframes logoHop {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.discord-contact {
    text-align: center;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 12px;
    flex-wrap: wrap;
}

.discord-btn {
    background: rgba(88, 101, 242, 0.3);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 2px solid rgba(88, 101, 242, 0.5);
    color: rgba(255, 255, 255, 0.95);
    padding: 12px 24px;
    border-radius: 14px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    text-decoration: none;
}

.discord-btn:hover {
    background: rgba(88, 101, 242, 0.22);
    border-color: rgba(88, 101, 242, 0.7);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15), 0 0 12px rgba(88, 101, 242, 0.25);
}

.discord-icon {
    flex-shrink: 0;
}

.discord-text {
    text-align: left;
    line-height: 1.4;
}

.discord-text strong {
    color: rgba(255, 255, 255, 1);
    transition: color 0.3s ease;
}

.kofi-btn {
    background: rgba(230, 57, 70, 0.3);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 2px solid rgba(230, 57, 70, 0.5);
    color: rgba(255, 255, 255, 0.95);
    padding: 12px 24px;
    border-radius: 14px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    text-decoration: none;
}

.kofi-btn:hover {
    background: rgba(230, 57, 70, 0.22);
    border-color: rgba(230, 57, 70, 0.7);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15), 0 0 12px rgba(230, 57, 70, 0.25);
}

.kofi-text {
    text-align: left;
    line-height: 1.4;
}

/* ========================================
   Changelog Section
   ======================================== */
.changelog-section {
    margin-top: 60px;
    padding: 40px 20px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(168, 85, 247, 0.05) 100%);
    border-top: 2px solid rgba(99, 102, 241, 0.2);
}

.changelog-wrapper {
    max-width: 900px;
    margin: 0 auto;
    position: relative;
}

.changelog-title {
    font-size: 2rem;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 30px;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.changelog-preview {
    position: relative;
}

.changelog-entries,
.changelog-entries-full {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.changelog-entry {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.changelog-entry:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.changelog-date {
    font-size: 1.1rem;
    font-weight: 600;
    color: #6366f1;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid rgba(99, 102, 241, 0.2);
}

.changelog-changes {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.changelog-category {
    margin-left: 8px;
}

.changelog-category-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.changelog-items {
    list-style: none;
    padding: 0;
    margin: 0 0 0 20px;
}

.changelog-items li {
    font-size: 0.9rem;
    color: #4a5568;
    line-height: 1.6;
    margin-bottom: 6px;
    padding-left: 20px;
    position: relative;
}

.changelog-items li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: #6366f1;
    font-weight: bold;
}

.changelog-items li:last-child {
    margin-bottom: 0;
}

.changelog-empty {
    text-align: center;
    color: #718096;
    font-style: italic;
    padding: 40px;
}

/* Fade Overlay and Show More Button */
.changelog-fade-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(to bottom,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 20%,
        rgba(255, 255, 255, 0.6) 40%,
        rgba(255, 255, 255, 0.85) 60%,
        rgba(247, 250, 252, 0.95) 80%,
        rgba(247, 250, 252, 1) 100%
    );
    pointer-events: none;
    border-radius: 0 0 12px 12px;
    z-index: 1;
}

.changelog-show-more {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 32px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    z-index: 2;
}

.changelog-show-more:hover {
    transform: translateX(-50%) translateY(-3px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
    background: linear-gradient(135deg, #5558e3 0%, #7c4ee8 100%);
}

.changelog-show-more:active {
    transform: translateX(-50%) translateY(0);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Changelog Modal */
.changelog-modal-panel {
    max-width: 900px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.changelog-filter-bar {
    padding: 16px 24px;
    background: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.changelog-filter-bar label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #4a5568;
}

.changelog-date-select {
    padding: 8px 32px 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #2d3748;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234a5568' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.changelog-date-select:hover {
    border-color: #6366f1;
}

.changelog-date-select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.changelog-modal-body {
    overflow-y: auto;
    max-height: calc(85vh - 180px);
}

.changelog-modal-body .changelog-entries-full {
    gap: 24px;
    padding: 8px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .changelog-section {
        margin-top: 40px;
        padding: 30px 15px;
    }
    
    .changelog-title {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }
    
    .changelog-entry {
        padding: 20px;
    }
    
    .changelog-date {
        font-size: 1rem;
    }
    
    .changelog-items li {
        font-size: 0.85rem;
    }
    
    .changelog-show-more {
        font-size: 0.9rem;
        padding: 10px 24px;
    }
    
    .changelog-modal-panel {
        max-width: 95%;
        max-height: 90vh;
    }
    
    .changelog-filter-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .changelog-date-select {
        width: 100%;
    }
}

.app-footer {
    margin-top: 40px;
    padding: 20px 20px;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    transition: opacity 0.5s ease-in-out;
    opacity: 0.3;
}

.app-footer:hover {
    opacity: 1;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 300;
}

.footer-heart {
    color: #d47a7a;
    font-size: 1.1em;
    animation: none;
    transition: all 0.3s ease;
}

.app-footer:hover .footer-heart {
    animation: heartbeat 2.5s ease-in-out infinite;
}

.footer-text strong {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

@keyframes heartbeat {
    0%, 50%, 100% {
        transform: scale(1);
        color: #d47a7a;
    }
    25%, 75% {
        transform: scale(1.4);
        color: #e89b9b;
    }
}

h1 {
    font-size: 2rem;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

.main-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    height: auto; /* allow planner to grow without inner scrollbars */
    align-items: start; /* base behavior */
}

.races-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: visible;
}
/* Glass effect variant for calendar container */
#calendar-section {
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(8px) saturate(120%);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
    border: 1px solid rgba(255,255,255,0.4);
}
/* Apply same glass style to planner and progress panels */
#planner-section,
#progress-panel {
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(8px) saturate(120%);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
    border: 1px solid rgba(255,255,255,0.4);
}

.progress-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow-y: auto; /* scroll within progress panel */
    overflow-x: hidden;
    align-self: start; /* do not stretch the grid row */
    display: flex;
    flex-direction: column;
}

.section-title {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: #4a5568;
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
}

.controls {
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.controls-selection-row {
    margin-top: -12px;
    padding-top: 0;
}

/* Database Toggle (JP/EN) */
.db-toggle {
    display: flex;
    gap: 4px;
    background: rgba(56, 161, 105, 0.3);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 2px solid rgba(56, 161, 105, 0.5);
    border-radius: 14px;
    padding: 4px;
    align-self: center;
}

.db-toggle-btn {
    padding: 8px 16px;
    border: 2px solid transparent;
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
    line-height: 1.2;
}

.db-toggle-btn:hover {
    background: rgba(56, 161, 105, 0.18);
    border-color: rgba(56, 161, 105, 0.4);
}

.db-toggle-btn.active {
    background: rgba(56, 161, 105, 0.7);
    color: white;
    box-shadow: 0 2px 8px rgba(56, 161, 105, 0.25);
    border-color: rgba(56, 161, 105, 0.6);
}

.db-toggle-btn.active[data-db="en"] {
    background: rgba(56, 161, 105, 0.75);
    box-shadow: 0 2px 8px rgba(56, 161, 105, 0.35);
}

.filter-btn {
    padding: 8px 16px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
    height: 56px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.filter-btn:hover {
    background: #667eea;
    color: white;
}

.filter-btn.active {
    background: #667eea;
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.filter-btn.summer-active {
    background: linear-gradient(135deg, #f97316 0%, #fb923c 100%);
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.4);
    border-color: #ea580c;
}

/* Summer series filter buttons - non-active state with orange outline */
.filter-btn[data-filter="SSS"]:not(.active),
.filter-btn[data-filter="SMS"]:not(.active),
.filter-btn[data-filter="S2000"]:not(.active) {
    border-color: #f97316;
    background: white;
    color: #f97316;
}

.filter-btn[data-filter="SSS"]:not(.active):hover,
.filter-btn[data-filter="SMS"]:not(.active):hover,
.filter-btn[data-filter="S2000"]:not(.active):hover {
    background: rgba(249, 115, 22, 0.1);
    border-color: #ea580c;
    color: #ea580c;
}

/* Selected filter button - green color scheme */
.filter-btn[data-filter="selected"] {
    border-color: #38a169;
    background: white;
    color: #38a169;
}

.filter-btn[data-filter="selected"]:hover {
    background: rgba(56, 161, 105, 0.1);
    border-color: #2f855a;
    color: #2f855a;
}

.filter-btn[data-filter="selected"].active {
    background: #38a169;
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(56, 161, 105, 0.3);
}

/* Clear All Selection button - red color scheme similar to Selected */
.clear-all-btn {
    border-color: #e53e3e !important;
    background: white !important;
    color: #e53e3e !important;
}

.clear-all-btn:hover {
    background: rgba(229, 62, 62, 0.1) !important;
    border-color: #c53030 !important;
    color: #c53030 !important;
}

.races-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 8px;
    max-height: 850px;
    overflow-y: auto;
    padding-right: 8px; /* Space for scrollbar */
}

/* Planner UI (game-like tabs and month/half grid) */
.year-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.year-tab {
    flex: 0 0 auto;
    padding: 8px 14px;
    border-radius: 18px;
    border: 2px solid transparent;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    height: 56px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Junior tab - Pastel mint green */
.year-tab[data-year="junior"] {
    background: #E8F5F0;
    color: #2d5f4d;
    border-color: #B8E6D5;
}
.year-tab[data-year="junior"].active,
.year-tab[data-year="junior"]:hover {
    background: #B8E6D5;
    color: #1a4032;
    border-color: #8fd4bd;
}

/* Classics tab - Pastel pink */
.year-tab[data-year="classics"] {
    background: #FFF0F5;
    color: #6b2d45;
    border-color: #FFD4E5;
}
.year-tab[data-year="classics"].active,
.year-tab[data-year="classics"]:hover {
    background: #FFD4E5;
    color: #4a1f31;
    border-color: #ffb3d1;
}

/* Senior tab - Pastel blue */
.year-tab[data-year="senior"] {
    background: #EEF3FF;
    color: #2d4a6b;
    border-color: #D4E5FF;
}
.year-tab[data-year="senior"].active,
.year-tab[data-year="senior"]:hover {
    background: #D4E5FF;
    color: #1a2f4a;
    border-color: #b3d1ff;
}
.planner-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.planner-slot {
    background: #f8f9fa;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}
.planner-slot.disabled { opacity: 0.55; filter: grayscale(1); }
.planner-slot-head {
    background: #e6fffa;
    color: #2c7a7b;
    border-bottom: 1px solid #bee3f8;
    padding: 4px 6px;
    font-weight: 700;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.planner-slot-head .en { font-size: 0.65rem; color: #4a5568; font-weight: 600; }

/* Year-specific colors for planner headers - using inactive filter colors */
.planner-slot.year-junior .planner-slot-head {
    background: #E8F5F0; /* Light mint green (inactive) */
    color: #2d5f4d;
    border-bottom-color: #B8E6D5;
}

.planner-slot.year-classics .planner-slot-head {
    background: #FFF0F5; /* Light pink (inactive) */
    color: #6b2d45;
    border-bottom-color: #FFD4E5;
}

.planner-slot.year-senior .planner-slot-head {
    background: #EEF3FF; /* Light blue (inactive) */
    color: #2d4a6b;
    border-bottom-color: #D4E5FF;
}

/* Year-specific colors for slot titles (race names) - using inactive filter colors */
.slot-title.year-junior .en,
.slot-title.year-junior .jp {
    color: #E8F5F0; /* Light mint green (inactive) */
    -webkit-text-stroke: 0.8px rgba(0,0,0,1);
    text-shadow:
        0 2px 4px rgba(0,0,0,1),
        0 1px 2px rgba(0,0,0,1),
        0 0 4px rgba(0,0,0,0.8);
}

.slot-title.year-classics .en,
.slot-title.year-classics .jp {
    color: #FFF0F5; /* Light pink (inactive) */
    -webkit-text-stroke: 0.8px rgba(0,0,0,1);
    text-shadow:
        0 2px 4px rgba(0,0,0,1),
        0 1px 2px rgba(0,0,0,1),
        0 0 4px rgba(0,0,0,0.8);
}

.slot-title.year-senior .en,
.slot-title.year-senior .jp {
    color: #EEF3FF; /* Light blue (inactive) */
    -webkit-text-stroke: 0.8px rgba(0,0,0,1);
    text-shadow:
        0 2px 4px rgba(0,0,0,1),
        0 1px 2px rgba(0,0,0,1),
        0 0 4px rgba(0,0,0,0.8);
}

/* Race Planner Legend */
.planner-section-title {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.planner-title-left {
    flex-shrink: 0;
}

.planner-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    font-size: 0.72rem;
    font-weight: 500;
    color: #718096;
    margin-bottom: 4px;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

.legend-icon {
    font-size: 0.85rem;
}

.legend-badge {
    width: 18px;
    height: 18px;
    font-size: 0.6rem;
}

.legend-label {
    font-weight: 600;
    color: #4a5568;
}

.legend-sep {
    color: #cbd5e0;
    font-weight: 300;
    user-select: none;
}

.legend-penalty-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: relative;
}

.legend-help {
    cursor: help;
    font-size: 0.75rem;
    opacity: 0.6;
    transition: opacity 0.2s ease;
    user-select: none;
}

.legend-help:hover {
    opacity: 1;
}

.legend-tooltip {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 420px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
    padding: 14px 16px;
    z-index: 100;
    font-size: 0.75rem;
    line-height: 1.5;
    color: #2d3748;
    pointer-events: none;
}

.legend-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 16px;
    width: 10px;
    height: 10px;
    background: #fff;
    border-left: 1px solid #e2e8f0;
    border-top: 1px solid #e2e8f0;
    transform: rotate(45deg);
}

.legend-penalty-group:hover .legend-tooltip {
    display: block;
    pointer-events: auto;
}

.legend-tooltip-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: #4a5568;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e2e8f0;
}

.legend-tooltip-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.legend-tooltip-list li {
    padding: 4px 0;
    border-bottom: 1px solid #f7fafc;
    color: #4a5568;
}

.legend-tooltip-list li:last-child {
    border-bottom: none;
}

.legend-tooltip-list li strong {
    color: #38a169;
    font-weight: 700;
}

/* Consecutive Race Counter Badges */
.consecutive-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
    line-height: 1;
    border: 2px solid;
}

.consecutive-green {
    background: rgba(56, 161, 105, 0.15);
    border-color: #38a169;
    color: #276749;
}

.consecutive-yellow {
    background: rgba(236, 201, 75, 0.2);
    border-color: #d69e2e;
    color: #975a16;
}

.consecutive-orange {
    background: rgba(237, 137, 54, 0.2);
    border-color: #dd6b20;
    color: #9c4221;
}

.consecutive-red {
    background: rgba(229, 62, 62, 0.2);
    border-color: #e53e3e;
    color: #9b2c2c;
}

/* Summer colors take precedence over year colors */
.planner-slot.summer {
    background: #fef5e7;
    border-color: #f6ad55;
}
.planner-slot.summer .planner-slot-head {
    background: #fed7aa;
    color: #9c4221;
    border-bottom-color: #fbbf24;
}
.planner-slot.summer .planner-slot-head .en {
    color: #92400e;
}

/* Summer colors for slot titles (race names) - override year colors */
.planner-slot.summer .slot-title .en,
.planner-slot.summer .slot-title .jp {
    color: #fff; /* White text for summer slots */
    -webkit-text-stroke: 0.8px rgba(0,0,0,1);
    text-shadow:
        0 2px 4px rgba(0,0,0,1),
        0 1px 2px rgba(0,0,0,1),
        0 0 4px rgba(0,0,0,0.8);
}

.planner-slot-body {
    padding: 6px;
    height: 98px; /* Fixed height: 80px button + 12px padding + 6px gap */
    min-height: 98px;
    max-height: 98px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    align-items: stretch;
    overflow: hidden; /* Prevent content overflow */
}
.planner-plus {
    border: 2px dashed #a0aec0;
    color: #718096;
    border-radius: 6px;
    padding: 6px 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    cursor: pointer;
    background: #fff;
    font-size: 0.85rem;
}
.planner-plus.disabled { border-color: #e2e8f0; color: #a0aec0; background: #f7fafc; cursor: not-allowed; pointer-events: none; }
/* Single-race slot button with background image and bottom overlay */
.slot-wrapper { position: relative; width: 100%; }
.slot-button {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    height: 80px;
    min-height: 80px;
    max-height: 80px; /* Prevent expansion */
    width: 100%;
    display: block;
    background: #edf2f7 center/cover no-repeat;
    border: 1px solid #cbd5e0;
    cursor: pointer;
}
.slot-button.badge-won { outline: 2px solid #38a169; }
.slot-button.badge-lost { outline: 2px solid #e53e3e; }
.slot-gradient {
    position: absolute;
    left: 0; right: 0; bottom: 0; top: 0;
    background: 
        /* Scanlines */
        repeating-linear-gradient(
            0deg,
            rgba(0, 0, 0, 0.15) 0px,
            rgba(0, 0, 0, 0.15) 1px,
            transparent 1px,
            transparent 3px
        ),
        /* Dark gradient overlay */
        linear-gradient(to top, rgba(0,0,0,0.65), rgba(0,0,0,0.18) 45%, rgba(0,0,0,0));
    pointer-events: none;
}
.slot-title {
    position: absolute;
    left: 0; 
    right: 0; 
    bottom: 0;
    color: #fff;
    z-index: 5;
    background: linear-gradient(to top, rgba(0,0,0,0.85), rgba(0,0,0,0.6) 50%, transparent);
    padding: 8px 10px 6px 10px;
    border-radius: 0 0 10px 10px; /* Match button border radius at bottom */
}
.slot-title .en { 
    font-weight: 800; 
    font-size: 0.9rem; 
    -webkit-text-stroke: 0.8px rgba(0,0,0,1); 
    letter-spacing: 0.3px;
    text-shadow: 
        0 2px 4px rgba(0,0,0,1), 
        0 1px 2px rgba(0,0,0,1), 
        0 0 4px rgba(0,0,0,0.8);
    line-height: 1.2;
    display: block;
}
.slot-title .jp { 
    font-size: 0.85rem; 
    font-weight: 700;
    -webkit-text-stroke: 0.7px rgba(0,0,0,1);
    text-shadow: 
        0 2px 4px rgba(0,0,0,1), 
        0 1px 2px rgba(0,0,0,1), 
        0 0 4px rgba(0,0,0,0.8);
    line-height: 1.2;
    display: block;
    margin-top: 2px;
}
.slot-remove { position: absolute; top: 6px; right: 6px; border: 1px solid #e2e8f0; background: rgba(255,255,255,0.9); color: #2d3748; border-radius: 6px; padding: 2px 6px; cursor: pointer; z-index: 10; }
/* Improve planner overlay legibility for the toggle button */
.slot-wrapper .loss-toggle-btn { background: rgba(0,0,0,0.55); color: #fff; border-color: rgba(255,255,255,0.7); box-shadow: 0 2px 6px rgba(0,0,0,0.35); -webkit-text-stroke: 0.6px rgba(0,0,0,0.6); padding: 2px 6px; font-size: 0.85rem; border-radius: 6px; z-index: 10; }
.slot-wrapper .loss-toggle-btn.lost { background: rgba(229,62,62,0.92); border-color: rgba(255,255,255,0.8); }

/* Picker modal */
.hidden { display: none !important; }
.picker-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.picker-backdrop { position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,0.55), rgba(0,0,0,0.25)); }
.picker-panel {
    position: relative;
    background: #fff;
    width: min(720px, 92vw);
    max-height: min(560px, 82vh);
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.35);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Carousel Container */
.picker-carousel {
    display: flex;
    width: 300%; /* 3 cards side by side */
    flex: 1; /* Take remaining space between header and footer */
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform: translate3d(-33.333%, 0, 0); /* Start at center card */
    will-change: transform;
    backface-visibility: hidden;
    overflow: hidden;
}

.picker-carousel.no-transition {
    transition: none;
    will-change: auto;
}

/* Individual Cards */
.picker-card {
    width: 33.333%; /* Each card takes 1/3 of carousel */
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    height: 100%;
}

.picker-card-prev,
.picker-card-next {
    pointer-events: none; /* Prevent interaction with adjacent cards */
}

.picker-card-current {
    pointer-events: auto;
}
.picker-nav { position: fixed; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,0.4); color:#fff; border: 1px solid rgba(255,255,255,0.7); border-radius: 999px; width: 56px; height: 56px; font-size: 28px; display:flex; align-items:center; justify-content:center; cursor: pointer; z-index: 1002; }
.picker-nav:hover { background: rgba(0,0,0,0.6); }
.picker-nav-left { left: 16px; }
.picker-nav-right { right: 16px; }
.picker-head { 
    padding: 8px 12px; 
    background: #38a169; 
    color: #fff; 
    display: flex; 
    align-items: center; 
    justify-content: space-between;
    flex-shrink: 0;
    min-height: 44px;
}

.picker-title { 
    font-weight: 800;
    line-height: 1.3;
    transition: opacity 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.picker-title.fading {
    opacity: 0;
}

.picker-title-en {
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.2;
}

.picker-title-jp {
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0.95;
    line-height: 1.2;
}
.picker-body { 
    padding: 8px 10px; 
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
}
.picker-actions { 
    display: none;
}
.btn { 
    padding: 8px 14px; 
    border-radius: 8px; 
    border: 2px solid transparent; 
    cursor: pointer; 
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.btn-text-en {
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.1;
}

.btn-text-jp {
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0.9;
    line-height: 1.1;
}
.btn-primary { background: #38a169; color: #fff; border-color: #38a169; }
.btn-secondary { background: #edf2f7; color: #2d3748; border-color: #cbd5e0; }
/* Picker item grid */
.picker-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    gap: 8px;
}

/* Banner card picker items */
.picker-item {
    position: relative;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    background: #f7fafc;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.picker-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.picker-item:active {
    transform: scale(0.98);
}

/* Banner image */
.picker-item-banner {
    position: relative;
    width: 100%;
    aspect-ratio: 2.8 / 1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
}

.picker-item-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 30%;
    display: block;
}

/* Grade pill - top right of banner */
.picker-item-grade {
    position: absolute;
    top: 4px;
    right: 4px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.55rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #fff;
    backdrop-filter: blur(4px);
    z-index: 2;
}

/* Name overlay on banner */
.picker-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 6px 4px;
    background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0) 100%);
    z-index: 1;
}

.picker-item-name-en {
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    -webkit-text-stroke: 0.5px rgba(0,0,0,0.6);
    text-shadow:
        0 1px 3px rgba(0,0,0,0.8),
        0 0 6px rgba(0,0,0,0.5),
        1px 1px 2px rgba(0,0,0,0.6);
}

.picker-item-name-jp {
    font-size: 0.6rem;
    font-weight: 500;
    color: rgba(255,255,255,0.95);
    line-height: 1.2;
    -webkit-text-stroke: 0.4px rgba(0,0,0,0.5);
    text-shadow:
        0 1px 3px rgba(0,0,0,0.8),
        0 0 6px rgba(0,0,0,0.5),
        1px 1px 2px rgba(0,0,0,0.6);
}

/* Detail pills row */
.picker-item-pills {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 6px;
}

.picker-pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.picker-pill {
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.5rem;
    font-weight: 600;
    background: #edf2f7;
    color: #4a5568;
    white-space: nowrap;
    line-height: 1.3;
}

/* States */
.picker-item.selected {
    border-color: #38a169;
    box-shadow: 0 0 0 2px rgba(56, 161, 105, 0.3), 0 4px 12px rgba(56, 161, 105, 0.15);
}

.picker-item.selected::before {
    content: "✓";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 18px;
    height: 18px;
    background: #38a169;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 800;
    z-index: 3;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.picker-item.picker-item-tracked {
    border-color: #1890ff;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

.picker-item.picker-item-tracked::after {
    content: "📍";
    position: absolute;
    top: 4px;
    left: 4px;
    font-size: 0.7rem;
    z-index: 3;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.picker-item.picker-item-filtered {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2);
}

/* Swipe Indicator - flex flow instead of absolute */
.picker-swipe-indicator {
    position: relative;
    display: flex;
    flex-shrink: 0;
    padding: 6px 10px;
    border-top: 1px solid #e2e8f0;
    background: rgba(247, 250, 252, 0.98);
    backdrop-filter: blur(10px);
    flex-direction: row;
    align-items: center;
    justify-content: center;
}

.picker-done-btn {
    position: absolute;
    right: 10px;
    padding: 4px 12px;
    font-size: 0.8rem;
    min-height: 0;
    z-index: 1;
}

.swipe-hint {
    display: none; /* Hidden on desktop, show on mobile */
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #718096;
    animation: swipeHintPulse 2s ease-in-out infinite;
}

.swipe-icon {
    font-size: 1.2rem;
    font-weight: bold;
    color: #667eea;
}

.swipe-text {
    font-weight: 600;
    color: #4a5568;
}

@keyframes swipeHintPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Pagination Dots */
.picker-pagination {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    justify-content: center;
}

.pagination-year-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.2;
    color: #2d3748;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.year-indicator-en {
    font-size: 0.75rem;
}

.year-indicator-jp {
    font-size: 0.65rem;
    opacity: 0.8;
}

.pagination-dots-wrapper {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
}

.pagination-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e0;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.pagination-dot:hover {
    background: #a0aec0;
    transform: scale(1.2);
}

.pagination-dot:active {
    transform: scale(0.9);
}

.pagination-dot.active {
    width: 24px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: dotPulse 0.3s ease-out;
}

.pagination-dot.active:hover {
    transform: scale(1);
}

@keyframes dotPulse {
    0% {
        transform: scale(0.8);
        box-shadow: 0 0 0 rgba(0, 0, 0, 0.2);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }
}

/* Year transition animations */
.picker-pagination.year-transition-forward .pagination-dots-wrapper {
    animation: slideDotsReset 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.picker-pagination.year-transition-backward .pagination-dots-wrapper {
    animation: slideDotsResetBackward 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.picker-pagination.year-transition-forward .pagination-year-indicator,
.picker-pagination.year-transition-backward .pagination-year-indicator {
    animation: yearBadgeFade 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes slideDotsReset {
    0% {
        transform: translateX(0);
        opacity: 1;
    }
    45% {
        transform: translateX(120%);
        opacity: 0;
    }
    46% {
        transform: translateX(-120%);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideDotsResetBackward {
    0% {
        transform: translateX(0);
        opacity: 1;
    }
    45% {
        transform: translateX(-120%);
        opacity: 0;
    }
    46% {
        transform: translateX(120%);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes yearBadgeFade {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    45% {
        opacity: 0;
        transform: scale(0.8);
    }
    55% {
        opacity: 0;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Mobile Navigation Arrows */
.picker-mobile-nav {
    display: none; /* Hidden on desktop */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.98);
    border-top: 2px solid #e2e8f0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1003;
}

.picker-mobile-nav-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.picker-mobile-nav-btn:active {
    transform: scale(0.95);
    box-shadow: 0 1px 4px rgba(102, 126, 234, 0.3);
}

.picker-mobile-nav-btn .nav-label {
    font-size: 0.85rem;
    font-weight: 600;
}

.picker-mobile-nav-prev {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.picker-mobile-nav-next {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.picker-mobile-close-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    font-size: 2rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    transition: all 0.2s ease;
    line-height: 1;
    flex-shrink: 0;
}

.picker-mobile-close-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}

.race-card {
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    padding: 2px;
    transition: all 0.3s ease;
    background: #f8f9fa;
    position: relative;
}

.race-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    overflow: hidden;
    background: #edf2f7;
    border: 1px solid #e2e8f0;
    margin-bottom: 4px;
}

.race-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.race-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.race-card.selected {
    border-color: #48bb78;
    background: #f0fff4;
}

.race-card.won {
    border-color: #38a169;
    background: #c6f6d5;
}

.race-card.selected::before {
    content: "✓ 出走";
    position: absolute;
    top: 10px;
    right: 10px;
    background: #48bb78;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
}

.race-name {
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.race-name-en {
    font-weight: bold;
    color: #2d3748;
    font-size: 0.8rem;
    margin-bottom: 2px;
}

.race-name-jp {
    font-weight: 600;
    color: #4a5568;
    font-size: 0.65rem;
    font-style: italic;
}

.race-details {
    font-size: 0.65rem;
    color: #718096;
    margin-bottom: 2px;
    text-align: right;
}
/* Calendar-specific compact text */
#calendar-section .race-details { font-size: 0.62rem; text-align: right; }
/* Details are already compact (two rows rendered). Do not hide them by nth-of-type. */

.race-grade {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 12px;
    font-size: 0.6rem;
    font-weight: bold;
    margin-right: 5px;
}

.grade-GI { background: #ffd700; color: #8b4513; }
.grade-GII { background: #c0c0c0; color: #000; }
.grade-GIII { background: #cd7f32; color: #fff; }
.grade-Open { background: #87ceeb; color: #000; }

.win-button-container {
    margin-top: 6px;
    text-align: center;
}

.win-btn {
    padding: 8px 16px;
    border: 2px solid #4299e1;
    background: white;
    color: #4299e1;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
    min-width: 160px;
    text-align: center;
}

.win-btn:hover {
    background: #4299e1;
    color: white;
    transform: scale(1.05);
}

.win-btn.won {
    background: #38a169;
    border-color: #38a169;
    color: white;
}

.win-btn.won:hover {
    background: #2f855a;
    border-color: #2f855a;
    transform: scale(1.05);
}

.win-btn.lost {
    background: #e53e3e;
    border-color: #e53e3e;
    color: white;
}

.win-btn.lost:hover {
    background: #c53030;
    border-color: #c53030;
    transform: scale(1.05);
}

.loss-toggle-btn {
    background: transparent;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 800;
    transition: all 0.2s ease;
    min-width: auto;
    width: auto;
}

.loss-toggle-btn.won {
    color: #38a169;
    border-color: #38a169;
}

.loss-toggle-btn.won:hover {
    background: #38a169;
    color: white;
}

.loss-toggle-btn.lost {
    background: #e53e3e;
    border-color: #e53e3e;
    color: white;
    -webkit-text-stroke: 1px rgba(0,0,0,0.6);
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.loss-toggle-btn.lost:hover {
    background: #c53030;
    border-color: #c53030;
}

/* Toggle close on selection button */
.toggle-close-on-selection {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    padding: 6px 10px;
    min-width: auto;
}

.toggle-close-on-selection.active {
    background: #2f855a;
    color: white;
    border-color: #2f855a;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-close-on-selection .toggle-icon {
    font-size: 1rem;
}

.toggle-close-on-selection .toggle-icon::before {
    content: "🔒";
}

.toggle-close-on-selection.active .toggle-icon::before {
    content: "🔓";
}

.toggle-close-on-selection .toggle-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.toggle-close-on-selection .toggle-text-en {
    font-size: 0.7rem;
    font-weight: 600;
}

.toggle-close-on-selection .toggle-text-jp {
    font-size: 0.65rem;
    font-weight: 500;
    opacity: 0.9;
}

/* Quick Stats Summary */
.quick-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
    background: rgba(102, 126, 234, 0.08);
    border-radius: 8px;
    font-size: 0.85rem;
    color: #4a5568;
    flex-wrap: wrap;
}

.quick-stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.quick-stat strong {
    color: #2d3748;
    font-weight: 700;
    font-size: 0.95rem;
}

.quick-stat-separator {
    color: #cbd5e0;
    font-weight: 300;
    user-select: none;
}

.hidden-factors {
    margin-top: 20px;
    flex-shrink: 0; /* Prevent shrinking in flex container */
}

/* When in compact mode (mobile/tablet), make visible factors scrollable */
@media (max-width: 900px) {
    .hidden-factors {
        max-height: 400px; /* Limit height for scrolling - smaller to ensure 2 factors are scrollable */
        overflow-y: auto; /* Enable scrolling */
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }
    
    /* When expanded, allow full height */
    .hidden-factors.factors-expanded {
        max-height: none;
    }
}

/* Show more button for hidden factors (desktop - hidden by default) */
.show-more-factors {
    display: none;
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    background: #f7fafc;
    border: 2px solid #cbd5e0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    color: #4a5568;
    text-align: center;
    transition: all 0.2s ease;
}

.show-more-factors:hover {
    background: #edf2f7;
    border-color: #667eea;
    color: #667eea;
}

.show-more-factors .arrow {
    display: inline-block;
    margin-left: 6px;
    transition: transform 0.2s ease;
}

.show-more-factors.expanded .arrow {
    transform: rotate(180deg);
}

.factor-item {
    margin-bottom: 15px;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #e2e8f0;
    transition: all 0.3s ease;
}

.factor-item.completed {
    background: #f0fff4;
    border-left-color: #48bb78;
}

.factor-item.partial {
    background: #fffaf0;
    border-left-color: #ed8936;
}

.factor-item.factor-tracked {
    background: #e6f7ff;
    border-left-color: #1890ff;
    box-shadow: 0 2px 8px rgba(24, 144, 255, 0.2);
}

/* Epithet prerequisite tags */
.epithet-prereqs {
    margin: 4px 0 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 0.78rem;
}
.prereq-tag {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 10px;
    background: #fed7d7;
    color: #9b2c2c;
    font-weight: 600;
    font-size: 0.72rem;
}
.prereq-tag.prereq-done {
    background: #c6f6d5;
    color: #276749;
}

/* Reward tally bar */
.reward-tally {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 12px;
    border-radius: 6px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    font-size: 0.82rem;
    color: #4a5568;
}
.tally-stats strong { color: #2d3748; }
.tally-hint {
    padding: 1px 8px;
    border-radius: 10px;
    background: #ebf4ff;
    color: #2b6cb0;
    font-size: 0.75rem;
    font-weight: 600;
}

.factor-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}

.factor-name {
    margin-bottom: 0;
    position: relative;
    flex: 1;
}

.factor-name-en {
    font-weight: bold;
    color: #2d3748;
    font-size: 1rem;
    margin-bottom: 2px;
}

.factor-name-jp {
    font-weight: 600;
    color: #4a5568;
    font-size: 0.9rem;
    font-style: italic;
}

.completion-badge {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 1.2rem;
}

.factor-condition {
    margin-bottom: 8px;
}

.condition-en {
    font-size: 0.9rem;
    color: #718096;
    margin-bottom: 3px;
}

.condition-jp {
    font-size: 0.85rem;
    color: #4a5568;
    font-style: italic;
}

.factor-progress {
    font-size: 0.8rem;
    font-weight: 500;
}

.progress-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    margin-top: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #48bb78;
    transition: width 0.3s ease;
}

.stats {
    background: #f7fafc;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.stat-item {
    text-align: center;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    font-size: 0.8rem;
    color: #718096;
}

/* Hidden Factor Tracking Styles */
.btn-track {
    font-size: 1.2rem;
    padding: 4px 10px;
    white-space: nowrap;
    flex-shrink: 0;
    background: #f0f0f0;
    border: 1px solid #d9d9d9;
    color: #595959;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-track:hover {
    background: #1890ff;
    border-color: #1890ff;
    color: white;
    transform: scale(1.05);
}

.btn-track.active {
    background: #1890ff;
    border-color: #1890ff;
    color: white;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(24, 144, 255, 0.3);
}

.btn-clear-tracking {
    font-size: 0.85rem;
    padding: 6px 12px;
    background: #ff4d4f;
    color: white;
    border: 1px solid #ff4d4f;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-clear-tracking:hover {
    background: #cf1322;
    border-color: #cf1322;
    transform: scale(1.02);
}

/* Race Card Tracking Highlight */
.race-card.race-tracked {
    outline: 3px solid #1890ff;
    outline-offset: -3px;
    box-shadow: 0 0 12px rgba(24, 144, 255, 0.4);
}

.race-card.race-tracked::after {
    content: "📍";
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 1.1rem;
}

/* Planner highlight - different from tracked */
.race-card.race-in-planner {
    outline: 3px solid #ff9800;
    outline-offset: -3px;
    box-shadow: 0 0 12px rgba(255, 152, 0, 0.4);
}

.race-card.race-in-planner::after {
    content: "📅";
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 1.1rem;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
    z-index: 2;
}

/* When both tracked and in planner, show both indicators */
.race-card.race-tracked.race-in-planner {
    outline: 3px solid #1890ff;
    outline-offset: -3px;
    box-shadow: 0 0 12px rgba(24, 144, 255, 0.4), 0 0 8px rgba(255, 152, 0, 0.3);
}

.race-card.race-tracked.race-in-planner::after {
    content: "📍📅";
    left: 5px;
}

/* Planner Slot Tracking Highlight */
.planner-slot.slot-tracked {
    background: linear-gradient(135deg, #e6f7ff 0%, #bae7ff 100%);
    border-color: #1890ff;
    border-width: 3px;
    box-shadow: 0 0 12px rgba(24, 144, 255, 0.3);
}

.planner-slot.slot-tracked .planner-slot-head {
    background: #91d5ff;
    color: #002766;
    border-bottom-color: #1890ff;
    font-weight: 800;
}

.planner-slot.slot-tracked .planner-slot-head::after {
    content: " 📍";
    font-size: 0.9rem;
}

/* Planner Slot Filter Match Highlight */
.planner-slot.filter-match {
    background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 100%);
    border-color: #f97316;
    border-width: 3px;
    box-shadow: 0 0 12px rgba(249, 115, 22, 0.4);
}

.planner-slot.filter-match .planner-slot-head {
    background: #fb923c;
    color: #7c2d12;
    border-bottom-color: #f97316;
    font-weight: 800;
}

.planner-slot.filter-match .planner-slot-head::after {
    content: " 📅";
    font-size: 0.9rem;
}

/* When both tracked and filter match, prioritize tracked style but add filter indicator */
.planner-slot.slot-tracked.filter-match .planner-slot-head::after {
    content: " 📍📅";
    font-size: 0.9rem;
}

/* ============================================
   STORAGE SYSTEM STYLES
   ============================================ */

/* Storage Toolbar */
.storage-toolbar {
    display: flex;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.btn-storage {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #f7fafc;
    border: 2px solid #cbd5e0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
    flex: 0 1 auto;
    min-width: 0;
}

.btn-storage:hover {
    background: #667eea;
    border-color: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.btn-storage .btn-label {
    font-size: 0.85rem;
    white-space: nowrap;
}

/* Storage Modal */
.storage-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.storage-modal.hidden {
    display: none;
}

.storage-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.storage-panel {
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90vw;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.storage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.storage-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.close-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.storage-body {
    padding: 20px;
    overflow-y: auto;
}

/* Save Slots Grid */
.save-slots-grid,
.load-slots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
}

.save-slot-card {
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.2s ease;
    cursor: pointer;
}

.save-slot-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

.save-slot-card.empty {
    border-style: dashed;
    background: #f7fafc;
}

.save-slot-card.filled {
    background: white;
}

.slot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #edf2f7;
    border-bottom: 1px solid #e2e8f0;
}

.slot-number {
    font-weight: 700;
    color: #4a5568;
    font-size: 0.85rem;
}

.slot-actions {
    display: flex;
    gap: 6px;
}

.btn-rename-slot,
.btn-delete-slot {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-rename-slot:hover {
    background: #90cdf4;
}

.btn-delete-slot:hover {
    background: #fc8181;
}

.slot-body {
    padding: 16px;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-slot {
    text-align: center;
    color: #a0aec0;
}

.empty-slot .plus-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.empty-slot .jp-text {
    font-size: 0.75rem;
    margin-top: 4px;
}

.slot-info {
    width: 100%;
}

.slot-name {
    font-weight: 700;
    font-size: 1rem;
    color: #2d3748;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.slot-timestamp {
    font-size: 0.75rem;
    color: #718096;
    margin-bottom: 8px;
}

.slot-stats {
    display: flex;
    gap: 12px;
    font-size: 0.9rem;
    color: #2d3748;
    font-weight: 600;
}

/* Share Dialog */
.share-panel {
    max-width: 480px;
}

.share-content {
    text-align: center;
}

.share-content p {
    margin-bottom: 8px;
    color: #4a5568;
    font-size: 0.9rem;
}

.share-url-container {
    display: flex;
    gap: 8px;
    margin: 0 0 14px 0;
}

.share-url-container input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #cbd5e0;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.85rem;
    background: #f7fafc;
}

.share-lang-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 14px;
}

.share-lang-label {
    font-size: 0.85rem;
    color: #4a5568;
    font-weight: 600;
}

.share-lang-switch {
    display: flex;
    border: 2px solid #cbd5e0;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
}

.share-lang-option {
    padding: 5px 14px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #718096;
    background: #f7fafc;
    transition: all 0.2s ease;
}

.share-lang-option.active {
    background: #667eea;
    color: white;
}

.share-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.share-action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    line-height: 1.3;
}

.share-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.share-action-icon {
    font-size: 1.4rem;
}

.share-action-text {
    font-weight: 600;
    color: #2d3748;
}

.share-btn-copy {
    border-color: #48bb78;
}
.share-btn-copy:hover {
    background: #f0fff4;
}

.share-btn-twitter {
    border-color: #1a1a1a;
}
.share-btn-twitter:hover {
    background: #f5f5f5;
}
.share-btn-twitter .share-action-icon {
    font-family: system-ui, -apple-system, sans-serif;
    font-weight: 900;
}

.share-btn-discord {
    border-color: #5865F2;
}
.share-btn-discord:hover {
    background: #f0f0ff;
}

.share-stats {
    display: flex;
    justify-content: space-around;
    padding: 14px;
    background: #f7fafc;
    border-radius: 8px;
    font-size: 0.9rem;
}

.share-stats strong {
    color: #667eea;
    font-size: 1.1rem;
}

@media (max-width: 480px) {
    .share-actions {
        flex-direction: column;
    }
    .share-action-btn {
        flex-direction: row;
        padding: 10px 14px;
    }
}

/* Naming Popup */
.naming-modal .naming-panel {
    max-width: 450px;
}

.naming-content {
    padding: 10px 0;
}

.naming-label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: #4a5568;
    font-size: 0.95rem;
}

.naming-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #cbd5e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
    font-family: inherit;
}

.naming-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.naming-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end;
}

/* Delete Confirmation */
.confirmation-modal .confirmation-panel {
    max-width: 450px;
}

.delete-header {
    background: linear-gradient(135deg, #f56565 0%, #c53030 100%) !important;
}

.confirmation-content {
    text-align: center;
    padding: 10px 0;
}

.confirmation-content p {
    color: #4a5568;
    font-size: 0.95rem;
    margin-bottom: 6px;
}

#delete-message-jp {
    font-size: 0.85rem;
    color: #718096;
}

.confirmation-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: center;
}

/* Button Styles */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

.btn-danger {
    background: #f56565;
    color: white;
}

.btn-danger:hover {
    background: #e53e3e;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 101, 101, 0.3);
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #48bb78;
    color: white;
    padding: 20px 32px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 3000;
    animation: slideInDown 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
    pointer-events: none;
    font-size: 16px;
    font-weight: 500;
}

.toast-notification.error {
    background: #fc8181;
}

@keyframes slideInDown {
    from {
        transform: translateX(-50%) translateY(-100px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
}

/* ============================================
   RESPONSIVE MOBILE LAYOUT (< 640px)
   ============================================ */
@media (max-width: 640px) {
    /* Container and header adjustments */
    .container {
        padding: 10px;
    }

    header {
        padding: 20px 10px;
        margin-bottom: 15px;
    }

    h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    /* Discord button mobile */
    .discord-contact {
        margin-bottom: 15px;
    }

    .discord-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    .kofi-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    /* Main content - switch to vertical stack */
    .main-content {
        display: flex;
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    /* Planner section - on top */
    .races-section {
        padding: 12px;
    }

    #planner-section {
        order: 1;
        width: 100%;
    }

    /* Progress section - in middle, same width as planner */
    #progress-panel {
        order: 2;
        max-height: none !important; /* Override dynamic height on mobile */
        width: 100%;
    }

    /* Calendar section - at bottom */
    #calendar-section {
        order: 3;
        width: 100%;
    }

    /* Planner grid - keep 4 columns even on mobile */
    .planner-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }

    /* Tighter planner slots for 4-column mobile layout */
    .planner-slot {
        border-radius: 6px;
    }

    .planner-slot-head {
        padding: 1px 2px;
        font-size: 0.5rem;
        line-height: 1;
        white-space: nowrap;
        overflow: hidden;
    }

    .planner-slot-head .en {
        font-size: 0.45rem;
        line-height: 1;
    }

    .planner-slot-body {
        padding: 3px;
        height: 66px; /* Fixed: 60px button + 6px padding */
        min-height: 66px;
        max-height: 66px;
        gap: 3px;
        overflow: hidden;
    }

    .planner-plus {
        padding: 4px 6px;
        font-size: 0.7rem;
        gap: 2px;
    }

    .slot-button {
        height: 60px;
        min-height: 60px;
        max-height: 60px;
        border-radius: 6px;
    }

    .slot-title {
        left: 0;
        right: 0;
        bottom: 0;
        padding: 4px 6px 3px 6px;
        border-radius: 0 0 6px 6px; /* Match mobile button border radius */
    }

    .slot-title .en {
        font-size: 0.65rem;
        line-height: 1.1;
    }

    .slot-title .jp {
        font-size: 0.62rem;
        line-height: 1.1;
        font-weight: 700;
        margin-top: 1px;
    }

    .slot-remove {
        padding: 1px 3px;
        font-size: 0.7rem;
        top: 3px;
        right: 3px;
    }

    .slot-wrapper .loss-toggle-btn {
        padding: 1px 3px;
        font-size: 0.7rem;
    }

    /* Year tabs mobile - more compact for 4-column layout */
    .year-tabs {
        gap: 3px;
        margin-bottom: 8px;
        flex-wrap: wrap;
    }

    .year-tab {
        padding: 3px 6px;
        font-size: 0.6rem;
        height: 40px;
        line-height: 1.1;
    }

    /* Reset button in planner to match year-tab height on mobile */
    .year-tabs .filter-btn {
        height: 40px;
        padding: 3px 6px;
        font-size: 0.6rem;
    }

    .year-tabs .filter-btn span {
        font-size: 0.5rem;
        line-height: 1.1;
    }

    /* Discord button mobile */
    .discord-contact {
        margin-bottom: 15px;
    }

    .discord-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    .kofi-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    /* Filter buttons mobile - smaller for race database */
    .controls {
        gap: 4px;
        margin-bottom: 12px;
    }

    #calendar-section .filter-btn {
        padding: 3px 6px;
        font-size: 0.55rem;
        height: 36px;
        flex: 1 1 calc(33.333% - 4px);
        min-width: 65px;
    }

    #calendar-section .filter-btn span {
        font-size: 0.48rem;
    }

    .db-toggle {
        padding: 3px;
        gap: 3px;
    }

    .db-toggle-btn {
        padding: 5px 12px;
        font-size: 0.8rem;
    }

    /* Storage toolbar mobile */
    .storage-toolbar {
        gap: 4px;
        padding: 8px 0;
        margin-bottom: 8px;
    }

    .btn-storage {
        padding: 5px 8px;
        font-size: 0.7rem;
        flex: 1 1 calc(33.333% - 4px);
        min-width: 0;
    }

    .btn-storage .btn-label {
        font-size: 0.65rem;
    }

    /* Section titles */
    .section-title {
        font-size: 1.2rem;
        margin-bottom: 12px;
        padding-bottom: 6px;
    }

    /* Stats grid */
    .stats {
        padding: 10px;
        margin-bottom: 12px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .stat-number {
        font-size: 1.2rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }


    /* Hidden factors mobile - collapsible */
    .hidden-factors {
        margin-top: 12px;
    }

    .factor-item {
        padding: 10px;
        margin-bottom: 10px;
    }

    .factor-item.hidden-factor-collapsed {
        display: none;
    }

    .factor-name-en {
        font-size: 0.9rem;
    }

    .factor-name-jp {
        font-size: 0.8rem;
    }

    .condition-en {
        font-size: 0.8rem;
    }

    .condition-jp {
        font-size: 0.75rem;
    }

    /* Show more button visible on mobile */
    .show-more-factors {
        display: block !important;
        padding: 10px;
        font-size: 0.9rem;
    }

    /* Race database grid - 2 columns on mobile */
    .races-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        max-height: 600px;
    }

    /* Race cards mobile */
    .race-card {
        padding: 2px;
    }

    .race-name-en {
        font-size: 0.85rem;
    }

    .race-name-jp {
        font-size: 0.6rem;
    }

    .race-details {
        font-size: 0.6rem;
        text-align: right;
    }

    #calendar-section .race-details {
        font-size: 0.58rem;
    }

    /* Modals mobile */
    .picker-panel {
        width: 95vw;
        max-height: min(520px, 80vh);
        margin-bottom: 80px;
    }

    .picker-list {
        grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
        gap: 6px;
    }

    .picker-item-name-en { font-size: 0.6rem; }
    .picker-item-name-jp { font-size: 0.5rem; }
    .picker-pill { font-size: 0.48rem; }

    /* Hide side navigation arrows on mobile */
    .picker-nav {
        display: none !important;
    }

    /* Show swipe hint on mobile */
    .swipe-hint {
        display: flex !important;
    }

    /* Show mobile navigation arrows on mobile */
    .picker-mobile-nav {
        display: flex !important;
    }

    .picker-mobile-nav-btn {
        padding: 10px 12px;
        font-size: 1rem;
    }

    .picker-mobile-nav-btn .nav-label {
        font-size: 0.75rem;
    }

    .storage-panel {
        width: 95vw;
        max-height: 85vh;
    }

    .save-slots-grid,
    .load-slots-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Consecutive badges mobile */
    .consecutive-badge {
        width: 16px;
        height: 16px;
        font-size: 0.5rem;
        border-width: 1.5px;
    }

    /* Legend mobile */
    .planner-section-title {
        flex-direction: column;
        align-items: flex-start;
    }

    .planner-legend {
        gap: 5px;
        font-size: 0.55rem;
        flex-wrap: wrap;
    }

    .legend-badge {
        width: 14px;
        height: 14px;
        font-size: 0.5rem;
    }

    .legend-tooltip {
        width: 300px;
        right: -10px;
        font-size: 0.68rem;
    }

    /* Overview modal mobile - handled by ov-* classes */

    /* Footer mobile */
    .app-footer {
        margin-top: 20px;
        padding: 15px 10px;
    }

    .footer-content {
        font-size: 0.75rem;
        flex-direction: column;
        gap: 4px;
    }
}

/* ============================================
   OVERVIEW MODAL  (compact in-game style)
   ============================================ */
.overview-btn {
    border-color: #6366f1 !important;
    color: #6366f1 !important;
    background: white !important;
}
.overview-btn:hover {
    background: #6366f1 !important;
    color: white !important;
}

/* panel — width driven by --ov-side-pct (default 10%) */
.ov-panel {
    position: relative;
    z-index: 1001;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,.25);
    width: calc(100vw - 2 * var(--ov-side-pct, 10) * 1vw);
    max-height: 94vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.ov-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}
.ov-title-bar h3 { margin: 0; font-size: .9rem; }
.ov-title-jp { font-size: .75rem; color: #718096; margin-left: 5px; }
.ov-scroll {
    overflow: auto;
    flex: 1;
    padding: 8px;
}

/* 3-year row */
.ov-wrap {
    display: flex;
    gap: 6px;
    align-items: stretch;
}
.ov-col {
    flex: 1;
    min-width: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1.5px solid #e2e8f0;
    display: flex;
    flex-direction: column;
}

/* year headers */
.ov-hdr {
    text-align: center;
    padding: 5px 4px;
    font-weight: 800;
    font-size: .72rem;
    line-height: 1.25;
}
.ov-hdr-jp { font-size: .6rem; font-weight: 600; opacity: .8; }
.ov-hdr-junior   { background: linear-gradient(135deg,#d4f5e4,#a7e8c9); color: #1a5c38; }
.ov-hdr-classics { background: linear-gradient(135deg,#ffe4ec,#ffc2d4); color: #6b1f3a; }
.ov-hdr-senior   { background: linear-gradient(135deg,#ffe8c8,#ffd6a0); color: #6b3e10; }

/* 4-column grid inside each year */
.ov-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 1fr;
    gap: 3px;
    padding: 4px;
    background: #f7fafc;
    flex: 1;
}

/* invisible spacer cells for junior year alignment */
.ov-cell-spacer {
    visibility: hidden;
}

/* cell */
.ov-cell {
    border: 1px solid #dde3ea;
    border-radius: 5px;
    overflow: hidden;
    background: #fff;
    display: flex;
    flex-direction: column;
}
.ov-cell.ov-summer { border-color: #e53e3e; border-width: 1.5px; }
.ov-cell.ov-y-junior  { background: #f0faf5; }
.ov-cell.ov-y-classics { background: #fff8fa; }
.ov-cell.ov-y-senior  { background: #fffbf2; }
.ov-cell.ov-summer { background: #fff5f5; }

/* inner (image + name) */
.ov-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2px 2px 1px;
    min-height: 42px;
    position: relative;
}
.ov-img {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    border-radius: 3px;
    border: 1px solid #e2e8f0;
    display: block;
}
.ov-img-ph {
    width: 100%;
    aspect-ratio: 16/9;
    background: #edf2f7;
    border-radius: 3px;
}
.ov-name {
    font-size: .46rem;
    font-weight: 700;
    color: #2d3748;
    text-align: center;
    line-height: 1.15;
    margin-top: 1px;
    padding: 0 1px;
    max-height: 2.3em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

/* win / loss */
.ov-inner.ov-won  { box-shadow: inset 0 0 0 2px rgba(56,161,105,.45); border-radius: 4px; }
.ov-inner.ov-lost { box-shadow: inset 0 0 0 2px rgba(229,62,62,.35); border-radius: 4px; }
.ov-badge { position: absolute; top: 1px; right: 1px; font-size: .5rem; line-height: 1; }

/* empty */
.ov-empty { flex: 1; display: flex; align-items: center; justify-content: center; }
.ov-plus { font-size: 1rem; font-weight: 300; color: #b0b8c4; line-height: 1; }

/* period label */
.ov-period {
    text-align: center;
    font-size: .44rem;
    font-weight: 700;
    padding: 1px 0 2px;
    color: #4a5568;
    background: #f1f5f9;
    border-top: 1px solid #e2e8f0;
}
.ov-cell.ov-summer .ov-period { background: #fee2e2; color: #9b2c2c; }
.ov-cell.ov-y-junior  .ov-period { background: #e2f5ec; color: #276749; }
.ov-cell.ov-y-classics .ov-period { background: #fce8ef; color: #702744; }
.ov-cell.ov-y-senior  .ov-period { background: #fef0da; color: #744210; }
.ov-cell.ov-summer .ov-period { background: #fee2e2; color: #9b2c2c; }

/* export controls in title bar */
.ov-export-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* margin radio buttons */
.ov-margin-control {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: .6rem;
}
.ov-margin-label {
    font-weight: 600;
    color: #4a5568;
    margin-right: 2px;
    white-space: nowrap;
}
.ov-margin-btn {
    border: 1px solid #cbd5e0;
    background: #fff;
    color: #4a5568;
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: .6rem;
    font-weight: 600;
    line-height: 1.3;
    transition: background .12s, color .12s, border-color .12s;
}
.ov-margin-btn:hover { background: #edf2f7; border-color: #a0aec0; }
.ov-margin-btn.ov-margin-active {
    background: #6366f1;
    color: #fff;
    border-color: #6366f1;
}
.ov-orient-toggle {
    display: flex;
    gap: 2px;
    background: #e2e8f0;
    border-radius: 6px;
    padding: 2px;
}
.ov-orient-btn {
    border: none;
    background: transparent;
    color: #718096;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: .7rem;
    line-height: 1;
    transition: background .15s, color .15s;
}
.ov-orient-btn:hover { background: rgba(255,255,255,0.6); }
.ov-orient-btn.ov-orient-active {
    background: #fff;
    color: #2d3748;
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
    font-weight: 700;
}
.ov-export-btn {
    border: 1px solid #38a169;
    background: #38a169;
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: .7rem;
    font-weight: 700;
    transition: background .15s;
}
.ov-export-btn:hover { background: #2f855a; }
.ov-export-btn:disabled { opacity: .6; cursor: not-allowed; }

/* export offscreen container */
.ov-export-container { padding: 0; }
.ov-export-container .ov-wrap { gap: 6px; padding: 8px; }
.ov-export-container .ov-wrap-portrait { flex-direction: column; }
.ov-export-container .ov-wrap-portrait .ov-col { width: 100%; }
.ov-export-header {
    background: linear-gradient(135deg, #38a169, #2f855a);
    color: #fff;
    padding: 10px 14px;
    text-align: center;
}
.ov-export-header-text {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
}

/* mobile: stack years vertically */
@media (max-width: 700px) {
    .ov-wrap { flex-direction: column; }
    .ov-col { width: 100%; }
    .ov-panel { width: 98vw !important; max-height: 96vh; }
    .ov-inner { min-height: 36px; }
    .ov-margin-control { display: none; }
    .ov-cell-spacer { display: none; }
}

/* Tablet adjustments (641px - 900px) */
@media (min-width: 641px) and (max-width: 900px) {
    .main-content {
        display: flex;
        flex-direction: column;
        gap: 20px;
        align-items: stretch;
    }

    #planner-section {
        order: 1;
        width: 100%;
    }

    #progress-panel {
        order: 2;
        max-height: none !important;
        width: 100%;
    }

    #calendar-section {
        order: 3;
        width: 100%;
    }

    /* Keep 4 columns for planner consistency */
    .planner-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }

    /* Tablet planner slots - slightly more compact */
    .planner-slot {
        border-radius: 8px;
    }

    .planner-slot-head {
        padding: 3px 5px;
        font-size: 0.7rem;
    }

    .planner-slot-head .en {
        font-size: 0.6rem;
    }

    .planner-slot-body {
        padding: 5px;
        height: 95px; /* Fixed: 85px button + 10px padding */
        min-height: 95px;
        max-height: 95px;
        gap: 5px;
        overflow: hidden;
    }

    .slot-button {
        height: 85px;
        min-height: 85px;
        max-height: 85px;
    }

    .slot-title .en {
        font-size: 0.85rem;
    }

    .slot-title .jp {
        font-size: 0.78rem;
        font-weight: 700;
    }

    /* Header adjustments on tablet */
    header {
        padding: 20px 15px;
        margin-bottom: 20px;
    }

    h1 {
        font-size: 1.8rem;
        margin-bottom: 6px;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .app-logo {
        width: 8rem;
        height: 8rem;
    }

    /* Discord button on tablet */
    .discord-contact {
        margin-bottom: 15px;
    }

    .discord-btn {
        padding: 10px 18px;
        font-size: 0.9rem;
    }

    .kofi-btn {
        padding: 10px 18px;
        font-size: 0.9rem;
    }

    /* Storage toolbar on tablet - span full width */
    .storage-toolbar {
        gap: 8px;
        width: 100%;
        justify-content: space-between;
    }

    .btn-storage {
        padding: 7px 12px;
        font-size: 0.85rem;
        flex: 1;
        min-width: 0;
    }

    /* Year tabs and reset button on tablet */
    .year-tabs {
        gap: 6px;
        margin-bottom: 10px;
    }

    .year-tab {
        padding: 6px 12px;
        font-size: 0.75rem;
        height: 50px;
        line-height: 1.2;
    }

    .year-tab span {
        font-size: 0.7rem;
    }

    /* Hidden factors collapsible on tablet */
    .factor-item.hidden-factor-collapsed {
        display: none;
    }

    .show-more-factors {
        display: block !important;
        padding: 10px;
        font-size: 0.9rem;
    }

    /* Smaller filter buttons for race database on tablet */
    .filter-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
        height: 50px;
    }

    .filter-btn span {
        font-size: 0.7rem;
    }

    .controls {
        gap: 8px;
    }

    .races-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Picker panel adjustment for tablet */
    .picker-panel {
        width: min(600px, 92vw);
        max-height: min(520px, 78vh);
        margin-bottom: 80px;
    }

    /* Hide side navigation arrows on tablet */
    .picker-nav {
        display: none !important;
    }

    /* Show swipe hint on tablet */
    .swipe-hint {
        display: flex !important;
    }

    /* Show mobile navigation arrows on tablet */
    .picker-mobile-nav {
        display: flex !important;
    }
}
