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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #FFF8F0;
    color: #333;
    min-height: 100vh;
}

.header {
    background: linear-gradient(135deg, #FF9A9E 0%, #FECFEF 100%);
    padding: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.search-box {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.9);
    border-radius: 20px;
    padding: 6px 16px;
    flex: 1;
    max-width: 300px;
    margin-left: 20px;
}

.search-input {
    border: none;
    background: transparent;
    outline: none;
    flex: 1;
    font-size: 14px;
}

.search-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
}

.category-scroll {
    background: #fff;
    padding: 12px 0;
    overflow-x: auto;
    white-space: nowrap;
    border-bottom: 1px solid #eee;
}

.category-list {
    display: inline-flex;
    padding: 0 16px;
    gap: 12px;
}

.category-item {
    padding: 8px 20px;
    border-radius: 20px;
    border: none;
    background: #F5F5F5;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.category-item:hover {
    background: #FFE4E1;
    color: #FF6B6B;
}

.category-item.active {
    background: linear-gradient(135deg, #FF9A9E 0%, #FECFEF 100%);
    color: #fff;
    font-weight: bold;
}

.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px;
}

.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.course-card {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.course-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.course-cover {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: linear-gradient(135deg, #FF9A9E 0%, #FECFEF 100%);
}

.course-info {
    padding: 16px;
}

.course-title {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.course-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #999;
    font-size: 12px;
}

.course-episodes {
    background: #FFF0F0;
    color: #FF6B6B;
    padding: 2px 8px;
    border-radius: 10px;
}

.course-platform {
    display: flex;
    align-items: center;
    gap: 4px;
}

.video-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.video-modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
}

.modal-content {
    position: relative;
    background: #fff;
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: linear-gradient(135deg, #FF9A9E 0%, #FECFEF 100%);
    color: #fff;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: bold;
}

.close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

.modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.video-container {
    flex: 1;
    background: #000;
    display: flex;
    position: relative;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.episode-sidebar {
    width: 200px;
    background: #f5f5f5;
    border-left: 1px solid #eee;
    overflow-y: auto;
    flex-shrink: 0;
}

.episode-list {
    padding: 8px;
}

.episode-item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    border-radius: 6px;
    margin-bottom: 4px;
    transition: all 0.2s;
    line-height: 1.4;
}

.episode-item:hover {
    background: #e8e8e8;
}

.episode-item.active {
    background: #FF9A9E;
    color: #fff;
    font-weight: 600;
}

.episode-item .ep-num {
    font-weight: 600;
    margin-right: 6px;
}

.video-container video {
    width: 100%;
    max-height: 500px;
}

.video-container iframe {
    width: 100%;
    height: 100%;
    min-height: 400px;
}

.video-info {
    padding: 16px;
    background: #f9f9f9;
}

.video-info p {
    color: #666;
    font-size: 14px;
}

.video-error {
    color: #FF6B6B;
    font-size: 13px;
    margin-top: 8px;
    padding: 8px 12px;
    background: #fff0f0;
    border-radius: 6px;
}

.video-loading {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #fff;
    font-size: 14px;
    z-index: 1;
}

.video-loading.hidden {
    display: none;
}

.play-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    cursor: pointer;
    z-index: 10;
    color: #fff;
    gap: 8px;
}

.play-overlay .play-icon {
    font-size: 48px;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,154,158,0.9);
    transition: transform 0.2s;
}

.play-overlay:hover .play-icon {
    transform: scale(1.1);
}

.play-overlay .play-text {
    font-size: 16px;
    opacity: 0.9;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.video-container {
    position: relative;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #999;
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 12px;
    }
    
    .search-box {
        width: 100%;
        max-width: none;
        margin-left: 0;
    }
    
    .course-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }
    
    .course-cover {
        height: 100px;
    }
    
    .course-title {
        font-size: 14px;
    }
    
    .modal-content {
        width: 95%;
        height: 90vh;
    }
    
    .video-container video {
        max-height: 300px;
    }
}

/* ---- TV / 大屏 ---- */
@media (min-width: 1280px) {
    .course-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 24px;
        padding: 32px 48px;
    }
    .course-cover { height: 160px; }
    .course-title { font-size: 20px; }
    .course-meta { font-size: 16px; }
    .category-item { font-size: 18px; padding: 12px 24px; }
    .logo { font-size: 28px; }
    .search-box input { font-size: 18px; height: 48px; }
    .modal-content { max-width: 1100px; }
}

/* DPAD focus styles for TV remote */
*:focus-visible {
    outline: 3px solid #FF9A9E !important;
    outline-offset: 3px;
}

.course-card:focus-visible {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(255,154,158,0.4);
}

.category-item:focus-visible {
    background: #FF9A9E;
    color: #fff;
}

.episode-item:focus-visible {
    background: #FF9A9E;
    color: #fff;
}