/* 遊戲內容 */
.game-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1.5rem;
    overflow-y: auto;
    justify-content: center;
    align-items: center;
}

/* 網格容器 */
.grid-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    width: 100%;
}

/* 數獨盤面 */
.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 0;
    background-color: var(--text-primary);
    border: 3px solid var(--text-primary);
    aspect-ratio: 1;
    max-width: 100%;
    max-height: 60vh;
}

@media (max-width: 768px) {
    .sudoku-grid {
        max-height: 50vh;
    }
}

/* 格子 */
.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-size: clamp(0.75rem, 3vw, 1.75rem);
    font-weight: 500;
    transition: background-color 0.15s, color 0.15s;
    user-select: none;
    position: relative;
}

/* 九宮格邊框加粗 */
.cell:nth-child(3n)::after {
    content: '';
    position: absolute;
    right: -1px;
    top: 0;
    height: 100%;
    width: 2px;
    background-color: var(--text-primary);
}

.cell:nth-child(27n+1)::before,
.cell:nth-child(27n+2)::before,
.cell:nth-child(27n+3)::before {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--text-primary);
}

/* 使用 CSS Grid 線而不是偽元素 */
.sudoku-grid {
    position: relative;
}

/* 更好的九宮格邊界 */
.cell:nth-child(3n) {
    border-right: 2px solid var(--text-primary);
}

.cell:nth-child(n + 19):nth-child(-n + 27),
.cell:nth-child(n + 46):nth-child(-n + 54),
.cell:nth-child(n + 73):nth-child(-n + 81) {
    border-bottom: 2px solid var(--text-primary);
}

/* 預設數字（初始題目） */
.cell.initial {
    font-weight: 700;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    cursor: not-allowed;
}

/* 選中的格子 */
.cell.selected {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

.cell.selected.initial {
    background-color: rgba(59, 130, 246, 0.3);
    color: var(--text-primary);
}

/* 相同行/列/九宮格的格子 - 視覺效果已移除 */
.cell.related {
    /* 不再顯示任何視覺標記 */
}

/* 玩家填寫的數字 */
.cell.player-input {
    color: var(--success-color);
    font-weight: 600;
}

/* 錯誤數字 */
.cell.error {
    color: var(--error-color);
    font-weight: 700;
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

/* 提示填寫的數字 */
.cell.hint {
    background-color: rgba(34, 197, 94, 0.2);
    color: var(--success-color);
    font-weight: 600;
}

/* 輔助功能列 */
.utility-bar {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
}

.utility-btn {
    padding: 0.75rem 1.5rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.utility-btn:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.utility-btn:active {
    transform: translateY(0);
}

.utility-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.hint-btn {
    flex-grow: 1;
    max-width: 150px;
}

.clear-btn {
    flex-grow: 1;
    max-width: 150px;
}

.home-btn {
    flex-grow: 1;
    max-width: 150px;
}

/* 數字鍵盤 */
.number-pad {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 500px;
}

.number-buttons {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 0.5rem;
}

.number-btn {
    padding: 0.75rem;
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 700;
    font-size: 1.125rem;
    transition: all 0.2s;
    color: var(--text-primary);
}

.number-btn:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.number-btn:active {
    transform: scale(0.95);
}

.number-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.delete-btn {
    padding: 0.75rem;
    background-color: var(--error-color);
    color: white;
    border: 2px solid var(--error-color);
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 700;
    font-size: 1.125rem;
    transition: all 0.2s;
}

.delete-btn:hover {
    background-color: #dc2626;
    border-color: #dc2626;
    transform: scale(1.05);
}

.delete-btn:active {
    transform: scale(0.95);
}

.delete-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Google AdSense 廣告容器 */
.ad-container {
    width: 100%;
    max-width: 500px;
    padding: 1rem;
    margin: 0.5rem 0;
    display: flex;
    justify-content: center;
    background-color: var(--bg-secondary);
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}

.ad-container ins {
    display: block;
    width: 100%;
}

/* 通關彈窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: modalFadeIn 0.3s ease-in;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.modal-content {
    position: relative;
    background-color: var(--bg-primary);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
    max-width: 400px;
    width: 90%;
    z-index: 1001;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.victory-stats {
    margin: 1.5rem 0;
    background-color: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 0.75rem;
}

.victory-time,
.victory-difficulty {
    font-size: 1.125rem;
    margin: 0.5rem 0;
    font-weight: 600;
}

.victory-time span,
.victory-difficulty span {
    color: var(--primary-color);
    font-weight: 700;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.modal-btn {
    flex: 1;
    padding: 1rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.2s;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
}

.primary-btn:hover {
    background-color: var(--primary-hover);
    transform: scale(1.02);
}

.secondary-btn {
    background-color: var(--success-color);
    color: white;
}

.secondary-btn:hover {
    background-color: #059669;
    transform: scale(1.02);
}

/* 響應式遊戲頁面 */
@media (max-width: 768px) {
    .game-content {
        padding: 0.75rem;
        gap: 1rem;
    }
    
    .sudoku-grid {
        max-height: 45vh;
    }
    
    .number-buttons {
       grid-template-columns: repeat(10, 1fr);
        gap: 0.35rem;
    }
    
    .number-btn {
        padding: 0.5rem 0.25rem;
        font-size: 1rem;
    }
    
    .delete-btn {
       padding: 0.5rem 0.25rem;
       font-size: 1rem;
    }
    
    .utility-btn {
        padding: 0.625rem 1rem;
        font-size: 0.75rem;
    }
    
    .modal-content {
        padding: 1.5rem;
    }
    
    .modal-content h2 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .game-content {
        padding: 0.5rem;
        gap: 0.75rem;
    }
    
    .sudoku-grid {
        max-height: 40vh;
    }
    
    .number-buttons {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.25rem;
    }
    
    .number-btn {
        padding: 0.4rem 0.2rem;
        font-size: 0.875rem;
    }
    
    .delete-btn {
        padding: 0.4rem 0.2rem;
        font-size: 0.875rem;
    }
    
    .utility-bar {
        gap: 0.5rem;
    }
    
    .utility-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.65rem;
        flex-grow: 1;
        max-width: none;
    }
}
