/* 数字华容道 - 样式文件 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    /* iPad适配：允许滚动以显示弹窗 */
    overflow: auto;
    position: relative;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.main-container {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    max-width: 1200px;
}

.left-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 200px;
}

.header {
    color: white;
    text-align: center;
    background: rgba(255,255,255,0.1);
    padding: 20px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

.header h1 {
    font-size: 28px;
    margin-bottom: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.score-board {
    display: flex;
    flex-direction: column;
    gap: 15px;
    color: white;
}

.score-item {
    background: rgba(255,255,255,0.2);
    padding: 15px 20px;
    border-radius: 10px;
    backdrop-filter: blur(10px);
    text-align: center;
    font-size: 18px;
}

.score-item .label {
    display: block;
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 5px;
}

.score-item .value {
    display: block;
    font-size: 32px;
    font-weight: bold;
}

.difficulty-selector {
    background: rgba(255,255,255,0.2);
    padding: 15px;
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.difficulty-selector h3 {
    color: white;
    font-size: 16px;
    margin-bottom: 10px;
    text-align: center;
}

.difficulty-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.difficulty-btn {
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    color: #667eea;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    min-height: 45px;
}

.difficulty-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.difficulty-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.difficulty-btn.active {
    background: linear-gradient(145deg, #51cf66, #8ce99a);
    color: white;
}

.game-container {
    background: rgba(255,255,255,0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    width: 450px;
    display: flex;
    flex-direction: column;
}

.grid {
    display: grid;
    grid-template-columns: repeat(6, 53px);
    grid-template-rows: repeat(6, 53px);
    gap: 6px;
    margin-bottom: 25px;
    justify-content: center;
}

.cell {
    background: linear-gradient(145deg, #f0f0f0, #ffffff);
    border: 2px solid #ddd;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
    width: 53px;
    height: 53px;
    box-sizing: border-box;
    color: #333;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.cell:active:not(.fixed) {
    transform: scale(0.95);
    box-shadow: 1px 1px 3px rgba(0,0,0,0.1);
}

.cell.fixed {
    background: linear-gradient(145deg, #e3f2fd, #bbdefb);
    color: #1976d2;
    cursor: not-allowed;
    font-weight: 900;
}

.cell.empty {
    background: linear-gradient(145deg, #fff9c4, #fff59d);
    border-color: #fbc02d;
    cursor: pointer;
}

.cell.empty:hover {
    background: linear-gradient(145deg, #fff59d, #fdd835);
    border-color: #f57f17;
}

.cell.selected {
    background: linear-gradient(145deg, #ffd700, #ffed4e);
    border-color: #ff6b6b;
    animation: pulse 0.5s ease-in-out;
}

.cell.correct {
    animation: correctAnim 0.5s ease;
    background: linear-gradient(145deg, #51cf66, #8ce99a);
    color: white;
}

.cell.wrong {
    animation: wrongAnim 0.5s ease;
}

.cell.conflict {
    border-color: #ff6b6b;
    background: linear-gradient(145deg, #ffe0e0, #ffcccc);
}

/* 提示高亮效果 */
.cell.hint-highlight {
    background: linear-gradient(145deg, #ffd700, #ffed4e) !important;
    border: 3px solid #ff6b6b !important;
    box-shadow: 0 0 25px #ffd700, 0 0 50px #ffd700 !important;
    animation: hintPulse 1s ease-in-out infinite;
    transform: scale(1.1);
    z-index: 10;
    position: relative;
}

@keyframes hintPulse {
    0%, 100% { 
        box-shadow: 0 0 25px #ffd700, 0 0 50px #ffd700;
        transform: scale(1.1);
    }
    50% { 
        box-shadow: 0 0 35px #ffd700, 0 0 70px #ffd700;
        transform: scale(1.15);
    }
}

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

@keyframes correctAnim {
    0%, 100% { 
        background: linear-gradient(145deg, #51cf66, #8ce99a);
    }
    50% { 
        background: linear-gradient(145deg, #69db7c, #a3e9b4);
    }
}

@keyframes wrongAnim {
    0%, 100% { 
        border-color: #ddd;
    }
    25%, 75% { 
        border-color: #ff6b6b;
    }
}

.number-pad {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.number-btn {
    padding: 12px;
    font-size: 20px;
    font-weight: bold;
    background: linear-gradient(145deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    min-height: 50px;
}

.number-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
}

.number-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.number-btn.disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.5;
}

.hint {
    text-align: center;
    color: #666;
    font-size: 16px;
    margin-bottom: 20px;
    height: 24px;
    line-height: 24px;
}

.tools-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.button-group {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

/* 右侧操作按钮组 */
.right-buttons {
    position: fixed;
    right: 10px;
    top: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 999;
}

.btn-restart {
    display: block;
    padding: 12px 20px;
    font-size: 16px;
    background: linear-gradient(145deg, #ff6b6b, #ff8787);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    min-width: 120px;
    text-align: center;
    font-weight: bold;
}

.btn-restart:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(0,0,0,0.3);
}

.btn-restart:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.btn-home {
    display: block;
    padding: 12px 20px;
    font-size: 16px;
    background: linear-gradient(145deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    min-width: 120px;
    text-align: center;
    font-weight: bold;
}

.btn-home:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(0,0,0,0.3);
}

.btn-home:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.btn-tool {
    padding: 10px 24px;
    font-size: 11px;
    border: none;
    border-radius: 17px;
    cursor: pointer;
    box-shadow: 0 3px 7px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    font-weight: bold;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    min-height: 34px;
    background: linear-gradient(145deg, #4dabf7, #74c0fc);
    color: white;
}

.btn-tool:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
}

.btn-tool:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* 道具栏样式 - 固定在右侧 */
.power-ups {
    position: fixed;
    right: 10px;
    top: 150px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 999;
}

.power-up {
    background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
    color: white;
    border: 3px solid #ffd700;
    border-radius: 10px;
    padding: 12px 16px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    min-width: 120px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.power-up:active {
    transform: scale(0.95);
}

.power-up.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #ccc;
}

.power-up .count {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    border: 2px solid white;
}

/* 道具栏样式 - 手机端优化 */
@media (max-width: 767px) {
    .power-ups {
        right: 5px;
        top: 55px;
        gap: 8px;
    }
    
    .power-up {
        padding: 8px 12px;
        font-size: 14px;
        min-width: 100px;
    }
    
    .power-up .count {
        width: 20px;
        height: 20px;
        font-size: 12px;
        top: -8px;
        right: -8px;
    }
}

/* iPad 端弹窗适配 */
@media (min-width: 768px) and (max-width: 1024px) {
    /* 确保iPad上登录弹窗可见 */
    body {
        display: block !important; /* 移除flex布局，确保弹窗可见 */
        overflow-y: auto;
        padding: 20px 5px; /* 上下增加内边距 */
    }
    
    .login-modal,
    .ranking-modal,
    .shop-modal,
    .anti-addiction-modal {
        position: fixed !important;
        z-index: 10000 !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .main-container {
        margin: 10px auto;
        flex-direction: column;
        align-items: center;
    }
}

/* iPad Pro 横屏和大屏幕平板优化 */
@media (min-width: 1024px) and (max-width: 1366px) {
    .game-container {
        width: 550px;
        padding: 30px;
    }
    
    .grid {
        grid-template-columns: repeat(6, 63px);
        grid-template-rows: repeat(6, 63px);
        gap: 7px;
    }
    
    .cell {
        width: 63px;
        height: 63px;
        font-size: 26px;
    }
    
    .number-btn {
        padding: 15px;
        font-size: 22px;
        min-height: 55px;
    }
    
    .btn-tool {
        padding: 10px 24px;
        font-size: 11px;
        border-radius: 17px;
        min-height: 34px;
    }
}

/* iPad 竖屏和中等屏幕优化 */
@media (min-width: 768px) and (max-width: 1023px) {
    .main-container {
        flex-direction: column;
        align-items: center;
    }

    .left-panel {
        width: 100%;
        max-width: 550px;
    }

    .score-board {
        flex-direction: row;
    }

    .header h1 {
        font-size: 24px;
    }

    .game-container {
        width: 100%;
        max-width: 550px;
        padding: 25px;
    }

    .grid {
        grid-template-columns: repeat(6, 1fr);
        grid-template-rows: repeat(6, 1fr);
        gap: 7px;
    }

    .cell {
        width: 100%;
        height: 100%;
        aspect-ratio: 1;
        font-size: 22px;
    }
    
    .number-btn {
        padding: 14px;
        font-size: 20px;
        min-height: 52px;
    }
    
    .number-pad {
        gap: 8px;
    }
    
    .btn-tool {
        padding: 9px 22px;
        font-size: 10px;
        border-radius: 17px;
        min-height: 34px;
    }
}

/* 手机和小屏幕设备 */
@media (max-width: 767px) {
    .main-container {
        flex-direction: column;
        align-items: center;
    }

    .left-panel {
        width: 100%;
        max-width: 400px;
    }

    .score-board {
        flex-direction: row;
    }

    .header h1 {
        font-size: 22px;
    }

    .game-container {
        width: 100%;
        max-width: 500px;
        padding: 20px;
    }

    .grid {
        grid-template-columns: repeat(6, 1fr);
        grid-template-rows: repeat(6, 1fr);
        gap: 6px;
    }

    .cell {
        width: 100%;
        height: 100%;
        aspect-ratio: 1;
        font-size: 24px;
    }
    
    .number-btn {
        padding: 15px;
        font-size: 24px;
        min-height: 65px;
    }
    
    .number-pad {
        gap: 8px;
    }
    
    .btn-tool {
        padding: 8px 17px;
        font-size: 9px;
        border-radius: 17px;
        min-height: 34px;
    }
}
