* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --error: #ef4444;
    --success: #10b981;
    --border: #334155;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    /* 移动端优化 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* 防止文本选择（移动端） */
    -webkit-tap-highlight-color: transparent;
    /* 优化滚动 */
    -webkit-overflow-scrolling: touch;
}

/* 登录页面样式 */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: var(--surface);
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-box .logo {
    text-align: center;
    color: var(--primary-color);
    font-size: 28px;
    margin-bottom: 10px;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-primary);
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
    transition: all 0.3s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.error-message {
    color: var(--error);
    font-size: 14px;
    margin-bottom: 15px;
    min-height: 20px;
    display: none;
}

.error-message.show {
    display: block;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
    padding: 8px 16px;
    width: auto;
}

.btn-secondary:hover {
    background: #475569;
}

.login-footer {
    margin-top: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
}

/* 头部样式 */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    color: var(--primary-color);
    font-size: 24px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-link {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 16px;
    transition: color 0.3s;
}

.back-link:hover {
    color: var(--primary-color);
}

/* 主页样式 */
.home-page {
    min-height: 100vh;
    padding-bottom: 70px; /* 为底部导航栏留出空间 */
}

.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
}

.hero-section {
    text-align: center;
    margin-bottom: 50px;
}

.hero-section h2 {
    font-size: 36px;
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 18px;
}

.drama-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 30px;
}

.drama-card {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid var(--border);
}

.drama-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
    border-color: var(--primary-color);
}

.drama-card-image {
    width: 100%;
    height: 400px;
    object-fit: cover;
    background: var(--surface-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 48px;
}

.drama-card-info {
    padding: 20px;
}

.drama-card-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.drama-card-description {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.loading {
    text-align: center;
    padding: 60px 20px;
    display: none;
}

.loading.show {
    display: block;
}

.spinner {
    border: 4px solid var(--border);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 播放页面样式 */
.player-page {
    min-height: 100vh;
    padding-bottom: 70px; /* 为底部导航栏留出空间 */
}

.player-main {
    max-width: 1600px;
    margin: 0 auto;
    padding: 30px 20px;
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 30px;
}

.player-container {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
}

.video-wrapper {
    width: 100%;
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
}

#videoPlayer {
    width: 100%;
    height: auto;
    display: block;
}

.video-info h2 {
    font-size: 24px;
    margin-bottom: 12px;
}

.video-info p {
    color: var(--text-secondary);
    line-height: 1.6;
}

.episode-list {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    height: fit-content;
    position: sticky;
    top: 100px;
}

.episode-list h3 {
    margin-bottom: 20px;
    font-size: 20px;
}

.episodes {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.episode-item {
    padding: 12px 16px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.episode-item:hover {
    background: var(--surface-light);
    border-color: var(--primary-color);
}

.episode-item.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.episode-item-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.episode-item-duration {
    font-size: 12px;
    opacity: 0.8;
}

/* 底部导航栏 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 24px;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.3s;
    border-radius: 8px;
    min-width: 80px;
}

.nav-item:hover {
    color: var(--primary-color);
    background: var(--background);
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.nav-label {
    font-size: 12px;
    font-weight: 500;
}

/* 我的页面样式 */
.my-page {
    min-height: 100vh;
    padding-bottom: 70px; /* 为底部导航栏留出空间 */
}

.my-main {
    max-width: 600px;
    margin: 0 auto;
    padding: 40px 20px;
}

.login-section {
    width: 100%;
}

.login-box-inline {
    background: var(--surface);
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.login-box-inline h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-primary);
    font-size: 24px;
}

.user-section {
    width: 100%;
}

.user-profile {
    background: var(--surface);
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.profile-header {
    text-align: center;
    margin-bottom: 30px;
}

.avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    margin: 0 auto 20px;
}

.profile-header h2 {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.username-text {
    color: var(--text-secondary);
    font-size: 16px;
}

.profile-actions {
    margin-top: 30px;
}

.btn-block {
    width: 100%;
}

/* 响应式设计 - 移动端优化 */

/* 平板设备 (1024px以下) */
@media (max-width: 1024px) {
    .player-main {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 20px 15px;
    }

    .episode-list {
        position: static;
        margin-top: 20px;
    }

    .main-content {
        padding: 30px 15px;
    }
}

/* 手机设备 (768px以下) */
@media (max-width: 768px) {
    /* 通用调整 */
    body {
        font-size: 14px;
    }

    /* 头部调整 */
    .header {
        padding: 12px 0;
    }

    .header-content {
        padding: 0 15px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .logo {
        font-size: 20px;
    }

    .back-link {
        font-size: 14px;
    }

    /* 主页调整 */
    .main-content {
        padding: 20px 15px;
    }

    .hero-section {
        margin-bottom: 30px;
    }

    .hero-section h2 {
        font-size: 28px;
        margin-bottom: 8px;
    }

    .subtitle {
        font-size: 16px;
    }

    .drama-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
        margin-top: 20px;
    }

    .drama-card {
        border-radius: 8px;
    }

    .drama-card-image {
        height: 220px;
        font-size: 36px;
    }

    .drama-card-info {
        padding: 15px;
    }

    .drama-card-title {
        font-size: 16px;
        margin-bottom: 6px;
    }

    .drama-card-description {
        font-size: 12px;
        -webkit-line-clamp: 2;
    }

    /* 播放页面调整 */
    .player-main {
        padding: 15px 10px;
        gap: 15px;
    }

    .player-container {
        padding: 15px;
        border-radius: 8px;
    }

    .video-wrapper {
        margin-bottom: 15px;
        border-radius: 6px;
    }

    .video-info h2 {
        font-size: 18px;
        margin-bottom: 10px;
    }

    .video-info p {
        font-size: 14px;
    }

    .episode-list {
        padding: 15px;
        border-radius: 8px;
    }

    .episode-list h3 {
        font-size: 18px;
        margin-bottom: 15px;
    }

    .episode-item {
        padding: 10px 12px;
        border-radius: 6px;
    }

    .episode-item-title {
        font-size: 14px;
    }

    .episode-item-duration {
        font-size: 11px;
    }

    /* 登录页面调整 */
    .login-container {
        padding: 15px;
    }

    .login-box {
        padding: 30px 20px;
        border-radius: 12px;
    }

    .login-box .logo {
        font-size: 24px;
    }

    .login-box h2 {
        font-size: 20px;
        margin-bottom: 25px;
    }

    .login-form input {
        padding: 10px 14px;
        font-size: 16px; /* 防止iOS自动缩放 */
    }

    /* 我的页面调整 */
    .my-main {
        padding: 20px 15px;
    }

    .login-box-inline {
        padding: 30px 20px;
        border-radius: 12px;
    }

    .login-box-inline h2 {
        font-size: 20px;
        margin-bottom: 25px;
    }

    .user-profile {
        padding: 30px 20px;
        border-radius: 12px;
    }

    .avatar {
        width: 70px;
        height: 70px;
        font-size: 35px;
    }

    .profile-header h2 {
        font-size: 20px;
    }

    .username-text {
        font-size: 14px;
    }

    /* 底部导航栏调整 */
    .bottom-nav {
        padding: 6px 0;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
    }

    .nav-item {
        padding: 6px 16px;
        min-width: 70px;
    }

    .nav-icon {
        font-size: 22px;
        margin-bottom: 3px;
    }

    .nav-label {
        font-size: 11px;
    }

    /* 加载指示器 */
    .loading {
        padding: 40px 15px;
    }

    .spinner {
        width: 40px;
        height: 40px;
    }
}

/* 小屏手机设备 (480px以下) */
@media (max-width: 480px) {
    /* 更紧凑的布局 */
    .main-content {
        padding: 15px 10px;
    }

    .hero-section h2 {
        font-size: 24px;
    }

    .subtitle {
        font-size: 14px;
    }

    .drama-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .drama-card-image {
        height: 180px;
        font-size: 32px;
    }

    .drama-card-info {
        padding: 12px;
    }

    .drama-card-title {
        font-size: 14px;
    }

    .drama-card-description {
        font-size: 11px;
        -webkit-line-clamp: 2;
    }

    .player-main {
        padding: 10px;
    }

    .player-container {
        padding: 12px;
    }

    .video-info h2 {
        font-size: 16px;
    }

    .episode-list {
        padding: 12px;
    }

    .episode-item {
        padding: 8px 10px;
    }

    .login-box,
    .login-box-inline,
    .user-profile {
        padding: 25px 15px;
    }

    .header-content {
        padding: 0 10px;
    }

    .logo {
        font-size: 18px;
    }

    .nav-item {
        padding: 6px 12px;
        min-width: 60px;
    }

    .nav-icon {
        font-size: 20px;
    }

    .nav-label {
        font-size: 10px;
    }
}

/* 横屏手机优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .drama-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    .drama-card-image {
        height: 200px;
    }

    .player-main {
        grid-template-columns: 1fr 300px;
    }

    .episode-list {
        position: sticky;
        top: 80px;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    /* 增大触摸目标 */
    .btn {
        min-height: 44px; /* iOS推荐的最小触摸目标 */
        padding: 12px 24px;
    }

    .drama-card {
        /* 移除hover效果，使用active状态 */
    }

    .drama-card:active {
        transform: scale(0.98);
        opacity: 0.9;
    }

    .episode-item {
        min-height: 44px;
    }

    .nav-item {
        min-height: 50px;
        padding: 8px 20px;
    }

    /* 移除hover效果 */
    .btn-primary:hover,
    .btn-secondary:hover,
    .nav-item:hover {
        transform: none;
    }
}

/* 高DPI屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .drama-card,
    .player-container,
    .episode-list,
    .login-box,
    .user-profile {
        border-width: 0.5px;
    }
}

/* 移动端特定优化 */
@media (max-width: 768px) {
    /* 优化滚动条 */
    .episode-list {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .episode-list::-webkit-scrollbar {
        width: 4px;
    }

    .episode-list::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 2px;
    }

    /* 防止双击缩放 */
    * {
        touch-action: manipulation;
    }

    /* 优化输入框 */
    input[type="text"],
    input[type="password"] {
        -webkit-appearance: none;
        appearance: none;
        border-radius: 8px;
    }

    /* 优化按钮点击 */
    .btn,
    .drama-card,
    .episode-item,
    .nav-item {
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);
        tap-highlight-color: rgba(99, 102, 241, 0.2);
    }

    /* 视频播放器优化 */
    #videoPlayer {
        -webkit-playsinline: true;
        playsinline: true;
    }
}

/* 超小屏幕设备 (360px以下) */
@media (max-width: 360px) {
    .drama-grid {
        grid-template-columns: 1fr;
    }

    .drama-card-image {
        height: 200px;
    }

    .hero-section h2 {
        font-size: 22px;
    }

    .nav-item {
        padding: 6px 10px;
        min-width: 50px;
    }

    .nav-icon {
        font-size: 18px;
    }

    .nav-label {
        font-size: 9px;
    }
}

