/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 移动端优先设计 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    width: 100%;
    max-width: 420px; /* 稍微增加移动端最大宽度 */
    padding: 8px;
}

#game-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    padding: 12px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

#game-board {
    border: 1px solid #1a5276; /* 减少边框宽度 */
    border-radius: 8px;
    cursor: pointer;
    margin: 0 auto 15px auto;
    width: 100%;
    max-width: 360px; /* 稍微增加最大宽度 */
    height: auto;
    aspect-ratio: 1 / 1;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    display: block;
    background: #f8f9fa; /* 添加浅色背景 */
}

/* 不支持aspect-ratio的浏览器备用方案 */
@supports not (aspect-ratio: 1) {
    #game-board {
        height: 360px; /* 调整备用固定高度 */
    }
    
    @media (max-width: 380px) {
        #game-board {
            height: 280px;
        }
    }
    
    @media (min-width: 381px) and (max-width: 480px) {
        #game-board {
            height: 320px;
        }
    }
    
    @media (min-width: 481px) and (max-width: 768px) {
        #game-board {
            height: 400px;
        }
    }
    
    @media (min-width: 769px) {
        #game-board {
            height: 450px;
        }
    }
    
    @media (min-width: 1200px) {
        #game-board {
            height: 500px;
        }
    }
}

#ui-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#player-info, #current-turn {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #2c3e50;
}

#my-player-indicator, #turn-indicator {
    font-weight: 700;
}

#game-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

#share-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#share-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

#share-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 按钮样式 - 移动端优化 */
button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 48px; /* 增加触摸目标大小 */
    min-width: 120px;
    width: 100%;
    max-width: 200px;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

button:active {
    transform: scale(0.98);
}

#restart-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

#restart-btn:hover {
    background: linear-gradient(135deg, #2980b9, #1f5f8b);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

#restart-btn:active {
    box-shadow: 0 2px 10px rgba(52, 152, 219, 0.3);
}

#undo-btn {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.3);
}

#undo-btn:hover {
    background: linear-gradient(135deg, #e67e22, #d35400);
    box-shadow: 0 6px 20px rgba(243, 156, 18, 0.4);
}

#undo-btn:active {
    box-shadow: 0 2px 10px rgba(243, 156, 18, 0.3);
}

#undo-btn:disabled {
    background: #bdc3c7;
    color: #7f8c8d;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

#undo-btn:disabled:active {
    transform: none;
}

#connection-status {
    font-size: 12px;
    color: #7f8c8d;
    margin-top: 5px;
}

#status-indicator {
    font-weight: 600;
}

/* 通知系统样式 */
#notification-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    pointer-events: none;
    width: calc(100% - 40px);
    max-width: 400px;
}

.notification {
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* 模态框样式优化 */
#modal-container {
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal {
    background: white;
    border-radius: 12px;
    padding: 20px;
    max-width: calc(100% - 40px);
    width: 320px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal p {
    font-size: 16px;
    line-height: 1.5;
    color: #2c3e50;
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-buttons button {
    flex: 1;
    min-width: 80px;
    max-width: 120px;
}

/* 小屏幕设备优化 (320px - 480px) */
@media (max-width: 480px) {
    body {
        padding: 5px;
        font-size: 14px;
    }
    
    #app {
        padding: 5px;
    }
    
    #game-container {
        padding: 12px;
        border-radius: 10px;
    }
    
    #game-board {
        max-width: 300px;
        border-width: 1px;
    }
    
    #player-info, #current-turn {
        font-size: 14px;
    }
    
    #game-controls {
        gap: 8px;
    }
    
    button {
        font-size: 14px;
        padding: 10px 16px;
        min-height: 44px;
        border-radius: 6px;
    }
    
    #share-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    #connection-status {
        font-size: 11px;
    }
    
    .modal {
        width: calc(100% - 20px);
        padding: 16px;
        max-width: none;
    }
    
    .modal h3 {
        font-size: 18px;
        margin-bottom: 12px;
    }
    
    .modal p {
        font-size: 14px;
        margin-bottom: 16px;
    }
    
    .modal-buttons {
        gap: 8px;
    }
    
    .modal-buttons button {
        min-width: 70px;
        max-width: none;
        flex: 1;
    }
    
    /* 摇色子界面移动端优化 */
    #dice-display {
        min-height: 80px !important;
        font-size: 14px !important;
    }
    
    #dice-display div[style*="font-size: 48px"] {
        font-size: 36px !important;
    }
    
    #dice-display div[style*="font-size: 24px"] {
        font-size: 18px !important;
    }
    
    .modal p {
        font-size: 14px;
    }
}

/* 中等屏幕设备 (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    #app {
        max-width: 500px;
        padding: 15px;
    }
    
    #game-container {
        padding: 20px;
    }
    
    #game-board {
        max-width: 400px;
    }
    
    #game-controls {
        flex-direction: row;
        justify-content: center;
        gap: 15px;
        flex-wrap: wrap;
    }
    
    button {
        width: auto;
        min-width: 120px;
    }
}

/* 大屏幕设备 (769px+) */
@media (min-width: 769px) {
    body {
        padding: 20px;
    }
    
    #app {
        max-width: 600px;
        padding: 20px;
    }
    
    #game-container {
        padding: 25px;
        border-radius: 15px;
    }
    
    #game-board {
        max-width: 450px;
        margin-bottom: 20px;
    }
    
    #ui-panel {
        gap: 18px;
    }
    
    #current-player {
        font-size: 20px;
    }
    
    #game-controls {
        flex-direction: row;
        justify-content: center;
        gap: 20px;
    }
    
    button {
        width: auto;
        min-width: 160px;
        font-size: 16px;
        padding: 14px 28px;
        min-height: 50px;
    }
    
    button:hover {
        transform: translateY(-2px);
    }
    
    #connection-status {
        font-size: 14px;
    }
}

/* 横屏适配 */
@media (orientation: landscape) and (max-height: 600px) {
    body {
        align-items: flex-start;
        padding-top: 10px;
    }
    
    #app {
        max-width: 90vw;
    }
    
    #game-container {
        padding: 15px;
        max-height: calc(100vh - 20px);
        overflow-y: auto;
    }
    
    #game-board {
        max-width: min(350px, 60vw);
        margin-bottom: 10px;
    }
    
    #ui-panel {
        gap: 10px;
    }
    
    #current-player {
        font-size: 14px;
    }
    
    button {
        min-height: 40px;
        font-size: 14px;
        padding: 8px 16px;
    }
    
    #connection-status {
        font-size: 11px;
    }
}

/* 超大屏幕适配 */
@media (min-width: 1200px) {
    #app {
        max-width: 700px;
    }
    
    #game-board {
        max-width: 500px;
    }
    
    #current-player {
        font-size: 22px;
    }
    
    button {
        min-width: 180px;
        font-size: 18px;
        padding: 16px 32px;
        min-height: 54px;
    }
}

/* 小屏幕设备特殊优化 */
@media (max-width: 380px) {
    body {
        padding: 5px;
    }
    
    #app {
        padding: 5px;
    }
    
    #game-container {
        padding: 8px;
        border-radius: 8px;
    }
    
    #game-board {
        max-width: 300px;
        border-radius: 6px;
    }
    
    #player-info, #current-turn {
        font-size: 14px;
    }
    
    button {
        min-height: 44px;
        font-size: 14px;
        padding: 10px 20px;
    }
}

/* 超小屏幕设备优化 */
@media (max-width: 320px) {
    #game-board {
        max-width: 280px;
    }
    
    #game-container {
        padding: 6px;
    }
    
    #player-info, #current-turn {
        font-size: 13px;
    }
}

/* 横屏模式优化 */
@media (orientation: landscape) and (max-height: 500px) {
    body {
        padding: 5px;
        align-items: flex-start;
    }
    
    #app {
        max-width: 90vw;
        display: flex;
        justify-content: center;
    }
    
    #game-container {
        padding: 8px;
        max-width: 80vh;
    }
    
    #game-board {
        max-width: 70vh;
        max-height: 70vh;
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #game-board {
        /* 确保在高分辨率屏幕上清晰显示 */
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
    
    button {
        border: 1px solid transparent;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    }
    
    #game-container {
        background: #34495e;
        color: #ecf0f1;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    }
    
    #current-player {
        color: #ecf0f1;
    }
    
    #connection-status {
        color: #bdc3c7;
    }
    
    .modal {
        background: #34495e;
        color: #ecf0f1;
    }
    
    .modal p {
        color: #ecf0f1;
    }
}

/* 减少动画偏好设置 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    button:active {
        transform: none;
    }
    
    button:hover {
        transform: none;
    }
}

/* 打印样式 */
@media print {
    body {
        background: white;
    }
    
    #game-container {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    button {
        display: none;
    }
    
    #connection-status {
        display: none;
    }
}/* 震动动画效
果 */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake-animation {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* 减少动画偏好设置下禁用震动 */
@media (prefers-reduced-motion: reduce) {
    .shake-animation {
        animation: none;
    }
}