/* Modern Mahjong 2D - Custom Styles */

/* 基础重置和配置 */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    user-select: none;
}

/* Canvas样式 */
#gameCanvas {
    cursor: crosshair;
    transition: all 0.3s ease;
    display: block;
    margin: 0 auto; /* 水平居中 */
}

#gameCanvas:hover {
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.4);
}

/* 游戏容器保护 */
#canvasContainer {
    /* 确保至少有足够空间显示游戏 */
    min-height: 300px;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 麻将牌动画效果 */
.tile-hover-effect {
    filter: brightness(1.2) drop-shadow(0 0 10px rgba(168, 85, 247, 0.6));
    transform: scale(1.05);
    transition: all 0.2s ease;
}

.tile-selected-effect {
    filter: brightness(1.3) drop-shadow(0 0 15px rgba(34, 197, 94, 0.8));
    transform: scale(1.1);
    transition: all 0.3s ease;
}

.tile-remove-animation {
    animation: tileRemove 0.5s ease-in-out forwards;
}

@keyframes tileRemove {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.2) rotate(5deg);
    }
    100% {
        opacity: 0;
        transform: scale(0) rotate(180deg);
    }
}

/* 提示动画 */
.hint-glow {
    animation: hintPulse 2s infinite;
}

@keyframes hintPulse {
    0%, 100% {
        filter: brightness(1) drop-shadow(0 0 10px rgba(59, 130, 246, 0.5));
    }
    50% {
        filter: brightness(1.4) drop-shadow(0 0 20px rgba(59, 130, 246, 1));
    }
}

/* 加载动画 */
.loading-spinner {
    animation: spin 1s linear infinite;
}

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

/* 按钮悬停效果 */
button {
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    font-weight: 500;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

button:active {
    transform: translateY(0);
}

/* 响应式设计 */
@media (max-width: 768px) {
    header .container {
        padding: 0.5rem 1rem;
    }
    
    header h1 {
        font-size: 1.25rem;
    }
    
    header .flex {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    /* 减少顶部导航栏占用空间 */
    main {
        padding-top: 3rem !important;
    }
    
    #gameCanvas {
        border-radius: 0.5rem;
        margin: 0.25rem;
    }
    
    footer {
        padding: 0.5rem;
    }
    
    footer .flex {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}

@media (max-width: 480px) {
    header {
        padding-top: 0.25rem;
        padding-bottom: 0.25rem;
    }
    
    header .space-x-2 > button {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* 进一步减少顶部空间占用 */
    main {
        padding-top: 2.5rem !important;
    }
    
    #canvasContainer {
        min-height: 250px;
        padding: 0.25rem;
    }
    
    #gameCanvas {
        margin: 0.125rem;
    }
    
    /* 底部信息栏在超小屏幕上简化 */
    footer .container .flex {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    footer .container .flex > div {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
}

/* 超宽屏优化 */
@media (min-width: 1440px) {
    #canvasContainer {
        max-width: 1200px;
        margin: 0 auto;
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #gameCanvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* 暗色主题优化 */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #0f172a 0%, #581c87 50%, #0f172a 100%);
    }
}

/* 动画性能优化 */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* 自定义滚动条（如果需要） */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
    background: rgba(168, 85, 247, 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(168, 85, 247, 0.7);
}

/* 游戏特效 */
.particle-effect {
    pointer-events: none;
    position: absolute;
    animation: particleFloat 3s ease-out forwards;
}

@keyframes particleFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) scale(0.5);
    }
}

/* 成功完成动画 */
.level-complete-burst {
    animation: levelBurst 0.8s ease-out forwards;
}

@keyframes levelBurst {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 焦点指示器（无障碍） */
button:focus-visible {
    outline: 2px solid #a855f7;
    outline-offset: 2px;
}

/* 打印样式（如果需要） */
@media print {
    body {
        background: white !important;
    }
    
    #gameContainer {
        display: none;
    }
    
    body::after {
        content: "Modern Mahjong 2D - Visit InstantGames.top to play online!";
        display: block;
        text-align: center;
        padding: 2rem;
        font-size: 1.5rem;
        color: black;
    }
}

/* ==============================================
   弹窗系统样式 (Overlay System)
   ============================================== */

/* 基础弹窗覆盖层 */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

/* 弹窗内容卡片 */
.overlay-content {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.95);
    opacity: 0;
    animation: overlayAppear 0.3s ease-out forwards;
}

/* 弹窗出现动画 */
@keyframes overlayAppear {
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* 弹窗标题 */
.overlay-content h2 {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0 0 1rem 0;
    color: #1f2937;
}

/* 弹窗文本 */
.overlay-content p {
    color: #6b7280;
    margin: 0.5rem 0;
    line-height: 1.6;
}

/* 弹窗按钮容器 */
.overlay-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* 按钮基础样式 */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #e5e7eb;
    color: #374151;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* 主要按钮样式 */
.btn-primary {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
}

/* 按钮悬停效果 */
.btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

/* 无解提示弹窗特殊样式 */
#no-moves-screen .overlay-content {
    border: 3px solid #fbbf24;
    box-shadow: 0 20px 25px -5px rgba(251, 191, 36, 0.3);
}

#no-moves-screen h2 {
    color: #f59e0b;
    margin-bottom: 1rem;
}

#shuffle-btn {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* 胜利弹窗特殊样式 */
#win-screen .overlay-content {
    border: 3px solid #10b981;
    box-shadow: 0 20px 25px -5px rgba(16, 185, 129, 0.3);
}

#win-screen h2 {
    color: #059669;
    margin-bottom: 1rem;
}

/* 响应式设计 */
@media (min-width: 640px) {
    .overlay-buttons {
        flex-direction: row;
        justify-content: center;
    }
    
    .btn {
        min-width: 120px;
    }
}

/* 统计面板响应式 */
@media (max-width: 640px) {
    .game-stats {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .overlay-content {
        padding: 1.5rem;
        margin: 1rem;
        max-width: none;
    }
    
    .overlay-content h2 {
        font-size: 1.25rem;
    }
    
    .btn {
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
    }
} 