@media (max-width: 992px) {
    .navbar-menu {
        display: none;
    }

    .navbar-toggle {
        display: block;
    }

    .mobile-nav-overlay {
        display: block;
    }

    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .lottery-card-body {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .lottery-card-countdown,
    .lottery-card-result {
        text-align: center;
    }

    .lottery-card-divider {
        width: 100%;
        height: 1px;
    }

    .current-draw-body {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .lottery-page-countdown {
        flex-direction: column;
        text-align: center;
    }

    .lottery-page-divider {
        width: 100%;
        height: 1px;
    }

    .lottery-page-result {
        text-align: center;
    }

    .history-row-main {
        grid-template-columns: 100px 1fr auto;
        gap: var(--spacing-md);
    }

    .countdown-large .time-block {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    .countdown-large .time-sep {
        font-size: 2rem;
    }

    .countdown-large-labels {
        gap: calc(var(--spacing-md) + 60px);
    }
}

@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }

    .navbar-actions .lang-switcher {
        display: none;
    }

    .container {
        padding: 0 var(--spacing-md);
    }

    .section {
        padding: var(--spacing-xl) 0;
    }

    .banner-carousel {
        aspect-ratio: 2.5 / 1;
    }

    .banner-prev,
    .banner-next {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .banner-dots {
        display: none;
    }

    .lottery-card-header {
        padding: var(--spacing-md);
    }

    .lottery-card-name {
        font-size: 1.125rem;
    }

    .lottery-card-body {
        padding: var(--spacing-md);
    }

    .lottery-numbers.kara-numbers {
        max-width: 100%;
    }

    .lottery-numbers.kara-numbers .number-ball {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }

    .lottery-numbers.kara-numbers .number-ball.special {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }

    .time-block {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .time-sep {
        font-size: 1.25rem;
    }

    .countdown-labels {
        gap: calc(var(--spacing-sm) + 40px);
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .footer-main {
        padding: var(--spacing-lg) var(--spacing-md);
    }

    .footer-section {
        text-align: center;
    }

    .footer-section h4 {
        display: block;
        margin-left: auto;
        margin-right: auto;
    }

    .footer-section ul {
        align-items: center;
    }

    .footer-section .footer-text {
        text-align: center;
    }

    .current-draw-body {
        padding: var(--spacing-lg);
    }

    .countdown-large .time-block {
        width: 56px;
        height: 56px;
        font-size: 1.25rem;
    }

    .countdown-large .time-sep {
        font-size: 1.5rem;
    }

    .countdown-large-labels {
        gap: calc(var(--spacing-md) + 56px);
        font-size: 0.75rem;
    }

    .numbers-display .number-ball {
        width: 36px;
        height: 36px;
        font-size: 1.25rem;
    }

    .numbers-display .number-ball.special {
        width: 44px;
        height: 44px;
        font-size: 1.5rem;
    }

    .history-row-main {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }

    .history-period-col {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: var(--spacing-sm);
    }

    .history-period {
        font-size: 1rem;
    }

    .history-numbers-section {
        flex-direction: column;
        align-items: center;
        gap: var(--spacing-sm);
    }

    .history-numbers {
        justify-content: center;
    }

    /* 历史记录特别号码与普通号码同尺寸 */
    .history-numbers .number-ball.special {
        width: 32px;
        height: 32px;
        font-size: 0.875rem;
    }

    .history-expand-btn {
        width: 100%;
        justify-content: center;
    }

    .history-detail {
        padding: var(--spacing-sm);
    }

    .prize-pool-table th,
    .prize-pool-table td {
        padding: var(--spacing-sm);
        font-size: 0.75rem;
    }

    .prize-modal-overlay {
        padding: var(--spacing-sm);
    }

    .prize-modal {
        max-width: 100%;
        max-height: 90vh;
    }

    .prize-modal-body {
        overflow-x: auto;
    }

    .prize-modal-table {
        min-width: 280px;
    }

    .prize-modal-table th,
    .prize-modal-table td {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 0.75rem;
        white-space: nowrap;
    }

    .pagination {
        flex-wrap: wrap;
    }

    .pagination-btn {
        min-width: 36px;
        height: 36px;
        font-size: 0.875rem;
    }

    .news-filter-bar {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .news-tag {
        padding: 4px 10px;
        font-size: 0.75rem;
    }

    .news-item {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .news-item-title {
        font-size: 0.938rem;
    }

    .news-item-meta {
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }

    /* 手机模式 header 改为垂直布局 */
    .news-detail-header,
    .content-detail-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
        padding: var(--spacing-md);
    }

    .news-detail-page .back-link,
    .content-detail-page .back-link {
        margin-bottom: 0;
    }

    .news-detail-title,
    .content-detail-title {
        font-size: 1.125rem;
    }

    .news-detail-meta-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-xs);
    }

    .news-detail-body {
        padding: var(--spacing-lg);
    }

    .api-tabs {
        flex-direction: column;
    }

    .api-tab {
        border-bottom: 1px solid var(--border-color);
    }

    .api-tab:last-child {
        border-bottom: none;
    }

    .api-tab.active::after {
        display: none;
    }

    .api-tab.active {
        background: var(--gradient-primary);
        color: var(--text-white);
    }

    .api-content {
        padding: var(--spacing-lg);
    }

    .code-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }

    .api-endpoint-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-xs);
    }

    .ws-apply-section {
        padding: var(--spacing-lg);
    }

    .modal {
        width: 95%;
        margin: var(--spacing-md);
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-btn {
        width: 100%;
        text-align: center;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .back-link {
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.125rem; }

    .banner-carousel {
        aspect-ratio: 2 / 1;
    }

    .banner-slide-placeholder i {
        font-size: 2.5rem;
    }

    .banner-slide-placeholder span {
        font-size: 1rem;
    }

    .countdown-large .time-block {
        width: 48px;
        height: 48px;
        font-size: 1.125rem;
    }

    .countdown-large .time-sep {
        font-size: 1.25rem;
    }

    .countdown-large-labels {
        gap: calc(var(--spacing-sm) + 48px);
    }

    .number-ball {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }

    .number-ball.special {
        width: 32px;
        height: 32px;
        font-size: 1.125rem;
    }

    .lottery-numbers.kara-numbers .number-ball {
        width: 24px;
        height: 24px;
        font-size: 0.875rem;
    }

    .lottery-numbers.kara-numbers .number-ball.special {
        width: 24px;
        height: 24px;
        font-size: 0.875rem;
    }

    .history-numbers .number-ball {
        width: 24px;
        height: 24px;
        font-size: 0.875rem;
    }

    .history-numbers .number-ball.special {
        width: 24px;
        height: 24px;
        font-size: 0.875rem;
    }

    .section-title {
        font-size: 1.125rem;
    }

    .card {
        padding: var(--spacing-md);
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }

    .home-news-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-xs);
    }

    .lottery-card-body {
        padding: var(--spacing-md);
    }

    .lottery-next-period,
    .lottery-last-period {
        font-size: 0.875rem;
    }

    .code-body pre {
        font-size: 0.75rem;
    }

    .param-table {
        font-size: 0.75rem;
    }

    .param-table th,
    .param-table td {
        padding: var(--spacing-sm);
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .navbar {
        height: 56px;
    }

    #main-content {
        margin-top: 56px;
    }

    .banner-carousel {
        aspect-ratio: 1920 / 600;
        max-height: 200px;
    }

    .modal {
        max-height: 95vh;
    }
}

@media print {
    .navbar,
    .footer,
    .banner-carousel,
    .pagination,
    .back-link {
        display: none !important;
    }

    #main-content {
        margin-top: 0;
    }

    .card,
    .lottery-card,
    .news-item {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    body {
        background: white;
        color: black;
    }

    a {
        color: black;
        text-decoration: underline;
    }

    .number-ball {
        background: #333;
        color: white;
        box-shadow: none;
    }
}

@media (prefers-contrast: high) {
    :root {
        --border-color: #333;
        --text-secondary: #333;
    }

    .btn,
    .news-tab,
    .api-tab {
        border: 2px solid currentColor;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}
