/* 响应式设计 */

/* 默认样式适用于所有设备 */
.container {
    padding: var(--spacing-md);
    max-width: 820px;
}

/* 连接状态指示器响应式 - 手机端移到右上角 */
@media (max-width: 768px) {
    .connection-indicator {
        top: 12px !important;
        right: 12px !important;
        bottom: auto !important;
        left: auto !important;
        transform: none !important;
        font-size: 11px !important;
        padding: 3px 8px !important;
        max-width: 120px !important;
        max-height: 28px !important;
        min-height: 20px !important;
        width: auto !important;
        height: auto !important;
        white-space: nowrap !important;
        border-radius: 12px !important;
        opacity: 0.9 !important;
        display: flex !important;
        align-items: center !important;
        flex-direction: row !important;
        flex-shrink: 0 !important;
    }
    
    .status-dot {
        width: 6px !important;
        height: 6px !important;
        flex-shrink: 0 !important;
    }
}

@media (max-width: 480px) {
    .connection-indicator {
        top: 10px !important;
        right: 10px !important;
        font-size: 10px !important;
        padding: 2px 6px !important;
        max-width: 100px !important;
        max-height: 24px !important;
        min-height: 18px !important;
        opacity: 0.8 !important;
        z-index: 998 !important;
    }
    
    /* 更小屏幕的游戏界面优化 */
    .game-content {
        height: calc(100vh - 105px);
        padding: 0;
        gap: 0px;
        overflow: hidden;
    }
    
    .timer-circle {
        width: 28px;
        height: 28px;
        border-width: 2px;
    }
    
    #timer-text {
        font-size: 10px;
    }
    
    .turn-info {
        font-size: 10px;
    }
    
    .players-stats {
        gap: 4px;
        margin-bottom: 0px;
    }
    
    .vs-section {
        font-size: 10px;
        margin: 0 1px;
    }
    
    .player-header .avatar {
        width: 16px;
        height: 16px;
        font-size: 0.6rem;
    }
    
    .player-header .player-name {
        font-size: 8px;
    }
    
    .stat-item {
        padding: 0px;
        min-height: 8px;
    }
    
    .stat-label {
        font-size: 6px;
    }
    
    .stat-value {
        font-size: 7px;
    }
    
    .game-message {
        min-height: 18px;
        font-size: 10px;
        padding: 0;
        margin: 0;
    }
    
    .actions-section {
        padding: 0px;
        flex: 1;
        overflow: hidden;
    }
    
    .actions-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 1px !important;
        height: 100%;
    }
    
    .action-btn {
        min-height: 18px;
        max-height: 18px;
        font-size: 13px;
        padding: 0px;
        gap: 0;
    }
    
    .action-name {
        font-size: 13px;
        line-height: 1;
        font-weight: bold;
    }
    
    .action-description {
        display: none;
    }
    
    .player-stats {
        padding: 1px 2px;
    }
}

@media (max-width: 360px) {
    .connection-indicator {
        top: 8px !important;
        right: 8px !important;
        font-size: 9px !important;
        padding: 2px 4px !important;
        max-width: 80px !important;
        max-height: 20px !important;
        min-height: 16px !important;
        opacity: 0.7 !important;
    }
    
    /* 极小屏幕游戏界面优化 */
    .game-content {
        height: calc(100vh - 95px);
        gap: 0px;
        overflow: hidden;
    }
    
    .game-header {
        margin-bottom: 1px;
        padding-bottom: 1px;
    }
    
    .timer-circle {
        width: 25px;
        height: 25px;
    }
    
    #timer-text {
        font-size: 9px;
    }
    
    .turn-info {
        font-size: 9px;
        gap: 2px;
    }
    
    .players-stats {
        gap: 2px;
        margin-bottom: 0px;
    }
    
    .vs-section {
        font-size: 8px;
        margin: 0;
    }
    
    .player-header {
        gap: 1px;
        margin-bottom: 1px;
        padding-bottom: 0px;
    }
    
    .player-header .avatar {
        width: 14px;
        height: 14px;
        font-size: 0.5rem;
    }
    
    .player-header .player-name {
        font-size: 7px;
    }
    
    .stats-grid {
        gap: 0;
        row-gap: 0;
    }
    
    .stat-item {
        padding: 0px;
        min-height: 6px;
    }
    
    .stat-label {
        font-size: 5px;
    }
    
    .stat-value {
        font-size: 6px;
    }
    
    .game-message {
        min-height: 15px;
        font-size: 9px;
        padding: 0px;
        margin: 0;
    }
    
    .actions-section {
        padding: 0px;
        flex: 1;
        overflow: hidden;
    }
    
    .actions-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 1px !important;
        height: 100%;
    }
    
    .action-btn {
        min-height: 15px;
        max-height: 15px;
        font-size: 12px;
        padding: 0px;
        gap: 0;
    }
    
    .action-name {
        font-size: 12px;
        line-height: 1;
        font-weight: bold;
    }
    
    .action-description {
        display: none;
    }
    
    .player-stats {
        padding: 0px 1px;
    }
}

/* 游戏界面特殊处理 - 避免与退出游戏按钮冲突 */
@media (max-width: 768px) {
    #game.screen.active .connection-indicator {
        top: 60px !important;
        right: 12px !important;
    }
}

@media (max-width: 480px) {
    #game.screen.active .connection-indicator {
        top: 50px !important;
        right: 10px !important;
    }
}

@media (max-width: 360px) {
    #game.screen.active .connection-indicator {
        top: 45px !important;
        right: 8px !important;
    }
}

/* 手机端 (320px - 768px) */
@media (max-width: 768px) {
    :root {
        --font-size-base: 14px;
        --font-size-lg: 16px;
        --font-size-xl: 20px;
        --spacing-xs: 0.25rem;
        --spacing-sm: 0.75rem;
        --spacing-md: 1rem;
        --spacing-lg: 1.5rem;
        --spacing-xl: 2rem;
    }
    
    .container {
        padding: var(--spacing-sm);
        min-height: 100vh;
        max-width: 820px;
    }
    
    h1 {
        font-size: 2rem;
        margin-bottom: var(--spacing-md);
    }
    
    /* 大厅界面 - 手机端 */
    .lobby-header {
        flex-direction: column;
        text-align: center;
        gap: var(--spacing-sm);
    }
    
    .user-info {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .rooms-list {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }
    
    .room-card {
        padding: var(--spacing-sm);
    }
    
    .room-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-xs);
    }
    
    /* 房间界面 - 手机端 */
    .players-section {
        flex-direction: row !important;
        gap: 2px !important;
        justify-content: space-between !important;
        align-items: stretch !important;
        flex-wrap: nowrap !important;
    }
    
    .player-slot {
        min-width: unset !important;
        width: 42% !important;
        max-width: 42% !important;
        margin: 0 !important;
        padding: 8px !important;
        font-size: 12px !important;
        box-sizing: border-box !important;
    }
    
    .vs-indicator {
        font-size: 12px;
        margin: 0;
        flex-shrink: 0;
        width: 16px;
        text-align: center;
        align-self: center;
    }
    
    .player-slot .avatar {
        font-size: 1.5rem !important;
        width: 36px !important;
        height: 36px !important;
    }
    
    .player-details {
        font-size: 12px !important;
    }
    
    .player-name,
    .player-status,
    .player-score {
        font-size: 11px !important;
        margin-bottom: 2px !important;
    }
    
    .chat-section {
        max-height: calc(100vh - 320px);
        min-height: 300px;
        height: calc(100vh - 320px);
    }
    
    .chat-messages {
        max-height: calc(100vh - 390px);
        min-height: 220px;
        height: calc(100vh - 390px);
        padding: var(--spacing-sm);
    }
    
    /* 手机端聊天消息优化 */
    .chat-message-content {
        max-width: 85%;
        font-size: 13px;
        padding: 6px 10px;
    }
    
    .chat-message-author {
        font-size: 11px;
    }
    
    .chat-message-text {
        font-size: 13px;
        line-height: 1.3;
    }
    
    /* 游戏界面 - 手机端优化，避免滚动 */
    .game-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: var(--spacing-xs);
        text-align: left;
        margin-bottom: var(--spacing-xs);
        padding-bottom: var(--spacing-xs);
    }
    
    .turn-info {
        flex-direction: row;
        gap: var(--spacing-sm);
        font-size: 13px;
    }
    
    .timer-circle {
        width: 35px;
        height: 35px;
        border-width: 2px;
    }
    
    #timer-text {
        font-size: 13px;
    }
    
    .game-content {
        gap: 1px;
        height: calc(100vh - 110px);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    .players-stats {
        display: flex;
        flex-direction: row;
        gap: 6px;
        margin-bottom: 1px;
        flex-shrink: 0;
        align-items: flex-start;
    }
    
    .vs-section {
        order: 0;
        margin: 0 2px;
        font-size: 12px;
        flex-shrink: 0;
        align-self: center;
    }
    
    .player-stats {
        padding: 1px 2px;
        flex: 1;
        border: none;
        background: none;
        box-shadow: none;
    }
    
    .player-header {
        display: flex;
        align-items: center;
        gap: 3px;
        margin-bottom: 1px;
        padding-bottom: 0;
        border-bottom: none;
    }
    
    .player-header .avatar {
        width: 18px;
        height: 18px;
        font-size: 0.7rem;
        flex-shrink: 0;
    }
    
    .player-header .player-name {
        font-size: 9px;
        flex: 1;
    }
    
    .stats-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: repeat(3, auto);
        gap: 0;
        row-gap: 0;
    }
    
    .stat-item {
        padding: 0px;
        background: none;
        border-radius: 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        min-height: 10px;
    }
    
    .stat-label {
        font-size: 7px;
        margin: 0;
        display: inline;
    }
    
    .stat-value {
        font-size: 8px;
        margin: 0;
        display: inline;
        font-weight: bold;
    }
    
    .game-message {
        font-size: 11px;
        padding: 0;
        margin: 0;
        min-height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
    
    .actions-section {
        flex: 1;
        padding: 1px;
        margin-bottom: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    
    .actions-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2px;
        flex: 1;
        display: grid;
        height: auto;
        overflow: hidden;
    }
    
    .action-btn {
        padding: 1px;
        min-height: 20px;
        max-height: 20px;
        font-size: 17px;
        gap: 0px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }
    
    .action-name {
        font-size: 17px;
        font-weight: bold;
        line-height: 1;
        white-space: nowrap;
    }
    
    .action-description {
        display: none;
    }
    
    /* 模态框 - 手机端 */
    .modal-content {
        width: 95%;
        margin: var(--spacing-sm);
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: var(--spacing-sm);
    }
    
    .modal-footer {
        flex-direction: column;
        gap: var(--spacing-xs);
    }
    
    .modal-footer button {
        width: 100%;
    }
    
    /* 表单 - 手机端 */
    .avatar-selection {
        justify-content: center;
    }
    
    .avatar-option {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    /* 连接状态 - 手机端 */
    .connection-indicator {
        top: var(--spacing-xs);
        right: var(--spacing-xs);
        font-size: 12px;
        padding: var(--spacing-xs);
    }
    
    .status-dot {
        width: 6px;
        height: 6px;
    }
}

/* 平板端 (768px - 1024px) */
@media (min-width: 768px) {
    .container {
        padding: var(--spacing-md);
        max-width: 820px;
    }
    
    /* 大厅界面 - 平板端 */
    .rooms-list {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
    
    /* 房间界面 - 平板端 */
    .room-content {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .players-section {
        flex: 2;
        min-width: 400px;
    }
    
    .chat-section {
        flex: 1;
        min-width: 300px;
        max-height: 400px;
    }
    
    .room-actions {
        width: 100%;
        margin-top: var(--spacing-md);
    }
    
    /* 游戏界面 - 平板端 */
    .players-stats {
        grid-template-columns: 1fr auto 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* 横屏优化 */
@media (orientation: landscape) and (max-height: 500px) {
    .container {
        min-height: 100vh;
        padding: var(--spacing-sm);
        max-width: 820px;
    }
    
    h1 {
        font-size: 1.5rem;
        margin-bottom: var(--spacing-sm);
    }
    
    .user-form {
        padding: var(--spacing-md);
    }
    
    .game-content {
        gap: var(--spacing-sm);
    }
    
    .players-stats {
        grid-template-columns: 1fr auto 1fr;
        gap: var(--spacing-md);
    }
    
    .chat-section {
        max-height: 200px;
    }
}


/* 无障碍访问优化 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #000;
        --secondary-color: #333;
        --bg-color: #fff;
        --card-bg: #fff;
        --text-color: #000;
        --border-color: #000;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #c55555;
        --secondary-color: #8a7a72;
        --accent-color: #d66666;
        --bg-color: #1a1a1a;
        --card-bg: #2d2d2d;
        --text-color: #e5e5e5;
        --text-muted: #999;
        --border-color: #444;
        --shadow: 0 4px 12px rgba(0,0,0,0.3);
    }
}